/// <summary>
        /// Callback method for Receive-Event SimConnect operation
        /// </summary>
        /// <param name="sender">SimConnect object initiating the callback</param>
        /// <param name="data">Receive-Event SimConnect data object associated with the event</param>
        void SimConnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data)
        {
            switch ((EventIdentifier)data.uEventID)
            {
            // Mission completion result.
            // This type of scenario information could potentially be used by an LMS,
            // however is beyond the scope of this sample.
            case EventIdentifier.MissionCompleted:
            {
                switch ((MissionStatus)data.dwData)
                {
                case MissionStatus.MissionStatusFailed:
                {
                    System.Console.WriteLine("Mission completion status: FAILED.");
                    break;
                }

                case MissionStatus.MissionStatusCrashed:
                {
                    System.Console.WriteLine("Mission completion status: CRASHED.");
                    break;
                }

                case MissionStatus.MissionStatusSucceeded:
                {
                    System.Console.WriteLine("Mission completion status: SUCCEEDED.");
                    break;
                }
                }

                break;
            }
            }
        }
Beispiel #2
0
        private void OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data)
        {
            switch ((Event)data.uEventID)
            {
            case Event.PositionChanged:
                Console.WriteLine("Position changed!");
                break;

            case Event.FlightLoaded:
                Console.WriteLine("Flight loaded");
                break;

            case Event.FlightPlanActivated:
                Console.WriteLine("Flight plan activated");
                break;

            case Event.FlightPlanDeactivated:
                Console.WriteLine("Flight plan deactivated");
                break;

            case Event.PlaneCrashed:
                Console.WriteLine("Plane crashed");
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            //_dataWriter.WriteToStoreAsync(planeCrashed: true)
            //    .ConfigureAwait(false)
            //    .GetAwaiter()
            //    .GetResult();
        }
Beispiel #3
0
 void sc_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data)
 {
     if ((Events)data.uEventID == Events.SixHz)
     {
         sc.RequestDataOnUserSimObject(Requests.UserAttitude, SIMCONNECT_PERIOD.ONCE, SIMCONNECT_DATA_REQUEST_FLAG.DEFAULT, typeof(Attitude));
     }
 }
Beispiel #4
0
        private void simconnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data)
        {
            FLIGHTSIM_STATUS_STRUCT fsStat;

            switch (data.uEventID)
            {
            case (uint)EVENTS.SIM_START:
                fsStat.inFlight = true;
                simconnect.SetSystemEventState(EVENTS.FLIGHTPLAN_LOADED, SIMCONNECT_STATE.ON);
                OnDataReceived(new DataReceivedEventArgs(FSDataType.DT_FLIGHTSIM_STATUS, fsStat));
                break;

            case (uint)EVENTS.SIM_STOP:
                fsStat.inFlight = false;
                OnDataReceived(new DataReceivedEventArgs(FSDataType.DT_FLIGHTSIM_STATUS, fsStat));
                break;

            case (uint)EVENTS.FLIGHTPLAN_DIACTIVATED:
                fsStat.inFlight = true;
                OnDataReceived(new DataReceivedEventArgs(FSDataType.DT_RESTART, fsStat));
                break;

            default:
                break;
            }
        }
Beispiel #5
0
        private void simconnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT recEvent)
        {
            var eventName = GetEventName(recEvent.uEventID);
            var simEvent  = GetEventModelByName(eventName);

            DisplayText(simEvent.DisplayMessage);
        }
        /// <summary>
        /// Events triggered by sending events to the Sim
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="data"></param>
        private void Simconnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data)
        {
            Groups  group   = (Groups)data.uGroupID;
            dynamic eventId = null;

            switch (group)
            {
            case Groups.System:
                eventId = (Events)data.uEventID;
                break;

            case Groups.AutoPilot:
                eventId = (AutoPilot)data.uEventID;
                break;

            case Groups.Fuel:
                eventId = (Fuel)data.uEventID;
                break;

            default:
                // No other actions
                break;
            }

            _logger.LogInformation($"{DateTime.Now} Recieved: {group} - {eventId}");
        }
Beispiel #7
0
        void simconnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT recEvent)
        {
            switch (recEvent.uEventID)
            {
                case (uint)EVENTS.PITOT_TOGGLE:

                    displayText("PITOT switched");
                    break;

                case (uint)EVENTS.FLAPS_UP:

                    displayText("Flaps Up");
                    break;

                case (uint)EVENTS.FLAPS_DOWN:

                    displayText("Flaps Down");
                    break;

                case (uint)EVENTS.FLAPS_INC:

                    displayText("Flaps Inc");
                    break;

                case (uint)EVENTS.FLAPS_DEC:

                    displayText("Flaps Dec");
                    break;
            }
        }
