- Messages
- 639
- Country

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:
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:
The application can connect/disconnect/receive events and event updates, send data requests but I can't get this (panel failure) to work.
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.