Jump to content
The simFlight Network Forums

Paul Henty

Members
  • Posts

    1,724
  • Joined

  • Days Won

    77

Everything posted by Paul Henty

  1. Hi Jindřich, The dataGroups are meant to be remembered; that's how the DLL is designed to work. You declare offsets in various groups once (usually when the app starts), then you process the groups when you need to as your app is running. It sounds like you're declaring your offsets more than once in the lifetime of the application. If your application has a predefined set of groups that never change, and all your web users are given the same data, then you should really just declare the offsets once when the application starts up. If each user can request different offsets, and those offsets are created specifically for that user request, then you should put them in a group named uniquely for that request. Then, after processing it you can delete it using DeleteGroup: FSUIPCConnection.DeleteGroup("MyOffsets"); I can't do that. Offsets and groups are meant to survive if the connection is closed (or lost) and reopened. You can delete individual groups as shown above. I suspect the problem is that your application keeps declaring offsets over and over again. I think you need to look at where and when the offsets are being declared and either stop that happening and just declare the offsets/groups once, or delete the groups you create. Paul
  2. Hi Luke, For future reference, there's a dedicated sub-forum to get support with using my DLL: https://forum.simflight.com/forum/167-fsuipc-client-dll-for-net/ Paul
  3. Hi Jindřich, Check that the flight sim is not running 'as administrator'. It's unlikely that your app pool in IIS is running with elevated permissions. Your app and the flight sim (and FSUIPC7 if you are using that) all need to be at the same level. Paul
  4. No problem. I've added it to the next version. I'll likely have it released at the weekend. I'm working on payload and fuel requests at the moment. Paul
  5. I don't think a string will work here. It's got to be a number when it arrives at the server. JSON may not support hex, but C# does! It should be fine. You declare it as a normal hex number in the C# object. Then your JSON encoder will write it out as a base 10 integer and send it like that. My server will understand that. Sounds like a magnetic variation error. The headings from FSUIPC are usually in degrees True. You need to convert to Magnetic (used by the aircraft instruments) using the current Magnetic Variation. There's an offset for that. Paul
  6. Hi Peter, It's good you got the connection working. The problem with your request is that the property names are case-sensitive. Your 'Command' should be 'command'. Like this: test cmdtest = new test { command = "about.read", name = "about", }; I'll put it on the list of things to do. I really didn't expect anyone to be using it from C# :-) Paul
  7. Hi Peter, I don't know either of those libraries. You can specify the protocol on the native WebSocket object built into .NET. I guess using that would require more coding than using a library though. However, using the WebSocket Server just for event notifications seems like a lot of work. Using the DLL you can check the .ValueChanged property on the Offset. This will tell you if the value is different since the last Process() call. If this is false you can choose not to send the data to the serial port. This feature was only added in the last few months. Do you think that will work for you? Paul
  8. Looking at this line of code: FsGate ^gate = this->selectedAirport->Gates[this->gatedropdwn->Text]; What is the Text property returning? The Gates[] collection requires you specify the ID of the Gate. Is that what the dropdown is showing? If the dropdown is displaying the ToString() result then that will also contain the Gate Type in (). This will not work with the Gates collection indexer. However, getting the gate like this seems unnecessary. Looking at this line: this->gatedropdwn->Items->AddRange(selectedAirport->Gates->ToArray()); It looks like your dropdown has an array of Gates at the data source. So you should be able to get the SelectedItem from the dropdown. That will be the FsGate object: FsGate ^gate = (FsGate)this->gatedropdwn->SelectedItem; LINQ is used internally, but that's part of the System.Core DLL so it should work fine. If you can't use LINQ then you can just search through the collections manually with a for..next or do..while type of loop. Paul
  9. I don't use C++ but I had some users in the past using the DLL in a C++ project so it is possible. Can you say more about what the problem is exactly? Are there error messages? Does your project compile? Did the DLL install OK from NuGet? I had tried here but I couldn't get it to install from NuGet. That could be because I don't know anything about configuring the options in C++. Paul
  10. Version 3.1.22 PayloadServices now has methods to automatically load fuel onto the aircraft. These methods start with 'LoadFuel' and there is one for each supported unit (Lbs, Kg, Gallons etc). Fuel can be loaded by weight or volume. You can choose to set the total fuel to the specified level, or to add the specified quantity of fuel to the fuel currently in the tanks. The tanks will be loaded according to the Fuel Distribution Plan. The Distribution Plan is a list of tanks groups. Fuel is balanced within each group. If a group of tanks becomes full it moves on to next group. A default plan is provided, but you can specify your own plan if you want. This example shows setting a new fuel distribution plan. (This is the default plan built in to the DLL). C# FSUIPCConnection.PayloadServices.FuelDistributionPlan = { new FSFuelTanks[] { FSFuelTanks.Left_Tip, FSFuelTanks.Right_Tip, FSFuelTanks.Left_Aux, FSFuelTanks.Right_Aux }, new FSFuelTanks[] { FSFuelTanks.Left_Main, FSFuelTanks.Right_Main }, new FSFuelTanks[] { FSFuelTanks.Centre_Main, FSFuelTanks.Centre_2, FSFuelTanks.Centre_3 }, new FSFuelTanks[] { FSFuelTanks.External_2, FSFuelTanks.External_1 } }; VB.NET FSUIPCConnection.PayloadServices.FuelDistributionPlan = { New FSFuelTanks() {FSFuelTanks.Left_Tip, FSFuelTanks.Right_Tip, FSFuelTanks.Left_Aux, FSFuelTanks.Right_Aux}, New FSFuelTanks() {FSFuelTanks.Left_Main, FSFuelTanks.Right_Main}, New FSFuelTanks() {FSFuelTanks.Centre_Main, FSFuelTanks.Centre_2, FSFuelTanks.Centre_3}, New FSFuelTanks() {FSFuelTanks.External_2, FSFuelTanks.External_1} } This plan means that fuel is first loaded into the Tip and Aux tanks equally. When they are full the remaining fuel is then loaded equally into the main tanks, and so on down the list. If a tank is not present on the aircraft it is ignored. You should therefore include all tanks in the distribution plan. You can have any number of groups and any number of tanks in a group. When adding fuel, the algorithm will attempt to correct any existing imbalance between the tank levels in a group. For example: a small plane has two main tanks - Left and Right. The current levels are 5 lbs and 8 lbs. If you use LoadFuelLbs() to add 7 lbs, the left tank will get 5 lbs and the right will get 2 lbs. This will leave each tank balanced at 10 lbs each. The LoadFuel methods return the amount of fuel that could not be loaded into the tanks because they were full. 0 means all requested fuel was loaded. Example code - Gets fuel amount from a number control on a form and uses it to set the total fuel in the aircraft. C# // Loading fuel in USGallons PayloadServices ps = FSUIPCConnection.PayloadServices; double newFuelAmt = (double)this.nudFuelToLoad.Value; // call load fuel to set an absolute amount. // to add fuel change the second parameter to false double fuelOver = ps.LoadFuelUSGallons(newFuelAmt, true); // you can check if your fuel fitted in the tanks but checking how much is left over if (fuelOver > 0) { this.txtResult.Text = "Over capacity by " + fuelOver.ToString("F2") + "Gal"; } else { this.txtResult.Text = "Filled OK"; } VB.NET ' Loading fuel in USGallons Dim ps As PayloadServices = FSUIPCConnection.PayloadServices Dim newFuelAmt As Double = Me.nudFuelToLoad.Value ' call load fuel to set an absolute amount. ' to add fuel change the second parameter to false Dim fuelOver As Double = ps.LoadFuelUSGallons(newFuelAmt, True) ' you can check if your fuel fitted in the tanks but checking how much Is left over If fuelOver > 0 Then Me.txtResult.Text = "Over capacity by " & fuelOver.ToString("F2") & " Gal" Else Me.txtResult.Text = "Filled OK" End If Paul
  11. I remember you mentioning it before. I think it's a very worthwhile project so I've been more than happy to help. Congratulations for being asked to present at the conference, that's great. You've also come up with some good ideas for the DLL which makes it better for other users too. Version 3.1.22 is now up on NuGet with the automatic fuel loading. Full documentation and examples will be in a separate post below. The fuel is loaded according to a flexible distribution scheme. I've set the default scheme to the one you described above (tips and aux first, then main, then centres). However, it's configurable so you can make up a different one if you need to. It seems to work okay on the default aircraft; let me know if you run into any issues... Paul
  12. Hi Jayson, I'll add this to the PayloadServices today. It'll be a useful feature. You'll be able to set your rules for the priority of each tank. It'll probably be later today. Paul
  13. Hi Firefly, It can't be changed from my code. It's the Windows security that's blocking it. If you don't want to run as admin you can grant permissions to your user account to use a particular URL. The only way I've found to do this is via the command line: (note you'll need to run the command line as admin, and you need use the http version of the url). Example for using 192.168.0.1 port 2048 netsh http add urlacl url=http://192.168.0.1:2048/fsuipc/ user=DOMAIN\user Your user account will be able to use the URL without running as admin. But it will also block you from using all other URLs (including localhost), unless you register them in the same way. To delete the permissions use: netsh http delete urlacl url=http://192.168.0.1:2048/fsuipc/ Paul
  14. Glad to hear its working! I will add a option for wss as it's very easy in code, but using it would require that you have an SSL certificate installed on the PC from a trusted issuing authority bound to the correct port. Paul
  15. Hi Everyone, I have the first beta version of the WebSocket Server ready for testing. If you'd like to download it and test it out, please visit: http://fsuipcwebsockets.paulhenty.com/ On the website you can download the server program and read all the documentation. If you have the server running locally while you are browsing the site, there are working examples on some of the pages. For the server program you'll need the .NET Framework Version 4.6.2 or higher. If you are keeping your Windows up-to-date it should already be installed. Paul
  16. Hi Andy, I have an initial version working well. It just does basic reading and writing of offsets at the moment. More will be added in the future to expose the all helper functions of the .NET Client DLL. I'm about half way through the documentation. I'm hoping to release it for beta testing early next week. I'll post again in this thread when it's ready. Your help with testing and any feedback will be very welcome. Paul
  17. I don't know if mine is up-to-date because the PMDG manager program can't check for newer versions anymore. It must be too old and unsupported by now. There might be different versions for FSX and FSX:SE. I don't know. It would seem unlikely that two products would have the exact same version number. It seems to be a problem with the PMDG software or installation. Maybe you should ask them directly or on their support forums. Another thought - try searching all your drives for 737NGX_Options.ini. You might have more than one installation for some reason and you're editing the wrong file. Paul
  18. These ones: [SDK] EnableDataBroadcast=1 EnableCDUBroadcast.0=1 EnableCDUBroadcast.1=0 You definitely have them in \FSX\PMDG\PMDG 737 NGX\737NGX_Options.ini Not in the FSUIPC4.ini? Paul
  19. Yeah I was thinking about that. Probably the best thing is to make it an option on the request. That way the user can decide if they want to check which values are present or not. It would also be a good way of knowing which values have changed. Some applications like flight recorders are mainly based on logging values changing. You would need to test for the change anyway so checking for the value to be present in the return message would be no less inconvenient. For people writing gauge type applications, they just wouldn't enable the option and get all value from the request back all the time (if at least one has changed). Paul
  20. That's a good idea. I'll put that in. Yes, you can set up multiple read requests each with their own interval. I think this is useful as not all information would need to be read at the same rate. It also makes sense to split the offsets up into logical groups, e.g. lights, engines etc. especially if the request only sends data if one of the offsets has changed. I'll be adding an 'offset.stop' so you can stop the request if you don't need it anymore. Paul
  21. Sorry Piotr, I really don't know what the problem could be. You haven't put the .ini file entries in FSUIPC4,.ini by mistake? Paul
  22. I can confirm this is working with the 3.1.21 version of my DLL. Also FSUIPC Version 4.975a. This is the code I used: Just a simple form with a button and a text box. public frmCDUTest() { InitializeComponent(); } private PMDG_NGX_CDU_Screen cdu0 = null; private void frmCDUTest_Load(object sender, EventArgs e) { FSUIPCConnection.Open(); cdu0 = new PMDG_NGX_CDU_Screen(0x5400); } private void Button1_Click(object sender, EventArgs e) { cdu0.RefreshData(); this.txtCDU.Text = cdu0.ToString("\r\n"); } Using the PMDG 737-800 NGX. In the file: \SteamLibrary\steamapps\common\FSX\PMDG\PMDG 737 NGX\737NGX_Options.ini I added: [SDK] EnableDataBroadcast=1 EnableCDUBroadcast.0=1 EnableCDUBroadcast.1=0 PMDG Version numbers: On the CDU: PMDG Setup -> About says 1.1 In the document: \SteamLibrary\steamapps\common\FSX\PMDG\PMDG 737 NGX\README_PMDG_737-800-900_NGX.txt it says: v1.10.6461 at the top. Hope that helps... Paul
  23. I've got WebSockets working. Here's a quick video of real time updates every 100ms. https://youtu.be/E6RR94O8nfs This is the JavaScript for this page: var fsuipcURL = "ws://127.0.0.1:2048/fsuipc"; var ws; function btnConnectClick(e) { if (!ws) { // create a new WebSocket using the URL with the 'fsuipc' protocol. ws = new WebSocket(fsuipcURL, "fsuipc"); ws.onopen = function () { alert("Socket Open..."); }; ws.onmessage = function (evt) { // Find out which request was responded to and process it var response = JSON.parse(evt.data); switch (response.name) { case 'info': showInfo(response); break; case 'offsetsTest': showOffsetData(response); break; } }; ws.onclose = function () { // websocket is closed. alert("Connection is closed..."); ws = null; }; } } function btnInfoClick(e) { // make a request to the sever for info. request = { request: 'info', name: 'info' }; if (ws) { ws.send(JSON.stringify(request)); } } function btnReadOffsetsClick(e) { // make a request to the sever to read offset data // First setup a data structure containing the offset requests // This contains an array of ofset objects. Each object contains: // name: used to identify the value when the response comes back (can be anything) // address: Hexadecimal address of the offset // type: the type of data in the offset. Must be: // 'int' (signed integer) // 'uint' (unsigned integer) // 'string' // 'float' // size: The size of the offset in bytes request = { request: 'offsets.read', // Tell the server to read offsets name: 'offsetsTest', // An ID so we can match the response interval: 100, // Send every 100ms - specfiy 0 for read once (no repeat). offsets: [ { name: 'altitude', address: '0570', type: 'int', size: 8 }, { name: 'avionicsMaster', address: '2E80', type: 'uint', size: 4 }, { name: 'heading', address: '0580', type: 'uint', size: 4 }, { name: 'aircraftName', address: '3D00', type: 'string', size: 256 }, ] }; if (ws) { ws.send(JSON.stringify(request)); } } function showInfo(response) { if (response.success) { var data = response.data; // Create a table to display the data displayHTML = '<table>'; // enumerate each returned data item and add as a row to the table for (var propertyName in data) { displayHTML += '<tr>'; displayHTML += '<td>' + propertyName + '</td><td>' + data[propertyName] + '</td>'; displayHTML += '</tr>'; } displayHTML += "</table>"; } else { displayHTML = "Request failed with error code: " + response.errorCode + "&nbsp;" + response.errorMessage; } document.getElementById('fsuipcInfo').innerHTML = displayHTML; } function showOffsetData(response) { // clear error display document.getElementById('fsuipcReadOffsets').innerHTML = ''; var displayHTML = ""; if (response.success) { var data = response.data; // display each offset value on the page document.getElementById('aircraftName').innerText = data['aircraftName']; document.getElementById('avionicsMaster').innerText = data['avionicsMaster'] > 0 ? 'ON' : 'OFF'; // convert heading from FS units to degrees var headingDegrees = data['heading'] * 360 / (65536 * 65536); document.getElementById('headingTrue').innerText = headingDegrees.toFixed(0); // convert altitude metres to feet var altitudeFeet = data['altitude'] / (65535 * 65535) * 3.28084; document.getElementById('altitude').innerText = altitudeFeet.toFixed(0); } else { displayHTML = "Request failed with error code: " + response.errorCode + "&nbsp;" + response.errorMessage; } // set any error HTML into the div document.getElementById('fsuipcReadOffsets').innerHTML = displayHTML; } Is that more like what you had in mind? If so, I'll get it to a stable version with offset read and write so you can test it. Let me know if you have any other comments or suggestions. Paul
  24. Hi Bastian, This is a bug in the sample application. The pause should not be declared as write-only. It works fine if you take that out. In your own application you can make it a normal read/write offset. Or if you just want to control the pause you can make it write-only, but you should put it in a group so you can process() it only when you need to send the pause state. I'll fix the problem in the next version of the example code application. Paul
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.