Beispiel #8
0
        void simconnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data)
        {
            logger.LogInformation("OnRecvEvent dwID " + data.dwID + " uEventID " + data.uEventID);
            switch ((SIMCONNECT_RECV_ID)data.dwID)
            {
            case SIMCONNECT_RECV_ID.EVENT_FILENAME:

                break;

            case SIMCONNECT_RECV_ID.QUIT:
                logger.LogInformation("Quit");
                break;
            }

            //switch ((EVENTS)data.uEventID)
            //{
            //    case EVENTS.SIM_START:
            //        logger.LogInformation("Sim start");
            //        break;
            //    case EVENTS.SIM_STOP:
            //        logger.LogInformation("Sim stop");
            //        break;
            //    case EVENTS.PAUSED:
            //        logger.LogInformation("Paused");
            //        //simconnect.TransmitClientEvent((uint)SimConnect.SIMCONNECT_OBJECT_ID_USER, EVENTS.SEND_UNPAUSE, (uint)0, GROUPID.FLAG, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);
            //        break;
            //}
        }
Beispiel #9
0
        void simconnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data)
        {
            logger.LogInformation("OnRecvEvent dwID " + data.dwID + " uEventID " + data.uEventID);
            switch ((SIMCONNECT_RECV_ID)data.dwID)
            {
            case SIMCONNECT_RECV_ID.EVENT_FILENAME:

                break;

            case SIMCONNECT_RECV_ID.QUIT:
                logger.LogInformation("Quit");
                break;
            }

            switch ((EVENTS)data.uEventID)
            {
            case EVENTS.SIM_START:
                logger.LogInformation("Sim start");
                break;

            case EVENTS.SIM_STOP:
                logger.LogInformation("Sim stop");
                break;

            case EVENTS.PAUSED:
                logger.LogInformation("Paused");
                //simconnect.TransmitClientEvent((uint)SimConnect.SIMCONNECT_OBJECT_ID_USER, EVENTS.SEND_UNPAUSE, (uint)0, GROUPID.FLAG, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);
                break;

            case EVENTS.FLIGHTPLAN_ACTIVATED:
                logger.LogInformation("Flight plan activated");

                break;

            case EVENTS.FLIGHTPLAN_DEACTIVATED:
                logger.LogInformation("Flight plan deactivated");
                break;

            case EVENTS.CRASHED:
                logger.LogInformation("Crashed");
                Crashed?.Invoke(this, new EventArgs());
                break;

            case EVENTS.CRASH_RESET:
                logger.LogInformation("Crash reset");
                CrashReset?.Invoke(this, new EventArgs());
                break;

            case EVENTS.POSITION_CHANGED:
                logger.LogInformation("Position changed");
                break;

            case EVENTS.SCREENSHOT:
                logger.LogInformation("Screenshot");

                break;
            }
        }
Beispiel #10
0
 void simconnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data)
 {
     switch ((DEFINITIONS)data.dwID)
     {
     case DEFINITIONS.SimStart:
         requestData();
         break;
     }
 }
 // callback function for simconnect
 void simconnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT recEvent)
 {
     // verify that this is one of the events we are looking for
     if (recEvent.uEventID == (uint)Event.MISSION_END)
     {
         System.Threading.Thread.Sleep(2000); // let the user see what happened
         this.Activate();                     //take focus
     }
 }
Beispiel #12
0
 //Event received. Should trigger a request for the actual data.
 void simconnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT recEvent)
 {
     switch (recEvent.uEventID)
     {
     case (uint)EVENTS.AP_MASTER:
         simconnect.RequestDataOnSimObjectType(DATA_REQUESTS.REQUEST_MCP, DEFINITION.MCP, 0, SIMCONNECT_SIMOBJECT_TYPE.USER);
         break;
     }
 }
Beispiel #13
0
        /*
         * A system event has been received from FS
         */
        public void onRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT recEvent)
        {
            switch ((EVENTS)recEvent.uEventID)
            {
            case EVENTS.SIMSTATE:
            {
                /*
                 * Simulator state has changed. If the simulator is running and we
                 * haven't yet loaded aircraft data, do so now
                 */

                if (recEvent.dwData == 1 && currentAircraft == null)
                {
                    currentAircraft = new Aircraft(sender);
                }
                break;
            }

            case EVENTS.JUMP:
            {
                /*
                 * A jump has been detected.
                 */
                eventJump();
                break;
            }

            case EVENTS.CRASH:
            {
                /*
                 * A crash was detected.
                 */
                eventCrash();
                break;
            }

            case EVENTS.MENU2:
            {
                /*
                 * Start flight was requested from FS
                 */
                startFlight();
                break;
            }

            case EVENTS.MENU3:
            {
                /*
                 * Cancel flight was requested from FS
                 */
                cancelFlight(null);
                break;
            }
            }
        }
