Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

SetDataOnSimObject PARTIAL PANEL failures not working

Featured Replies

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.

 

E.G.
Freelance IT Consultant

www.PanamaVibes.com | www.lordofwingsPTY.com | www.coralys.com

@aviationweb

  • 2 weeks later...
  • Author

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

E.G.
Freelance IT Consultant

www.PanamaVibes.com | www.lordofwingsPTY.com | www.coralys.com

@aviationweb

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.