Sfoglia il codice sorgente

解析器

tags/v2.2.0
liukt 5 anni fa
parent
commit
a530de0297
22 ha cambiato i file con 481 aggiunte e 63 eliminazioni
  1. +2
    -2
      src/JT809.Protocol.Test/JT809MessageBody/JT809_0x9007Test.cs
  2. +25
    -0
      src/JT809.Protocol/Extensions/JT809AnalyzeExtensions.cs
  3. +48
    -0
      src/JT809.Protocol/Extensions/JT809HexExtensions.cs
  4. +29
    -9
      src/JT809.Protocol/MessageBody/JT809_0x1001.cs
  5. +16
    -5
      src/JT809.Protocol/MessageBody/JT809_0x1002.cs
  6. +18
    -5
      src/JT809.Protocol/MessageBody/JT809_0x1003.cs
  7. +14
    -4
      src/JT809.Protocol/MessageBody/JT809_0x1007.cs
  8. +15
    -5
      src/JT809.Protocol/MessageBody/JT809_0x1008.cs
  9. +24
    -1
      src/JT809.Protocol/MessageBody/JT809_0x1102.cs
  10. +28
    -1
      src/JT809.Protocol/MessageBody/JT809_0x1103.cs
  11. +35
    -3
      src/JT809.Protocol/MessageBody/JT809_0x1200.cs
  12. +30
    -1
      src/JT809.Protocol/MessageBody/JT809_0x1300.cs
  13. +36
    -1
      src/JT809.Protocol/MessageBody/JT809_0x1400.cs
  14. +35
    -1
      src/JT809.Protocol/MessageBody/JT809_0x1500.cs
  15. +34
    -1
      src/JT809.Protocol/MessageBody/JT809_0x1600.cs
  16. +13
    -4
      src/JT809.Protocol/MessageBody/JT809_0x9001.cs
  17. +14
    -4
      src/JT809.Protocol/MessageBody/JT809_0x9002.cs
  18. +13
    -4
      src/JT809.Protocol/MessageBody/JT809_0x9003.cs
  19. +16
    -6
      src/JT809.Protocol/MessageBody/JT809_0x9007.cs
  20. +15
    -5
      src/JT809.Protocol/MessageBody/JT809_0x9008.cs
  21. +17
    -1
      src/JT809.Protocol/MessageBody/JT809_0x9101.cs
  22. +4
    -0
      src/JT809.Protocol/MessagePack/JT809MessagePackReader.cs

+ 2
- 2
src/JT809.Protocol.Test/JT809MessageBody/JT809_0x9007Test.cs Vedi File

@@ -17,7 +17,7 @@ namespace JT809.Protocol.Test.JT809MessageBody
public void Test1()
{
JT809_0x9007 jT809_0X9007 = new JT809_0x9007();
jT809_0X9007.ReasonCode = JT809_0x9007_ReasonCode.无法连接下级平台指定的服务IP与端口;
jT809_0X9007.ErrorCode = JT809_0x1007_ErrorCode.主链路断开;
var hex = JT809Serializer.Serialize(jT809_0X9007).ToHexString();
Assert.Equal("00", hex);
}
@@ -27,7 +27,7 @@ namespace JT809.Protocol.Test.JT809MessageBody
{
var bytes = "00".ToHexBytes();
JT809_0x9007 jT809_0X9007 = JT809Serializer.Deserialize<JT809_0x9007>(bytes);
Assert.Equal(JT809_0x9007_ReasonCode.无法连接下级平台指定的服务IP与端口, jT809_0X9007.ReasonCode);
Assert.Equal(JT809_0x1007_ErrorCode.主链路断开, jT809_0X9007.ErrorCode);
}
}
}

+ 25
- 0
src/JT809.Protocol/Extensions/JT809AnalyzeExtensions.cs Vedi File

@@ -0,0 +1,25 @@
using JT809.Protocol;
using JT809.Protocol.Interfaces;
using JT809.Protocol.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;

namespace JT809.Protocol.Extensions
{
public static class JT809AnalyzeExtensions
{
public static void Analyze(this object instance, ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config)
{
if(instance is IJT809Analyze analyze)
{
analyze.Analyze(ref reader, writer, config);
}
else
{
throw new NotImplementedException($"Not Implemented {instance.GetType().FullName} {nameof(IJT809Analyze)}");
}
}
}
}

+ 48
- 0
src/JT809.Protocol/Extensions/JT809HexExtensions.cs Vedi File

@@ -133,6 +133,54 @@ namespace JT809.Protocol.Extensions
return buf;
}

