Jump to content
The simFlight Network Forums

Paul Henty

Members
  • Content Count

    1,132
  • Joined

  • Days Won

    36

Paul Henty last won the day on September 20

Paul Henty had the most liked content!

Community Reputation

63 Excellent

About Paul Henty

  • Rank
    Advanced Member
  • Birthday 01/01/1970

Profile Information

  • Gender
    Male
  • Location
    Gloucestershire, UK

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. 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
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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
  9. Hi Peter, It's quite complicated to compile and run .NET code at runtime. It's usually called Dynamic Execution. I don't think it's needed here however; there is a way you can do this with the base (untyped) Offset class. I suggest something along these lines... Text File: In the text file have the following: pin, controlName, offset address, type, size e.g. 23, EVT_MCP_LVL_CHG_SWITCH, FFFF, byte, 1 Dictionary: Create a structure to hold the pin, the event, the offset, and a method to get the offset value back as an int: internal struct pinInfo { public int pin; public string eventName; public Offset offset; public string offsetType; public pinInfo(int Pin, string EventName, Offset FSUIPCOffset, string OffsetType) { this.pin = Pin; this.eventName = EventName; this.offset = FSUIPCOffset; this.offsetType = OffsetType; } public int getOffsetValue() { int value = 0; switch (this.offsetType) { case "byte": value = (int)this.offset.GetValue<byte>(); break; case "short": value = (int)this.offset.GetValue<short>(); break; case "int": value = this.offset.GetValue<int>(); break; } return value; } } Create the dictionary to hold these entries, keyed on the pin: Dictionary<int, pinInfo> pins = new Dictionary<int, pinInfo>(); Populating the dictionary: As you read each line in the text file, create an instance of pinInfo and add to the dictionary: // these would be from the file... string pinID = "23"; string controlName = "EVT_MCP_LVL_CHG_SWITCH"; string offsetAddressHex = "FFFF"; string offsetType = "byte"; string offsetSize = "1"; // convert pin to int int pinInt = int.Parse(pinID); // convert offset address from string to int (as hexadecimal) int offsetAddressInt = int.Parse(offsetAddressHex, NumberStyles.HexNumber); // convert size to int int offsetSizeInt = int.Parse(offsetSize); // convert event string to int int eventInt = (int)Enum.Parse(typeof(PMDG_737_NGX_Control), controlName, false); // create (untyped) offset Offset offset = new Offset(offsetAddressInt, offsetSizeInt); // create new pinInfo and add to the dictionary pinInfo newPin = new pinInfo(pinInt, eventInt, offset, offsetType); pins.Add(newPin.pin, newPin); Using the dictionary: When the pin number arrives, get the pinInfo using the pin number. Then use the pin info to get the offset value and send the control: int incommingPinNumber = 23; pinInfo pin = pins[incommingPinNumber]; FSUIPCConnection.SendControlToFS(pin.controlID, pin.getOffsetValue()); Paul
  10. Yes the broadcast is working fine then. I really don't know what else to suggest other than to make sure you have the latest updates to whatever version of FSUIPC you are using, my dll, and the PMDG Aircraft. Paul
  11. Hi Peter, Glad to hear it's all going well. I like the dictionary idea. As well as cutting down on the code, it will also allow you to change and add switches without recompiling the code. Paul
  12. Looks like the PMDG info just isn't being broadcast. It would be worth trying some of the other PMDG offsets and see if they work. If they don't, it's definitely a problem with the PMDG broadcast rather than your (or my) code. Paul
  13. Is cdu.Powered still false? Which plane are you using? Paul
  14. The offset address should be in hexadecimal: PMDG_NGX_CDU_Screen cdu = new PMDG_NGX_CDU_Screen(0x5400); Paul
  15. That's OK. Can you post your code here so I can check it? 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.