Esempio n. 1
0
        public void Initialize(IntPtr Handle)
        {
            simconnect = new SimConnect("Flight Recorder", Handle, WM_USER_SIMCONNECT, null, 0);

            // listen to connect and quit msgs
            simconnect.OnRecvOpen += new SimConnect.RecvOpenEventHandler(Simconnect_OnRecvOpen);
            simconnect.OnRecvQuit += new SimConnect.RecvQuitEventHandler(Simconnect_OnRecvQuit);

            simconnect.OnRecvException     += Simconnect_OnRecvException;
            simconnect.OnRecvEvent         += Simconnect_OnRecvEvent;
            simconnect.OnRecvSimobjectData += Simconnect_OnRecvSimobjectData;
            RegisterAircraftPositionDefinition();
            RegisterAircraftPositionSetDefinition();
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftPositionInitial, "Initial Position", null, SIMCONNECT_DATATYPE.INITPOSITION, 0.0f, SimConnect.SIMCONNECT_UNUSED);

            simconnect.OnRecvEventFrame += Simconnect_OnRecvEventFrame;

            //simconnect.SubscribeToSystemEvent(EVENTS.POSITION_CHANGED, "PositionChanged");
            simconnect.SubscribeToSystemEvent(EVENTS.FRAME, "Frame");

            simconnect.OnRecvSystemState += Simconnect_OnRecvSystemState;

            simconnect.MapClientEventToSimEvent(EVENTS.FREEZE_LATITUDE_LONGITUDE, "FREEZE_LATITUDE_LONGITUDE_SET");
            simconnect.MapClientEventToSimEvent(EVENTS.FREEZE_ALTITUDE, "FREEZE_ALTITUDE_SET");
            simconnect.MapClientEventToSimEvent(EVENTS.FREEZE_ATTITUDE, "FREEZE_ATTITUDE_SET");
            RegisterEvents();

            Initialized?.Invoke(this, new());
        }
Esempio n. 2
0
        public void setFail(SimConnect sc)
        {
            Console.WriteLine(sName + failureValue);
            switch (possibleType)
            {
            case POSSIBLE_FAIL_TYPE.STUCK:
            {
                if (!failStart)
                {
                    failureValue = dValue;
                    Console.WriteLine("start" + failureValue);
                    failStart = true;
                }
                dValue = failureValue;
                break;
            }

            case POSSIBLE_FAIL_TYPE.LEAK:
            {
                dValue -= failureValue;
                break;
            }

            case POSSIBLE_FAIL_TYPE.CONTINOUS:
            {
                if (isEvent)
                {
                    if (rnd.Next(11) >= 5)
                    {
                        sc.MapClientEventToSimEvent(eEvent, sName);
                        sc.TransmitClientEvent(SimConnect.SIMCONNECT_OBJECT_ID_USER, eEvent, 0, GROUP.ID_PRIORITY_STANDARD, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);
                    }
                }
                else
                {
                    dValue = failureValue;
                }
                break;
            }

            case POSSIBLE_FAIL_TYPE.COMPLETE:
            {
                if (isEvent)
                {
                    sc.MapClientEventToSimEvent(eEvent, sName);
                    sc.TransmitClientEvent(SimConnect.SIMCONNECT_OBJECT_ID_USER, eEvent, 0, GROUP.ID_PRIORITY_STANDARD, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);
                }
                else
                {
                    dValue = failureValue;
                }

                done = true;
                break;
            }
            }

            sc.SetDataOnSimObject(eDef, SimConnect.SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_DATA_SET_FLAG.DEFAULT, dValue);
        }
 private void btnJetway_Click(object sender, RoutedEventArgs e)
 {
     if (!_simConnectionStatus)
     {
         return;
     }
     _simClient.MapClientEventToSimEvent(PushbackEventsEnum.KEY_TOGGLE_JETWAY, "TOGGLE_JETWAY");
     _simClient.TransmitClientEvent(0U, PushbackEventsEnum.KEY_TOGGLE_JETWAY, 1, NotificationGroupsEnum.Group0, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);
 }
