• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FSX New PMDG 737NG variables

Messages
3
Country
bulgaria
Hi everyone!

The file PMDG_NGX_SKD.h, situated in C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\PMDG\PMDG 737 NGX\SDK, suggests that there are some new variables added sometimes. Those are:
C++:
    // New variables for SP2
    unsigned int    COMM_ReceiverSwitches[3];            // Bit flags for selector receivers (see ACP_SEL_RECV_VHF1 etc): [0]=Capt, [1]=FO, [2]=Overhead
    bool            MAIN_annunAP_Amber[2];                // Amber color
    bool            MAIN_annunAT_Amber[2];                // Amber color
    int                ICE_WindowHeatTestSw;                // 0: OVHT  1: Neutral  2: PWR TEST
    bool            DOOR_annunFWD_ENTRY;
    bool            DOOR_annunFWD_SERVICE;
    bool            DOOR_annunAIRSTAIR;
    bool            DOOR_annunLEFT_FWD_OVERWING;
    bool            DOOR_annunRIGHT_FWD_OVERWING;
    bool            DOOR_annunFWD_CARGO;
    bool            DOOR_annunEQUIP;
    bool            DOOR_annunLEFT_AFT_OVERWING;
    bool            DOOR_annunRIGHT_AFT_OVERWING;
    bool            DOOR_annunAFT_CARGO;
    bool            DOOR_annunAFT_ENTRY;
    bool            DOOR_annunAFT_SERVICE;
    bool            AIR_annunAUTO_FAIL;
    bool            AIR_annunOFFSCHED_DESCENT;
    bool            AIR_annunALTN;
    bool            AIR_annunMANUAL;
    float            AIR_CabinAltNeedle;                // Value - ft
    float            AIR_CabinDPNeedle;                // Value - PSI
    float            AIR_CabinVSNeedle;                // Value - ft/min
    float            AIR_CabinValveNeedle;            // Value - 0 (closed) .. 1 (open)
    float            AIR_TemperatureNeedle;            // Value - degrees C
    float            AIR_DuctPressNeedle[2];            // Value - degrees C
    char            ELEC_MeterDisplayTop[13];        // Top line of the display: 3 groups of 4 digits (or symbols) + terminating zero
    char            ELEC_MeterDisplayBottom[13];    // Bottom line of the display
    char            IRS_DisplayLeft[7];                // Left display string, zero terminated
    char            IRS_DisplayRight[8];            // Right display string, zero terminated
    bool            IRS_DisplayShowsDots;            // True if the degrees and decimal dot symbols are shown on the IRS display

I am using C# to speak with PMDG. I have a struct of PMDG variables, however, those "new ones" appear to be missing. When I add a few of those to that struct:
C#:
            public float AIR_CabinAltNeedle; // Value
            public float AIR_CabinDPNeedle; // Value
            public float AIR_CabinVSNeedle; // Value
When the struct is returned, those are zeros, not populated. Any idea how to fix that? This is a piece of my code:

C#:
            _simConnect.MapClientDataNameToID(PMDG.PMDG_NGX_DATA_NAME, PMDG.PMDGIds.PMDG_NGX_DATA_ID);
            // Define the data area structure - this is a required step
            _simConnect.AddToClientDataDefinition(PMDG.PMDGIds.PMDG_NGX_DATA_DEFINITION, 0, (uint)Marshal.SizeOf(typeof(PMDG.PMDG_NGX_Data)), 0.0f, SimConnect.SIMCONNECT_UNUSED);

            _simConnect.RegisterStruct<SIMCONNECT_RECV_CLIENT_DATA, PMDG.PMDG_NGX_Data>(PMDG.PMDGIds.PMDG_NGX_DATA_DEFINITION);

            _simConnect.RequestClientData(PMDG.PMDGIds.PMDG_NGX_DATA_ID, DATA_REQUEST_ID.DATA_REQUEST, PMDG.PMDGIds.PMDG_NGX_DATA_DEFINITION, SIMCONNECT_CLIENT_DATA_PERIOD.ON_SET, SIMCONNECT_CLIENT_DATA_REQUEST_FLAG.CHANGED, 0, 0, 0);

            _simConnect.OnRecvClientData += new SimConnect.RecvClientDataEventHandler(simconnect_PMDGVarsHandler);