Beispiel #14
0
        /// <summary>
        /// Called when SimConnect observes an event taking place.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="data"></param>
        private void SimConnect_RecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data)
        {
            var args = new SimConnectEventObservedEventArgs()
            {
                EventId          = data.uEventID,
                GroupId          = data.uGroupID,
                GroupIdIsUnknown = data.uGroupID == SIMCONNECT_RECV_EVENT.UNKNOWN_GROUP,
                Value            = data.dwData,
            };

            OnEventObserved(args);
        }
Beispiel #15
0
        void simconnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT recEvent)
        {
            switch (recEvent.uEventID)
            {
            case (uint)CLIENT_EVENTS.COM_RADIO_WHOLE_INC:
            case (uint)CLIENT_EVENTS.COM_RADIO_WHOLE_DEC:
#if DEBUG
                this.Log("COM_RADIO_WHOLE_DEC");
#endif
                break;
            }
        }
        private void SimconnectOnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data)
        {
            switch ((EVENT_ID)data.uEventID)
            {
            case EVENT_ID.EVENT_PAUSE:
                _pause = !_pause;
                break;

            case EVENT_ID.EVENT_BRAKES:

                break;
            }
        }
Beispiel #17
0
        void simconnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT recEvent)
        {
            Field field = (Field)recEvent.uEventID;

            Console.WriteLine($"Received event: {field}");
            if (!controlAdaptors.ContainsKey(field))
            {
                return;
            }
            var controlAdaptor = controlAdaptors[field];

            controlAdaptor.ReceiveEvent(recEvent.dwData);
        }
Beispiel #18
0
        private void OnRecvEvent(SimConnect simConnect, SIMCONNECT_RECV_EVENT data)
        {
            EVENT e = (EVENT)data.uEventID;

            debugConsole.Text = $"Received {e} = {Convert.ToString(data.dwData, 16)} {(int)data.dwData}s (of {data.dwSize})"
                                + $"\n@{System.DateTime.Now}\nGroup ID {(GROUP)data.uGroupID} with ID {data.dwID} and version {data.dwVersion}";
            foreach (KeyValuePair <IEventNotification, EVENT> entry
                     in ((simConnect as SimConnectzmo) !.notificationsToEvent !)
                     .Where <KeyValuePair <IEventNotification, EVENT> >(candidate => e == candidate.Value))
            {
                entry.Key.OnRecieve(simConnect, data);
            }
        }
Beispiel #19
0
        // The simulation will pause each time a key is selected in the addon, so unpause the sim each time this happens

        void simconnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data)
        {
            displayText("Pause event received");

            switch ((EVENTS)data.uEventID)
            {
            case EVENTS.PAUSED:

                simconnect.TransmitClientEvent((uint)SimConnect.SIMCONNECT_OBJECT_ID_USER, EVENTS.SEND_UNPAUSE, (uint)0, GROUPID.FLAG, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);
                displayText("Unpause request sent...");
                break;
            }
        }
Beispiel #20
0
        void SimConnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data)
        {
            switch (data.uEventID)
            {
            case (uint)EventIdentifier.Every6Hz:
            {
                // Check SimObject properties either to:
                // a) Recieve information for the first time
                // b) Check if station / SimObject information has changed
                QuerySimObjectGeneralQuery();

                break;
            }
            }
        }
Beispiel #21
0
        private void simconnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data)
        {
            //MessageBox.Show("EVENT");

            switch (data.uEventID)
            {
            case (uint)EVENTS.EVENT_TOWPLANE_DETACHED:
                detach_towplane();
                break;

            case (uint)EVENTS.EVENT_TOWPLANE_REQUESTED:
                //button2_click(this, null);
                //lbx_planes_attachTo.SelectedIndex = 1;
                playerid = 1;
                attach_towplane();
                break;
            }
        }
Beispiel #22
0
        void simconnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT recEvent)
        {
            switch (recEvent.uEventID)
            {
            case (uint)EVENTS.SIMSTART:

                displayText("Sim running");
                break;

            case (uint)EVENTS.SIMSTOP:

                displayText("Sim stopped");
                break;

            case (uint)EVENTS.FOURSECS:

                displayText("4s tick");
                break;
            }
        }