public static string ReadNumber(this byte value, string format = "X2")
{
return value.ToString(format);
}
public static string ReadNumber(this int value, string format = "X8")
{
return value.ToString(format);
}
public static string ReadNumber(this uint value, string format = "X8")
{
return value.ToString(format);
}
public static string ReadNumber(this long value, string format = "X16")
{
return value.ToString(format);
}
public static string ReadNumber(this ulong value, string format = "X16")
{
return value.ToString(format);
}
public static string ReadNumber(this short value, string format = "X4")
{
return value.ToString(format);
}
public static string ReadNumber(this ushort value, string format = "X4")
{
return value.ToString(format);
}
public static ReadOnlySpan<char> ReadBinary(this ushort value)
{
return System.Convert.ToString(value, 2).PadLeft(16, '0').AsSpan();
}
public static ReadOnlySpan<char> ReadBinary(this short value)
{
return System.Convert.ToString(value, 2).PadLeft(16, '0').AsSpan();
}
public static ReadOnlySpan<char> ReadBinary(this uint value)
{
return System.Convert.ToString(value, 2).PadLeft(32, '0').AsSpan();
}
public static ReadOnlySpan<char> ReadBinary(this int value)
{
return System.Convert.ToString(value, 2).PadLeft(32, '0').AsSpan();
}
public static ReadOnlySpan<char> ReadBinary(this byte value)
{
return System.Convert.ToString(value, 2).PadLeft(8, '0').AsSpan();
}
public unsafe static string ReadHexStringLittle(ReadOnlySpan<byte> read, ref int offset, int len)
{
ReadOnlySpan<byte> source = read.Slice(offset, len);


+ 29
- 9
src/JT809.Protocol/MessageBody/JT809_0x1001.cs Vedi File

@@ -3,7 +3,7 @@ using JT809.Protocol.Extensions;
using JT809.Protocol.Formatters;
using JT809.Protocol.Interfaces;
using JT809.Protocol.MessagePack;
using System.Text.Json;

namespace JT809.Protocol.MessageBody
{
@@ -14,7 +14,7 @@ namespace JT809.Protocol.MessageBody
/// <para>业务数据类型标识: UP-CONNECT-REQ</para>
/// <para>描述:下级平台向上级平台发送用户名和密码等登录信息</para>
/// </summary>
public class JT809_0x1001: JT809Bodies,IJT809MessagePackFormatter<JT809_0x1001>, IJT809_2019_Version
public class JT809_0x1001: JT809Bodies,IJT809MessagePackFormatter<JT809_0x1001>, IJT809Analyze, IJT809_2019_Version
{
/// <summary>
/// 用户名
@@ -45,18 +45,38 @@ namespace JT809.Protocol.MessageBody

public override JT809_LinkType LinkType => JT809_LinkType.main;

public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config)
{
JT809_0x1001 value = new JT809_0x1001();
value.UserId = reader.ReadUInt32();
writer.WriteNumber($"[{value.UserId.ReadNumber()}]用户名", value.UserId);
var virtualHex = reader.ReadVirtualArray(8);
value.Password = reader.ReadString(8);
writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]密码", value.Password);
if (config.Version == JT809Version.JTT2019)
{
value.MsgGNSSCENTERID = reader.ReadUInt32();
writer.WriteNumber($"[{value.MsgGNSSCENTERID.ReadNumber()}]下级平台接入码", value.MsgGNSSCENTERID);
}
virtualHex = reader.ReadVirtualArray(32);
value.DownLinkIP = reader.ReadString(32);
writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]下级平台提供对应的从链路服务端IP地址", value.DownLinkIP);
value.DownLinkPort = reader.ReadUInt16();
writer.WriteNumber($"[{value.DownLinkPort.ReadNumber()}]下级平台提供对应的从链路服务器端口号", value.DownLinkPort);
}

public JT809_0x1001 Deserialize(ref JT809MessagePackReader reader, IJT809Config config)
{
JT809_0x1001 jT809_0X1001 = new JT809_0x1001();
jT809_0X1001.UserId = reader.ReadUInt32();
jT809_0X1001.Password = reader.ReadString(8);
JT809_0x1001 value = new JT809_0x1001();
value.UserId = reader.ReadUInt32();
value.Password = reader.ReadString(8);
if(config.Version== JT809Version.JTT2019)
{
jT809_0X1001.MsgGNSSCENTERID = reader.ReadUInt32();
value.MsgGNSSCENTERID = reader.ReadUInt32();
}
jT809_0X1001.DownLinkIP = reader.ReadString(32);
jT809_0X1001.DownLinkPort = reader.ReadUInt16();
return jT809_0X1001;
value.DownLinkIP = reader.ReadString(32);
value.DownLinkPort = reader.ReadUInt16();
return value;
}

public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1001 value, IJT809Config config)


+ 16
- 5
src/JT809.Protocol/MessageBody/JT809_0x1002.cs Vedi File

@@ -6,6 +6,7 @@ using JT809.Protocol.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;

