public AvlData Decode(IBitReader reader) { DateTime dateTime = reader != null?DateTimeExt.FromAvl(reader.ReadInt64()) : throw new ArgumentNullException(nameof(reader)); AvlDataPriority priority = (AvlDataPriority)reader.ReadByte(); GpsElement gps = DefaultGpsElementEncoding.Instance.Decode(reader); IoElement data = DefaultIOElementEncoding.Instance16.Decode(reader); return(new AvlData(priority, dateTime, gps, data)); }
public AvlData Decode(IBitReader reader) { DateTime dateTime = reader != null?DateTimeExt.FromAvl(reader.ReadUInt32() * 1000L + reader.ReadByte() * 10) : throw new ArgumentNullException(nameof(reader)); AvlDataPriority priority = (AvlDataPriority)reader.ReadByte(); GpsElementExt gpsElementExt = FMPro3GpsElementEncoding.Instance.Decode(reader); IoElement data = FMPro3IOElementEncoding.Instance.Decode(reader); data.Add(gpsElementExt.IO[500001]); return(new AvlData(priority, dateTime, gpsElementExt.GPS, data)); }
public AvlData Decode(IBitReader reader) { DateTime dateTime = reader != null?DateTimeExt.FromAvl(reader.ReadInt64()) : throw new ArgumentNullException(nameof(reader)); AvlDataPriority priority = AvlDataPriority.Low; byte num = reader.ReadByte(); if (num > 10 && num <= 20) { priority = AvlDataPriority.High; } GpsElement gps = DefaultGpsElementEncoding.Instance.Decode(reader); IoElement data = LegacyIoElementEncoding.Instance.Decode(reader); if (priority == AvlDataPriority.High) { data = new IoElement(-1, data.Properties); } return(new AvlData(priority, dateTime, gps, data)); }
public AvlData Decode(IBitReader reader) { byte num = reader != null?reader.ReadByte() : throw new ArgumentNullException(nameof(reader)); byte[] buffer = reader.ReadBytes(num); if (reader.ReadByte() != CRC.CalculateXor(buffer)) { throw new Exception("AvlData Record CRC failure. Received CRC - {0}, calculated CRC - {1}."); } using (MemoryStream stream = new MemoryStream()) { using (IBitReader suitableBitReader = stream.CreateSuitableBitReader()) { stream.Write(buffer, 0, num); stream.Position = 0L; long timestamp = suitableBitReader.ReadUInt32() * 1000L; AvlDataPriority priority = (AvlDataPriority)suitableBitReader.ReadByte(); GpsElement gps = DefaultGpsElementEncoding.Instance.Decode(suitableBitReader); IoElement data = DefaultIOElementEncoding.Instance.Decode(suitableBitReader); DateTime dateTime = DateTimeExt.FromAvl(timestamp); return(new AvlData(priority, dateTime, gps, data)); } } }
public AvlData[] Decode(IBitReader reader) { if (reader == null) { throw new ArgumentNullException(nameof(reader)); } long y2Ktime; if (ReadBitSequence(reader, out y2Ktime, 35) != 35) { throw new Exception("Wrong timestamp bits count"); } long timestamp = Y2K2Timestamp(y2Ktime); long bits; if (reader.ReadBits(out bits, 5) != 5) { throw new Exception("Wrong element count bits count"); } long num1 = Math.Min(bits, 24L); List <AvlData> avlDataList = new List <AvlData>(); long compressedGws1 = 0; long compressedGws2 = 0; for (int index = 0; index < num1; ++index) { bool bit1; if (reader.ReadBit(out bit1) != 1) { throw new Exception("Wrong data bits count"); } if (bit1) { bool bit2; if (reader.ReadBit(out bit2) != 1) { throw new Exception("Wrong data bits count"); } if (bit2) { long num2; if (ReadBitSequence(reader, out num2, 14) != 14) { throw new Exception("Wrong data bits count"); } long num3; if (ReadBitSequence(reader, out num3, 14) != 14) { throw new Exception("Wrong data bits count"); } compressedGws1 = compressedGws1 - num2 + 8191L; compressedGws2 = compressedGws2 - num3 + 8191L; } else { if (ReadBitSequence(reader, out compressedGws1, 21) != 21) { throw new Exception("Wrong data bits count"); } if (ReadBitSequence(reader, out compressedGws2, 20) != 20) { throw new Exception("Wrong data bits count"); } } long num4 = DecompressGws(compressedGws1, -1800000000L, 1800000000L, 3600000000L, 2097151L); long num5 = DecompressGws(compressedGws2, -900000000L, 900000000L, 1800000000L, 1048575L); short speed = reader.ReadByte(); AvlData avlData = new AvlData(AvlDataPriority.Low, DateTimeExt.FromAvl(timestamp), new GpsElement((int)num4, (int)num5, 0, speed, 0, 3)); avlDataList.Add(avlData); } timestamp += 3600000L; } return(avlDataList.ToArray()); }