Esempio n. 1
0
            public async void Update(Aircraft newTraffic)
            {
                State = newTraffic.State;

                await SimObjectType <AircraftState> .
                SetDataOnSimObject((uint)ObjectId, State);
            }
Esempio n. 2
0
            internal async Task <AircraftState> Read()
            {
                State = await SimObjectType <AircraftState>
                        .RequestDataOnSimObjectType();

                return(State);
            }
Esempio n. 3
0
            public async void Create()
            {
                ObjectId = await SimObjectType <AircraftState> .
                           AICreateNonATCAircraft(State.title, Callsign, State);

                modelMatchingOnServer.Add(new ModelMatchingOnServer {
                    ModelCallsign = Callsign, ModelTitle = State.title
                });

                await VerifyModelMatching();
            }
Esempio n. 4
0
        /// <summary>
        /// Asynchronous wait for a listening SimConnect server.
        ///
        /// Listen to SimConnectOpen event
        /// </summary>
        public async void OpenSimConnect()
        {
            while (FSX.Sim == null)
            {
                try
                {
                    // the constructor is similar to SimConnect_Open in the native API
                    FSX.Sim = new SimConnect("SimLib.SimLibSimConnect", Handle, WM_USER_SIMCONNECT, null, 0);

                    // Register data definitions
                    SimObjectType <AircraftState> .Register(new SimObjectType <AircraftState> .Field[]
                    {
                        new SimObjectType <AircraftState> .Field()
                        {
                            DatumName = "Title", UnitsName = null,
                            DatumType = SIMCONNECT_DATATYPE.STRING256
                        },
                        new SimObjectType <AircraftState> .Field()
                        {
                            DatumName = "PLANE LATITUDE", UnitsName = "degrees",
                            DatumType = SIMCONNECT_DATATYPE.FLOAT64
                        },
                        new SimObjectType <AircraftState> .Field()
                        {
                            DatumName = "PLANE LONGITUDE", UnitsName = "degrees",
                            DatumType = SIMCONNECT_DATATYPE.FLOAT64
                        },
                        new SimObjectType <AircraftState> .Field()
                        {
                            DatumName = "PLANE ALTITUDE", UnitsName = "feet",
                            DatumType = SIMCONNECT_DATATYPE.FLOAT64
                        },
                        new SimObjectType <AircraftState> .Field()
                        {
                            DatumName = "PLANE PITCH DEGREES", UnitsName = "degrees",
                            DatumType = SIMCONNECT_DATATYPE.FLOAT64
                        },
                        new SimObjectType <AircraftState> .Field()
                        {
                            DatumName = "PLANE BANK DEGREES", UnitsName = "degrees",
                            DatumType = SIMCONNECT_DATATYPE.FLOAT64
                        },
                        new SimObjectType <AircraftState> .Field()
                        {
                            DatumName = "PLANE HEADING DEGREES MAGNETIC", UnitsName = "degrees",
                            DatumType = SIMCONNECT_DATATYPE.INT32
                        },
                        new SimObjectType <AircraftState> .Field()
                        {
                            DatumName = "PLANE HEADING DEGREES TRUE", UnitsName = "degrees",
                            DatumType = SIMCONNECT_DATATYPE.FLOAT64
                        },
                        new SimObjectType <AircraftState> .Field()
                        {
                            DatumName = "AIRSPEED TRUE", UnitsName = "knots",
                            DatumType = SIMCONNECT_DATATYPE.INT32
                        },
                        new SimObjectType <AircraftState> .Field()
                        {
                            DatumName = "SIM ON GROUND", UnitsName = "bool",
                            DatumType = SIMCONNECT_DATATYPE.INT32
                        },
                        new SimObjectType <AircraftState> .Field()
                        {
                            DatumName = "GEAR POSITION:0", UnitsName = "BCO16",
                            DatumType = SIMCONNECT_DATATYPE.INT32
                        },
                        new SimObjectType <AircraftState> .Field()
                        {
                            DatumName = "LIGHT LANDING", UnitsName = "bool",
                            DatumType = SIMCONNECT_DATATYPE.INT32
                        },
                        new SimObjectType <AircraftState> .Field()
                        {
                            DatumName = "FLAPS HANDLE INDEX", UnitsName = "Number",
                            DatumType = SIMCONNECT_DATATYPE.FLOAT64
                        },
                        new SimObjectType <AircraftState> .Field()
                        {
                            DatumName = "IS GEAR RETRACTABLE", UnitsName = "bool",
                            DatumType = SIMCONNECT_DATATYPE.INT32
                        },
                        new SimObjectType <AircraftState> .Field()
                        {
                            DatumName = "ELEVATOR POSITION", UnitsName = "Position",
                            DatumType = SIMCONNECT_DATATYPE.FLOAT64
                        },
                        new SimObjectType <AircraftState> .Field()
                        {
                            DatumName = "AILERON POSITION", UnitsName = "Position",
                            DatumType = SIMCONNECT_DATATYPE.FLOAT64
                        },
                        new SimObjectType <AircraftState> .Field()
                        {
                            DatumName = "RUDDER POSITION", UnitsName = "Position",
                            DatumType = SIMCONNECT_DATATYPE.FLOAT64
                        },
                        new SimObjectType <AircraftState> .Field()
                        {
                            DatumName = "GENERAL ENG COMBUSTION:1", UnitsName = "Bool",
                            DatumType = SIMCONNECT_DATATYPE.INT32
                        },
                        new SimObjectType <AircraftState> .Field()
                        {
                            DatumName = "GENERAL ENG COMBUSTION:2", UnitsName = "Bool",
                            DatumType = SIMCONNECT_DATATYPE.INT32
                        },
                        new SimObjectType <AircraftState> .Field()
                        {
                            DatumName = "GENERAL ENG COMBUSTION:3", UnitsName = "Bool",
                            DatumType = SIMCONNECT_DATATYPE.INT32
                        },
                        new SimObjectType <AircraftState> .Field()
                        {
                            DatumName = "GENERAL ENG COMBUSTION:4", UnitsName = "Bool",
                            DatumType = SIMCONNECT_DATATYPE.INT32
                        },
                        new SimObjectType <AircraftState> .Field()
                        {
                            DatumName = "GENERAL ENG THROTTLE LEVER POSITION:1", UnitsName = "Percent",
                            DatumType = SIMCONNECT_DATATYPE.INT32
                        },
                        new SimObjectType <AircraftState> .Field()
                        {
                            DatumName = "GENERAL ENG THROTTLE LEVER POSITION:2", UnitsName = "Percent",
                            DatumType = SIMCONNECT_DATATYPE.INT32
                        },
                        new SimObjectType <AircraftState> .Field()
                        {
                            DatumName = "GENERAL ENG THROTTLE LEVER POSITION:3", UnitsName = "Percent",
                            DatumType = SIMCONNECT_DATATYPE.INT32
                        },
                        new SimObjectType <AircraftState> .Field()
                        {
                            DatumName = "GENERAL ENG THROTTLE LEVER POSITION:4", UnitsName = "Percent",
                            DatumType = SIMCONNECT_DATATYPE.INT32
                        },
                        new SimObjectType <AircraftState> .Field()
                        {
                            DatumName = "LIGHT ON STATES", UnitsName = "Mask",
                            DatumType = SIMCONNECT_DATATYPE.INT32
                        },
                    });

                    SimObjectType <Radios> .Register(new SimObjectType <Radios> .Field[]
                    {
                        new SimObjectType <Radios> .Field()
                        {
                            DatumName = "TRANSPONDER CODE:1", UnitsName = "BCO16",
                            DatumType = SIMCONNECT_DATATYPE.INT32
                        },
                    });

                    //RegisterEvents();
                }
                catch (COMException)
                {
                    await Task.Delay(5000);
                }
            }
        }