namespace JT809.Protocol.MessageBody
{
@@ -16,7 +17,7 @@ namespace JT809.Protocol.MessageBody
/// <para>业务数据类型标识:UP_CONNCCT_RSP</para>
/// <para>描述:上级平台对下级平台登录请求信息、进行安全验证后,返回相应的验证结果。</para>
/// </summary>
public class JT809_0x1002 : JT809Bodies, IJT809MessagePackFormatter<JT809_0x1002>, IJT809_2019_Version
public class JT809_0x1002 : JT809Bodies, IJT809MessagePackFormatter<JT809_0x1002>, IJT809Analyze, IJT809_2019_Version
{
public override ushort MsgId => JT809BusinessType.主链路登录应答消息.ToUInt16Value();

@@ -38,12 +39,22 @@ namespace JT809.Protocol.MessageBody
/// 校验码
/// </summary>
public uint VerifyCode { get; set; }

public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config)
{
JT809_0x1002 value = new JT809_0x1002();
value.Result = (JT809_0x1002_Result)reader.ReadByte();
writer.WriteString($"[{value.Result.ToByteValue()}]验证结果", value.Result.ToString());
value.VerifyCode = reader.ReadUInt32();
writer.WriteNumber($"[{value.VerifyCode.ReadNumber()}]校验码",value.VerifyCode);
}

public JT809_0x1002 Deserialize(ref JT809MessagePackReader reader, IJT809Config config)
{
JT809_0x1002 jT809_0X1002 = new JT809_0x1002();
jT809_0X1002.Result = (JT809_0x1002_Result)reader.ReadByte();
jT809_0X1002.VerifyCode = reader.ReadUInt32();
return jT809_0X1002;
JT809_0x1002 value = new JT809_0x1002();
value.Result = (JT809_0x1002_Result)reader.ReadByte();
value.VerifyCode = reader.ReadUInt32();
return value;
}
public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1002 value, IJT809Config config)
{


+ 18
- 5
src/JT809.Protocol/MessageBody/JT809_0x1003.cs Vedi File

@@ -1,10 +1,12 @@
using JT809.Protocol.Enums;
using JT809.Protocol.Extensions;
using JT809.Protocol.Formatters;
using JT809.Protocol.Interfaces;
using JT809.Protocol.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;

namespace JT809.Protocol.MessageBody
{
@@ -15,7 +17,7 @@ namespace JT809.Protocol.MessageBody
/// <para>业务数据类型标识:UP-DISCONNECT-REQ</para>
/// <para>描述:下级平台在中断与上级平台的主链路连接时,应向上级平台发送主链路注销请求消息。</para>
/// </summary>
public class JT809_0x1003 : JT809Bodies, IJT809MessagePackFormatter<JT809_0x1003>
public class JT809_0x1003 : JT809Bodies, IJT809MessagePackFormatter<JT809_0x1003>, IJT809Analyze
{
public override ushort MsgId => JT809BusinessType.主链路注销请求消息.ToUInt16Value();

@@ -30,12 +32,23 @@ namespace JT809.Protocol.MessageBody
/// 密码
/// </summary>
public string Password { get; set; }

public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config)
{
JT809_0x1003 value = new JT809_0x1003();
value.UserId = reader.ReadUInt32();
writer.WriteNumber($"[{value.UserId.ReadNumber()}]用户名", value.UserId);
var virtualHex = reader.ReadVirtualArray(8);
value.Password = reader.ReadString(8);
writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]密码", value.Password);
}

public JT809_0x1003 Deserialize(ref JT809MessagePackReader reader, IJT809Config config)
{
JT809_0x1003 jT809_0X1003 = new JT809_0x1003();
jT809_0X1003.UserId = reader.ReadUInt32();
jT809_0X1003.Password = reader.ReadString(8);
return jT809_0X1003;
JT809_0x1003 value = new JT809_0x1003();
value.UserId = reader.ReadUInt32();
value.Password = reader.ReadString(8);
return value;
}
public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1003 value, IJT809Config config)
{


+ 14
- 4
src/JT809.Protocol/MessageBody/JT809_0x1007.cs Vedi File

@@ -1,7 +1,9 @@
using JT809.Protocol.Enums;
using JT809.Protocol.Extensions;
using JT809.Protocol.Formatters;
using JT809.Protocol.Interfaces;
using JT809.Protocol.MessagePack;
using System.Text.Json;

namespace JT809.Protocol.MessageBody
{
@@ -14,7 +16,7 @@ namespace JT809.Protocol.MessageBody
/// <para>主链路连接保持应答消息,数据体为空</para>
/// <para>本条消息无需被通知方应答</para>
/// </summary>
public class JT809_0x1007:JT809Bodies, IJT809MessagePackFormatter<JT809_0x1007>
public class JT809_0x1007:JT809Bodies, IJT809MessagePackFormatter<JT809_0x1007>, IJT809Analyze
{
public override ushort MsgId => JT809BusinessType.主链路断开通知消息.ToUInt16Value();
public override string Description => "主链路断开通知消息";
@@ -23,11 +25,19 @@ namespace JT809.Protocol.MessageBody
/// 错误代码
/// </summary>
public JT809_0x1007_ErrorCode ErrorCode { get; set; }

public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config)
{
JT809_0x1007 value = new JT809_0x1007();
value.ErrorCode = (JT809_0x1007_ErrorCode)reader.ReadByte();
writer.WriteString($"[{value.ErrorCode.ToByteValue()}]错误代码", value.ErrorCode.ToString());
}

public JT809_0x1007 Deserialize(ref JT809MessagePackReader reader, IJT809Config config)
{
JT809_0x1007 jT809_0X1007 = new JT809_0x1007();
jT809_0X1007.ErrorCode = (JT809_0x1007_ErrorCode)reader.ReadByte();
return jT809_0X1007;
JT809_0x1007 value = new JT809_0x1007();
value.ErrorCode = (JT809_0x1007_ErrorCode)reader.ReadByte();
return value;
}

public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1007 value, IJT809Config config)


+ 15
- 5
src/JT809.Protocol/MessageBody/JT809_0x1008.cs Vedi File

@@ -1,7 +1,9 @@
using JT809.Protocol.Enums;
using JT809.Protocol.Extensions;
using JT809.Protocol.Formatters;
using JT809.Protocol.Interfaces;
using JT809.Protocol.MessagePack;
using System.Text.Json;

namespace JT809.Protocol.MessageBody
{
@@ -12,20 +14,28 @@ namespace JT809.Protocol.MessageBody
/// <para>业务数据类型标识:UP_CLOSELINIC INFORM</para>
/// <para>描述:下级平台作为服务端,发现从链路出现异常时,下级平台通过从链路向上级平台发送本消息,通知上级平台下级平台即将关闭主从链路</para>
/// </summary>
public class JT809_0x1008:JT809Bodies, IJT809MessagePackFormatter<JT809_0x1008>
public class JT809_0x1008:JT809Bodies, IJT809MessagePackFormatter<JT809_0x1008>, IJT809Analyze
{
public override ushort MsgId => JT809BusinessType.下级平台主动关闭主从链路通知消息.ToUInt16Value();
public override string Description => "下级平台主动关闭主从链路通知消息";
public override JT809_LinkType LinkType => JT809_LinkType.subordinate;
/// <summary>
/// 错误代码
/// 链路关闭原因
/// </summary>
public JT809_0x1008_ReasonCode ReasonCode { get; set; }

public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config)
{
JT809_0x1008 value = new JT809_0x1008();
value.ReasonCode = (JT809_0x1008_ReasonCode)reader.ReadByte();
writer.WriteString($"[{value.ReasonCode.ToByteValue()}]链路关闭原因", value.ReasonCode.ToString());
}

public JT809_0x1008 Deserialize(ref JT809MessagePackReader reader, IJT809Config config)
{
JT809_0x1008 jT809_0X1008 = new JT809_0x1008();
jT809_0X1008.ReasonCode = (JT809_0x1008_ReasonCode)reader.ReadByte();
return jT809_0X1008;
JT809_0x1008 value = new JT809_0x1008();
value.ReasonCode = (JT809_0x1008_ReasonCode)reader.ReadByte();
return value;
}

public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1008 value, IJT809Config config)


+ 24
- 1
src/JT809.Protocol/MessageBody/JT809_0x1102.cs Vedi File

@@ -6,6 +6,7 @@ using JT809.Protocol.Interfaces;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;

namespace JT809.Protocol.MessageBody
{
@@ -16,7 +17,7 @@ namespace JT809.Protocol.MessageBody
/// <para>业务类型标识:UP_MANAGE_MSG_RSP</para>
/// <para>下级平台收到上级平台下发的“平台链路连接情况与车辆定位消息传输情况上报请求消息”后,上报指定平台,指定时间段内的平台链路连接情况与车辆定位消息传输情况</para>
/// </summary>
public class JT809_0x1102 : JT809ExchangeMessageBodies, IJT809MessagePackFormatter<JT809_0x1102>,IJT809_2019_Version
public class JT809_0x1102 : JT809ExchangeMessageBodies, IJT809MessagePackFormatter<JT809_0x1102>, IJT809Analyze, IJT809_2019_Version
{
public override ushort MsgId => JT809BusinessType.平台链路连接情况与车辆定位消息传输情况上报应答消息_2019.ToUInt16Value();
public override string Description => "平台链路连接情况与车辆定位消息传输情况上报应答消息";
@@ -50,6 +51,28 @@ namespace JT809.Protocol.MessageBody
/// START_TIME~END_TIME期间下级监控平台链路断开总时长,用秒表示
/// </summary>
public uint DisconnectTime { get; set; }

public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config)
{
JT809_0x1102 value = new JT809_0x1102();
var virtualHex = reader.ReadVirtualArray(11);
value.PlateformId = reader.ReadBigNumber(11);
writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]平台唯一编码", value.PlateformId);
virtualHex = reader.ReadVirtualArray(8);
value.StartTime = reader.ReadUTCDateTime();
writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]开始时间", value.StartTime);
virtualHex = reader.ReadVirtualArray(8);
value.EndTime = reader.ReadUTCDateTime();
writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]结束时间", value.EndTime);
value.LoseDymamicSum = reader.ReadUInt32();
writer.WriteNumber($"[{value.LoseDymamicSum.ReadNumber()}]START_TIME~END_TIME期间下级平台丢失得车辆定位消息总数", value.LoseDymamicSum);
value.DisconnectNum = reader.ReadByte();
writer.WriteNumber($"[{value.DisconnectNum.ReadNumber()}]START_TIME~END_TIME期间下级监控平台链路断开次数", value.DisconnectNum);
value.DisconnectTime = reader.ReadUInt32();
writer.WriteNumber($"[{value.DisconnectTime.ReadNumber()}]START_TIME~END_TIME期间下级监控平台链路断开总时长,用秒表示", value.DisconnectTime);

}

