public JT808_0x8602 Deserialize(ReadOnlySpan <byte> bytes, out int readSize) { int offset = 0; JT808_0x8602 jT808_0X8602 = new JT808_0x8602(); jT808_0X8602.SettingAreaProperty = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset); jT808_0X8602.AreaCount = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset); jT808_0X8602.AreaItems = new List <JT808RectangleAreaProperty>(); for (var i = 0; i < jT808_0X8602.AreaCount; i++) { JT808RectangleAreaProperty jT808CircleAreaProperty = new JT808RectangleAreaProperty(); jT808CircleAreaProperty.AreaId = JT808BinaryExtensions.ReadUInt32Little(bytes, ref offset); jT808CircleAreaProperty.AreaProperty = JT808BinaryExtensions.ReadUInt16Little(bytes, ref offset); jT808CircleAreaProperty.UpLeftPointLat = JT808BinaryExtensions.ReadUInt32Little(bytes, ref offset); jT808CircleAreaProperty.UpLeftPointLng = JT808BinaryExtensions.ReadUInt32Little(bytes, ref offset); jT808CircleAreaProperty.LowRightPointLat = JT808BinaryExtensions.ReadUInt32Little(bytes, ref offset); jT808CircleAreaProperty.LowRightPointLng = JT808BinaryExtensions.ReadUInt32Little(bytes, ref offset); ReadOnlySpan <char> areaProperty16Bit = Convert.ToString(jT808CircleAreaProperty.AreaProperty, 2).PadLeft(16, '0').AsSpan(); bool bit0Flag = areaProperty16Bit.Slice(areaProperty16Bit.Length - 1).ToString().Equals("0"); if (!bit0Flag) { jT808CircleAreaProperty.StartTime = JT808BinaryExtensions.ReadDateTime6Little(bytes, ref offset); jT808CircleAreaProperty.EndTime = JT808BinaryExtensions.ReadDateTime6Little(bytes, ref offset); } bool bit1Flag = areaProperty16Bit.Slice(areaProperty16Bit.Length - 2, 1).ToString().Equals("0"); if (!bit1Flag) { jT808CircleAreaProperty.HighestSpeed = JT808BinaryExtensions.ReadUInt16Little(bytes, ref offset); jT808CircleAreaProperty.OverspeedDuration = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset); } jT808_0X8602.AreaItems.Add(jT808CircleAreaProperty); } readSize = offset; return(jT808_0X8602); }
public JT808_0x0702 Deserialize(ReadOnlySpan <byte> bytes, out int readSize, IJT808Config config) { int offset = 0; JT808_0x0702 jT808_0X0702 = new JT808_0x0702 { IC_Card_Status = (JT808ICCardStatus)JT808BinaryExtensions.ReadByteLittle(bytes, ref offset), IC_Card_PlugDateTime = JT808BinaryExtensions.ReadDateTime6Little(bytes, ref offset) }; if (jT808_0X0702.IC_Card_Status == JT808ICCardStatus.从业资格证IC卡插入_驾驶员上班) { jT808_0X0702.IC_Card_ReadResult = (JT808ICCardReadResult)JT808BinaryExtensions.ReadByteLittle(bytes, ref offset); if (jT808_0X0702.IC_Card_ReadResult == JT808ICCardReadResult.IC卡读卡成功) { jT808_0X0702.DriverUserNameLength = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset); jT808_0X0702.DriverUserName = JT808BinaryExtensions.ReadStringLittle(bytes, ref offset, jT808_0X0702.DriverUserNameLength); jT808_0X0702.QualificationCode = JT808BinaryExtensions.ReadStringLittle(bytes, ref offset, 20); jT808_0X0702.LicenseIssuingLength = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset); jT808_0X0702.LicenseIssuing = JT808BinaryExtensions.ReadStringLittle(bytes, ref offset, jT808_0X0702.LicenseIssuingLength); jT808_0X0702.CertificateExpiresDate = JT808BinaryExtensions.ReadDateTime4Little(bytes, ref offset); } } readSize = offset; return(jT808_0X0702); }
public JT808_0x8802 Deserialize(ReadOnlySpan <byte> bytes, out int readSize) { int offset = 0; JT808_0x8802 jT808_0X8802 = new JT808_0x8802(); jT808_0X8802.MultimediaType = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset); jT808_0X8802.ChannelId = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset); jT808_0X8802.EventItemCoding = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset); jT808_0X8802.StartTime = JT808BinaryExtensions.ReadDateTime6Little(bytes, ref offset); jT808_0X8802.EndTime = JT808BinaryExtensions.ReadDateTime6Little(bytes, ref offset); readSize = offset; return(jT808_0X8802); }
public JT808_0x8803 Deserialize(ReadOnlySpan <byte> bytes, out int readSize, IJT808Config config) { int offset = 0; JT808_0x8803 jT808_0X8803 = new JT808_0x8803 { MultimediaType = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset), ChannelId = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset), EventItemCoding = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset), StartTime = JT808BinaryExtensions.ReadDateTime6Little(bytes, ref offset), EndTime = JT808BinaryExtensions.ReadDateTime6Little(bytes, ref offset), MultimediaDeleted = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset) }; readSize = offset; return(jT808_0X8803); }
public JT808_0x8606 Deserialize(ReadOnlySpan <byte> bytes, out int readSize) { int offset = 0; JT808_0x8606 jT808_0X8606 = new JT808_0x8606 { RouteId = JT808BinaryExtensions.ReadUInt32Little(bytes, ref offset), RouteProperty = JT808BinaryExtensions.ReadUInt16Little(bytes, ref offset) }; ReadOnlySpan <char> routeProperty16Bit = Convert.ToString(jT808_0X8606.RouteProperty, 2).PadLeft(16, '0').AsSpan(); bool bit0Flag = routeProperty16Bit.Slice(routeProperty16Bit.Length - 1).ToString().Equals("0"); if (!bit0Flag) { jT808_0X8606.StartTime = JT808BinaryExtensions.ReadDateTime6Little(bytes, ref offset); jT808_0X8606.EndTime = JT808BinaryExtensions.ReadDateTime6Little(bytes, ref offset); } jT808_0X8606.InflectionPointCount = JT808BinaryExtensions.ReadUInt16Little(bytes, ref offset); jT808_0X8606.InflectionPointItems = new List <JT808InflectionPointProperty>(); for (var i = 0; i < jT808_0X8606.InflectionPointCount; i++) { JT808InflectionPointProperty jT808InflectionPointProperty = new JT808InflectionPointProperty { InflectionPointId = JT808BinaryExtensions.ReadUInt32Little(bytes, ref offset), SectionId = JT808BinaryExtensions.ReadUInt32Little(bytes, ref offset), InflectionPointLat = JT808BinaryExtensions.ReadUInt32Little(bytes, ref offset), InflectionPointLng = JT808BinaryExtensions.ReadUInt32Little(bytes, ref offset), SectionWidth = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset), SectionProperty = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset) }; ReadOnlySpan <char> sectionProperty16Bit = Convert.ToString(jT808InflectionPointProperty.SectionProperty, 2).PadLeft(16, '0').AsSpan(); bool sectionBit0Flag = sectionProperty16Bit.Slice(sectionProperty16Bit.Length - 1).ToString().Equals("0"); if (!sectionBit0Flag) { jT808InflectionPointProperty.SectionLongDrivingThreshold = JT808BinaryExtensions.ReadUInt16Little(bytes, ref offset); jT808InflectionPointProperty.SectionDrivingUnderThreshold = JT808BinaryExtensions.ReadUInt16Little(bytes, ref offset); } bool sectionBit1Flag = sectionProperty16Bit.Slice(sectionProperty16Bit.Length - 2, 1).ToString().Equals("0"); if (!sectionBit1Flag) { jT808InflectionPointProperty.SectionHighestSpeed = JT808BinaryExtensions.ReadUInt16Little(bytes, ref offset); jT808InflectionPointProperty.SectionOverspeedDuration = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset); } jT808_0X8606.InflectionPointItems.Add(jT808InflectionPointProperty); } readSize = offset; return(jT808_0X8606); }
public JT808_0x8604 Deserialize(ReadOnlySpan <byte> bytes, out int readSize) { int offset = 0; JT808_0x8604 jT808_0X8604 = new JT808_0x8604 { AreaId = JT808BinaryExtensions.ReadUInt32Little(bytes, ref offset), AreaProperty = JT808BinaryExtensions.ReadUInt16Little(bytes, ref offset) }; ReadOnlySpan <char> areaProperty16Bit = Convert.ToString(jT808_0X8604.AreaProperty, 2).PadLeft(16, '0').AsSpan(); bool bit0Flag = areaProperty16Bit.Slice(areaProperty16Bit.Length - 1).ToString().Equals("0"); if (!bit0Flag) { jT808_0X8604.StartTime = JT808BinaryExtensions.ReadDateTime6Little(bytes, ref offset); jT808_0X8604.EndTime = JT808BinaryExtensions.ReadDateTime6Little(bytes, ref offset); } bool bit1Flag = areaProperty16Bit.Slice(areaProperty16Bit.Length - 2, 1).ToString().Equals("0"); if (!bit1Flag) { jT808_0X8604.HighestSpeed = JT808BinaryExtensions.ReadUInt16Little(bytes, ref offset); jT808_0X8604.OverspeedDuration = JT808BinaryExtensions.ReadByteLittle(bytes, ref offset); } jT808_0X8604.PeakCount = JT808BinaryExtensions.ReadUInt16Little(bytes, ref offset); jT808_0X8604.PeakItems = new List <JT808PeakProperty>(); if (jT808_0X8604.PeakCount > 0) { for (var i = 0; i < jT808_0X8604.PeakCount; i++) { var item = new JT808PeakProperty { Lat = JT808BinaryExtensions.ReadUInt32Little(bytes, ref offset), Lng = JT808BinaryExtensions.ReadUInt32Little(bytes, ref offset) }; jT808_0X8604.PeakItems.Add(item); } } readSize = offset; return(jT808_0X8604); }
public JT808_0x0200 Deserialize(ReadOnlySpan <byte> bytes, out int readSize) { int offset = 0; JT808_0x0200 jT808_0X0200 = new JT808_0x0200 { AlarmFlag = JT808BinaryExtensions.ReadUInt32Little(bytes, ref offset), StatusFlag = JT808BinaryExtensions.ReadUInt32Little(bytes, ref offset), Lat = JT808BinaryExtensions.ReadInt32Little(bytes, ref offset), Lng = JT808BinaryExtensions.ReadInt32Little(bytes, ref offset) }; JT808StatusProperty jT808StatusProperty = new JT808StatusProperty(Convert.ToString(jT808_0X0200.StatusFlag, 2).PadLeft(32, '0')); if (jT808StatusProperty.Bit28 == '1')//西经 { jT808_0X0200.Lng = -jT808_0X0200.Lng; } if (jT808StatusProperty.Bit29 == '1')//南纬 { jT808_0X0200.Lat = -jT808_0X0200.Lat; } jT808_0X0200.Altitude = JT808BinaryExtensions.ReadUInt16Little(bytes, ref offset); jT808_0X0200.Speed = JT808BinaryExtensions.ReadUInt16Little(bytes, ref offset); jT808_0X0200.Direction = JT808BinaryExtensions.ReadUInt16Little(bytes, ref offset); jT808_0X0200.GPSTime = JT808BinaryExtensions.ReadDateTime6Little(bytes, ref offset); // 位置附加信息 jT808_0X0200.JT808LocationAttachData = new Dictionary <byte, JT808_0x0200_BodyBase>(); jT808_0X0200.JT808CustomLocationAttachOriginalData = new Dictionary <byte, byte[]>(); if (bytes.Length > 28) { int attachOffset = 0; ReadOnlySpan <byte> locationAttachMemory = bytes; ReadOnlySpan <byte> locationAttachSpan = locationAttachMemory.Slice(28); while (locationAttachSpan.Length > attachOffset) { int attachId = 1; int attachLen = 1; try { Type jT808LocationAttachType; if (JT808_0x0200_BodyBase.JT808LocationAttachMethod.TryGetValue(locationAttachSpan[attachOffset], out jT808LocationAttachType)) { int attachContentLen = locationAttachSpan[attachOffset + 1]; int locationAttachTotalLen = attachId + attachLen + attachContentLen; ReadOnlySpan <byte> attachBuffer = locationAttachSpan.Slice(attachOffset, locationAttachTotalLen); object attachImplObj = JT808FormatterExtensions.GetFormatter(jT808LocationAttachType); dynamic attachImpl = JT808FormatterResolverExtensions.JT808DynamicDeserialize(attachImplObj, attachBuffer, out readSize); attachOffset = attachOffset + locationAttachTotalLen; jT808_0X0200.JT808LocationAttachData.Add(attachImpl.AttachInfoId, attachImpl); } else if (JT808_0x0200_CustomBodyBase.CustomAttachIds.Contains(locationAttachSpan[attachOffset])) { int attachContentLen = locationAttachSpan[attachOffset + 1]; int locationAttachTotalLen = attachId + attachLen + attachContentLen; ReadOnlySpan <byte> attachBuffer = locationAttachSpan.Slice(attachOffset, locationAttachTotalLen); jT808_0X0200.JT808CustomLocationAttachOriginalData.Add(locationAttachSpan[attachOffset], attachBuffer.ToArray()); attachOffset = attachOffset + locationAttachTotalLen; } else { int attachContentLen = locationAttachSpan[attachOffset + 1]; int locationAttachTotalLen = attachId + attachLen + attachContentLen; attachOffset = attachOffset + locationAttachTotalLen; } } catch (Exception) { int attachContentLen = locationAttachSpan[attachOffset + 1]; int locationAttachTotalLen = attachId + attachLen + attachContentLen; attachOffset = attachOffset + locationAttachTotalLen; } } offset = offset + attachOffset; } readSize = offset; return(jT808_0X0200); }