• 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 SetDataOnSimObject with Enum doesn't work for setting PARTIAL PANEL failures

Messages
639
Country
panama
There seems to be something wrong with the FsDeveloper site, I get an IP 173.233.77.148 on the URL bar rather than fsdeveloper.com.

So, everything working okay with my test app so far, I can use events, receive event updates, connect, disconnect, etc.

However, what I have not been able to get working is using SetDataOnSimObject() to set an instrument/gauge failure, for example "PARTIAL PANEL AIRSPEED".

According to the SDK "PARTIAL PANEL AIRSPEED" as well as the various other gauges with "PARTIAL" than can be failed are of type Enum with values 0=ok,1=fail and 2=blank.

One problem is... there seems to be absolutely NO SimConnect unit type named "enum". I tried setting the unit to "number" but that doesn't work, nothing is set but I get no exception.

Another problem is that is not not clear in the wicked SimConnect SDK documentation what is the size of an enum. I try INT32 and it doesn't work, but if I try anything else I get a SimConnect exception.

Can anybody provide me a working example for that using managed code? Basically what I am doing is this:

Code:
enum DEFINITIONS {
   PlaneLocationDR,
   AirspeedGaugeFailureDR
}

enum DATA_REQUESTS {
   RequestLocation
}

public enum GaugeStateMode   // values as in the SimConnect SDK
    {
        OK = 0,
        Fail = 1,
        Blank = 2
    }

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
struct AirspeedGaugeDR
{
    GaugeStateMode AirspeedGaugeStatus;

    static void Register(SimConnect simconnect)
    {
        simconnect.AddToDataDefinition(DEFINITIONS.AirspeedGaugeFailureDR, 
                SimVars.PARTIAL_PANEL_AIRSPEED, // "PARTIAL PANEL AIRSPEED"
                SimUnits.NUMBER,                // "number"
                SIMCONNECT_DATATYPE.INT32, 
                0.0f, 
                SimConnect.SIMCONNECT_UNUSED);

        simconnect.RegisterDataDefineStruct<AirspeedGaugeDR>(DEFINITIONS.AirspeedGaugeFailureDR);
    }
}

Since the "PARTIAL PANEL AIRSPEED" description on the SDK, like all the other partial panel failures is defined as type "Enum" I chose to use "NUMBER" as SimConnect unit because there seems to be no "Enum" unit. I also chos INT32 as I think the enum is 32 bits. Correct me if I am wrong in any of the assumptions.

So then in the code I create my SimConnect object and when I want to trigger the Airspeed Indicator failure I do this:

Code:
// Initialization
SimConnect simconnect = new SimConnect("FSX Test", this.appWindowHandle, WM_USER_SIMCONNECT, null, 0);
// registered for OnRecvOpen/Quit/Exception/Event/OnRecvSimobjectDataBytype/OnRecvSimobjectData
AirspeedGaugeDR.Register(simconnect);
// Then elsewhere in the code
// Now trigger the failure
AirspeedGaugeDR setdata = new AirspeedGaugeDR();
setdata.AirspeedGaugeStatus = GaugeStateMode.Fail; // 1
simconnect.SetDataOnSimObject(DEFINITIONS.AirspeedGaugeFailureDR, 
        (uint)SIMCONNECT_SIMOBJECT_TYPE.USER, 
        SIMCONNECT_DATA_SET_FLAG.DEFAULT, 
        setdata);

The application can connect/disconnect/receive events and event updates, send data requests but I can't get this (panel failure) to work.
 
I am also trying the same with PUSHBACK STATE but the same problem happens, in other words no pushback regardless of the value, I get a DATA_ERROR exception.
 
Back
Top