public JT809_0x1102 Deserialize(ref JT809MessagePackReader reader, IJT809Config config)
{
JT809_0x1102 value = new JT809_0x1102();


+ 28
- 1
src/JT809.Protocol/MessageBody/JT809_0x1103.cs Vedi File

@@ -7,6 +7,7 @@ using System;
using System.Collections.Generic;
using System.Text;
using JT809.Protocol.Metadata;
using System.Text.Json;

namespace JT809.Protocol.MessageBody
{
@@ -17,7 +18,7 @@ namespace JT809.Protocol.MessageBody
/// <para>业务类型标识:UP_MANAGE_MSG_SN_INFORM</para>
/// <para>描述:链路登录成功后,平台须发送链路断开之前所有子业务数据类型对应的消息序列号,发送方根据收到的消息序列号,在发送消息时,续编链路中断之前的消息序列号</para>
/// </summary>
public class JT809_0x1103 : JT809ExchangeMessageBodies, IJT809MessagePackFormatter<JT809_0x1103>,IJT809_2019_Version
public class JT809_0x1103 : JT809ExchangeMessageBodies, IJT809MessagePackFormatter<JT809_0x1103>, IJT809Analyze, IJT809_2019_Version
{
public override ushort MsgId => JT809BusinessType.上传平台间消息序列号通知消息_2019.ToUInt16Value();
public override string Description => "上传平台间消息序列号通知消息";
@@ -27,6 +28,32 @@ namespace JT809.Protocol.MessageBody
public List<JT809ManageMsgSNInform> ManageMsgSNInform { get; set; } = new List<JT809ManageMsgSNInform>();
public byte Count { get; set; }

public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config)
{
JT809_0x1103 value = new JT809_0x1103();
value.SubBusinessType = reader.ReadUInt16();
writer.WriteString($"[{value.SubBusinessType.ReadNumber()}]子业务类型标识", ((JT809SubBusinessType)value.SubBusinessType).ToString());
value.DataLength = reader.ReadUInt32();
writer.WriteNumber($"[{value.DataLength.ReadNumber()}]后续数据长度", value.DataLength);
value.Count = reader.ReadByte();
writer.WriteNumber($"[{value.Count.ReadNumber()}]个数", value.Count);
writer.WriteStartArray("上传平台间消息序列号通知消息");
for (int i = 0; i < value.Count; i++)
{
writer.WriteStartObject();
JT809ManageMsgSNInform item = new JT809ManageMsgSNInform();
item.SubBusinessType = reader.ReadUInt16();
writer.WriteString($"[{item.SubBusinessType.ReadNumber()}]子业务类型标识", ((JT809SubBusinessType)item.SubBusinessType).ToString());
item.MsgSN = reader.ReadUInt32();
writer.WriteNumber($"[{item.MsgSN.ReadNumber()}]对应得子夜吴数据类型报文序列号", item.MsgSN);
var virtualHex = reader.ReadVirtualArray(8);
item.Time = reader.ReadUTCDateTime();
writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]系统UTC时间", item.Time);
writer.WriteEndObject();
}
writer.WriteEndArray();
}

public JT809_0x1103 Deserialize(ref JT809MessagePackReader reader, IJT809Config config)
{
JT809_0x1103 value = new JT809_0x1103();


+ 35
- 3
src/JT809.Protocol/MessageBody/JT809_0x1200.cs Vedi File

@@ -1,10 +1,11 @@

using JT809.Protocol.Enums;
using JT809.Protocol.Enums;
using JT809.Protocol.Exceptions;
using JT809.Protocol.Extensions;
using JT809.Protocol.Formatters;
using JT809.Protocol.Interfaces;
using JT809.Protocol.MessagePack;
using System;
using System.Text.Json;

namespace JT809.Protocol.MessageBody
{
@@ -15,12 +16,43 @@ namespace JT809.Protocol.MessageBody
/// <para>业务数据类型标识:UP_EXG_MSG</para>
/// <para>描述:下级平台向上级平台发送车辆动态信息交换业务数据包</para>
/// </summary>
public class JT809_0x1200: JT809ExchangeMessageBodies, IJT809MessagePackFormatter<JT809_0x1200>
public class JT809_0x1200: JT809ExchangeMessageBodies, IJT809MessagePackFormatter<JT809_0x1200>, IJT809Analyze
{
public override ushort MsgId => JT809BusinessType.主链路车辆动态信息交换业务.ToUInt16Value();
public override string Description => "主链路车辆动态信息交换业务";
public override JT809_LinkType LinkType => JT809_LinkType.main;

public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config)
{
JT809_0x1200 value = new JT809_0x1200();
var virtualHex = reader.ReadVirtualArray(21);
value.VehicleNo = reader.ReadString(21);
writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]车牌号", value.VehicleNo);
value.VehicleColor = (JT809VehicleColorType)reader.ReadByte();
writer.WriteString($"[{value.VehicleColor.ToByteValue()}]车牌颜色", value.VehicleColor.ToString());
value.SubBusinessType = reader.ReadUInt16();
writer.WriteString($"[{value.SubBusinessType.ReadNumber()}]子业务类型标识", ((JT809SubBusinessType)value.SubBusinessType).ToString());
value.DataLength = reader.ReadUInt32();
writer.WriteNumber($"[{value.DataLength.ReadNumber()}]后续数据长度", value.DataLength);
try
{
if (config.SubBusinessTypeFactory.TryGetValue(value.SubBusinessType, out object instance))
{
if (instance is JT809SubBodies subBodies)
{
if (!subBodies.SkipSerialization)
{
instance.Analyze(ref reader, writer, config);
}
}
}
}
catch
{
throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}");
}
}

public JT809_0x1200 Deserialize(ref JT809MessagePackReader reader, IJT809Config config)
{
JT809_0x1200 value = new JT809_0x1200();


+ 30
- 1
src/JT809.Protocol/MessageBody/JT809_0x1300.cs Vedi File

@@ -2,8 +2,10 @@
using JT809.Protocol.Exceptions;
using JT809.Protocol.Extensions;
using JT809.Protocol.Formatters;
using JT809.Protocol.Interfaces;
using JT809.Protocol.MessagePack;
using System;
using System.Text.Json;

namespace JT809.Protocol.MessageBody
{
@@ -14,11 +16,38 @@ namespace JT809.Protocol.MessageBody
/// <para>业务数据类型标识:UP_PLATFORM_MSG</para>
/// <para>描述:下级平台向上级平台发送平台间交互信息</para>
/// </summary>
public class JT809_0x1300: JT809ExchangeMessageBodies, IJT809MessagePackFormatter<JT809_0x1300>
public class JT809_0x1300: JT809ExchangeMessageBodies, IJT809MessagePackFormatter<JT809_0x1300>, IJT809Analyze
{
public override ushort MsgId => JT809BusinessType.主链路平台间信息交互消息.ToUInt16Value();
public override string Description => "主链路平台间信息交互消息";
public override JT809_LinkType LinkType => JT809_LinkType.main;

public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config)
{
JT809_0x1300 value = new JT809_0x1300();
value.SubBusinessType = reader.ReadUInt16();
writer.WriteString($"[{value.SubBusinessType.ReadNumber()}]子业务类型标识", ((JT809SubBusinessType)value.SubBusinessType).ToString());
value.DataLength = reader.ReadUInt32();
writer.WriteNumber($"[{value.DataLength.ReadNumber()}]后续数据长度", value.DataLength);
try
{
if (config.SubBusinessTypeFactory.TryGetValue(value.SubBusinessType, out object instance))
{
if (instance is JT809SubBodies subBodies)
{
if (!subBodies.SkipSerialization)
{
instance.Analyze(ref reader, writer, config);
}
}
}
}
catch
{
throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}");
}
}

public JT809_0x1300 Deserialize(ref JT809MessagePackReader reader, IJT809Config config)
{
JT809_0x1300 value = new JT809_0x1300();


+ 36
- 1
src/JT809.Protocol/MessageBody/JT809_0x1400.cs Vedi File

@@ -4,6 +4,7 @@ using JT809.Protocol.Extensions;
using JT809.Protocol.Formatters;
using JT809.Protocol.Interfaces;
using JT809.Protocol.MessagePack;
using System.Text.Json;

namespace JT809.Protocol.MessageBody
{
@@ -15,12 +16,46 @@ namespace JT809.Protocol.MessageBody
/// <para>业务数据类型标识:UP_WARN_MSG</para>
/// <para>描述:下级平台向上级平台发送车辆报警信息业务</para>
/// </summary>
public class JT809_0x1400: JT809ExchangeMessageBodies, IJT809MessagePackFormatter<JT809_0x1400>, IJT809_2019_Version
public class JT809_0x1400: JT809ExchangeMessageBodies, IJT809MessagePackFormatter<JT809_0x1400>, IJT809Analyze, IJT809_2019_Version
{
public override ushort MsgId => JT809BusinessType.主链路报警信息交互消息.ToUInt16Value();
public override string Description => "主链路报警信息交互消息";
public override JT809_LinkType LinkType => JT809_LinkType.main;

public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config)
{
JT809_0x1400 value = new JT809_0x1400();
if (config.Version == JT809Version.JTT2011)
{
var virtualHex = reader.ReadVirtualArray(21);
value.VehicleNo = reader.ReadString(21);
writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]车牌号", value.VehicleNo);
value.VehicleColor = (JT809VehicleColorType)reader.ReadByte();
writer.WriteString($"[{value.VehicleColor.ToByteValue()}]车牌颜色", value.VehicleColor.ToString());
}
value.SubBusinessType = reader.ReadUInt16();
writer.WriteString($"[{value.SubBusinessType.ReadNumber()}]子业务类型标识", ((JT809SubBusinessType)value.SubBusinessType).ToString());
value.DataLength = reader.ReadUInt32();
writer.WriteNumber($"[{value.DataLength.ReadNumber()}]后续数据长度", value.DataLength);
try
{
if (config.SubBusinessTypeFactory.TryGetValue(value.SubBusinessType, out object instance))
{
if (instance is JT809SubBodies subBodies)
{
if (!subBodies.SkipSerialization)
{
instance.Analyze(ref reader, writer, config);
}
}
}
}
catch
{
throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}");
}
}

public JT809_0x1400 Deserialize(ref JT809MessagePackReader reader, IJT809Config config)
{
JT809_0x1400 value = new JT809_0x1400();


+ 35
- 1
src/JT809.Protocol/MessageBody/JT809_0x1500.cs Vedi File

@@ -2,7 +2,9 @@
using JT809.Protocol.Exceptions;
using JT809.Protocol.Extensions;
using JT809.Protocol.Formatters;
using JT809.Protocol.Interfaces;
using JT809.Protocol.MessagePack;
using System.Text.Json;

namespace JT809.Protocol.MessageBody
{
@@ -13,11 +15,43 @@ namespace JT809.Protocol.MessageBody
/// <para>业务数据类型标识:UP_CTRL_MSG</para>
/// <para>描述:下级平台向上级平台发送车辆监管业务</para>
/// </summary>
public class JT809_0x1500: JT809ExchangeMessageBodies, IJT809MessagePackFormatter<JT809_0x1500>
public class JT809_0x1500: JT809ExchangeMessageBodies, IJT809MessagePackFormatter<JT809_0x1500>, IJT809Analyze
{
public override ushort MsgId => JT809BusinessType.主链路车辆监管消息.ToUInt16Value();
public override string Description => "主链路车辆监管消息";
public override JT809_LinkType LinkType => JT809_LinkType.main;

public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config)
{
JT809_0x1500 value = new JT809_0x1500();
var virtualHex = reader.ReadVirtualArray(21);
value.VehicleNo = reader.ReadString(21);
writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]车牌号", value.VehicleNo);
value.VehicleColor = (JT809VehicleColorType)reader.ReadByte();
writer.WriteString($"[{value.VehicleColor.ToByteValue()}]车牌颜色", value.VehicleColor.ToString());
value.SubBusinessType = reader.ReadUInt16();
writer.WriteString($"[{value.SubBusinessType.ReadNumber()}]子业务类型标识", ((JT809SubBusinessType)value.SubBusinessType).ToString());
value.DataLength = reader.ReadUInt32();
writer.WriteNumber($"[{value.DataLength.ReadNumber()}]后续数据长度", value.DataLength);
try
{
if (config.SubBusinessTypeFactory.TryGetValue(value.SubBusinessType, out object instance))
{
if (instance is JT809SubBodies subBodies)
{
if (!subBodies.SkipSerialization)
{
instance.Analyze(ref reader, writer, config);
}
}
}
}
catch
{
throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}");
}
}

public JT809_0x1500 Deserialize(ref JT809MessagePackReader reader, IJT809Config config)
{
JT809_0x1500 value = new JT809_0x1500();


+ 34
- 1
src/JT809.Protocol/MessageBody/JT809_0x1600.cs Vedi File

@@ -2,7 +2,9 @@
using JT809.Protocol.Exceptions;
using JT809.Protocol.Extensions;
using JT809.Protocol.Formatters;
using JT809.Protocol.Interfaces;
using JT809.Protocol.MessagePack;
using System.Text.Json;

namespace JT809.Protocol.MessageBody
{
@@ -13,12 +15,43 @@ namespace JT809.Protocol.MessageBody
/// <para>消息方向:下级平台往上级平台</para>
/// <para>描述:下级平台向上级平台发送车辆睁态信息交换业务</para>
/// </summary>
public class JT809_0x1600: JT809ExchangeMessageBodies, IJT809MessagePackFormatter<JT809_0x1600>
public class JT809_0x1600: JT809ExchangeMessageBodies, IJT809MessagePackFormatter<JT809_0x1600>, IJT809Analyze
{
public override ushort MsgId => JT809BusinessType.主链路静态信息交换消息.ToUInt16Value();
public override string Description => "主链路静态信息交换消息";
public override JT809_LinkType LinkType => JT809_LinkType.main;

public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config)
{
JT809_0x1600 value = new JT809_0x1600();
var virtualHex = reader.ReadVirtualArray(21);
value.VehicleNo = reader.ReadString(21);
writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]车牌号", value.VehicleNo);
value.VehicleColor = (JT809VehicleColorType)reader.ReadByte();
writer.WriteString($"[{value.VehicleColor.ToByteValue()}]车牌颜色", value.VehicleColor.ToString());
value.SubBusinessType = reader.ReadUInt16();
writer.WriteString($"[{value.SubBusinessType.ReadNumber()}]子业务类型标识", ((JT809SubBusinessType)value.SubBusinessType).ToString());
value.DataLength = reader.ReadUInt32();
writer.WriteNumber($"[{value.DataLength.ReadNumber()}]后续数据长度", value.DataLength);
try
{
if (config.SubBusinessTypeFactory.TryGetValue(value.SubBusinessType, out object instance))
{
if (instance is JT809SubBodies subBodies)
{
if (!subBodies.SkipSerialization)
{
instance.Analyze(ref reader, writer, config);
}
}
}
}
catch
{
throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}");
}
}

public JT809_0x1600 Deserialize(ref JT809MessagePackReader reader, IJT809Config config)
{
JT809_0x1600 value = new JT809_0x1600();


+ 13
- 4
src/JT809.Protocol/MessageBody/JT809_0x9001.cs Vedi File

@@ -1,7 +1,9 @@
using JT809.Protocol.Enums;
using JT809.Protocol.Extensions;
using JT809.Protocol.Formatters;
using JT809.Protocol.Interfaces;
using JT809.Protocol.MessagePack;
using System.Text.Json;

namespace JT809.Protocol.MessageBody
{
@@ -13,7 +15,7 @@ namespace JT809.Protocol.MessageBody
/// <para>描述:主链路建立连接后,上级平台向下级平台发送从链路连接清求消息,以建立从链路连接</para>
/// <para>下级平台在收到本息后,根据本校验码 VERIFY CODE 来实现数据的校验,校验后,则返回DOWN CONNECT RSP 消息</para>
/// </summary>
public class JT809_0x9001 : JT809Bodies, IJT809MessagePackFormatter<JT809_0x9001>
public class JT809_0x9001 : JT809Bodies, IJT809MessagePackFormatter<JT809_0x9001>, IJT809Analyze
{
public override ushort MsgId => JT809BusinessType.从链路连接请求消息.ToUInt16Value();
public override string Description => "从链路连接请求消息";
@@ -23,11 +25,18 @@ namespace JT809.Protocol.MessageBody
/// </summary>
public uint VerifyCode { get; set; }

public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config)
{
JT809_0x9001 value = new JT809_0x9001();
value.VerifyCode = reader.ReadUInt32();
writer.WriteNumber($"[{value.VerifyCode.ReadNumber()}校验码]", value.VerifyCode);
}

public JT809_0x9001 Deserialize(ref JT809MessagePackReader reader, IJT809Config config)
{
JT809_0x9001 jT809_0X9001 = new JT809_0x9001();
jT809_0X9001.VerifyCode = reader.ReadUInt32();
return jT809_0X9001;
JT809_0x9001 value = new JT809_0x9001();
value.VerifyCode = reader.ReadUInt32();
return value;
}

public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9001 value, IJT809Config config)


+ 14
- 4
src/JT809.Protocol/MessageBody/JT809_0x9002.cs Vedi File

@@ -1,7 +1,9 @@
using JT809.Protocol.Enums;
using JT809.Protocol.Extensions;
using JT809.Protocol.Formatters;
using JT809.Protocol.Interfaces;
using JT809.Protocol.MessagePack;
using System.Text.Json;

namespace JT809.Protocol.MessageBody
{
@@ -12,7 +14,7 @@ namespace JT809.Protocol.MessageBody
/// <para>业务数据类型标识:DOWN_CONNNECT_RSP</para>
/// <para>描述:下级平台作为服务器端向上级平台客户端返回从链路连接应答消息,上级平台在接收到该应答消息结果后</para>
/// </summary>
public class JT809_0x9002:JT809Bodies, IJT809MessagePackFormatter<JT809_0x9002>
public class JT809_0x9002:JT809Bodies, IJT809MessagePackFormatter<JT809_0x9002>, IJT809Analyze
{
public override ushort MsgId => JT809BusinessType.从链路连接应答信息.ToUInt16Value();
public override string Description => "从链路连接应答信息";
@@ -21,11 +23,19 @@ namespace JT809.Protocol.MessageBody
/// 验证结果
/// </summary>
public JT809_0x9002_Result Result { get; set; }

public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config)
{
JT809_0x9002 value = new JT809_0x9002();
value.Result = (JT809_0x9002_Result)reader.ReadByte();
writer.WriteString($"[{value.Result.ToByteValue()}验证结果]", value.Result.ToString());
}

public JT809_0x9002 Deserialize(ref JT809MessagePackReader reader, IJT809Config config)
{
JT809_0x9002 jT809_0X9002 = new JT809_0x9002();
jT809_0X9002.Result = (JT809_0x9002_Result)reader.ReadByte();
return jT809_0X9002;
JT809_0x9002 value = new JT809_0x9002();
value.Result = (JT809_0x9002_Result)reader.ReadByte();
return value;
}

public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9002 value, IJT809Config config)


+ 13
- 4
src/JT809.Protocol/MessageBody/JT809_0x9003.cs Vedi File

@@ -1,7 +1,9 @@
using JT809.Protocol.Enums;
using JT809.Protocol.Extensions;
using JT809.Protocol.Formatters;
using JT809.Protocol.Interfaces;
using JT809.Protocol.MessagePack;
using System.Text.Json;

namespace JT809.Protocol.MessageBody
{
@@ -12,7 +14,7 @@ namespace JT809.Protocol.MessageBody
///<para>业务数据类型标识:DOWN_DISCONNIrCT_REQ</para>
///<para>描述:从链路建立后,上级平台在取消该链路时,应向下级平台发送从链路注销请求消息</para>
/// </summary>
public class JT809_0x9003: JT809Bodies, IJT809MessagePackFormatter<JT809_0x9003>
public class JT809_0x9003: JT809Bodies, IJT809MessagePackFormatter<JT809_0x9003>, IJT809Analyze
{
public override ushort MsgId => JT809BusinessType.从链路注销请求消息.ToUInt16Value();
public override string Description => "从链路注销请求消息";
@@ -22,11 +24,18 @@ namespace JT809.Protocol.MessageBody
/// </summary>
public uint VerifyCode { get; set; }

public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config)
{
JT809_0x9003 value = new JT809_0x9003();
value.VerifyCode = reader.ReadUInt32();
writer.WriteNumber($"[{value.VerifyCode.ReadNumber()}校验码]", value.VerifyCode);
}

public JT809_0x9003 Deserialize(ref JT809MessagePackReader reader, IJT809Config config)
{
JT809_0x9003 jT809_0X9003 = new JT809_0x9003();
jT809_0X9003.VerifyCode = reader.ReadUInt32();
return jT809_0X9003;
JT809_0x9003 value = new JT809_0x9003();
value.VerifyCode = reader.ReadUInt32();
return value;
}

public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9003 value, IJT809Config config)


+ 16
- 6
src/JT809.Protocol/MessageBody/JT809_0x9007.cs Vedi File

@@ -1,7 +1,9 @@
using JT809.Protocol.Enums;
using JT809.Protocol.Extensions;
using JT809.Protocol.Formatters;
using JT809.Protocol.Interfaces;
using JT809.Protocol.MessagePack;
using System.Text.Json;

namespace JT809.Protocol.MessageBody
{
@@ -16,7 +18,7 @@ namespace JT809.Protocol.MessageBody
/// </para>
/// <para>本条消息无需被通知方应答</para>
/// </summary>
public class JT809_0x9007:JT809Bodies, IJT809MessagePackFormatter<JT809_0x9007>
public class JT809_0x9007:JT809Bodies, IJT809MessagePackFormatter<JT809_0x9007>, IJT809Analyze
{
public override ushort MsgId => JT809BusinessType.从链路断开通知消息.ToUInt16Value();
public override string Description => "从链路断开通知消息";
@@ -24,16 +26,24 @@ namespace JT809.Protocol.MessageBody
/// <summary>
/// 错误代码
/// </summary>
public JT809_0x9007_ReasonCode ReasonCode { get; set; }
public JT809_0x1007_ErrorCode ErrorCode { get; set; }

public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config)
{
JT809_0x9007 value = new JT809_0x9007();
value.ErrorCode = (JT809_0x1007_ErrorCode)reader.ReadByte();
writer.WriteString($"[{value.ErrorCode.ToByteValue()}错误代码]", value.ErrorCode.ToString());
}

public JT809_0x9007 Deserialize(ref JT809MessagePackReader reader, IJT809Config config)
{
JT809_0x9007 jT809_0X9007 = new JT809_0x9007();
jT809_0X9007.ReasonCode = (JT809_0x9007_ReasonCode)reader.ReadByte();
return jT809_0X9007;
JT809_0x9007 value = new JT809_0x9007();
value.ErrorCode = (JT809_0x1007_ErrorCode)reader.ReadByte();
return value;
}
public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9007 value, IJT809Config config)
{
writer.WriteByte((byte)value.ReasonCode);
writer.WriteByte((byte)value.ErrorCode);
}
}
}

+ 15
- 5
src/JT809.Protocol/MessageBody/JT809_0x9008.cs Vedi File

@@ -1,7 +1,9 @@
using JT809.Protocol.Enums;
using JT809.Protocol.Extensions;
using JT809.Protocol.Formatters;
using JT809.Protocol.Interfaces;
using JT809.Protocol.MessagePack;
using System.Text.Json;

namespace JT809.Protocol.MessageBody
{
@@ -9,21 +11,29 @@ namespace JT809.Protocol.MessageBody
/// 上级平台主动关闭链路通知消息
/// <para>业务数据类型标识:DOWN_CLOSELINK_INFORM</para>
/// </summary>
public class JT809_0x9008:JT809Bodies, IJT809MessagePackFormatter<JT809_0x9008>
public class JT809_0x9008:JT809Bodies, IJT809MessagePackFormatter<JT809_0x9008>, IJT809Analyze
{
public override ushort MsgId => JT809BusinessType.上级平台主动关闭链路通知消息.ToUInt16Value();
public override string Description => "上级平台主动关闭链路通知消息";
#warning 待验证主从链路
public override JT809_LinkType LinkType => JT809_LinkType.subordinate;
/// <summary>
/// 错误代码
/// 链路关闭原因
/// </summary>
public JT809_0x9008_ReasonCode ReasonCode { get; set; }

public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config)
{
JT809_0x9008 value = new JT809_0x9008();
value.ReasonCode = (JT809_0x9008_ReasonCode)reader.ReadByte();
writer.WriteString($"[{value.ReasonCode.ToByteValue()}链路关闭原因]", value.ReasonCode.ToString());
}

public JT809_0x9008 Deserialize(ref JT809MessagePackReader reader, IJT809Config config)
{
JT809_0x9008 jT809_0X9008 = new JT809_0x9008();
jT809_0X9008.ReasonCode = (JT809_0x9008_ReasonCode)reader.ReadByte();
return jT809_0X9008;
JT809_0x9008 value = new JT809_0x9008();
value.ReasonCode = (JT809_0x9008_ReasonCode)reader.ReadByte();
return value;
}

public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9008 value, IJT809Config config)


+ 17
- 1
src/JT809.Protocol/MessageBody/JT809_0x9101.cs Vedi File

@@ -1,10 +1,12 @@
using JT809.Protocol.Enums;
using JT809.Protocol.Extensions;
using JT809.Protocol.Formatters;
using JT809.Protocol.Interfaces;
using JT809.Protocol.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;

namespace JT809.Protocol.MessageBody
{
@@ -16,7 +18,7 @@ namespace JT809.Protocol.MessageBody
/// <para>描述:上级平台向下级平台定星通知已经收到下级平台上传的车辆定位信息数量(如:每收到10,000 条车辆定位信息通知一次)</para>
/// <para>本条消息不需下级平台应答。</para>
/// </summary>
public class JT809_0x9101:JT809Bodies, IJT809MessagePackFormatter<JT809_0x9101>
public class JT809_0x9101:JT809Bodies, IJT809MessagePackFormatter<JT809_0x9101>, IJT809Analyze
{
public override ushort MsgId => JT809BusinessType.接收车辆定位信息数量通知消息.ToUInt16Value();
public override string Description => "接收车辆定位信息数量通知消息";
@@ -35,6 +37,20 @@ namespace JT809.Protocol.MessageBody
/// 注:采用 UTC 时间表示,如 2010-1-10 9:7:54 的 UTC 值为 1263085674,其在协议中表示为0x000000004B49286A.
/// </summary>
public DateTime EndTime { get; set; }

public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config)
{
JT809_0x9101 value = new JT809_0x9101();
value.DynamicInfoTotal = reader.ReadUInt32();
writer.WriteNumber($"[{value.DynamicInfoTotal.ReadNumber()}START_TIME_END_TIME共收到的车辆定位信息数量]", value.DynamicInfoTotal);
var virtualHex = reader.ReadVirtualArray(8);
value.StartTime = reader.ReadUTCDateTime();
writer.WriteString($"[{virtualHex.ToArray().ToHexString()}开始时间]", value.StartTime);
virtualHex = reader.ReadVirtualArray(8);
value.EndTime = reader.ReadUTCDateTime();
writer.WriteString($"[{virtualHex.ToArray().ToHexString()}结束时间]", value.EndTime);
}

public JT809_0x9101 Deserialize(ref JT809MessagePackReader reader, IJT809Config config)
{
JT809_0x9101 value = new JT809_0x9101();


+ 4
- 0
src/JT809.Protocol/MessagePack/JT809MessagePackReader.cs Vedi File

@@ -237,6 +237,10 @@ namespace JT809.Protocol.MessagePack
{
return BinaryPrimitives.ReadInt64BigEndian(GetReadOnlySpan(8));
}
public ReadOnlySpan<byte> ReadVirtualArray(int count)
{
return GetVirtualReadOnlySpan(count);
}
public byte ReadByte()
{
return GetReadOnlySpan(1)[0];


Caricamento…
Annulla
Salva