Jump to content
Sign in to follow this  
Emilio_G

SetDataOnSimObject PARTIAL PANEL failures not working

Recommended Posts

I am trying to trigger some instrument panel failures as an experiment but can't get it to work. In snippets this is more or less what I have done, I am using C# managed 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:

// 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.

 

Share this post


Link to post
Share on other sites

This is what the SDK says:

 

Simulation Variable Description                                     Units   Settable Multiplayer
----------------------------------------------------------------------------------------------------
PARTIAL PANEL ADF Gauge fail flag (0 = ok, 1 = fail, 2 = blank) Enum Y -
PARTIAL PANEL AIRSPEED Gauge fail flag (0 = ok, 1 = fail, 2 = blank) Enum Y -
PARTIAL PANEL ALTIMETER Gauge fail flag (0 = ok, 1 = fail, 2 = blank) Enum Y -
PARTIAL PANEL ATTITUDE Gauge fail flag (0 = ok, 1 = fail, 2 = blank) Enum Y -
PARTIAL PANEL COMM Gauge fail flag (0 = ok, 1 = fail, 2 = blank) Enum Y -
PARTIAL PANEL COMPASS Gauge fail flag (0 = ok, 1 = fail, 2 = blank) Enum Y -
PARTIAL PANEL ELECTRICAL Gauge fail flag (0 = ok, 1 = fail, 2 = blank) Enum Y -
PARTIAL PANEL AVIONICS Gauge fail flag (0 = ok, 1 = fail, 2 = blank) Enum N -
PARTIAL PANEL ENGINE Gauge fail flag (0 = ok, 1 = fail, 2 = blank) Enum Y -
PARTIAL PANEL FUEL INDICATOR Gauge fail flag (0 = ok, 1 = fail, 2 = blank) Enum N
PARTIAL PANEL HEADING Gauge fail flag (0 = ok, 1 = fail, 2 = blank) Enum Y -
PARTIAL PANEL VERTICAL VELOCITY Gauge fail flag (0 = ok, 1 = fail, 2 = blank) Enum Y -
PARTIAL PANEL TRANSPONDER Gauge fail flag (0 = ok, 1 = fail, 2 = blank) Enum Y -
PARTIAL PANEL NAV Gauge fail flag (0 = ok, 1 = fail, 2 = blank) Enum Y -
PARTIAL PANEL PITOT Gauge fail flag (0 = ok, 1 = fail, 2 = blank) Enum Y -
PARTIAL PANEL TURN COORDINATOR Gauge fail flag (0 = ok, 1 = fail, 2 = blank) Enum N -
PARTIAL PANEL VACUUM Gauge fail flag (0 = ok, 1 = fail, 2 = blank) Enum Y
 
Events (Aircraft Failures)
Event ID                        String Name             Description                     Multiplayer
KEY_TOGGLE_VACUUM_FAILURE TOGGLE_VACUUM_FAILURE Toggle vacuum system failure Shared Cockpit
KEY_TOGGLE_ELECTRICAL_FAILURE TOGGLE_ELECTRICAL_FAILURE Toggle electrical system failure Shared Cockpit
KEY_TOGGLE_PITOT_BLOCKAGE TOGGLE_PITOT_BLOCKAGE Toggles blocked pitot tube Shared Cockpit
KEY_TOGGLE_STATIC_PORT_BLOCKAGE TOGGLE_STATIC_PORT_BLOCKAGE Toggles blocked static port Shared Cockpit
KEY_TOGGLE_HYDRAULIC_FAILURE TOGGLE_HYDRAULIC_FAILURE Toggles hydraulic system failure Shared Cockpit
KEY_TOGGLE_TOTAL_BRAKE_FAILURE TOGGLE_TOTAL_BRAKE_FAILURE Toggles brake failure (both) Shared Cockpit
KEY_TOGGLE_LEFT_BRAKE_FAILURE TOGGLE_LEFT_BRAKE_FAILURE Toggles left brake failure Shared Cockpit
KEY_TOGGLE_RIGHT_BRAKE_FAILURE TOGGLE_RIGHT_BRAKE_FAILURE Toggles right brake failure Shared Cockpit
KEY_TOGGLE_ENGINE1_FAILURE TOGGLE_ENGINE1_FAILURE Toggle engine 1 failure        Shared Cockpit
KEY_TOGGLE_ENGINE2_FAILURE TOGGLE_ENGINE2_FAILURE Toggle engine 2 failure        Shared Cockpit
KEY_TOGGLE_ENGINE3_FAILURE TOGGLE_ENGINE3_FAILURE Toggle engine 3 failure        Shared Cockpit
KEY_TOGGLE_ENGINE4_FAILURE TOGGLE_ENGINE4_FAILURE Toggle engine 4 failure        Shared Cockpit

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...