C#:
        void simconnect_PMDGVarsHandler(SimConnect sender, SIMCONNECT_RECV_CLIENT_DATA data)
        {

            switch ((DATA_REQUEST_ID)data.dwRequestID)
            {
                case DATA_REQUEST_ID.DATA_REQUEST:
                    PMDG.PMDG_NGX_Data ngxVars = (PMDG.PMDG_NGX_Data)data.dwData[0];
                     //code here,

                    break;
            }
        }

My SDK is the same as this one:

https://github.com/maciekish/SimInterface/blob/master/Windows/SimInterface/PmdgSDK.cs

However, I've added the three variables from above at the end of the public struct PMDG_NGX_Data.
 
Messages
3
Country
bulgaria
Hi again everyone!

So I managed to find out what's wrong. The variables need to be added in a certain order. This is what I've appended to the existing C# data struct:

C#:
            // New variables for SP2
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
            public uint[] COMM_ReceiverSwitches;          // Bit flags for selector receivers (see ACP_SEL_RECV_VHF1 etc): [0]=Capt, [1]=FO, [2]=Overhead
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
            public byte[] MAIN_annunAP_Amber;
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
            public byte[] MAIN_annunAT_Amber;
            public byte ICE_WindowHeatTestSw;
            public byte DOOR_annunFWD_ENTRY;
            public byte DOOR_annunFWD_SERVICE;
            public byte DOOR_annunAIRSTAIR;
            public byte DOOR_annunLEFT_FWD_OVERWING;
            public byte DOOR_annunRIGHT_FWD_OVERWING;
            public byte DOOR_annunFWD_CARGO;
            public byte DOOR_annunEQUIP;
            public byte DOOR_annunLEFT_AFT_OVERWING;
            public byte DOOR_annunRIGHT_AFT_OVERWING;
            public byte DOOR_annunAFT_CARGO;
            public byte DOOR_annunAFT_ENTRY;
            public byte DOOR_annunAFT_SERVICE;
            public byte AIR_annunAUTO_FAIL;
            public byte AIR_annunOFFSCHED_DESCENT;
            public byte AIR_annunALTN;
            public byte AIR_annunMANUAL;
            public float AIR_CabinAltNeedle;
            public float AIR_CabinDPNeedle;
            public float AIR_CabinVSNeedle;
            public float AIR_CabinValveNeedle;
            public float AIR_TemperatureNeedle;
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
            public float[] AIR_DuctPressNeedle;
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 13)]
            public char[] ELEC_MeterDisplayTop;
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 13)]
            public char[] ELEC_MeterDisplayBottom;
            //[MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)]
            //public char[] IRS_DisplayLeft;
            //[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
            //public char[] IRS_DisplayRight;
            public byte IRS_DisplayShowsDots;            // True if the degrees and decimal dot symbols are shown on the IRS display

One problem though. I've commented IRS_DisplayLeft and IRS_DisplayRight out, because when those two variables are in the struct, SimConnect gives me exceptions 9 and 29. Anyone has any idea why? All other variables work just fine, just those two cause the exceptions to pop up. Looking at the reference, this is what I get, however, those exceptions do not make too much sense to me in this context. I am not dealing with Events, but variables. Any ideas?


SIMCONNECT_EXCEPTION_DUPLICATE_ID
Specifies that the ID has already been used. This can occur with menu IDs, or with the IDs provided to SimConnect_AddToDataDefinition, SimConnect_AddClientEventToNotificationGroup or SimConnect_MapClientDataNameToID.

SIMCONNECT_EXCEPTION_EVENT_ID_DUPLICATE
Specifies that the event ID has been used already. This can occur with calls to SimConnect_MapClientEventToSimEvent, or SimConnect_SubscribeToSystemEvent.

Regards,
Ivan
 
Top