private void WriteSampleToFile(SharedMemorySample sample)
        {
            if (_gzipStreamBinaryWriter == null)
            {
                return;
            }
            _gzipStreamBinaryWriter.Write(sample.PrimaryFlightDataLength);
            if (sample.PrimaryFlightDataLength > 0)
            {
                _gzipStreamBinaryWriter.Write(sample.PrimaryFlightData);
            }
            _gzipStreamBinaryWriter.Write(sample.FlightData2Length);
            if (sample.FlightData2Length > 0)
            {
                _gzipStreamBinaryWriter.Write(sample.FlightData2);
            }
            _gzipStreamBinaryWriter.Write(sample.OSBDataLength);
            if (sample.OSBDataLength > 0)
            {
                _gzipStreamBinaryWriter.Write(sample.OSBData);
            }
            _gzipStreamBinaryWriter.Write(sample.IntellivibeDataLength);
            if (sample.IntellivibeDataLength > 0)
            {
                _gzipStreamBinaryWriter.Write(sample.IntellivibeData);
            }
            _gzipStreamBinaryWriter.Write(sample.RadioClientStatusDataLength);
            if (sample.RadioClientStatusDataLength > 0)
            {
                _gzipStreamBinaryWriter.Write(sample.RadioClientStatusData);
            }
            _gzipStreamBinaryWriter.Write(sample.RadioClientControlDataLength);
            if (sample.RadioClientControlDataLength > 0)
            {
                _gzipStreamBinaryWriter.Write(sample.RadioClientControlData);
            }
            _gzipStreamBinaryWriter.Write(sample.StringDataLength);
            if (sample.StringDataLength > 0)
            {
                _gzipStreamBinaryWriter.Write(sample.StringData);
            }
            _gzipStreamBinaryWriter.Write(sample.DrawingDataLength);
            if (sample.DrawingDataLength > 0)
            {
                _gzipStreamBinaryWriter.Write(sample.DrawingData);
            }

            _gzipStreamBinaryWriter.Flush();
            _gzipStream.Flush();
            _fileStream.Flush();
        }
 private void WriteSampleToSharedMemory(SharedMemorySample sample)
 {
     if (sample.PrimaryFlightData != null)
     {
         try
         {
             _sharedMemoryWriter.WritePrimaryFlightData(sample.PrimaryFlightData);
         }
         catch { }
     }
     if (sample.FlightData2 != null)
     {
         try
         {
             _sharedMemoryWriter.WriteFlightData2(sample.FlightData2);
         }
         catch { }
     }
     if (sample.OSBData != null)
     {
         try
         {
             _sharedMemoryWriter.WriteOSBData(sample.OSBData);
         }
         catch { }
     }
     if (sample.IntellivibeData != null)
     {
         try
         {
             _sharedMemoryWriter.WriteIntellivibeData(sample.IntellivibeData);
         }
         catch { }
     }
     if (sample.RadioClientStatusData != null)
     {
         try
         {
             _sharedMemoryWriter.WriteRadioClientStatusData(sample.RadioClientStatusData);
         }
         catch { }
     }
     if (sample.RadioClientControlData != null)
     {
         try
         {
             _sharedMemoryWriter.WriteRadioClientControlData(sample.RadioClientControlData);
         }
         catch { }
     }
 }
        private SharedMemorySample ReadNextSampleFromFile()
        {
            var sample = new SharedMemorySample();

            sample.PrimaryFlightDataLength = _gzipStreamBinaryReader.ReadUInt32();
            if (sample.PrimaryFlightDataLength > 0)
            {
                sample.PrimaryFlightData = _gzipStreamBinaryReader.ReadBytes((int)sample.PrimaryFlightDataLength);
            }
            sample.FlightData2Length = _gzipStreamBinaryReader.ReadUInt32();
            if (sample.FlightData2Length > 0)
            {
                sample.FlightData2 = _gzipStreamBinaryReader.ReadBytes((int)sample.FlightData2Length);
            }
            sample.OSBDataLength = _gzipStreamBinaryReader.ReadUInt32();
            if (sample.OSBDataLength > 0)
            {
                sample.OSBData = _gzipStreamBinaryReader.ReadBytes((int)sample.OSBDataLength);
            }
            sample.IntellivibeDataLength = _gzipStreamBinaryReader.ReadUInt32();
            if (sample.IntellivibeDataLength > 0)
            {
                sample.IntellivibeData = _gzipStreamBinaryReader.ReadBytes((int)sample.IntellivibeDataLength);
            }
            sample.RadioClientStatusDataLength = _gzipStreamBinaryReader.ReadUInt32();
            if (sample.RadioClientStatusDataLength > 0)
            {
                sample.RadioClientStatusData = _gzipStreamBinaryReader.ReadBytes((int)sample.RadioClientStatusDataLength);
            }
            sample.RadioClientControlDataLength = _gzipStreamBinaryReader.ReadUInt32();
            if (sample.RadioClientControlDataLength > 0)
            {
                sample.RadioClientControlData = _gzipStreamBinaryReader.ReadBytes((int)sample.RadioClientControlDataLength);
            }
            sample.StringDataLength = _gzipStreamBinaryReader.ReadUInt32();
            if (sample.StringDataLength > 0)
            {
                sample.StringData = _gzipStreamBinaryReader.ReadBytes((int)sample.StringDataLength);
            }
            sample.DrawingDataLength = _gzipStreamBinaryReader.ReadUInt32();
            if (sample.DrawingDataLength > 0)
            {
                sample.DrawingData = _gzipStreamBinaryReader.ReadBytes((int)sample.DrawingDataLength);
            }
            return(sample);
        }
        private SharedMemorySample ReadSampleFromSharedmem()
        {
            var sample = new SharedMemorySample();

            sample.PrimaryFlightData       = _sharedMemoryReader.GetRawPrimaryFlightData();
            sample.PrimaryFlightDataLength = (ushort)(sample.PrimaryFlightData != null ? sample.PrimaryFlightData.Length : 0);
            sample.FlightData2             = _sharedMemoryReader.GetRawFlightData2();
            sample.FlightData2Length       = (ushort)(sample.FlightData2 != null ? sample.FlightData2.Length : 0);
            sample.OSBData                      = _sharedMemoryReader.GetRawOSBData();
            sample.OSBDataLength                = (ushort)(sample.OSBData != null ? sample.OSBData.Length : 0);
            sample.IntellivibeData              = _sharedMemoryReader.GetRawIntelliVibeData();
            sample.IntellivibeDataLength        = (ushort)(sample.IntellivibeData != null ? sample.IntellivibeData.Length : 0);
            sample.RadioClientControlData       = _sharedMemoryReader.GetRawRadioClientControlData();
            sample.RadioClientControlDataLength = (ushort)(sample.RadioClientControlData != null ? sample.RadioClientControlData.Length : 0);
            sample.RadioClientStatusData        = _sharedMemoryReader.GetRawRadioClientStatusData();
            sample.RadioClientStatusDataLength  = (ushort)(sample.RadioClientStatusData != null ? sample.RadioClientStatusData.Length : 0);
            return(sample);
        }
        private SharedMemorySample ReadSampleFromSharedmem()
        {
            var sample = new SharedMemorySample();
            var fd     = _sharedMemoryReader.GetCurrentData();

            sample.PrimaryFlightData       = _sharedMemoryReader.GetRawPrimaryFlightData();
            sample.PrimaryFlightDataLength = (uint)(sample.PrimaryFlightData != null ? sample.PrimaryFlightData.Length : 0);
            sample.FlightData2             = _sharedMemoryReader.GetRawFlightData2();
            sample.FlightData2Length       = (uint)(sample.FlightData2 != null ? sample.FlightData2.Length : 0);
            sample.OSBData                      = _sharedMemoryReader.GetRawOSBData();
            sample.OSBDataLength                = (uint)(sample.OSBData != null ? sample.OSBData.Length : 0);
            sample.IntellivibeData              = _sharedMemoryReader.GetRawIntelliVibeData();
            sample.IntellivibeDataLength        = (uint)(sample.IntellivibeData != null ? sample.IntellivibeData.Length : 0);
            sample.RadioClientControlData       = _sharedMemoryReader.GetRawRadioClientControlData();
            sample.RadioClientControlDataLength = (uint)(sample.RadioClientControlData != null ? sample.RadioClientControlData.Length : 0);
            sample.RadioClientStatusData        = _sharedMemoryReader.GetRawRadioClientStatusData();
            sample.RadioClientStatusDataLength  = (uint)(sample.RadioClientStatusData != null ? sample.RadioClientStatusData.Length : 0);
            sample.StringData                   = _sharedMemoryReader.GetRawStringData(fd.StringAreaSize);
            sample.StringDataLength             = (uint)(sample.DrawingData != null ? sample.DrawingData.Length : 0);
            sample.DrawingData                  = _sharedMemoryReader.GetRawDrawingData(fd.DrawingAreaSize);
            sample.DrawingDataLength            = (uint)(sample.DrawingData != null ? sample.DrawingData.Length : 0);
            return(sample);
        }