How to decipher Mask data?

Hi, I’m working on a project and I need help to know when the engines are running. I believe that the ENGINE CONTROL SELECT variable shows when the engines are running. How to convert the response (mask) a C # bool variable?

CODE:

private SimConnect my_simconnect;

public double Latitude { get; set; }
public double Longitude { get; set; }
public bool Eng1Running { get; set; }
public bool Eng2Running { get; set; }

public Form1()
{
    InitializeComponent();
}


protected override void DefWndProc(ref Message m)
{
    if (m.Msg == 0x402)
    {
        if (my_simconnect != null)
        {
            my_simconnect.ReceiveMessage();
        }
    }
    else
    {
        base.DefWndProc(ref m);
    }
}


private void initDataRequest()
{
    try
    {
        my_simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "Title", null, SIMCONNECT_DATATYPE.STRING256, 0.0f, SimConnect.SIMCONNECT_UNUSED);
        my_simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "Plane Latitude", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
        my_simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "Plane Longitude", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
        my_simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "ENGINE CONTROL SELECT", "bool", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);

        my_simconnect.RegisterDataDefineStruct<Struct1>(DEFINITIONS.Struct1);
        my_simconnect.OnRecvSimobjectDataBytype += new SimConnect.RecvSimobjectDataBytypeEventHandler(simconnect_OnRecvSimobjectDataBytype);
    }
    catch (COMException exception1)
    {
        Console.WriteLine(exception1.Message);
    }
}

private void simconnect_OnRecvSimobjectDataBytype(SimConnect sender, SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE data)
{
    if (data.dwRequestID == 0)
    {
        Struct1 struct1 = (Struct1)data.dwData[0];
        Latitude = struct1.latitude;
        Longitude = struct1.longitude;

        Engine1 = struct1.engines;
    }
    else
    {
        Console.writeline("Unknown request ID: " + ((uint)data.dwRequestID));
        Latitude = Longitude = 0;
    }
}

public enum Engs
{
    Eng1,
    Eng2,
    Eng3,
    Eng4
}

private void OpenConnection()
{
    try
    {
        my_simconnect = new Microsoft.FlightSimulator.SimConnect.SimConnect("Managed Data Request", base.Handle, 0x402, null, 0);
        initDataRequest();
    }
    catch (COMException)
    {
        label_status.Text = "Unable to connect to sim";
    }
}

private void CloseConnection()
{
    if (my_simconnect != null)
    {
        my_simconnect.Dispose();
        my_simconnect = null;
        label_status.Text = "Connection closed";
    }
}

private enum DATA_REQUESTS
{
    REQUEST_1
}


private enum DEFINITIONS
{
    Struct1
}

[StructLayout(LayoutKind.Sequential, Pack = 1)]
private struct Struct1
{
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x100)]
    public string title;
    public double latitude;
    public double longitude;
    public int engine1;
    public bool engine2;
}


private void timer1_Tick_1(object sender, EventArgs e)
{
    if (my_simconnect == null)
    {
        OpenConnection();
    }
    else
    {

        my_simconnect.RequestDataOnSimObjectType(DATA_REQUESTS.REQUEST_1, DEFINITIONS.Struct1, 0, SIMCONNECT_SIMOBJECT_TYPE.USER);
        Console.WriteLine("Request sent...");
    }

    Console.WriteLine(Eng1Running);
}

According to the documentation, the ENGINE CONTROL SELECT SimVar is a settable bitmask.

This implies you would use this to inform the Sim which engine(s) you are about to control or query.

Selected engines (combination of bit flags):
1 = Engine 1
2 = Engine 2
4 = Engine 3
8 = Engine 4

To determine if an engine is running, the documentation suggests you should use ENG COMBUSTION (True if the engine is running).

Presumably you would request this after selecting the engine(s) you wish to query.

Thanks @Dragonlaird, the solution is simple. Just insert the engine index along with the request for the variable.

private void initDataRequest()
        {
            try
            {
                //LOCATION
                simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "Plane Latitude", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
                simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "Plane Longitude", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
                //ENGINES
                simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "NUMBER OF ENGINES", "number", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
                simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "General eng combustion:1", null, SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
                simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "General eng combustion:2", null, SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
                simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "General eng combustion:3", null, SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
                simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "General eng combustion:4", null, SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);

                simconnect.RegisterDataDefineStruct<Struct1>(DEFINITIONS.Struct1);
                simconnect.OnRecvSimobjectDataBytype += new SimConnect.RecvSimobjectDataBytypeEventHandler(simconnect_OnRecvSimobjectDataBytype);
            }
            catch (COMException exception1)
            {
                Console.WriteLine(exception1.Message);
            }
        }