示例#1
0
        private bool RegisterWithSimConnect(SimvarRequest _oSimvarRequest)
        {
            if (_simConnect != null)
            {
                // Define a data structure
                _simConnect.AddToDataDefinition(_oSimvarRequest.eDef, _oSimvarRequest.Variable.SimConnectVariable, _oSimvarRequest.Variable.SimConnectUnit, 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>(_oSimvarRequest.eDef);

                return(true);
            }

            return(false);
        }
示例#2
0
        private void AddRequest(SimVar simVar)
        {
            Debug.WriteLine($"AddRequest: {simVar.SimConnectVariable} {simVar.SimConnectUnit}");

            SimvarRequest request = new SimvarRequest(simVar, (DEFINITION)_currentDefinition, (REQUEST)_currentRequest);

            RegisterWithSimConnect(request);

            _simvarRequests.Add(request);

            ++_currentDefinition;
            ++_currentRequest;

            _simConnect?.RequestDataOnSimObject(
                request.eRequest,
                request.eDef,
                SimConnect.SIMCONNECT_OBJECT_ID_USER,
                SIMCONNECT_PERIOD.VISUAL_FRAME,
                SIMCONNECT_DATA_REQUEST_FLAG.CHANGED, 0, 0, 0);
        }