Esempio n. 4
0
        /// <summary>
        /// Registers a data object with the SimConnect management class
        /// </summary>
        /// <param name="sim"></param>
        public static void RegisterDataObjects(SimConnect sim)
        {
            // Define the data structure from FSX
            sim.AddToDataDefinition(DEFINITIONS.AircraftDataStruct, "Title", null, SIMCONNECT_DATATYPE.STRING256, 0.0f, SimConnect.SIMCONNECT_UNUSED);

            sim.AddToDataDefinition(DEFINITIONS.AircraftDataStruct, "PLANE LATITUDE", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            sim.AddToDataDefinition(DEFINITIONS.AircraftDataStruct, "PLANE LONGITUDE", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            sim.AddToDataDefinition(DEFINITIONS.AircraftDataStruct, "INDICATED ALTITUDE", "feet", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);

            sim.AddToDataDefinition(DEFINITIONS.AircraftDataStruct, "Plane Pitch Degrees", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            sim.AddToDataDefinition(DEFINITIONS.AircraftDataStruct, "Plane Heading Degrees True", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            sim.AddToDataDefinition(DEFINITIONS.AircraftDataStruct, "Plane Bank Degrees", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);

            sim.AddToDataDefinition(DEFINITIONS.AircraftDataStruct, "Velocity Body Z", "feet per second", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            sim.AddToDataDefinition(DEFINITIONS.AircraftDataStruct, "Velocity Body X", "feet per second", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            sim.AddToDataDefinition(DEFINITIONS.AircraftDataStruct, "Velocity Body Y", "feet per second", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);

            sim.AddToDataDefinition(DEFINITIONS.AircraftDataStruct, "Rotation Velocity Body Z", "radians per second", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            sim.AddToDataDefinition(DEFINITIONS.AircraftDataStruct, "Rotation Velocity Body X", "radians per second", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            sim.AddToDataDefinition(DEFINITIONS.AircraftDataStruct, "Rotation Velocity Body Y", "radians per second", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);

            sim.AddToDataDefinition(DEFINITIONS.AircraftDataStruct, "Airspeed Mach", "Mach", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            sim.AddToDataDefinition(DEFINITIONS.AircraftDataStruct, "INCIDENCE BETA", "Radians", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);

            // Define the data structure to FSX
            sim.AddToDataDefinition(DEFINITIONS.ControlDataStruct, "AILERON POSITION", "Position", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            sim.AddToDataDefinition(DEFINITIONS.ControlDataStruct, "ELEVATOR POSITION", "Position", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            sim.AddToDataDefinition(DEFINITIONS.ControlDataStruct, "RUDDER POSITION", "Position", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            sim.AddToDataDefinition(DEFINITIONS.ControlDataStruct, "GENERAL ENG THROTTLE LEVER POSITION:1", "Percent", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            sim.AddToDataDefinition(DEFINITIONS.ControlDataStruct, "GENERAL ENG THROTTLE LEVER POSITION:2", "Percent", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            sim.AddToDataDefinition(DEFINITIONS.ControlDataStruct, "GENERAL ENG THROTTLE LEVER POSITION:3", "Percent", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            sim.AddToDataDefinition(DEFINITIONS.ControlDataStruct, "GENERAL ENG THROTTLE LEVER POSITION:4", "Percent", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            //sim.AddToDataDefinition(DEFINITIONS.ControlDataStruct, "SPOILERS HANDLE POSITION", "Percent", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);

            // Register data objects with the simconnect managed wrapper marshaller
            sim.RegisterDataDefineStruct <AircraftDataStructure>(DEFINITIONS.AircraftDataStruct);
            sim.RegisterDataDefineStruct <ControlDataStructure>(DEFINITIONS.ControlDataStruct);

            // Map Events
            sim.MapClientEventToSimEvent(EVENTS.FLAPS0, "FLAPS_UP");
            sim.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP0, EVENTS.FLAPS0, false);

            sim.MapClientEventToSimEvent(EVENTS.FLAPS1, "FLAPS_1");
            sim.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP0, EVENTS.FLAPS1, false);

            sim.MapClientEventToSimEvent(EVENTS.FLAPS2, "FLAPS_2");
            sim.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP0, EVENTS.FLAPS2, false);

            sim.MapClientEventToSimEvent(EVENTS.GEAR_DOWN, "GEAR_DOWN");
            sim.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP0, EVENTS.GEAR_DOWN, false);

            sim.MapClientEventToSimEvent(EVENTS.GEAR_UP, "GEAR_UP");
            sim.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP0, EVENTS.GEAR_UP, false);

            sim.SetNotificationGroupPriority(NOTIFICATION_GROUPS.GROUP0, SimConnect.SIMCONNECT_GROUP_PRIORITY_HIGHEST);
        }
Esempio n. 5
0
        // Подключение jetway к самолету по нажатию кнопки
        private void JetWayBtn_Click(object sender, EventArgs e)
        {
            if (!simConnectStatus)
            {
                return;
            }

            simConn.MapClientEventToSimEvent(EVENT_ENUM.toggleJetway, "TOGGLE_JETWAY");
            simConn.TransmitClientEvent(0U, EVENT_ENUM.toggleJetway, 1, SENDER_EVENT_ENUM.group0, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);
        }
Esempio n. 6
0
        // Set up the SimConnect event handlers
        public void Initialize(IntPtr Handle)
        {
            simconnect = new SimConnect("Honeycomb Connect", Handle, WM_USER_SIMCONNECT, null, 0);

            // listen to connect and quit msgs
            simconnect.OnRecvOpen += new SimConnect.RecvOpenEventHandler(simconnect_OnRecvOpen);
            simconnect.OnRecvQuit += new SimConnect.RecvQuitEventHandler(simconnect_OnRecvQuit);

            // listen to exceptions
            simconnect.OnRecvException += simconnect_OnRecvException;

            RegisterPlaneStatusDefinition();
            simconnect.OnRecvSimobjectDataBytype += simconnect_OnRecvSimobjectDataBytypeAsync;

            simconnect.SubscribeToSystemEvent(EVENTS.PAUSE, "Pause");
            simconnect.OnRecvEvent += simconnect_OnRecvEvent;

            simconnect.MapClientEventToSimEvent(EVENTS.BEACON_TOGGLE, "TOGGLE_BEACON_LIGHTS");
            simconnect.MapClientEventToSimEvent(EVENTS.LANDING_LIGHTS_TOGGLE, "LANDING_LIGHTS_TOGGLE");
            simconnect.MapClientEventToSimEvent(EVENTS.TAXI_TOGGLE, "TOGGLE_TAXI_LIGHTS");
            simconnect.MapClientEventToSimEvent(EVENTS.NAV_TOGGLE, "TOGGLE_NAV_LIGHTS");
            simconnect.MapClientEventToSimEvent(EVENTS.STROBE_ON, "STROBES_ON");
            simconnect.MapClientEventToSimEvent(EVENTS.STROBE_OFF, "STROBES_OFF");

            simconnect.MapClientEventToSimEvent(EVENTS.MASTER_ALT_TOGGLE, "TOGGLE_MASTER_ALTERNATOR");
            simconnect.MapClientEventToSimEvent(EVENTS.MASTER_BATTERY_TOGGLE, "TOGGLE_MASTER_BATTERY");
            //simconnect.MapClientEventToSimEvent(EVENTS.MASTER_AVIONICS_TOGGLE, "TOGGLE_AVIONICS_MASTER");
            simconnect.MapClientEventToSimEvent(EVENTS.MASTER_AVIONICS_SET, "AVIONICS_MASTER_SET");
        }
Esempio n. 7
0
 public void Connect()
 {
     try
     {
         simconnect = new SimConnect("Managed Voice Control", this.Handle, WM_USER_SIMCONNECT, null, 0);
         simconnect.MapClientEventToSimEvent(EVENTS.PAUSE, "PAUSE_ON");
         simconnect.MapClientEventToSimEvent(EVENTS.UNPAUSE, "PAUSE_OFF");
     }
     catch (Exception ex)
     {
         Console.WriteLine("Sim Connect unable to connect to Prepar3D!\n\n{0}\n\n{1}", ex.Message, ex.StackTrace);
     }
 }
Esempio n. 8
0
        void simconnect_OnRecvOpen(SimConnect sender, SIMCONNECT_RECV_OPEN data)
        {
            button_Connect.Text = "Disconnect";
            displayText("Connected to FSX");


            simconnect.MapClientEventToSimEvent(EVENT_ID.EVENT_TOGGLE_MASTER_ALTERNATOR, "TOGGLE_ALTERNATOR1");
            simconnect.MapClientEventToSimEvent(EVENT_ID.EVENT_TOGGLE_MASTER_BATTERY, "TOGGLE_MASTER_BATTERY");
            simconnect.MapClientEventToSimEvent(EVENT_ID.EVENT_FUEL_PUMP, "FUEL_PUMP");
            simconnect.MapClientEventToSimEvent(EVENT_ID.EVENT_TOGGLE_BEACON_LIGHTS, "TOGGLE_BEACON_LIGHTS");
            simconnect.MapClientEventToSimEvent(EVENT_ID.EVENT_LANDING_LIGHTS_TOGGLE, "LANDING_LIGHTS_TOGGLE");
            simconnect.MapClientEventToSimEvent(EVENT_ID.EVENT_TOGGLE_TAXI_LIGHTS, "TOGGLE_TAXI_LIGHTS");
            simconnect.MapClientEventToSimEvent(EVENT_ID.EVENT_TOGGLE_NAV_LIGHTS, "TOGGLE_NAV_LIGHTS");
            simconnect.MapClientEventToSimEvent(EVENT_ID.EVENT_STROBES_TOGGLE, "STROBES_TOGGLE");
            simconnect.MapClientEventToSimEvent(EVENT_ID.EVENT_PITOT_TOGGLE, "PITOT_HEAT_TOGGLE");
            simconnect.MapClientEventToSimEvent(EVENT_ID.EVENT_TOGGLE_AVIONICS_MASTER, "TOGGLE_AVIONICS_MASTER");



            simconnect.AddClientEventToNotificationGroup(GROUP_ID.GROUP0, EVENT_ID.EVENT_TOGGLE_MASTER_ALTERNATOR, false);
            simconnect.AddClientEventToNotificationGroup(GROUP_ID.GROUP0, EVENT_ID.EVENT_TOGGLE_MASTER_BATTERY, false);
            simconnect.AddClientEventToNotificationGroup(GROUP_ID.GROUP0, EVENT_ID.EVENT_FUEL_PUMP, false);
            simconnect.AddClientEventToNotificationGroup(GROUP_ID.GROUP0, EVENT_ID.EVENT_TOGGLE_BEACON_LIGHTS, false);
            simconnect.AddClientEventToNotificationGroup(GROUP_ID.GROUP0, EVENT_ID.EVENT_LANDING_LIGHTS_TOGGLE, false);
            simconnect.AddClientEventToNotificationGroup(GROUP_ID.GROUP0, EVENT_ID.EVENT_TOGGLE_TAXI_LIGHTS, false);
            simconnect.AddClientEventToNotificationGroup(GROUP_ID.GROUP0, EVENT_ID.EVENT_TOGGLE_NAV_LIGHTS, false);
            simconnect.AddClientEventToNotificationGroup(GROUP_ID.GROUP0, EVENT_ID.EVENT_STROBES_TOGGLE, false);
            simconnect.AddClientEventToNotificationGroup(GROUP_ID.GROUP0, EVENT_ID.EVENT_PITOT_TOGGLE, false);
            simconnect.AddClientEventToNotificationGroup(GROUP_ID.GROUP0, EVENT_ID.EVENT_TOGGLE_AVIONICS_MASTER, false);


            simconnect.MapInputEventToClientEvent(GROUP_ID.GROUP0, "joystick:1:button:0", EVENT_ID.EVENT_TOGGLE_MASTER_ALTERNATOR, 0, null, 0, false);
            simconnect.MapInputEventToClientEvent(GROUP_ID.GROUP0, "joystick:1:button:1", EVENT_ID.EVENT_TOGGLE_MASTER_BATTERY, 0, null, 0, false);
            simconnect.MapInputEventToClientEvent(GROUP_ID.GROUP0, "joystick:1:button:8", EVENT_ID.EVENT_FUEL_PUMP, 0, null, 0, true);
            simconnect.MapInputEventToClientEvent(GROUP_ID.GROUP0, "joystick:1:button:9", EVENT_ID.EVENT_TOGGLE_BEACON_LIGHTS, 0, null, 0, false);

            simconnect.MapInputEventToClientEvent(GROUP_ID.GROUP0, "joystick:1:button:10", EVENT_ID.EVENT_LANDING_LIGHTS_TOGGLE, 0, null, 0, false);

            simconnect.MapInputEventToClientEvent(GROUP_ID.GROUP0, "joystick:1:button:11", EVENT_ID.EVENT_TOGGLE_TAXI_LIGHTS, 0, null, 0, false);
            simconnect.MapInputEventToClientEvent(GROUP_ID.GROUP0, "joystick:1:button:12", EVENT_ID.EVENT_TOGGLE_NAV_LIGHTS, 0, null, 0, false);

            simconnect.MapInputEventToClientEvent(GROUP_ID.GROUP0, "joystick:1:button:13", EVENT_ID.EVENT_STROBES_TOGGLE, 0, null, 0, false);
            simconnect.MapInputEventToClientEvent(GROUP_ID.GROUP0, "joystick:1:button:14", EVENT_ID.EVENT_PITOT_TOGGLE, 0, null, 0, false);

            simconnect.MapInputEventToClientEvent(GROUP_ID.GROUP0, "joystick:1:button:15", EVENT_ID.EVENT_TOGGLE_AVIONICS_MASTER, 0, null, 0, false);



            simconnect.SetInputGroupState(GROUP_ID.GROUP0, 1);
        }
Esempio n. 9
0
        // Set up all the SimConnect related event handlers
        private void initClientEvent()
        {
            try
            {
                // listen to connect and quit msgs
                simconnect.OnRecvOpen      += new SimConnect.RecvOpenEventHandler(simconnect_OnRecvOpen);
                simconnect.OnRecvQuit      += new SimConnect.RecvQuitEventHandler(simconnect_OnRecvQuit);
                simconnect.OnRecvException += new SimConnect.RecvExceptionEventHandler(simconnect_OnRecvException);
                simconnect.OnRecvEvent     += new SimConnect.RecvEventEventHandler(simconnect_OnRecvEvent);

                //Subscribe to events. Used to trigger data requests.
                simconnect.MapClientEventToSimEvent(EVENTS.AP_MASTER, "AP_MASTER");
                simconnect.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP0, EVENTS.AP_MASTER, false);

                //Data request definitions. These are used when when we receive events.
                simconnect.AddToDataDefinition(DEFINITION.MCP, "Autopilot Master", "Boolean", SIMCONNECT_DATATYPE.INT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);

                simconnect.RegisterDataDefineStruct <MCP>(DEFINITION.MCP);

                simconnect.OnRecvSimobjectDataBytype += new SimConnect.RecvSimobjectDataBytypeEventHandler(simconnect_OnRecvSimobjectDataBytype);

                // set the group priority
                simconnect.SetNotificationGroupPriority(NOTIFICATION_GROUPS.GROUP0, SimConnect.SIMCONNECT_GROUP_PRIORITY_HIGHEST);
            }
            catch (COMException ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
Esempio n. 10
0
        private void InitSimConnectField(Field field)
        {
            if (!isConnected)
            {
                return;
            }
            var attrib = FieldDefinition(field);

            if (attrib is null)
            {
                return;
            }

            var unitConfig = UnitTypeConfig.GetConfig(attrib.UnitType);

            // Set up data definition
            Console.WriteLine($"Def {attrib.DatumName}, {attrib.UnitType}");
            simconnect.AddToDataDefinition(field, attrib.DatumName, unitConfig.Units,
                                           unitConfig.DataType, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            var method    = typeof(SimConnect).GetMethod("RegisterDataDefineStruct");
            var methodRef = method.MakeGenericMethod(unitConfig.Struct);

            methodRef.Invoke(simconnect, new object[] { field });

            // Get initial value
            simconnect.RequestDataOnSimObjectType(field, field, 0, SIMCONNECT_SIMOBJECT_TYPE.USER);

            // Create event mapping
            simconnect.MapClientEventToSimEvent(field, attrib.EventId);
            simconnect.AddClientEventToNotificationGroup(GROUPS.GroupA, field, false);
        }
Esempio n. 11
0
        // Set up the SimConnect event handlers
        private void initComms()
        {
            try
            {
                // listen to connect and quit msgs
                simconnect.OnRecvOpen += new SimConnect.RecvOpenEventHandler(simconnect_OnRecvOpen);
                simconnect.OnRecvQuit += new SimConnect.RecvQuitEventHandler(simconnect_OnRecvQuit);

                // listen to exceptions
                simconnect.OnRecvException += new SimConnect.RecvExceptionEventHandler(simconnect_OnRecvException);

                // catch the assigned object IDs
                simconnect.OnRecvAssignedObjectId += new SimConnect.RecvAssignedObjectIdEventHandler(simconnect_OnRecvAssignedObjectId);

                // set up the data definiton for the Maule lights
                simconnect.AddToDataDefinition(DEFINITIONS.MauleLights, "LIGHT STATES", "mask", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);

                // IMPORTANT: register it with the simconnect managed wrapper marshaller
                // if you skip this step, you will only receive a uint in the .dwData field.
                simconnect.RegisterDataDefineStruct <MauleLights>(DEFINITIONS.MauleLights);

                // Subscribe to system event Pause

                simconnect.SubscribeToSystemEvent(EVENTS.PAUSED, "Pause");
                simconnect.OnRecvEvent += new SimConnect.RecvEventEventHandler(simconnect_OnRecvEvent);

                // Map an event to the EventID: PAUSE_OFF
                simconnect.MapClientEventToSimEvent(EVENTS.SEND_UNPAUSE, "PAUSE_OFF");
            }
            catch (COMException ex)
            {
                displayText(ex.Message);
            }
        }
        private void OnConnected(SimConnect sender, SIMCONNECT_RECV_OPEN data)
        {
            foreach (var simEvent in Enum.GetValues(typeof(SimEvents)).Cast <SimEvents>())
            {
                _simConnect.MapClientEventToSimEvent(simEvent, simEvent.ToString());
            }

            foreach (var simVar in _simVars)
            {
                _simConnect.AddToDataDefinition(
                    simVar.SimVar,
                    simVar.Name,
                    string.Empty,
                    simVar.SimConnectType,
                    0,
                    SimConnect.SIMCONNECT_UNUSED);

                _registerDataDefineStructMethodInfo.MakeGenericMethod(simVar.ClrType).Invoke(_simConnect, new object[] { simVar.SimVar });

                _simConnect.RequestDataOnSimObject(
                    simVar.SimVar,
                    simVar.SimVar,
                    SimConnect.SIMCONNECT_OBJECT_ID_USER,
                    SIMCONNECT_PERIOD.VISUAL_FRAME, SIMCONNECT_DATA_REQUEST_FLAG.CHANGED, 0, 0, 0);
            }
        }
Esempio n. 13
0
        public void RegisterToggleEvent(TOGGLE_EVENT toggleAction)
        {
            if (simconnect == null)
            {
                return;
            }

            if (genericEvents.Contains(toggleAction))
            {
                return;
            }

            genericEvents.Add(toggleAction);
            logger.LogInformation("RegisterEvent {action} {simConnectAction}", toggleAction, toggleAction.EventToSimConnectEvent());
            simconnect.MapClientEventToSimEvent(toggleAction, toggleAction.EventToSimConnectEvent());
        }
Esempio n. 14
0
 private void RegisterEventsEnum <TEnum>()
 {
     foreach (var value in Enum.GetValues(typeof(TEnum)))
     {
         m_simConnect.MapClientEventToSimEvent((Enum)value, Enum.GetName(typeof(TEnum), value).Replace("MOBIFLIGHT_", "MobiFlight."));
     }
 }
Esempio n. 15
0
 private void MapClientEvents()
 {
     foreach (SimEvents simEvent in Enum.GetValues(typeof(SimEvents)))
     {
         var simEventString = ParseEventString(simEvent);
         _simConnect.MapClientEventToSimEvent(simEvent, simEventString);
     }
 }
Esempio n. 16
0
        // Set up the SimConnect event handlers
        public void Initialize(IntPtr Handle)
        {
            simconnect = new SimConnect("Flight Tracker", Handle, WM_USER_SIMCONNECT, null, 0);

            // listen to connect and quit msgs
            simconnect.OnRecvOpen += new SimConnect.RecvOpenEventHandler(simconnect_OnRecvOpen);
            simconnect.OnRecvQuit += new SimConnect.RecvQuitEventHandler(simconnect_OnRecvQuit);

            // listen to exceptions
            simconnect.OnRecvException += simconnect_OnRecvException;

            // catch the assigned object IDs
            simconnect.OnRecvSimobjectDataBytype += simconnect_OnRecvSimobjectDataBytypeAsync;
            RegisterAircraftDataDefinition();
            RegisterFlightPlanDefinition();
            RegisterFlightStatusDefinition();

            simconnect.OnRecvSimobjectData += Simconnect_OnRecvSimobjectData;
            RegisterEnvironmentDataDefinition();

            // Subscribe to system event Pause
            simconnect.SubscribeToSystemEvent(EVENTS.SIM_START, "SimStart");
            simconnect.SubscribeToSystemEvent(EVENTS.SIM_STOP, "SimStop");
            simconnect.SubscribeToSystemEvent(EVENTS.PAUSED, "Pause");
            simconnect.SubscribeToSystemEvent(EVENTS.AIRCRAFT_LOADED, "AircraftLoaded");
            simconnect.SubscribeToSystemEvent(EVENTS.FLIGHT_LOADED, "FlightLoaded");
            simconnect.SubscribeToSystemEvent(EVENTS.CRASHED, "Crashed");
            simconnect.SubscribeToSystemEvent(EVENTS.CRASH_RESET, "CrashReset");
            simconnect.SubscribeToSystemEvent(EVENTS.FLIGHTPLAN_ACTIVATED, "FlightPlanActivated");
            simconnect.SubscribeToSystemEvent(EVENTS.FLIGHTPLAN_DEACTIVATED, "FlightPlandeactivated");
            simconnect.SubscribeToSystemEvent(EVENTS.POSITION_CHANGED, "PositionChanged");
            simconnect.OnRecvEventFilename += Simconnect_OnRecvEventFilename;
            simconnect.OnRecvEvent         += simconnect_OnRecvEvent;

            simconnect.OnRecvAirportList += simconnect_OnRecvAirportList;

            simconnect.OnRecvSystemState += simconnect_OnRecvSystemState;
            simconnect.RequestSystemState(DATA_REQUESTS.FLIGHT_PLAN, "FlightPlan");

            simconnect.MapClientEventToSimEvent(EVENTS.SCREENSHOT, "CAPTURE_SCREENSHOT");

            simconnect.MapClientEventToSimEvent(EVENTS.SIM_RATE_INCREASE, "SIM_RATE_INCR");
            simconnect.MapClientEventToSimEvent(EVENTS.SIM_RATE_DECREASE, "SIM_RATE_DECR");
        }
Esempio n. 17
0
        void setupPulling()
        {
            sc.AddToDataDefinition(SIMCONNECT_DATA_DEFINITION_ID.planeLocation, "Plane Longitude", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            sc.AddToDataDefinition(SIMCONNECT_DATA_DEFINITION_ID.planeLocation, "Plane Latitude", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            sc.AddToDataDefinition(SIMCONNECT_DATA_DEFINITION_ID.planeLocation, "Plane Altitude", "kilometers", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            sc.AddToDataDefinition(SIMCONNECT_DATA_DEFINITION_ID.planeLocation, "AIRSPEED TRUE", "knots", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            sc.AddToDataDefinition(SIMCONNECT_DATA_DEFINITION_ID.planeLocation, "ATTITUDE INDICATOR PITCH DEGREES", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            sc.AddToDataDefinition(SIMCONNECT_DATA_DEFINITION_ID.planeLocation, "ATTITUDE INDICATOR BANK DEGREES", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            sc.AddToDataDefinition(SIMCONNECT_DATA_DEFINITION_ID.planeLocation, "Delta Heading Rate", "degrees per second", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            sc.AddToDataDefinition(SIMCONNECT_DATA_DEFINITION_ID.planeLocation, "Turn Coordinator Ball", "number", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            sc.AddToDataDefinition(SIMCONNECT_DATA_DEFINITION_ID.planeLocation, "Heading Indicator", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            sc.AddToDataDefinition(SIMCONNECT_DATA_DEFINITION_ID.planeLocation, "Vertical Speed", "ft/min", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            sc.AddToDataDefinition(SIMCONNECT_DATA_DEFINITION_ID.planeLocation, "GPS GROUND SPEED", "m/s", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            sc.MapClientEventToSimEvent(EVENT_ID.EVENT_PAUSE, "pause_toggle");
            sc.MapClientEventToSimEvent(EVENT_ID.EVENT_BRAKES, "brakes");

            sc.RegisterDataDefineStruct <PlaneStruct>(SIMCONNECT_DATA_DEFINITION_ID.planeLocation);
            sc.RequestDataOnSimObject(DATA_REQUEST_ID.REQUEST_1, SIMCONNECT_DATA_DEFINITION_ID.planeLocation, SimConnect.SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD.SECOND, 0, 0, 0, 0);
        }
Esempio n. 18
0
        private void addSimEvent(CLIENT_EVENTS clientEvent, bool notify = false)
        {
            string simEvent = clientEvent.ToString();

            simconnect.MapClientEventToSimEvent(clientEvent, simEvent);
            if (notify == true)
            {
                simconnect.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP0, clientEvent, false);
            }
        }
        public bool MapClientEventToSimEvent(Enum eventId, string eventName)
        {
            if (_connected)
            {
                _simConnect.MapClientEventToSimEvent(eventId, eventName);
                return(true);
            }

            return(false);
        }
        void connect()
        {
            try
            {
                simconnect = new SimConnect("Managed Data Request", this.Handle, WM_USER_SIMCONNECT, null, 0);
                simconnect.MapClientEventToSimEvent(PAUSE_EVENTS.PAUSE, "PAUSE_ON");
                simconnect.MapClientEventToSimEvent(PAUSE_EVENTS.UNPAUSE, "PAUSE_OFF");
                simconnect.MapClientEventToSimEvent(PAUSE_EVENTS.GEAR_UP, "GEAR_UP");
                simconnect.MapClientEventToSimEvent(PAUSE_EVENTS.GEAR_DOWN, "GEAR_DOWN");
                simconnect.MapClientEventToSimEvent(PAUSE_EVENTS.THROTTLE_SET, "THROTTLE_SET");
                simconnect.MapClientEventToSimEvent(PAUSE_EVENTS.THROTTLE_FULL, "THROTTLE_FULL");


                simconnect.AddToDataDefinition(DEFINITIONS.Control1, "RUDDER POSITION", "", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
                simconnect.AddToDataDefinition(DEFINITIONS.Control1, "ELEVATOR POSITION", "", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
                simconnect.AddToDataDefinition(DEFINITIONS.Control1, "AILERON POSITION", "", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
                simconnect.AddToDataDefinition(DEFINITIONS.Control1, "FLAPS HANDLE INDEX", "", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
                simconnect.AddToDataDefinition(DEFINITIONS.Control1, "SPOILERS HANDLE POSITION", "", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
                simconnect.AddToDataDefinition(DEFINITIONS.Control1, "General Eng Throttle Lever Position:1", "", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
                simconnect.AddToDataDefinition(DEFINITIONS.Control1, "General Eng Throttle Lever Position:2", "", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);

                // IMPORTANT: register it with the simconnect managed wrapper marshaller
                // if you skip this step, you will only receive a uint in the .dwData field.
                simconnect.RegisterDataDefineStruct <Control1>(DEFINITIONS.Control1);

                // catch a simobject data request
                simconnect.OnRecvSimobjectData += new SimConnect.RecvSimobjectDataEventHandler(simconnect_OnRecvSimobjectData);
            }
            catch (COMException ex)
            {
                Console.WriteLine(ex);
            }
        }
Esempio n. 21
0
        // Set up all the SimConnect related event handlers
        private void initClientEvent()
        {
            try
            {
                // listen to connect and quit msgs
                simconnect.OnRecvOpen += new SimConnect.RecvOpenEventHandler(simconnect_OnRecvOpen);
                simconnect.OnRecvQuit += new SimConnect.RecvQuitEventHandler(simconnect_OnRecvQuit);

                // listen to exceptions
                simconnect.OnRecvException += new SimConnect.RecvExceptionEventHandler(simconnect_OnRecvException);

                // listen to events
                simconnect.OnRecvEvent += new SimConnect.RecvEventEventHandler(simconnect_OnRecvEvent);

                // subscribe to pitot heat switch toggle
                simconnect.MapClientEventToSimEvent(EVENTS.PITOT_TOGGLE, "PITOT_HEAT_TOGGLE");
                simconnect.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP0, EVENTS.PITOT_TOGGLE, false);

                // subscribe to all four flaps controls
                simconnect.MapClientEventToSimEvent(EVENTS.FLAPS_UP, "FLAPS_UP");
                simconnect.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP0, EVENTS.FLAPS_UP, false);
                simconnect.MapClientEventToSimEvent(EVENTS.FLAPS_DOWN, "FLAPS_DOWN");
                simconnect.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP0, EVENTS.FLAPS_DOWN, false);
                simconnect.MapClientEventToSimEvent(EVENTS.FLAPS_INC, "FLAPS_INCR");
                simconnect.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP0, EVENTS.FLAPS_INC, false);
                simconnect.MapClientEventToSimEvent(EVENTS.FLAPS_DEC, "FLAPS_DECR");
                simconnect.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP0, EVENTS.FLAPS_DEC, false);

                // set the group priority
                simconnect.SetNotificationGroupPriority(NOTIFICATION_GROUPS.GROUP0, SimConnect.SIMCONNECT_GROUP_PRIORITY_HIGHEST);

            }
            catch (COMException ex)
            {
                displayText(ex.Message);
            }
        }
Esempio n. 22
0
        static void Main()
        {
            simConnect = new SimConnect("SimConnectTest", GetConsoleWindow(), WM_USER_SIMCONNECT, null, 0);

            simConnect.MapClientEventToSimEvent(Events.EventSteerAileron, "AILERON_SET");
            simConnect.AddClientEventToNotificationGroup(NotificationGroups.Group0, Events.EventSteerAileron, false);

            simConnect.SetNotificationGroupPriority(NotificationGroups.Group0, SimConnect.SIMCONNECT_GROUP_PRIORITY_HIGHEST);

            while (true)
            {
                Thread.Sleep(50);
                int d = (int)(Math.Sin((DateTime.Now - DateTime.Today).TotalSeconds / 2) * 16000);
                simConnect.TransmitClientEvent(0, Events.EventSteerAileron, (uint)d, NotificationGroups.Group0, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);
            }
        }
Esempio n. 23
0
        // Set up the SimConnect event handlers
        private void initComms()
        {
            try
            {
                // listen to connect and quit msgs
                simconnect.OnRecvOpen += new SimConnect.RecvOpenEventHandler(simconnect_OnRecvOpen);
                simconnect.OnRecvQuit += new SimConnect.RecvQuitEventHandler(simconnect_OnRecvQuit);

                // listen to exceptions
                simconnect.OnRecvException += new SimConnect.RecvExceptionEventHandler(simconnect_OnRecvException);

                // catch the assigned object IDs
                simconnect.OnRecvAssignedObjectId += new SimConnect.RecvAssignedObjectIdEventHandler(simconnect_OnRecvAssignedObjectId);

                // set up the data definiton for the Extra smoke
                simconnect.AddToDataDefinition(DEFINITIONS.ExtraSmoke, "SMOKE ENABLE", "bool", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);

                // IMPORTANT: register it with the simconnect managed wrapper marshaller
                // if you skip this step, you will only receive a uint in the .dwData field.
                simconnect.RegisterDataDefineStruct <ExtraSmoke>(DEFINITIONS.ExtraSmoke);

                // Subscribe to system event Pause
                simconnect.SubscribeToSystemEvent(EVENTS.PAUSED, "Pause");
                simconnect.OnRecvEvent += new SimConnect.RecvEventEventHandler(simconnect_OnRecvEvent);

                // Map an event to the EventID: PAUSE_OFF
                simconnect.MapClientEventToSimEvent(EVENTS.SEND_UNPAUSE, "PAUSE_OFF");

                // define & register PositionData, used for LLAPBH updates on Sim Objects
                simconnect.AddToDataDefinition(DEFINITIONS.PositionData, "Plane Latitude", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
                simconnect.AddToDataDefinition(DEFINITIONS.PositionData, "Plane Longitude", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
                simconnect.AddToDataDefinition(DEFINITIONS.PositionData, "PLANE ALTITUDE", "meters", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
                simconnect.AddToDataDefinition(DEFINITIONS.PositionData, "Plane Pitch Degrees", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
                simconnect.AddToDataDefinition(DEFINITIONS.PositionData, "Plane Bank Degrees", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
                simconnect.AddToDataDefinition(DEFINITIONS.PositionData, "Plane Heading Degrees True", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            }
            catch (COMException ex)
            {
                displayText(ex.Message);
            }
        }
Esempio n. 24
0
        /// <summary>
        /// Méthode d'assignation des commandes et des variables
        /// </summary>
        public void AssignCommandsAndValues <T>()
        {
            EngineCommands      = new EngineCommands(SimConnect);
            MiscSystemsCommands = new MiscSystemsCommands(SimConnect);
            LightsCommands      = new LightsCommands(SimConnect);
            FuelSystemsCommands = new FuelSystemsCommands(SimConnect);

            // On assigne les différentes commandes qu'on veut envoyer au simulateur
            foreach (SimEvents simEvent in Enum.GetValues(typeof(SimEvents)))
            {
                SimConnect.MapClientEventToSimEvent(simEvent, simEvent.ToString());
            }

            // Il reste à assigner les différentes variables à récupérer au niveau du simulateur
            foreach (var variable in SimVariables.Variables)
            {
                SimConnect.AddToDataDefinition(DEFINITIONS.Dummy, variable.PropertyName, variable.PropertyType, SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            }

            SimConnect.RegisterDataDefineStruct <T>(DEFINITIONS.Dummy);
        }
Esempio n. 25
0
        private Events GetEventID(string strEventID)
        {
            var evt = strEventID.Trim().ToUpperInvariant();

            if (_simEvents != null && !_simEvents.Contains(evt))
            {
                throw new KeyNotFoundException($"Given event string '{strEventID}' does not exist in Flight Simulator X.");
            }
            uint value;
            var  result = _events.TryGetValue(evt, out value);

            if (result)
            {
                return((Events)value);
            }
            else
            {
                value = (uint)_events.Count;
                _sc.MapClientEventToSimEvent((Events)value, evt);
                _events.Add(evt, value);
                return((Events)value);
            }
        }
        // Set up the SimConnect event handlers
        public void Initialize(IntPtr Handle)
        {
            simconnect = new SimConnect("Flight Tracker Stream Deck", Handle, WM_USER_SIMCONNECT, null, 0);

            // listen to connect and quit msgs
            simconnect.OnRecvOpen += new SimConnect.RecvOpenEventHandler(Simconnect_OnRecvOpen);
            simconnect.OnRecvQuit += new SimConnect.RecvQuitEventHandler(Simconnect_OnRecvQuit);

            // listen to exceptions
            simconnect.OnRecvException += Simconnect_OnRecvException;

            simconnect.OnRecvSimobjectDataBytype += Simconnect_OnRecvSimobjectDataBytypeAsync;
            RegisterFlightStatusDefinition();
            RegisterGenericValues(true);

            simconnect.OnRecvSystemState += Simconnect_OnRecvSystemState;

            simconnect.MapClientEventToSimEvent(EVENTS.AUTOPILOT_ON, "AUTOPILOT_ON");
            simconnect.MapClientEventToSimEvent(EVENTS.AUTOPILOT_OFF, "AUTOPILOT_OFF");
            simconnect.MapClientEventToSimEvent(EVENTS.AUTOPILOT_TOGGLE, "AP_MASTER");
            simconnect.MapClientEventToSimEvent(EVENTS.AP_HDG_TOGGLE, "AP_PANEL_HEADING_HOLD");
            simconnect.MapClientEventToSimEvent(EVENTS.AP_NAV_TOGGLE, "AP_NAV1_HOLD");
            simconnect.MapClientEventToSimEvent(EVENTS.AP_APR_TOGGLE, "AP_APR_HOLD");
            simconnect.MapClientEventToSimEvent(EVENTS.AP_ALT_TOGGLE, "AP_PANEL_ALTITUDE_HOLD");

            simconnect.MapClientEventToSimEvent(EVENTS.AP_HDG_SET, "HEADING_BUG_SET");
            simconnect.MapClientEventToSimEvent(EVENTS.AP_HDG_INC, "HEADING_BUG_INC");
            simconnect.MapClientEventToSimEvent(EVENTS.AP_HDG_DEC, "HEADING_BUG_DEC");

            simconnect.MapClientEventToSimEvent(EVENTS.AP_ALT_SET, "AP_ALT_VAR_SET_ENGLISH");
            simconnect.MapClientEventToSimEvent(EVENTS.AP_ALT_INC, "AP_ALT_VAR_INC");
            simconnect.MapClientEventToSimEvent(EVENTS.AP_ALT_DEC, "AP_ALT_VAR_DEC");
        }
Esempio n. 27
0
        private void SetFlightDataDefinitions()
        {
            #region Aircraft Properties
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "PLANE LATITUDE", "Degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "PLANE LONGITUDE", "Degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "PLANE ALTITUDE", "feet", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "FUEL TOTAL QUANTITY", "gallons", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "FUEL TOTAL CAPACITY", "gallons", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "PLANE HEADING DEGREES TRUE", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "AIRSPEED INDICATED", "knots", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "AIRSPEED TRUE", "knots", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            #endregion

            #region Nav Properties
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "NAV HAS NAV", "bool", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "NAV HAS DME", "bool", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "NAV DME", "nautical miles", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            #endregion

            #region Autopilot Properties
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "AUTOPILOT AVAILABLE", "bool", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "AUTOPILOT MASTER", "bool", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "AUTOPILOT WING LEVELER", "bool", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "AUTOPILOT ALTITUDE LOCK", "bool", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "AUTOPILOT ALTITUDE LOCK VAR", "feet", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "AUTOPILOT APPROACH HOLD", "bool", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "AUTOPILOT BACKCOURSE HOLD", "bool", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "AUTOPILOT FLIGHT DIRECTOR ACTIVE", "bool", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "AUTOPILOT AIRSPEED HOLD", "bool", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "AUTOPILOT AIRSPEED HOLD VAR", "knots", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "AUTOPILOT MACH HOLD", "bool", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "AUTOPILOT YAW DAMPER", "bool", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "AUTOTHROTTLE ACTIVE", "bool", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "AUTOPILOT VERTICAL HOLD", "bool", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "AUTOPILOT VERTICAL HOLD VAR", "Feet/minute", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "AUTOPILOT HEADING LOCK", "bool", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "AUTOPILOT HEADING LOCK DIR", "degrees", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "AUTOPILOT NAV1 LOCK", "bool", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);

            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "GEAR HANDLE POSITION", "position", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "GEAR CENTER POSITION", "position", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "GEAR LEFT POSITION", "position", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "GEAR RIGHT POSITION", "position", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "IS GEAR RETRACTABLE", "bool", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "GEAR TOTAL PCT EXTENDED", "percent", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            simconnect.AddToDataDefinition(DEFINITIONS.AircraftStatus, "BRAKE PARKING POSITION", "position", SIMCONNECT_DATATYPE.INT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
            #endregion

            simconnect.RegisterDataDefineStruct <AircraftStatusStruct>(DEFINITIONS.AircraftStatus);

            simconnect.MapClientEventToSimEvent(Events.GEAR_UP, "GEAR_UP");
            simconnect.MapClientEventToSimEvent(Events.GEAR_DOWN, "GEAR_DOWN");
            simconnect.MapClientEventToSimEvent(Events.PARKING_BRAKES_TOGGLE, "PARKING_BRAKES");

            simconnect.MapClientEventToSimEvent(Events.AUTOPILOT_MASTER_TOGGLE, "AP_MASTER");
            simconnect.MapClientEventToSimEvent(Events.AUTOPILOT_HEADING_INC, "HEADING_BUG_INC");
            simconnect.MapClientEventToSimEvent(Events.AUTOPILOT_HEADING_DEC, "HEADING_BUG_DEC");
            simconnect.MapClientEventToSimEvent(Events.AUTOPILOT_HEADING_SET, "HEADING_BUG_SET");
            simconnect.MapClientEventToSimEvent(Events.AUTOPILOT_HEADING_HOLD_TOGGLE, "AP_HDG_HOLD");

            simconnect.MapClientEventToSimEvent(Events.AUTOPILOT_SET_ALT_REF, "AP_ALT_VAR_SET_ENGLISH");
            simconnect.MapClientEventToSimEvent(Events.AUTOPILOT_ALTITUDE_HOLD_TOGGLE, "AP_ALT_HOLD");

            simconnect.MapClientEventToSimEvent(Events.AUTOPILOT_LOC_HOLD_TOGGLE, "AP_LOC_HOLD");
            simconnect.MapClientEventToSimEvent(Events.AUTOPILOT_APPR_HOLD_TOGGLE, "AP_APR_HOLD");
            simconnect.MapClientEventToSimEvent(Events.AUTOPILOT_NAV_HOLD_TOGGLE, "AP_NAV1_HOLD");
            simconnect.MapClientEventToSimEvent(Events.AUTOPILOT_FD_TOGGLE, "TOGGLE_FLIGHT_DIRECTOR");
            simconnect.MapClientEventToSimEvent(Events.AUTOPILOT_AUTO_THROTTLE_TOGGLE, "AUTO_THROTTLE_ARM");

            simconnect.MapClientEventToSimEvent(Events.AUTOPILOT_PANEL_SPEED_HOLD, "AP_PANEL_SPEED_HOLD");
            simconnect.MapClientEventToSimEvent(Events.AUTOPILOT_PANEL_SPEED_SET, "AP_SPD_VAR_SET");

            simconnect.MapClientEventToSimEvent(Events.AUTOPILOT_VERTICAL_SPEED_SET, "AP_VS_VAR_SET_ENGLISH");
            simconnect.MapClientEventToSimEvent(Events.AUTOPILOT_VERTICAL_SPEED_TOGGLE, "AP_VS_HOLD");

            simconnect.MapClientEventToSimEvent(Events.CAMERA_TOGGLE_CHASE_VIEW, "CHASE_VIEW_TOGGLE");
            simconnect.MapClientEventToSimEvent(Events.CAMERA_VIEW_MODE, "VIEW_MODE");
        }
Esempio n. 28
0
        public void Connect(string name, IntPtr hWnd, WaitHandle hEventHandle, uint configIndex)
        {
            simConnect = new SimConnect(name, hWnd, WM_USER_SIMCONNECT, hEventHandle, configIndex);

            simConnect.MapClientEventToSimEvent(Events.FreezeLatitudeLongitude, "FREEZE_LATITUDE_LONGITUDE_SET");
        }
Esempio n. 29
0
 public override void Declare(SimConnect conn)
 {
     base.Declare(conn);
     conn.MapClientEventToSimEvent(EventEnum, setEventName);
 }
Esempio n. 30
0
        // Set up the SimConnect event handlers
        public void Initialize(IntPtr Handle)
        {
            if (simconnect != null)
            {
                logger.LogWarning("Initialization is already done. Cancelled this request.");
                return;
            }
            simconnect = new SimConnect("Flight Tracker Stream Deck", Handle, WM_USER_SIMCONNECT, null, 0);

            // listen to connect and quit msgs
            simconnect.OnRecvOpen += new SimConnect.RecvOpenEventHandler(Simconnect_OnRecvOpen);
            simconnect.OnRecvQuit += new SimConnect.RecvQuitEventHandler(Simconnect_OnRecvQuit);

            // listen to exceptions
            simconnect.OnRecvException += Simconnect_OnRecvException;

            simconnect.OnRecvSimobjectDataBytype += Simconnect_OnRecvSimobjectDataBytypeAsync;
            simconnect.OnRecvSystemState         += Simconnect_OnRecvSystemState;

            RegisterFlightStatusDefinition();

            simconnect.MapClientEventToSimEvent(EVENTS.AUTOPILOT_ON, "AUTOPILOT_ON");
            simconnect.MapClientEventToSimEvent(EVENTS.AUTOPILOT_OFF, "AUTOPILOT_OFF");
            simconnect.MapClientEventToSimEvent(EVENTS.AUTOPILOT_TOGGLE, "AP_MASTER");
            simconnect.MapClientEventToSimEvent(EVENTS.AP_HDG_TOGGLE, "AP_PANEL_HEADING_HOLD");
            simconnect.MapClientEventToSimEvent(EVENTS.AP_NAV_TOGGLE, "AP_NAV1_HOLD");
            simconnect.MapClientEventToSimEvent(EVENTS.AP_APR_TOGGLE, "AP_APR_HOLD");
            simconnect.MapClientEventToSimEvent(EVENTS.AP_ALT_TOGGLE, "AP_PANEL_ALTITUDE_HOLD");
            simconnect.MapClientEventToSimEvent(EVENTS.AP_VS_TOGGLE, "AP_VS_HOLD");
            simconnect.MapClientEventToSimEvent(EVENTS.AP_FLC_ON, "FLIGHT_LEVEL_CHANGE_ON");
            simconnect.MapClientEventToSimEvent(EVENTS.AP_FLC_OFF, "FLIGHT_LEVEL_CHANGE_OFF");

            simconnect.MapClientEventToSimEvent(EVENTS.AP_HDG_SET, "HEADING_BUG_SET");
            simconnect.MapClientEventToSimEvent(EVENTS.AP_HDG_INC, "HEADING_BUG_INC");
            simconnect.MapClientEventToSimEvent(EVENTS.AP_HDG_DEC, "HEADING_BUG_DEC");

            simconnect.MapClientEventToSimEvent(EVENTS.AP_ALT_SET, "AP_ALT_VAR_SET_ENGLISH");
            simconnect.MapClientEventToSimEvent(EVENTS.AP_ALT_INC, "AP_ALT_VAR_INC");
            simconnect.MapClientEventToSimEvent(EVENTS.AP_ALT_DEC, "AP_ALT_VAR_DEC");

            simconnect.MapClientEventToSimEvent(EVENTS.AP_VS_SET, "AP_VS_VAR_SET_ENGLISH");
            simconnect.MapClientEventToSimEvent(EVENTS.AP_VS_INC, "AP_VS_VAR_INC");
            simconnect.MapClientEventToSimEvent(EVENTS.AP_VS_DEC, "AP_VS_VAR_DEC");

            simconnect.MapClientEventToSimEvent(EVENTS.AP_AIRSPEED_SET, "AP_SPD_VAR_SET");
            simconnect.MapClientEventToSimEvent(EVENTS.AP_AIRSPEED_INC, "AP_SPD_VAR_INC");
            simconnect.MapClientEventToSimEvent(EVENTS.AP_AIRSPEED_DEC, "AP_SPD_VAR_DEC");

            simconnect.MapClientEventToSimEvent(EVENTS.AVIONICS_TOGGLE, "AVIONICS_MASTER_SET");

            isGenericValueRegistered = false;
            RegisterGenericValues();
            RegisterGenericEvents();
        }
Esempio n. 31
0
        static void Main(string[] args)
        {
            try
            {
                //Création d'une instance pour acceder à la librairie simconnect
                //m_scConnection = new Microsoft.FlightSimulator.SimConnect.SimConnect("FFSTracker", base.Handle, WM_USER_SIMCONNECT, null, 0);
                m_scConnection = new SimConnect("FSXML", IntPtr.Zero, WM_USER_SIMCONNECT, null, 0);
                Console.WriteLine("La connexion au simulateur a réussie");
            }
            catch
            {
                Console.WriteLine("La connexion à FS à échouée.");
                return;
            }
            // On map les event avec notre enumérateur
            foreach (EventEnum item in Enum.GetValues(typeof(EventEnum)))
            {
                m_scConnection.MapClientEventToSimEvent(item, item.ToString());
            }

            //On map les variables avec notre structure
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Title", "", SIMCONNECT_DATATYPE.STRING256, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Plane Latitude", "degrees latitude", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Plane Longitude", "degrees longitude", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Plane Altitude", "feet", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Airspeed Indicated", "knots", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Plane Heading Degrees Magnetic", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Plane Heading Degrees True", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Com Active Frequency:1", "MHz", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Com Active Frequency:2", "MHz", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Com Standby Frequency:1", "MHz", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Com Standby Frequency:2", "MHz", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Nav Active Frequency:1", "MHz", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Nav Active Frequency:2", "MHz", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Nav Standby Frequency:1", "MHz", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Nav Standby Frequency:2", "MHz", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Autopilot Master", "", SIMCONNECT_DATATYPE.INT32, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Autopilot Approach Hold", "", SIMCONNECT_DATATYPE.INT32, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Autopilot Heading Lock", "", SIMCONNECT_DATATYPE.INT32, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Autopilot Heading Lock Dir", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Autopilot Altitude Lock", "", SIMCONNECT_DATATYPE.INT32, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Autopilot Altitude Lock Var", "feet", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Autopilot Vertical Hold Var", "feet/minute", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Autopilot Throttle Arm", "", SIMCONNECT_DATATYPE.INT32, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Autopilot Airspeed Hold", "", SIMCONNECT_DATATYPE.INT32, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Autopilot Airspeed Hold Var", "knots", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Autopilot Nav1 Lock", "", SIMCONNECT_DATATYPE.INT32, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Gps Drives Nav1", "", SIMCONNECT_DATATYPE.INT32, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Number Of Engines", "", SIMCONNECT_DATATYPE.INT32, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "General Eng Throttle Lever Position:1", "", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "General Eng Throttle Lever Position:2", "", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "General Eng Throttle Lever Position:3", "", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "General Eng Throttle Lever Position:4", "", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Flaps Handle Percent", "", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Gear Handle Position", "", SIMCONNECT_DATATYPE.INT32, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Spoilers Armed", "", SIMCONNECT_DATATYPE.INT32, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Spoilers Handle Position", "", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Brake Left Position", "", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "Brake Right Position", "", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);

            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "APU GENERATOR SWITCH", "", SIMCONNECT_DATATYPE.INT32, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "APU_GENERATOR_ACTIVE", "", SIMCONNECT_DATATYPE.INT32, 0, SimConnect.SIMCONNECT_UNUSED);
            m_scConnection.AddToDataDefinition(DEFINITIONS.PERIODIQUE, "TOGGLE_MASTER_BATTERY", "", SIMCONNECT_DATATYPE.INT32, 0, SimConnect.SIMCONNECT_UNUSED);

            // On associe notre structure à la définition simconnect
            m_scConnection.RegisterDataDefineStruct<DonneesAvion>(DEFINITIONS.PERIODIQUE);

            m_scConnection.OnRecvException += new SimConnect.RecvExceptionEventHandler(OnRecvException);
            m_scConnection.OnRecvQuit += new SimConnect.RecvQuitEventHandler(OnRecvQuit);
            m_scConnection.OnRecvSimobjectData += new SimConnect.RecvSimobjectDataEventHandler(OnRecvSimobjectData);
            //On programme la requete cyclique pour l'obtention des données de l'avion
            m_scConnection.RequestDataOnSimObject(DATA_REQUESTS.REQUEST_1, DEFINITIONS.PERIODIQUE, SimConnect.SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD.SECOND, 0, 0, 0, 0);

            Timer timer = new Timer();
            timer.Interval = 1000;
            timer.AutoReset = true;
            timer.Elapsed += new ElapsedEventHandler(OnTimer);
            timer.Start();
            listener = new HttpListener();
            listener.Prefixes.Add("http://+:8000/");
            Console.WriteLine("Listening..");
            listener.Start();
            while (!quit)
            {
                // Note: The GetContext method blocks while waiting for a request.
                HttpListenerContext context = listener.GetContext();
                HttpListenerRequest request = context.Request;
                // Obtain a response object.
                HttpListenerResponse response = context.Response;
                // Construct a response.
                if ((request.RawUrl == "/cmd") && (request.HttpMethod == "POST") && request.HasEntityBody && request.ContentType == "application/json")
                {
                    var sr = new System.IO.StreamReader(request.InputStream, request.ContentEncoding);
                    var code = sr.ReadToEnd();
                    Console.WriteLine(code);
                    var deserializer = new JavaScriptSerializer();
                    var json = deserializer.Deserialize<commande>(code);
                    Console.WriteLine(json.cmd + " : " + json.param);
                    json.cmd = json.cmd.ToUpper();
                    Byte[] Bytes = BitConverter.GetBytes(Convert.ToInt32(json.param));
                    UInt32 Param = BitConverter.ToUInt32(Bytes, 0);
                    try
                    {
                        m_scConnection.TransmitClientEvent(0, (EventEnum)Enum.Parse(typeof(EventEnum), json.cmd), Param, GROUP.GROUP1, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("La requete simconnect a échouée :" + e.Message);
                    }
                    response.Close();

                }
                else if (request.RawUrl == "/getall")
                {
                    response.ContentType = "application/json";
                    var serializer = new JavaScriptSerializer();
                    string json = serializer.Serialize(Donnees);
                    byte[] buffer = System.Text.Encoding.UTF8.GetBytes(json);
                    var output = response.OutputStream;
                    output.Write(buffer, 0, buffer.Length);
                    output.Close();
                    response.Close();

                }
                else
                {
                    response.StatusCode = 404;
                    response.StatusDescription = "Not Found";
                    response.Close();
                }
            }
            listener.Stop();
        }