@@ -29,5 +29,12 @@ namespace JT808.Protocol.Test.MessageBody | |||
Assert.Equal(new byte[] { 0x01, 0x02, 0x02, 0x03 }, jT808_0X8005.AgainPackageData); | |||
Assert.Equal(2, jT808_0X8005.AgainPackageCount); | |||
} | |||
[Fact] | |||
public void Test3() | |||
{ | |||
var bytes = "04D20201020203".ToHexBytes(); | |||
string json = JT808Serializer.Analyze<JT808_0x0005>(bytes); | |||
} | |||
} | |||
} |
@@ -4,6 +4,7 @@ using System; | |||
using System.Collections.Generic; | |||
using Xunit; | |||
using JT808.Protocol.Metadata; | |||
using JT808.Protocol.Enums; | |||
namespace JT808.Protocol.Test.MessageBody | |||
{ | |||
@@ -209,5 +210,90 @@ namespace JT808.Protocol.Test.MessageBody | |||
Assert.Equal(3, jT808_0X8606.InflectionPointItems[1].SectionProperty); | |||
Assert.Equal(75, jT808_0X8606.InflectionPointItems[1].SectionWidth); | |||
} | |||
[Fact] | |||
public void Test5_2019() | |||
{ | |||
JT808_0x8606 jT808_0X8606 = new JT808_0x8606 | |||
{ | |||
RouteId = 9999, | |||
RouteProperty = 51, | |||
StartTime = DateTime.Parse("2020-01-04 00:00:12"), | |||
EndTime = DateTime.Parse("2020-01-04 00:00:12"), | |||
InflectionPointItems = new List<JT808InflectionPointProperty>() | |||
}; | |||
jT808_0X8606.InflectionPointItems.Add(new JT808InflectionPointProperty() | |||
{ | |||
InflectionPointId = 1000, | |||
InflectionPointLat = 123456789, | |||
InflectionPointLng = 123456788, | |||
SectionDrivingUnderThreshold = 123, | |||
SectionHighestSpeed = 69, | |||
SectionId = 1287, | |||
SectionLongDrivingThreshold = 50, | |||
SectionOverspeedDuration = 23, | |||
SectionProperty = 3, | |||
SectionWidth = 56, | |||
NightMaximumSpeed=80 | |||
}); | |||
jT808_0X8606.InflectionPointItems.Add(new JT808InflectionPointProperty() | |||
{ | |||
InflectionPointId = 1001, | |||
InflectionPointLat = 123456780, | |||
InflectionPointLng = 123456781, | |||
SectionDrivingUnderThreshold = 124, | |||
SectionHighestSpeed = 42, | |||
SectionId = 12007, | |||
SectionLongDrivingThreshold = 58, | |||
SectionOverspeedDuration = 26, | |||
SectionProperty = 3, | |||
SectionWidth = 75, | |||
NightMaximumSpeed = 66 | |||
}); | |||
jT808_0X8606.RouteName = "koike518"; | |||
var hex = JT808Serializer.Serialize(jT808_0X8606,JT808Version.JTT2019).ToHexString(); | |||
Assert.Equal("0000270F00332001040000122001040000120002000003E800000507075BCD15075BCD1438030032007B0045170050000003E900002EE7075BCD0C075BCD0D4B03003A007C002A1A004200086B6F696B65353138", hex); | |||
} | |||
[Fact] | |||
public void Test6_2019() | |||
{ | |||
byte[] bytes = "0000270F00332001040000122001040000120002000003E800000507075BCD15075BCD1438030032007B0045170050000003E900002EE7075BCD0C075BCD0D4B03003A007C002A1A004200086B6F696B65353138".ToHexBytes(); | |||
JT808_0x8606 jT808_0X8606 = JT808Serializer.Deserialize<JT808_0x8606>(bytes, JT808Version.JTT2019); | |||
Assert.Equal((uint)9999, jT808_0X8606.RouteId); | |||
Assert.Equal((uint)51, jT808_0X8606.RouteProperty); | |||
Assert.Equal(DateTime.Parse("2020-01-04 00:00:12"), jT808_0X8606.StartTime); | |||
Assert.Equal(DateTime.Parse("2020-01-04 00:00:12"), jT808_0X8606.EndTime); | |||
Assert.Equal(2, jT808_0X8606.InflectionPointItems.Count); | |||
Assert.Equal((uint)1000, jT808_0X8606.InflectionPointItems[0].InflectionPointId); | |||
Assert.Equal((uint)123456789, jT808_0X8606.InflectionPointItems[0].InflectionPointLat); | |||
Assert.Equal((uint)123456788, jT808_0X8606.InflectionPointItems[0].InflectionPointLng); | |||
Assert.Equal((ushort)123, jT808_0X8606.InflectionPointItems[0].SectionDrivingUnderThreshold); | |||
Assert.Equal((ushort)69, jT808_0X8606.InflectionPointItems[0].SectionHighestSpeed); | |||
Assert.Equal((uint)1287, jT808_0X8606.InflectionPointItems[0].SectionId); | |||
Assert.Equal((ushort)50, jT808_0X8606.InflectionPointItems[0].SectionLongDrivingThreshold); | |||
Assert.Equal((byte)23, jT808_0X8606.InflectionPointItems[0].SectionOverspeedDuration); | |||
Assert.Equal(3, jT808_0X8606.InflectionPointItems[0].SectionProperty); | |||
Assert.Equal(56, jT808_0X8606.InflectionPointItems[0].SectionWidth); | |||
Assert.Equal(80, jT808_0X8606.InflectionPointItems[0].NightMaximumSpeed.Value); | |||
Assert.Equal((uint)1001, jT808_0X8606.InflectionPointItems[1].InflectionPointId); | |||
Assert.Equal((uint)123456780, jT808_0X8606.InflectionPointItems[1].InflectionPointLat); | |||
Assert.Equal((uint)123456781, jT808_0X8606.InflectionPointItems[1].InflectionPointLng); | |||
Assert.Equal((ushort)124, jT808_0X8606.InflectionPointItems[1].SectionDrivingUnderThreshold); | |||
Assert.Equal((ushort)42, jT808_0X8606.InflectionPointItems[1].SectionHighestSpeed); | |||
Assert.Equal((uint)12007, jT808_0X8606.InflectionPointItems[1].SectionId); | |||
Assert.Equal((ushort)58, jT808_0X8606.InflectionPointItems[1].SectionLongDrivingThreshold); | |||
Assert.Equal((byte)26, jT808_0X8606.InflectionPointItems[1].SectionOverspeedDuration); | |||
Assert.Equal(3, jT808_0X8606.InflectionPointItems[1].SectionProperty); | |||
Assert.Equal(75, jT808_0X8606.InflectionPointItems[1].SectionWidth); | |||
Assert.Equal(66, jT808_0X8606.InflectionPointItems[1].NightMaximumSpeed.Value); | |||
Assert.Equal("koike518", jT808_0X8606.RouteName); | |||
} | |||
} | |||
} |
@@ -14,7 +14,7 @@ | |||
<licenseUrl>https://github.com/SmallChi/JT808/blob/master/LICENSE</licenseUrl> | |||
<license>https://github.com/SmallChi/JT808/blob/master/LICENSE</license> | |||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild> | |||
<Version>2.3.0-preview1</Version> | |||
<Version>2.2.4</Version> | |||
<PackageLicenseFile>LICENSE</PackageLicenseFile> | |||
</PropertyGroup> | |||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> | |||
@@ -6918,6 +6918,11 @@ | |||
单位为秒(s),若路段属性 1 位为 0 则没有该字段 | |||
</summary> | |||
</member> | |||
<member name="P:JT808.Protocol.Metadata.JT808InflectionPointProperty.NightMaximumSpeed"> | |||
<summary> | |||
单位为千米每小时(km/h),若路段属性 1 位为 0 则没有该字段 | |||
</summary> | |||
</member> | |||
<member name="T:JT808.Protocol.Metadata.JT808InformationItemProperty"> | |||
<summary> | |||
信息点播属性 | |||
@@ -22,6 +22,8 @@ namespace JT808.Protocol | |||
public const byte JT808_0x0200_0x02 = 0x02; | |||
public const byte JT808_0x0200_0x03 = 0x03; | |||
public const byte JT808_0x0200_0x04 = 0x04; | |||
public const byte JT808_0x0200_0x05 = 0x05; | |||
public const byte JT808_0x0200_0x06 = 0x06; | |||
public const byte JT808_0x0200_0x11 = 0x11; | |||
public const byte JT808_0x0200_0x12 = 0x12; | |||
public const byte JT808_0x0200_0x13 = 0x13; | |||
@@ -269,11 +269,11 @@ namespace JT808.Protocol | |||
writer.WriteNumber($"[{messageBodyPropertyReadOnlySpan.ToString()}]消息体属性", messageBodyPropertyValue); | |||
if (headerMessageBodyProperty.VersionFlag) | |||
{ | |||
writer.WriteNumber($"[{messageBodyPropertyReadOnlySpan[0]}]保留", 0); | |||
writer.WriteBoolean($"[{messageBodyPropertyReadOnlySpan[1]}]协议版本标识", headerMessageBodyProperty.VersionFlag); | |||
writer.WriteBoolean($"[{messageBodyPropertyReadOnlySpan.Slice(2,1).ToString()}]是否分包", headerMessageBodyProperty.IsPackage); | |||
writer.WriteString($"[{messageBodyPropertyReadOnlySpan.Slice(3,3).ToString()}]数据加密", headerMessageBodyProperty.Encrypt.ToString()); | |||
writer.WriteNumber($"[{messageBodyPropertyReadOnlySpan.Slice(7).ToString()}]消息体长度", headerMessageBodyProperty.DataLength); | |||
writer.WriteNumber( "[bit15]保留", 0); | |||
writer.WriteBoolean("[bit14]协议版本标识", headerMessageBodyProperty.VersionFlag); | |||
writer.WriteBoolean("[bit13]是否分包", headerMessageBodyProperty.IsPackage); | |||
writer.WriteString("[bit10~bit12]数据加密", headerMessageBodyProperty.Encrypt.ToString()); | |||
writer.WriteNumber("[bit0~bit9]消息体长度", headerMessageBodyProperty.DataLength); | |||
//消息体属性对象 结束 | |||
writer.WriteEndObject(); | |||
//2019版本 | |||
@@ -285,11 +285,11 @@ namespace JT808.Protocol | |||
} | |||
else | |||
{ | |||
writer.WriteNumber($"[{messageBodyPropertyReadOnlySpan[0]}]保留", 0); | |||
writer.WriteNumber($"[{messageBodyPropertyReadOnlySpan[1]}]保留", 0); | |||
writer.WriteBoolean($"[{messageBodyPropertyReadOnlySpan.Slice(2, 1).ToString()}]是否分包", headerMessageBodyProperty.IsPackage); | |||
writer.WriteString($"[{messageBodyPropertyReadOnlySpan.Slice(3, 3).ToString()}]数据加密", headerMessageBodyProperty.Encrypt.ToString()); | |||
writer.WriteNumber($"[{messageBodyPropertyReadOnlySpan.Slice(7).ToString()}]消息体长度", headerMessageBodyProperty.DataLength); | |||
writer.WriteNumber("[bit15]保留", 0); | |||
writer.WriteNumber("[bit14]保留", 0); | |||
writer.WriteBoolean("[bit13]是否分包", headerMessageBodyProperty.IsPackage); | |||
writer.WriteString("[bit10~bit12]数据加密", headerMessageBodyProperty.Encrypt.ToString()); | |||
writer.WriteNumber("[bit0~bit9]消息体长度", headerMessageBodyProperty.DataLength); | |||
writer.WriteEndObject(); | |||
//2013版本 | |||
// 3.3.读取终端手机号 | |||
@@ -375,6 +375,10 @@ namespace JT808.Protocol | |||
//数据体属性对象 结束 | |||
writer.WriteEndObject(); | |||
} | |||
else | |||
{ | |||
writer.WriteNull($"[Null]数据体"); | |||
} | |||
} | |||
else | |||
{ | |||
@@ -190,26 +190,26 @@ namespace JT808.Protocol | |||
public string Analyze<T>(ReadOnlySpan<byte> bytes, JT808Version version = JT808Version.JTT2013, JsonWriterOptions options = default, int minBufferSize = 8096) | |||
{ | |||
byte[] buffer = JT808ArrayPool.Rent(minBufferSize); | |||
byte[] buffer1 = JT808ArrayPool.Rent(minBufferSize); | |||
try | |||
{ | |||
JT808MessagePackReader jT808MessagePackReader = new JT808MessagePackReader(bytes, version); | |||
if (CheckPackageType(typeof(T))) | |||
jT808MessagePackReader.Decode(buffer); | |||
var analyze = jT808Config.GetAnalyze<T>(); | |||
using (MemoryStream memoryStream = new MemoryStream(buffer1)) | |||
using (MemoryStream memoryStream = new MemoryStream()) | |||
using (Utf8JsonWriter utf8JsonWriter = new Utf8JsonWriter(memoryStream, options)) | |||
{ | |||
if (!CheckPackageType(typeof(T))) utf8JsonWriter.WriteStartObject(); | |||
analyze.Analyze(ref jT808MessagePackReader, utf8JsonWriter, jT808Config); | |||
if (!CheckPackageType(typeof(T))) utf8JsonWriter.WriteEndObject(); | |||
utf8JsonWriter.Flush(); | |||
return utf8JsonWriter.ToString(); | |||
string value = Encoding.UTF8.GetString(memoryStream.ToArray()); | |||
return value; | |||
} | |||
} | |||
finally | |||
{ | |||
JT808ArrayPool.Return(buffer); | |||
JT808ArrayPool.Return(buffer1); | |||
} | |||
} | |||
@@ -246,7 +246,9 @@ namespace JT808.Protocol | |||
using (MemoryStream memoryStream = new MemoryStream()) | |||
using (Utf8JsonWriter utf8JsonWriter = new Utf8JsonWriter(memoryStream, options)) | |||
{ | |||
if (!CheckPackageType(typeof(T))) utf8JsonWriter.WriteStartObject(); | |||
analyze.Analyze(ref jT808MessagePackReader, utf8JsonWriter, jT808Config); | |||
if (!CheckPackageType(typeof(T))) utf8JsonWriter.WriteEndObject(); | |||
utf8JsonWriter.Flush(); | |||
return memoryStream.ToArray(); | |||
} | |||
@@ -1,6 +1,8 @@ | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessagePack; | |||
using JT808.Protocol.Extensions; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.MessageBody | |||
{ | |||
@@ -8,7 +10,7 @@ namespace JT808.Protocol.MessageBody | |||
/// 终端补传分包请求 | |||
/// 2019版本 | |||
/// </summary> | |||
public class JT808_0x0005 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0005>, IJT808_2019_Version | |||
public class JT808_0x0005 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0005>, IJT808_2019_Version, IJT808Analyze | |||
{ | |||
public override ushort MsgId { get; } = 0x0005; | |||
public override string Description => "终端补传分包请求"; | |||
@@ -28,6 +30,7 @@ namespace JT808.Protocol.MessageBody | |||
/// 重传包序号顺序排列,如“包 ID1 包 ID2......包 IDn”。 | |||
/// </summary> | |||
public byte[] AgainPackageData { get; set; } | |||
public JT808_0x0005 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x0005 value = new JT808_0x0005(); | |||
@@ -42,5 +45,21 @@ namespace JT808.Protocol.MessageBody | |||
writer.WriteByte((byte)(value.AgainPackageData.Length / 2)); | |||
writer.WriteArray(value.AgainPackageData); | |||
} | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
var originalMsgNum = reader.ReadUInt16(); | |||
var againPackageCount = reader.ReadByte(); | |||
var againPackageData = reader.ReadArray(againPackageCount * 2); | |||
writer.WriteNumber($"[{originalMsgNum.ReadNumber()}]原始消息流水号", originalMsgNum); | |||
writer.WriteNumber($"[{againPackageCount.ReadNumber()}]重传包总数", againPackageCount); | |||
writer.WriteString("重传包ID", string.Join(",", againPackageData.ToArray())); | |||
writer.WriteStartArray("重传包ID列表"); | |||
for (var i=0;i< againPackageCount; i++) | |||
{ | |||
writer.WriteStringValue(string.Join(",",againPackageData.Slice(i*2,2).ToArray())); | |||
} | |||
writer.WriteEndArray(); | |||
} | |||
} | |||
} |
@@ -6,7 +6,7 @@ namespace JT808.Protocol.MessageBody | |||
{ | |||
public class JT808_0x0200_0x01 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x01> | |||
{ | |||
public override byte AttachInfoId { get; set; } = 0x01; | |||
public override byte AttachInfoId { get; set; } = JT808Constants.JT808_0x0200_0x01; | |||
public override byte AttachInfoLength { get; set; } = 4; | |||
/// <summary> | |||
/// 里程 | |||
@@ -15,7 +15,7 @@ namespace JT808.Protocol.MessageBody | |||
/// </summary> | |||
[IgnoreDataMember] | |||
public double ConvertOil => Oil / 10.0; | |||
public override byte AttachInfoId { get; set; } = 0x02; | |||
public override byte AttachInfoId { get; set; } = JT808Constants.JT808_0x0200_0x02; | |||
public override byte AttachInfoLength { get; set; } = 2; | |||
public JT808_0x0200_0x02 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
@@ -16,7 +16,7 @@ namespace JT808.Protocol.MessageBody | |||
/// </summary> | |||
[IgnoreDataMember] | |||
public double ConvertSpeed => Speed / 10.0; | |||
public override byte AttachInfoId { get; set; } = 0x03; | |||
public override byte AttachInfoId { get; set; } = JT808Constants.JT808_0x0200_0x03; | |||
public override byte AttachInfoLength { get; set; } = 2; | |||
public JT808_0x0200_0x03 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
@@ -10,7 +10,7 @@ namespace JT808.Protocol.MessageBody | |||
/// 需要人工确认报警事件的 ID,从 1 开始计数 | |||
/// </summary> | |||
public ushort EventId { get; set; } | |||
public override byte AttachInfoId { get; set; } = 0x04; | |||
public override byte AttachInfoId { get; set; } = JT808Constants.JT808_0x0200_0x04; | |||
public override byte AttachInfoLength { get; set; } = 2; | |||
public JT808_0x0200_0x04 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
@@ -14,8 +14,8 @@ namespace JT808.Protocol.MessageBody | |||
/// <summary> | |||
/// 胎压 | |||
/// </summary> | |||
public string TirePressure { get; set; } | |||
public override byte AttachInfoId { get; set; } = 0x05; | |||
public byte[] TirePressure { get; set; } | |||
public override byte AttachInfoId { get; set; } = JT808Constants.JT808_0x0200_0x05; | |||
public override byte AttachInfoLength { get; set; } = 30; | |||
public JT808_0x0200_0x05 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
@@ -23,7 +23,7 @@ namespace JT808.Protocol.MessageBody | |||
JT808_0x0200_0x05 value = new JT808_0x0200_0x05(); | |||
value.AttachInfoId = reader.ReadByte(); | |||
value.AttachInfoLength = reader.ReadByte(); | |||
value.TirePressure = reader.ReadString(value.AttachInfoLength); | |||
value.TirePressure = reader.ReadArray(value.AttachInfoLength).ToArray(); | |||
return value; | |||
} | |||
@@ -31,7 +31,7 @@ namespace JT808.Protocol.MessageBody | |||
{ | |||
writer.WriteByte(value.AttachInfoId); | |||
writer.WriteByte(value.AttachInfoLength); | |||
writer.WriteString(value.TirePressure); | |||
writer.WriteArray(value.TirePressure); | |||
} | |||
} | |||
} |
@@ -15,7 +15,7 @@ namespace JT808.Protocol.MessageBody | |||
/// 车厢温度 | |||
/// </summary> | |||
public short CarTemperature { get; set; } | |||
public override byte AttachInfoId { get; set; } = 0x05; | |||
public override byte AttachInfoId { get; set; } = JT808Constants.JT808_0x0200_0x06; | |||
public override byte AttachInfoLength { get; set; } = 2; | |||
public JT808_0x0200_0x06 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
@@ -21,7 +21,7 @@ namespace JT808.Protocol.MessageBody | |||
/// 若位置类型为 0,无该字段 | |||
/// </summary> | |||
public uint AreaId { get; set; } | |||
public override byte AttachInfoId { get; set; } = 0x11; | |||
public override byte AttachInfoId { get; set; } = JT808Constants.JT808_0x0200_0x11; | |||
public override byte AttachInfoLength | |||
{ | |||
get | |||
@@ -26,7 +26,7 @@ namespace JT808.Protocol.MessageBody | |||
/// 1:出 | |||
/// </summary> | |||
public JT808DirectionType Direction { get; set; } | |||
public override byte AttachInfoId { get; set; } = 0x12; | |||
public override byte AttachInfoId { get; set; } = JT808Constants.JT808_0x0200_0x12; | |||
public override byte AttachInfoLength { get; set; } = 6; | |||
public JT808_0x0200_0x12 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
@@ -6,7 +6,7 @@ namespace JT808.Protocol.MessageBody | |||
{ | |||
public class JT808_0x0200_0x13 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x13> | |||
{ | |||
public override byte AttachInfoId { get; set; } = 0x13; | |||
public override byte AttachInfoId { get; set; } = JT808Constants.JT808_0x0200_0x13; | |||
public override byte AttachInfoLength { get; set; } = 7; | |||
/// <summary> | |||
@@ -9,7 +9,7 @@ namespace JT808.Protocol.MessageBody | |||
/// 扩展车辆信号状态位 | |||
/// </summary> | |||
public int CarSignalStatus { get; set; } | |||
public override byte AttachInfoId { get; set; } = 0x25; | |||
public override byte AttachInfoId { get; set; } = JT808Constants.JT808_0x0200_0x25; | |||
public override byte AttachInfoLength { get; set; } = 4; | |||
public JT808_0x0200_0x25 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
@@ -9,7 +9,7 @@ namespace JT808.Protocol.MessageBody | |||
/// IO状态位 | |||
/// </summary> | |||
public ushort IOStatus { get; set; } | |||
public override byte AttachInfoId { get; set; } = 0x2A; | |||
public override byte AttachInfoId { get; set; } = JT808Constants.JT808_0x0200_0x2A; | |||
public override byte AttachInfoLength { get; set; } = 2; | |||
public JT808_0x0200_0x2A Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
@@ -10,7 +10,7 @@ namespace JT808.Protocol.MessageBody | |||
/// 模拟量 bit0-15,AD0;bit16-31,AD1 | |||
/// </summary> | |||
public int Analog { get; set; } | |||
public override byte AttachInfoId { get; set; } = 0x2B; | |||
public override byte AttachInfoId { get; set; } = JT808Constants.JT808_0x0200_0x2B; | |||
public override byte AttachInfoLength { get; set; } = 4; | |||
public JT808_0x0200_0x2B Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
@@ -10,7 +10,7 @@ namespace JT808.Protocol.MessageBody | |||
/// 无线通信网络信号强度 | |||
/// </summary> | |||
public byte WiFiSignalStrength { get; set; } | |||
public override byte AttachInfoId { get; set; } = 0x30; | |||
public override byte AttachInfoId { get; set; } = JT808Constants.JT808_0x0200_0x30; | |||
public override byte AttachInfoLength { get; set; } = 1; | |||
public JT808_0x0200_0x30 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
@@ -9,7 +9,7 @@ namespace JT808.Protocol.MessageBody | |||
/// GNSS 定位卫星数 | |||
/// </summary> | |||
public byte GNSSCount { get; set; } | |||
public override byte AttachInfoId { get; set; } = 0x31; | |||
public override byte AttachInfoId { get; set; } = JT808Constants.JT808_0x0200_0x31; | |||
public override byte AttachInfoLength { get; set; } = 1; | |||
public JT808_0x0200_0x31 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
@@ -87,13 +87,15 @@ namespace JT808.Protocol.MessageBody | |||
{ | |||
jT808InflectionPointProperty.SectionHighestSpeed = reader.ReadUInt16(); | |||
jT808InflectionPointProperty.SectionOverspeedDuration = reader.ReadByte(); | |||
if (reader.Version == JT808Version.JTT2019) | |||
jT808InflectionPointProperty.NightMaximumSpeed = reader.ReadUInt16(); | |||
} | |||
jT808_0X8606.InflectionPointItems.Add(jT808InflectionPointProperty); | |||
if (reader.Version == JT808Version.JTT2019) | |||
{ | |||
jT808_0X8606.RouteNameLength = reader.ReadUInt16(); | |||
jT808_0X8606.RouteName = reader.ReadString(jT808_0X8606.RouteNameLength); | |||
} | |||
} | |||
if (reader.Version == JT808Version.JTT2019) | |||
{ | |||
jT808_0X8606.RouteNameLength = reader.ReadUInt16(); | |||
jT808_0X8606.RouteName = reader.ReadString(jT808_0X8606.RouteNameLength); | |||
} | |||
return jT808_0X8606; | |||
} | |||
@@ -141,6 +143,11 @@ namespace JT808.Protocol.MessageBody | |||
writer.WriteUInt16(item.SectionHighestSpeed.Value); | |||
if (item.SectionOverspeedDuration.HasValue) | |||
writer.WriteByte(item.SectionOverspeedDuration.Value); | |||
if (writer.Version == JT808Version.JTT2019) | |||
{ | |||
if (item.NightMaximumSpeed.HasValue) | |||
writer.WriteUInt16(item.NightMaximumSpeed.Value); | |||
} | |||
} | |||
} | |||
} | |||
@@ -52,5 +52,9 @@ | |||
/// 单位为秒(s),若路段属性 1 位为 0 则没有该字段 | |||
/// </summary> | |||
public byte? SectionOverspeedDuration { get; set; } | |||
/// <summary> | |||
/// 单位为千米每小时(km/h),若路段属性 1 位为 0 则没有该字段 | |||
/// </summary> | |||
public ushort? NightMaximumSpeed { get; set; } | |||
} | |||
} |