Beispiel #23
0
        void Simconnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data)
        {
            switch ((SIMCONNECT_RECV_ID)data.dwID)
            {
            case SIMCONNECT_RECV_ID.EVENT_FILENAME:

                break;

            case SIMCONNECT_RECV_ID.QUIT:

                break;
            }

            switch ((EVENTS)data.uEventID)
            {
            case EVENTS.POSITION_CHANGED:
                AircraftPositionChanged?.Invoke(this, new EventArgs());
                break;
            }
        }
        void Simconnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data)
        {
            LogDebug("OnRecvEvent dwID " + data.dwID + " uEventID " + data.uEventID);
            switch ((SIMCONNECT_RECV_ID)data.dwID)
            {
            case SIMCONNECT_RECV_ID.EVENT_FILENAME:

                break;

            case SIMCONNECT_RECV_ID.QUIT:
                LogDebug("Quit");
                break;
            }

            switch ((EVENTS)data.uEventID)
            {
            case EVENTS.POSITION_CHANGED:
                LogDebug("Position changed");
                break;
            }
        }
Beispiel #25
0
        void Simconnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data)
        {
            logger.LogInformation("OnRecvEvent dwID " + data.dwID + " uEventID " + data.uEventID);
            switch ((SIMCONNECT_RECV_ID)data.dwID)
            {
            case SIMCONNECT_RECV_ID.EVENT_FILENAME:

                break;

            case SIMCONNECT_RECV_ID.QUIT:
                logger.LogInformation("Quit");
                break;
            }

            switch ((EVENTS)data.uEventID)
            {
            case EVENTS.POSITION_CHANGED:
                logger.LogInformation("Position changed");
                AircraftPositionChanged?.Invoke(this, new EventArgs());
                break;
            }
        }
Beispiel #26
0
        void simconnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT recEvent)
        {
            if (!simrunning)
            {
                return;
            }


            switch (recEvent.uEventID)
            {
            case (uint)EVENTS.SIMSTART:
                if (!paused)
                {
                    sw.Start();
                    displayText("Sim started");
                }
                break;

            case (uint)EVENTS.SIMSTOP:
                if (!paused)
                {
                    sw.Stop();
                    displayText("Sim stopped");
                }
                break;

            case (uint)EVENTS.PAUSED:
                paused = true;
                sw.Stop();
                displayText("Sim stopped");
                break;

            case (uint)EVENTS.UNPAUSED:
                paused = false;
                sw.Start();
                displayText("Sim started");
                break;
            }
        }
        //private void simconnect_OnRecvAssignedObjectId(SimConnect sender, SIMCONNECT_RECV_ASSIGNED_OBJECT_ID data) {
        //  Console.WriteLine("Recieved");
        //}

        /// <summary>
        /// Events triggered by sending events to the Sim
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="data"></param>
        private void simconnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data)
        {
            Groups  group   = (Groups)data.uGroupID;
            dynamic eventId = null;

            switch (group)
            {
            case Groups.System:
                eventId = (Events)data.uEventID;
                break;

            case Groups.AutoPilot:
                eventId = (AutoPilot)data.uEventID;
                break;

            case Groups.Fuel:
                eventId = (Fuel)data.uEventID;
                break;
            }

            Console.WriteLine($"{DateTime.Now} Recieved: {group} - {eventId}");
        }
Beispiel #28
0
 private void OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data)
 {
     //Console.WriteLine($"OnRecvEvent: {JsonConvert.SerializeObject(data, Formatting.Indented)}");
 }
Beispiel #29
0
 void sc_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data)
 {
     Console.WriteLine("sc_OnRecvEvent");
 }
 private void SimConnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data)
 {
     SimConnectEvent(this, new EventArgs());
 }
Beispiel #31
0
 void Simconnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data)
 {
     logger.LogDebug("OnRecvEvent dwID {dwID} uEventID {uEventID}", (SIMCONNECT_RECV_ID)data.dwID, data.uEventID);
 }
Beispiel #32
0
 void simconnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT recEvent)
 {
     FSXActionEventArgs args = new FSXActionEventArgs();
     args.Action = recEvent.uEventID;
     OnFSXAction(args);
 }
Beispiel #33
0
        // The simulation will pause each time a key is selected in the addon, so unpause the sim each time this happens
        void simconnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data)
        {
            displayText("Pause event received");

            switch ((EVENTS)data.uEventID)
            {
                case EVENTS.PAUSED:

                    simconnect.TransmitClientEvent((uint) SimConnect.SIMCONNECT_OBJECT_ID_USER, EVENTS.SEND_UNPAUSE, (uint) 0, GROUPID.FLAG, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);
                    displayText("Unpause request sent...");
                    break;

            }
        }