sesc360 Posted April 28, 2017 Report Posted April 28, 2017 Dear all, I read a lot about how to connect FSUIPC with PMDG, but still feel stuck. I want to start simple and just flick a switch for a start, so what I did is this to flick the AntiCollisionLight on the OVHD. 1) Adapt the ini of PMDG 2) write up a test function to switch the light switches private Offset<BitArray> Lights = new Offset<BitArray>(0x0D0C, 2); private Offset<int> sendControl = new Offset<int>(0x3110, true); private Offset<int> controlParameter = new Offset<int>(0x3114); private readonly int EVT_OH_LIGHTS_ANT_COL = 69756 ; public void Process() { try { FSUIPCConnection.Process(); } catch (FSUIPCException ex) { if (ex.FSUIPCErrorCode == FSUIPCError.FSUIPC_ERR_SENDMSG) { // Send Message error - connection lost to FSUIPC FSUIPCConnection.Close(); } else { throw ex; } } } public void SetLightSwitch(int lightSwitch, bool state) { // this.Lights.Value[(int)lightSwitch] = state; controlParameter.Value = EVT_OH_LIGHTS_ANT_COL; sendControl.Value = Convert.ToInt32(state); } The function Process() is called through a timer in my .net windows form app every 200ms. When I start the app nothing happens within PMDG 737NGX. I tested my functions with a default plane and I can switch my switches with the commented out line in my SetLightswitch properly, so the connection is working. I have difficulties understanding how to read and write to PMDG only using FSUIPC. Can you help me please and show me an example how it is done properly?
Pete Dowson Posted April 28, 2017 Report Posted April 28, 2017 I don't know about the code, Paul will have to help with that. Are both control and its parameter being sent as one package, one 8-byte structure? If not, the parameter needs to be first. Did you test the control and its parameter by assigning in to a keypress or button in FSUIPC first? You'd need the actual numbers. Some of the parameters are not obvious -- not necessarily 0 and 1 for a switch for instance. You might find more about that in the User Contributions threads. I can't really help on that as I don't have any PMDG aircraft. Pete
Paul Henty Posted April 29, 2017 Report Posted April 29, 2017 private Offset<int> sendControl = new Offset<int>(0x3110, true); private Offset<int> controlParameter = new Offset<int>(0x3114); 1. These are the wrong way round. The sendControl should be declared after the parameter. This forces the control to be written after the parameter which is how it should work. controlParameter.Value = EVT_OH_LIGHTS_ANT_COL; sendControl.Value = Convert.ToInt32(state); 2. This code above looks wrong. The sendControl should be set to the control number. The parameter should be set to the state of the lights. It looks like you have this the wrong way round. 3, Another thing to check is that the EVT_OH_LIGHTS_ANT_COL includes the BASE control value. This value needs to be added to all the control numbers defined in the SDK. EVT_OH_LIGHTS_ANT_COL should equal 69756. 4. The parameter value normally needs to be one of the mouse commands. e.g Left click, right click etc. These are also defined in the SDK. Paul
Paul Henty Posted April 29, 2017 Report Posted April 29, 2017 In addition to my post above, I've found a previous post helping someone with the VNAV switch. It goes into more detail of how to use the information in the PDMG SDK: ---------------------------------------------------------------------------- If you're using FSUIPC to send the controls then you just need the event ID number. For example, let's say you want to press the VNAV switch on the MCP on the 737. In the PMDG SDK header file it's defined like this: #define EVT_MCP_VNAV_SWITCH (THIRD_PARTY_EVENT_ID_MIN + 386) THIRD_PARTY_EVENT_ID_MIN is defined as: #define THIRD_PARTY_EVENT_ID_MIN 0x00011000 // equals to 69632 So the control number for EVT_MCP_VNAV_SWITCH = 69632 + 386 = 70018. The parameter value is usually one of the mouse buttons: #define MOUSE_FLAG_RIGHTSINGLE 0x80000000 #define MOUSE_FLAG_MIDDLESINGLE 0x40000000 #define MOUSE_FLAG_LEFTSINGLE 0x20000000 ... etc ------------------------ The Control Value would be 70018. (Decimal) The Parameter to left click on this button would be 0x20000000 (Hex) Paul
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now