Paul Henty Posted May 19, 2013 Author Report Share Posted May 19, 2013 Ok I copied it now exactly like this into my application: but nothig changes. My fuel tank is still fuel. I am missing surely one thing here or? Sorry, it seems I don't know how to use my own DLL! To get the fuel tank you must use the GetFuelTank() method. I've updated the code below and tested it on my system here on the default Cessna. Try FSUIPCConnection.Open(FlightSim.FSX) Dim ps As PayloadServices = FSUIPCConnection.PayloadServices ps.RefreshData() ps.GetFuelTank(FSFuelTanks.Left_Main).LevelUSGallons = 10 ps.WriteChanges() MsgBox("Done") Catch ex As Exception MessageBox.Show(ex.Message) End Try[/CODE]Paul Link to comment Share on other sites More sharing options...
Paul Henty Posted May 19, 2013 Author Report Share Posted May 19, 2013 I'm working with both .Net2.0 and .Net4.0. The latest version is recognised in .Net4.0 but not in .Net2.0? Hi Thomas, It seems the DLL I uploaded was targeting the .NET 4 Framework so wouldn't have been usable in a .NET 2 project. I've edited that post with two versions, one for .NET 4 Client Profile and one for .NET 2. Paul Link to comment Share on other sites More sharing options...
Thomas Richter Posted May 19, 2013 Report Share Posted May 19, 2013 Hi Thomas, It seems the DLL I uploaded was targeting the .NET 4 Framework so wouldn't have been usable in a .NET 2 project. I've edited that post with two versions, one for .NET 4 Client Profile and one for .NET 2. Paul Hi Paul, perfect! Thanks a mill. Link to comment Share on other sites More sharing options...
ScKevin Posted May 20, 2013 Report Share Posted May 20, 2013 Thanks Paul, now working like a charm! Link to comment Share on other sites More sharing options...
lordofwings Posted May 20, 2013 Report Share Posted May 20, 2013 Does this 2.3 version posted a few days ago newer than the 2.3 Beta that was made available some months ago? Link to comment Share on other sites More sharing options...
Paul Henty Posted May 20, 2013 Author Report Share Posted May 20, 2013 Does this 2.3 version posted a few days ago newer than the 2.3 Beta that was made available some months ago? No it's the same, I just dropped the 'beta' tag because it's been well tested by now. Link to comment Share on other sites More sharing options...
ScKevin Posted May 21, 2013 Report Share Posted May 21, 2013 Hey Paul, sorry for making you mad again I am however hanging on one part: In the aircraft.cfg the index for payload stations starts from 0 to 13. I use this code to load these payloadstations: PS.PayloadStations([u][b]INDEX[/b][/u]).WeightLbs = 187[/CODE]However I do not get it to make it work for the following one:[CODE]PS.PayloadStations(0).WeightLbs = 374[/CODE]This one is the weight of the pilot & co-pilots so basically it is everytime 374, but my FSX does not want to accept this although the rest of the 13 stations do work as they should.What is my mistake here?The index starts from "0" and goes up. And based that the other stations work, my code should be fine no? Link to comment Share on other sites More sharing options...
Paul Henty Posted May 22, 2013 Author Report Share Posted May 22, 2013 However I do not get it to make it work for the following one: PS.PayloadStations(0).WeightLbs = 374[/CODE]This one is the weight of the pilot & co-pilots so basically it is everytime 374, but my FSX does not want to accept this although the rest of the 13 stations do work as they should.What is my mistake here?I can't see any mistake in that line. I've tested it here on the default Cessna and 737 and setting payload station 0 (Pilot) works fine.If you are using a third-party payware/freeware aircraft, test your code on one of the default planes. It may be a problem with the particular plane you are using.Paul Link to comment Share on other sites More sharing options...
ScKevin Posted May 22, 2013 Report Share Posted May 22, 2013 Ok while writing here a reply I think I have found my mistake. I simply added a PS.RefreshData() and it seems to work now: Dim PS As PayloadServices = FSUIPCConnection.PayloadServices PS.RefreshData() PS.PayloadStations(0).WeightLbs = 187 PS.WriteChanges() PS.RefreshData()[/CODE]So the problem is solved as far as I can see :)Thanks for your help (again) :) Link to comment Share on other sites More sharing options...
HondaCop Posted June 8, 2013 Report Share Posted June 8, 2013 Hi Paul, first of all, thanks for this client DLL!!! Ok, I downloaded the .NET 4.0 version of your client and was wondering if it would still work if compiled with VS2012 and targeting .NET 4.5? Reason being is that I need to make a Windows 8 compatible version of my application... Thanks in advance... Link to comment Share on other sites More sharing options...
Paul Henty Posted June 8, 2013 Author Report Share Posted June 8, 2013 if it would still work if compiled with VS2012 and targeting .NET 4.5? Yes it should be fine. From what I've read 4.5 is just an enhanced version of 4.0 so any assembly compiled for 4.0 will also run under 4.5. Remember that the project still needs to target the x86 processor only. You can't compile your application to target x64 or 'any cpu'. Paul Link to comment Share on other sites More sharing options...
Thomas Richter Posted June 9, 2013 Report Share Posted June 9, 2013 Hi Paul, to connect to a different Class other than the local or 'Class 0' you 'need' to have a connected local or 'class 0'. If not than you can not connect to a different class? Lets say you have FS running local and a WideClient local that connects with Class 1. FSUIPCConnection.Open(); or FSUIPCConnection.Open(0); and when it is connected you can connet to any other class FSUIPCConnection.Open(1); But to connect direct to Class 1 or any other than zero doesn't work? FSUIPCConnection.Open(1); Thanks Link to comment Share on other sites More sharing options...
Paul Henty Posted June 9, 2013 Author Report Share Posted June 9, 2013 But to connect direct to Class 1 or any other than zero doesn't work? FSUIPCConnection.Open(1); Hi Thomas, There is no overload that takes only the class number. The overload that takes only an integer is for requesting a specific version of flight sim without using the FlightSim enum. This is a bit confusing I admit, but not many people use multiple classes. To connect to a specific class, always use the overload that takes the class number and the flight sim version. You can pass 'any' if you want to work on all versions. e.g. to connect to class 1 for any version of FS use this: FSUIPCConnection.Open(1, FlightSim.Any); Paul Link to comment Share on other sites More sharing options...
Thomas Richter Posted June 9, 2013 Report Share Posted June 9, 2013 Hi Thomas, There is no overload that takes only the class number. The overload that takes only an integer is for requesting a specific version of flight sim without using the FlightSim enum. This is a bit confusing I admit, but not many people use multiple classes. To connect to a specific class, always use the overload that takes the class number and the flight sim version. You can pass 'any' if you want to work on all versions. e.g. to connect to class 1 for any version of FS use this: FSUIPCConnection.Open(1, FlightSim.Any); Paul Hi Paul, thanks for fast answer. Ups ... Tried that but that doesn't work either If I use FSUIPCConnection.Open(0, FlightSim.Any); for WideClient Class0 or local FS it is OK. But when I use FSUIPCConnection.Open(1, FlightSim.Any); for WideClient Class1 I just get the following exception [5132] FSUIPC - FSUIPC.FSUIPCException: FSUIPC Error #9: FSUIPC_ERR_NOTOPEN. The connection to FSUIPC is not open. [5132] bei FSUIPC.FSUIPCConnection.Process(Byte ClassInstance, IEnumerable`1 GroupNames) [5132] bei FSUIPC.FSUIPCConnection.Process(Byte ClassInstance, String GroupName) [5132] bei FSUIPC.UserInputServices..ctor() [5132] bei FSUIPC.FSUIPCConnection.Open(Byte ClassInstance, Int32 RequiredFlightSimVersion) [5132] bei FRM_IO.IPC_try_00_Tick(Object sender, EventArgs e) Link to comment Share on other sites More sharing options...
Paul Henty Posted June 9, 2013 Author Report Share Posted June 9, 2013 Hi Paul, Ups ... Tried that but that doesn't work either Hi Thomas, I can confirm this is a bug in my DLL. It seems that some of the higher level components like payload and AITraffic services are not aware of 'classes' and so always use the default class 0. Even if your code does not use them they do make a call to FSUIPC when the DLL initialises. So, if there is no class 0 connection then they throw an error. It'll take me a few days to sort this out properly. I'll post the fix here. Paul Link to comment Share on other sites More sharing options...
Thomas Richter Posted June 9, 2013 Report Share Posted June 9, 2013 Hi Thomas, I can confirm this is a bug in my DLL. It seems that some of the higher level components like payload and AITraffic services are not aware of 'classes' and so always use the default class 0. Even if your code does not use them they do make a call to FSUIPC when the DLL initialises. So, if there is no class 0 connection then they throw an error. It'll take me a few days to sort this out properly. I'll post the fix here. Paul Hi Paul, that sounds great (the fix of course) :-) Thanks a mill! Link to comment Share on other sites More sharing options...
Paul Henty Posted June 11, 2013 Author Report Share Posted June 11, 2013 Attached is version 2.4 of the DLL which will only be of interest to those addressing multiple instances of WideClient on the same machine. 1. Fixes a bug where you couldn't open a connection for any other class instance unless you had a class 0 wideclient/FS running. 2. Enables Payload, AITraffic and UserInput services for class instances > 0. To get a reference to the Payload/Traffic/UserInput object for a class instance use the new ...ForClass methods. E.g. to get the Payload services that's attached to class instance 2 use: PayloadServices ps2 = FSUIPCConnection.PayloadServicesForClass(2) Paul FSUIPCClient2.4_NET2.zip FSUIPCClient2.4_NET4.zip Link to comment Share on other sites More sharing options...
Thomas Richter Posted June 11, 2013 Report Share Posted June 11, 2013 Attached is version 2.4 of the DLL which will only be of interest to those addressing multiple instances of WideClient on the same machine. 1. Fixes a bug where you couldn't open a connection for any other class instance unless you had a class 0 wideclient/FS running. 2. Enables Payload, AITraffic and UserInput services for class instances > 0. To get a reference to the Payload/Traffic/UserInput object for a class instance use the new ...ForClass methods. E.g. to get the Payload services that's attached to class instance 2 use: PayloadServices ps2 = FSUIPCConnection.PayloadServicesForClass(2) Paul Hi Paul, that's really fast !! Works perfect, fantastic. Thanks again. Link to comment Share on other sites More sharing options...
greevard Posted June 12, 2013 Report Share Posted June 12, 2013 hi Paul, how can i put my application make in c# whit FSUIPC Client DLL for .NET in fsx menu??? thanks a lot .Your client dll is wonderfull Link to comment Share on other sites More sharing options...
Paul Henty Posted June 12, 2013 Author Report Share Posted June 12, 2013 hi Paul, how can i put my application make in c# whit FSUIPC Client DLL for .NET in fsx menu??? Below is code for a form that puts two menu items on the FS menu and responds to the user selecting these menu items. This shows you everything you need to do. If you want to put this behind a real form to see it working, you'll need two timers on the form called 'timerPollForInput' and 'timerKeepAlive'. You'll also have to change the namespace and class name to suit your project and wire up the _load event. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using FSUIPC; namespace TestApp { public partial class MenuDemo : Form { UserInputServices ui; public MenuDemo() { InitializeComponent(); } private void MenuDemo_Load(object sender, EventArgs e) { // Open FSUIPC FSUIPCConnection.Open(); // Get a reference to the UserInputServices ui = FSUIPCConnection.UserInputServices; // Add our Menu Items // The first parameter is the key and can be whatever you want. // We'll use this later to see which item was chosen. // The second patamter is the text to display on the menu item. // Putting an & before a letter makes it underlined and becomes the shortcut key. // Set the last paramter to true is you want to FS to pause when the user chooses this item. ui.AddMenuItem("MenuA", "Our Menu Item &A", false); ui.AddMenuItem("MenuB", "Our Menu Item &B", false); // Sink the MenuSelected event so we can respond ui.MenuSelected += new EventHandler<UserInputMenuEventArgs>(ui_MenuSelected); // Start our two timers. // This one keeps FSUIPC from deleting our menu items (every 4 seconds) this.timerKeepAlive.Interval = 4000; this.timerKeepAlive.Tick += new EventHandler(timerKeepAlive_Tick); this.timerKeepAlive.Start(); // This one checks to see if the user has selected a menu item (2 times a second). this.timerPollForInput.Interval = 500; this.timerPollForInput.Tick +=new EventHandler(timerPollForInput_Tick); this.timerPollForInput.Start(); } private void timerPollForInput_Tick(object sender, EventArgs e) { // Check if the user has selected our menu items ui.CheckForInput(); } private void timerKeepAlive_Tick(object sender, EventArgs e) { // Stop FSUIPC from deleting out menu items ui.KeepMenuItemsAlive(); } private void ui_MenuSelected(object sender, UserInputMenuEventArgs e) { // This method is called when the user selects one of our menu items. // Check which one and do stuff switch (e.ID) { case "MenuA": // Do menu A stuff here MessageBox.Show("Menu Item A selected!"); break; case "MenuB": // DO menu B stuf here MessageBox.Show("Menu Item B selected!"); break; } } private void Form2_FormClosing(object sender, FormClosingEventArgs e) { // Remove our menu items from FS ui.RemoveAll(); // Close FSUIPC FSUIPCConnection.Close(); } } } Paul Link to comment Share on other sites More sharing options...
HondaCop Posted June 22, 2013 Report Share Posted June 22, 2013 Paul, I loaded up X-Plane 10.21 along with XPUIPC and my App along with your client DLL worked very nicely! As far as I was able to see, everything worked as if it was FSX running! I do have a question though. How can I detect that it's X-Plane running and not FSX? My app displays FSX as the sim running. Any ideas? Link to comment Share on other sites More sharing options...
Paul Henty Posted June 22, 2013 Author Report Share Posted June 22, 2013 Paul, I loaded up X-Plane 10.21 along with XPUIPC and my App along with your client DLL worked very nicely! As far as I was able to see, everything worked as if it was FSX running! I do have a question though. How can I detect that it's X-Plane running and not FSX? My app displays FSX as the sim running. Any ideas? I'm not really sure. I think the whole point of XPUIPC is to spoof the FSUIPC interface and report that FSX is running. If it didn't then some FSUIPC applications would not work with it as they check for a specific version of FS. Also there doesn't seem to be an ID number reserved for XPlane in the FSUIPC SDK documentation. I can only suggest contacting the makers of XPUIPC and see if they have a way you can detect it. They may have a way of reporting a different version number than FSX, or maybe they have some special offset you can check. Paul Link to comment Share on other sites More sharing options...
HondaCop Posted June 22, 2013 Report Share Posted June 22, 2013 I'm not really sure. I think the whole point of XPUIPC is to spoof the FSUIPC interface and report that FSX is running. If it didn't then some FSUIPC applications would not work with it as they check for a specific version of FS. Also there doesn't seem to be an ID number reserved for XPlane in the FSUIPC SDK documentation. I can only suggest contacting the makers of XPUIPC and see if they have a way you can detect it. They may have a way of reporting a different version number than FSX, or maybe they have some special offset you can check. Paul That makes sense, Paul... Will contact them. Thanks! Link to comment Share on other sites More sharing options...
HondaCop Posted June 24, 2013 Report Share Posted June 24, 2013 Paul, I am having a little problem. How can I set the aircraft total payload to ZERO when connected to FS2004? According to the FSUIPC SDK for FS2004, payload can be accessed via 0x1400 with a size of 48 x n, but I have no clue how to code it so that I can set the total payload to zero. Any help would be greatly appreciated! Link to comment Share on other sites More sharing options...
Paul Henty Posted June 24, 2013 Author Report Share Posted June 24, 2013 Paul, I am having a little problem. How can I set the aircraft total payload to ZERO when connected to FS2004? According to the FSUIPC SDK for FS2004, payload can be accessed via 0x1400 with a size of 48 x n, but I have no clue how to code it so that I can set the total payload to zero. 0x1400 is not a simple offset but the start address of a block of data that represents all the payload 'stations' on the aircraft. If you use the latest version of my DLL it gives you a much easier way to read and write the payload data (and fuel as well) than marshalling the data to and from this block yourself. The latest version 2.4 is attached to post 392 on this page. Instructions and code samples (in VB) for using the Payload Services can be found on page 19, post 371. In Flight Sim there is not one payload value, there are many payload stations for an aircraft and each plane has different stations added by the aircraft designer. If you want to set the total payload to 0 you need to set each individual station to 0. You can do this by iterating through them with a For Each loop as shown in the sample code. If you need any help using the payload features feel free to ask here. Paul Link to comment Share on other sites More sharing options...
Recommended Posts