Esempio n. 1
0
 void RegisterIfPending(SimvarRequest simvar)
 {
     if (simvar.Pending)
     {
         simvar.Pending      = !RegisterToSimConnect(simvar);
         simvar.StillPending = simvar.Pending;
     }
 }
Esempio n. 2
0
 void SetupRequests()
 {
     _latitudeSimvarRequest    = SetupRequest("GPS POSITION LAT", "degrees");
     _longitudeSimvarRequest   = SetupRequest("GPS POSITION LON", "degrees");
     _groundSpeedSimvarRequest = SetupRequest("GPS GROUND SPEED", "meter/second");
     _trueHeadingSimvarRequest = SetupRequest("GPS GROUND TRUE HEADING", "radians");
     _trueTrackSimvarRequest   = SetupRequest("GPS GROUND TRUE TRACK", "radians");
 }
Esempio n. 3
0
 void HandleRequest(SimvarRequest simvar, SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE data)
 {
     if (data.dwRequestID == (uint)simvar.Request)
     {
         double value = (double)data.dwData[0];
         simvar.Value        = value;
         simvar.Pending      = false;
         simvar.StillPending = false;
     }
 }
Esempio n. 4
0
 void RequestIfNotPending(SimvarRequest simvar)
 {
     if (!simvar.Pending)
     {
         SimConnect?.RequestDataOnSimObjectType(simvar.Request, simvar.Definition, 0, SIMCONNECT_SIMOBJECT_TYPE.USER);
         simvar.Pending = true;
     }
     else
     {
         simvar.StillPending = true;
     }
 }
Esempio n. 5
0
        private bool RegisterToSimConnect(SimvarRequest simvarRequest)
        {
            if (SimConnect != null)
            {
                /// Define a data structure
                SimConnect.AddToDataDefinition(simvarRequest.Definition, simvarRequest.Name, simvarRequest.Units, SIMCONNECT_DATATYPE.FLOAT64, 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 <double>(simvarRequest.Definition);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 6
0
        SimvarRequest SetupRequest(string requestName, string requestUnit)
        {
            SimvarRequest simvarRequest = new SimvarRequest
            {
                Definition = (DEFINITION)_currentDefinition,
                Request    = (REQUEST)_currentRequest,
                Name       = requestName,
                Units      = requestUnit
            };

            simvarRequest.Pending      = !RegisterToSimConnect(simvarRequest);
            simvarRequest.StillPending = simvarRequest.Pending;

            ++_currentDefinition;
            ++_currentRequest;

            return(simvarRequest);
        }
Esempio n. 7
0
 void ResetRequest(SimvarRequest simvar)
 {
     simvar.Pending      = true;
     simvar.StillPending = true;
 }