Beispiel #1
0
        public FlightData GetCurrentData()
        {
            var dataType = typeof(BMS4FlightData);

            if (_hPrimarySharedMemoryAreaFileMappingObject.Equals(IntPtr.Zero))
            {
                ConnectToFalcon();
            }
            if (_hPrimarySharedMemoryAreaFileMappingObject.Equals(IntPtr.Zero))
            {
                return(null);
            }

            var data     = Convert.ChangeType(Marshal.PtrToStructure(_lpPrimarySharedMemoryAreaBaseAddress, dataType), dataType);
            var toReturn = new FlightData((BMS4FlightData)data);

            if (!_hSecondarySharedMemoryAreaFileMappingObject.Equals(IntPtr.Zero))
            {
                data = (FlightData2)(Marshal.PtrToStructure(_lpSecondarySharedMemoryAreaBaseAddress, typeof(FlightData2)));
                toReturn.PopulateFromStruct(data);
            }

            if (!_hOsbSharedMemoryAreaFileMappingObject.Equals(IntPtr.Zero))
            {
                data = (OSBData)(Marshal.PtrToStructure(_lpOsbSharedMemoryAreaBaseAddress, typeof(OSBData)));
                toReturn.PopulateFromStruct(data);
            }

            if (!_hIntelliVibeSharedMemoryAreaFileMappingObject.Equals(IntPtr.Zero))
            {
                data = (IntellivibeData)(Marshal.PtrToStructure(_lpIntelliVibeSharedMemoryAreaBaseAddress, typeof(IntellivibeData)));
                toReturn.IntellivibeData = (IntellivibeData)data;
            }

            if (!_hRadioClientControlSharedMemoryAreaFileMappingObject.Equals(IntPtr.Zero))
            {
                data = (RadioClientControl)(Marshal.PtrToStructure(_lpRadioClientControlSharedMemoryAreaBaseAddress, typeof(RadioClientControl)));
                toReturn.RadioClientControlData = (RadioClientControl)data;
            }

            if (!_hRadioClientStatusSharedMemoryAreaFileMappingObject.Equals(IntPtr.Zero))
            {
                data = (RadioClientStatus)(Marshal.PtrToStructure(_lpRadioClientStatusSharedMemoryAreaBaseAddress, typeof(RadioClientStatus)));
                toReturn.RadioClientStatus = (RadioClientStatus)data;
            }

            if (!_hStringSharedMemoryAreaFileMappingObject.Equals(IntPtr.Zero))
            {
                var rawStringData = GetRawStringData(toReturn.StringAreaSize);
                toReturn.StringData = StringData.GetStringData(rawStringData);
            }

            if (!_hDrawingSharedMemoryAreaFileMappingObject.Equals(IntPtr.Zero))
            {
                var rawDrawingData = GetRawDrawingData(toReturn.DrawingAreaSize);
                toReturn.DrawingData = DrawingData.GetDrawingData(rawDrawingData);
            }

            return(toReturn);
        }
Beispiel #2
0
        public FlightData GetCurrentData()
        {
            Type dataType = null;

            switch (_dataFormat)
            {
            case FalconDataFormats.AlliedForce:
                dataType = typeof(Headers.AFFlightData);
                break;

            case FalconDataFormats.BMS4:
                dataType = typeof(Headers.BMS4FlightData);
                break;

            default:
                break;
            }
            if (dataType == null)
            {
                return(null);
            }
            if (_hPrimarySharedMemoryAreaFileMappingObject.Equals(IntPtr.Zero))
            {
                ConnectToFalcon();
            }
            if (_hPrimarySharedMemoryAreaFileMappingObject.Equals(IntPtr.Zero))
            {
                return(null);
            }
            object     data     = Convert.ChangeType(Marshal.PtrToStructure(_lpPrimarySharedMemoryAreaBaseAddress, dataType), dataType);
            var        len      = Marshal.SizeOf(dataType);
            FlightData toReturn = null;

            switch (_dataFormat)
            {
            case FalconDataFormats.AlliedForce:
                toReturn = new FlightData((Headers.AFFlightData)data);
                break;

            case FalconDataFormats.BMS4:
                toReturn = new FlightData((Headers.BMS4FlightData)data);
                break;

            default:
                break;
            }
            if (toReturn == null)
            {
                return(null);
            }
            if (!_hSecondarySharedMemoryAreaFileMappingObject.Equals(IntPtr.Zero))
            {
                data = (Marshal.PtrToStructure(_lpSecondarySharedMemoryAreaBaseAddress, typeof(Headers.FlightData2)));
                toReturn.PopulateFromStruct(data);
            }
            if (!_hOsbSharedMemoryAreaFileMappingObject.Equals(IntPtr.Zero))
            {
                data = (Marshal.PtrToStructure(_lpOsbSharedMemoryAreaBaseAddress, typeof(Headers.OSBData)));
                toReturn.PopulateFromStruct(data);
            }
            toReturn.DataFormat = _dataFormat;
            return(toReturn);
        }