Exemplo n.º 1
0
 internal static OSTCSetpointInfo FromBinary(OSTCBinaryReader br)
 {
     br.ReadUInt16();
     // TODO
     return(new OSTCSetpointInfo
     {
     });
 }
Exemplo n.º 2
0
        internal static OSTCDiveHeader FromBinary(OSTCBinaryReader br, byte tocIndex)
        {
            try
            {
                byte a = br.ReadByte();
                byte b = br.ReadByte();
                // if this is an empty dive!
                if (a == 0xFF && b == 0xFF)
                {
                    return(null);
                }
                if (a != 0xFA || b != 0xFA)
                {
                    throw new InvalidDataException("Expected 0xFAFA as dive header start but got " + a.ToString("X2") + b.ToString("X2"));
                }
            }
            catch (EndOfStreamException)
            {
                return(null);
            }

            var dh = new OSTCDiveHeader
            {
                TOCIndex          = tocIndex,
                DataStartAddress  = br.ReadUInt24(),
                DataStopAddress   = br.ReadUInt24(),
                ProfileVersion    = (LogbookProfileVersion)br.ReadByte(),
                ProfileDataLength = br.ReadUInt24(),
                Date = br.ReadDate(),
                WaterPressureMbarMax = br.ReadUInt16(),
                DiveTime             = br.ReadTimeSpan24(),
                WaterTemperatureMin  = br.ReadInt16() / 10.0,
                SurfacePressureMBar  = br.ReadUInt16(),
                DesaturationTime     = br.ReadTimeSpan16(),
                Gases = new List <OSTCGasInfo>(new OSTCGasInfo[] {
                    br.ReadGas32(), // GAS1
                    br.ReadGas32(), // GAS2
                    br.ReadGas32(), // GAS3
                    br.ReadGas32(), // GAS4
                    br.ReadGas32()  // GAS5
                }),
                FirmwareVersion     = br.ReadFWVersion(),
                BatteryVoltage      = br.ReadUInt16() / 1000.0,
                SamplingRate        = TimeSpan.FromSeconds(br.ReadByte()),
                CNSDiveStartPercent = br.ReadUInt16() / 12.0,
                GFDiveStartPercent  = br.ReadByte() / 12.0,
                GFDiveEndPercent    = br.ReadByte() / 12.0,
                LogbookOffset       = br.ReadUInt16(),
                BatteryInformation  = br.ReadByte(),
                Setpoints           = new List <OSTCSetpointInfo>(new OSTCSetpointInfo[]
                {
                    br.ReadSetpoint16(), // SP1
                    br.ReadSetpoint16(), // SP2
                    br.ReadSetpoint16(), // SP3
                    br.ReadSetpoint16(), // SP4
                    br.ReadSetpoint16()  // SP5
                }),
                Salinity                     = br.ReadByte(),
                MaxCNSPercent                = br.ReadUInt16() / 12.0,
                WaterPressureMBarAverage     = br.ReadUInt16(),
                TotalDivetime                = TimeSpan.FromSeconds(br.ReadUInt16()),
                DecoModelInfoA               = br.ReadByte(),
                DecoModelInfoB               = br.ReadByte(),
                DecoModel                    = (DecoModel)br.ReadByte(),
                DiveNumber                   = br.ReadUInt16(),
                DiveMode                     = (DiveMode)br.ReadByte(),
                CompartmentsN2DesatTime      = br.ReadBytes(16),
                CompartmentsN2               = br.ReadBytes(64),
                CompartmentsHEDesatTime      = br.ReadBytes(16),
                CompartmentsHE               = br.ReadBytes(64),
                LastDecoStopMeters           = br.ReadByte(),
                AssumedDistanceToShownStopCm = br.ReadByte(),
                HWHudBatteryVoltage          = br.ReadUInt16() / 1000.0,
                HWHudLastStatus              = br.ReadByte(),
                BatteryGauge                 = br.ReadBytes(6)
            };

            if (br.ReadByte() != 0xFB || br.ReadByte() != 0xFB)
            {
                throw new InvalidDataException("Expected 0xFBFB as dive header end but got something else!");
            }
            return(dh);
        }