From 06a09c098ff6224379b8786549c064475bbbaca1 Mon Sep 17 00:00:00 2001 From: "smallchi(Koike)" <564952747@qq.com> Date: Mon, 20 Jan 2020 23:06:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8D=8F=E8=AE=AE=E5=88=86?= =?UTF-8?q?=E6=9E=90=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MessageBody/JT808_0x8001Test.cs | 7 + .../MessageBody/JT808_0x8003Test.cs | 7 + .../MessageBody/JT808_0x8004Test.cs | 7 + .../MessageBody/JT808_0x8100Test.cs | 7 + .../MessageBody/JT808_0x8105Test.cs | 7 + .../MessageBody/JT808_0x8106Test.cs | 7 + .../MessageBody/JT808_0x8108Test.cs | 7 + .../MessageBody/JT808_0x8202Test.cs | 6 + .../MessageBody/JT808_0x8203Test.cs | 7 + .../MessageBody/JT808_0x8300Test.cs | 7 + .../MessageBody/JT808_0x8301Test.cs | 7 + .../MessageBody/JT808_0x8302Test.cs | 7 + .../MessageBody/JT808_0x8303Test.cs | 7 + .../MessageBody/JT808_0x8304Test.cs | 7 + .../MessageBody/JT808_0x8400Test.cs | 7 + .../MessageBody/JT808_0x8401Test.cs | 7 + .../MessageBody/JT808_0x8500Test.cs | 7 + src/JT808.Protocol/JT808.Protocol.xml | 43 +- .../MessageBody/JT808_0x8001.cs | 34 +- .../MessageBody/JT808_0x8003.cs | 36 +- .../MessageBody/JT808_0x8004.cs | 9 +- .../MessageBody/JT808_0x8100.cs | 33 +- .../MessageBody/JT808_0x8105.cs | 387 ++++++++++++------ .../MessageBody/JT808_0x8106.cs | 23 +- .../MessageBody/JT808_0x8108.cs | 32 +- .../MessageBody/JT808_0x8202.cs | 17 +- .../MessageBody/JT808_0x8203.cs | 16 +- .../MessageBody/JT808_0x8300.cs | 19 +- .../MessageBody/JT808_0x8301.cs | 31 +- .../MessageBody/JT808_0x8302.cs | 33 +- .../MessageBody/JT808_0x8303.cs | 31 +- .../MessageBody/JT808_0x8304.cs | 18 +- .../MessageBody/JT808_0x8400.cs | 16 +- .../MessageBody/JT808_0x8401.cs | 35 +- .../MessageBody/JT808_0x8500.cs | 21 +- .../MessageBody/JT808_0x8500_0x0001.cs | 15 +- .../Metadata/JT808ContactProperty.cs | 2 +- 37 files changed, 784 insertions(+), 185 deletions(-) diff --git a/src/JT808.Protocol.Test/MessageBody/JT808_0x8001Test.cs b/src/JT808.Protocol.Test/MessageBody/JT808_0x8001Test.cs index 745292d..7b78d2f 100644 --- a/src/JT808.Protocol.Test/MessageBody/JT808_0x8001Test.cs +++ b/src/JT808.Protocol.Test/MessageBody/JT808_0x8001Test.cs @@ -53,5 +53,12 @@ namespace JT808.Protocol.Test.MessageBody Assert.Equal(100, JT808Bodies.MsgNum); Assert.Equal(Enums.JT808PlatformResult.成功, JT808Bodies.JT808PlatformResult); } + + [Fact] + public void Test3() + { + var bytes = "7E 80 01 00 05 01 23 45 67 89 00 00 0A 00 64 02 00 00 61 7E".ToHexBytes(); + string json = JT808Serializer.Analyze(bytes); + } } } diff --git a/src/JT808.Protocol.Test/MessageBody/JT808_0x8003Test.cs b/src/JT808.Protocol.Test/MessageBody/JT808_0x8003Test.cs index ef5a8d8..4a2ac87 100644 --- a/src/JT808.Protocol.Test/MessageBody/JT808_0x8003Test.cs +++ b/src/JT808.Protocol.Test/MessageBody/JT808_0x8003Test.cs @@ -29,5 +29,12 @@ namespace JT808.Protocol.Test.MessageBody Assert.Equal(new byte[] { 0x01, 0x02, 0x02, 0x03 }, jT808_0X8003.AgainPackageData); Assert.Equal(2, jT808_0X8003.AgainPackageCount); } + + [Fact] + public void Test3() + { + var bytes = "04D20201020203".ToHexBytes(); + string json = JT808Serializer.Analyze(bytes); + } } } diff --git a/src/JT808.Protocol.Test/MessageBody/JT808_0x8004Test.cs b/src/JT808.Protocol.Test/MessageBody/JT808_0x8004Test.cs index d244654..f6581fd 100644 --- a/src/JT808.Protocol.Test/MessageBody/JT808_0x8004Test.cs +++ b/src/JT808.Protocol.Test/MessageBody/JT808_0x8004Test.cs @@ -27,5 +27,12 @@ namespace JT808.Protocol.Test.MessageBody JT808_0x8004 jT808_0X8004 = JT808Serializer.Deserialize(bytes); Assert.Equal(DateTime.Parse("2019-11-26 15:58:50"), jT808_0X8004.Time); } + + [Fact] + public void Test3() + { + var bytes = "191126155850".ToHexBytes(); + string json = JT808Serializer.Analyze(bytes); + } } } diff --git a/src/JT808.Protocol.Test/MessageBody/JT808_0x8100Test.cs b/src/JT808.Protocol.Test/MessageBody/JT808_0x8100Test.cs index 3e9e40a..d717918 100644 --- a/src/JT808.Protocol.Test/MessageBody/JT808_0x8100Test.cs +++ b/src/JT808.Protocol.Test/MessageBody/JT808_0x8100Test.cs @@ -138,5 +138,12 @@ namespace JT808.Protocol.Test.MessageBody Assert.Equal(100, JT808Bodies.AckMsgNum); Assert.Equal(Enums.JT808TerminalRegisterResult.成功, JT808Bodies.JT808TerminalRegisterResult); } + + [Fact] + public void Test7() + { + var bytes = "7E 81 00 00 13 01 23 45 67 89 00 00 0A 00 64 00 7A 73 73 64 61 66 32 33 31 32 34 73 66 64 73 63 3B 7E".ToHexBytes(); + string json = JT808Serializer.Analyze(bytes); + } } } diff --git a/src/JT808.Protocol.Test/MessageBody/JT808_0x8105Test.cs b/src/JT808.Protocol.Test/MessageBody/JT808_0x8105Test.cs index 6ea8828..72f2bc5 100644 --- a/src/JT808.Protocol.Test/MessageBody/JT808_0x8105Test.cs +++ b/src/JT808.Protocol.Test/MessageBody/JT808_0x8105Test.cs @@ -2,6 +2,7 @@ using JT808.Protocol.MessageBody; using System; using Xunit; +using static JT808.Protocol.MessageBody.JT808_0x8105; namespace JT808.Protocol.Test.MessageBody { @@ -70,6 +71,12 @@ namespace JT808.Protocol.Test.MessageBody Assert.Equal(60, (UInt16)JT808_0x8105.CommandValue.ConnectTimeLimit); } + [Fact] + public void Test1_2() + { + var bytes = "7E8105004B012345678900000101313B544B4E616D653B544B3B544B3132333B7777772E62616964752E636F6D3B383830363B333330363B31323334353B636F64653B322E303B312E303B7777772E544B2E636F6D3B3630227E".ToHexBytes(); + string json = JT808Serializer.Analyze(bytes); + } [Fact] public void Test2() diff --git a/src/JT808.Protocol.Test/MessageBody/JT808_0x8106Test.cs b/src/JT808.Protocol.Test/MessageBody/JT808_0x8106Test.cs index d4f87a2..07ed626 100644 --- a/src/JT808.Protocol.Test/MessageBody/JT808_0x8106Test.cs +++ b/src/JT808.Protocol.Test/MessageBody/JT808_0x8106Test.cs @@ -28,5 +28,12 @@ namespace JT808.Protocol.Test.MessageBody Assert.Equal(2, jT808_0X8106.ParameterCount); Assert.Equal(new uint[] { 0x0001, 0x0002 }, jT808_0X8106.Parameters); } + + [Fact] + public void Test3() + { + byte[] bytes = "020000000100000002".ToHexBytes(); + string json = JT808Serializer.Analyze(bytes); + } } } diff --git a/src/JT808.Protocol.Test/MessageBody/JT808_0x8108Test.cs b/src/JT808.Protocol.Test/MessageBody/JT808_0x8108Test.cs index de24c54..e77d8a9 100644 --- a/src/JT808.Protocol.Test/MessageBody/JT808_0x8108Test.cs +++ b/src/JT808.Protocol.Test/MessageBody/JT808_0x8108Test.cs @@ -33,5 +33,12 @@ namespace JT808.Protocol.Test.MessageBody Assert.Equal("qscvhiuytrew", jT808_0X8108.VersionNum); Assert.Equal(new byte[] { 1, 2, 3, 4, 5 }, jT808_0X8108.UpgradePackage); } + + [Fact] + public void Test3() + { + byte[] bytes = "34 61 73 64 66 67 0C 71 73 63 76 68 69 75 79 74 72 65 77 00 00 00 05 01 02 03 04 05".ToHexBytes(); + string json = JT808Serializer.Analyze(bytes); + } } } diff --git a/src/JT808.Protocol.Test/MessageBody/JT808_0x8202Test.cs b/src/JT808.Protocol.Test/MessageBody/JT808_0x8202Test.cs index 4482103..b4d0ebe 100644 --- a/src/JT808.Protocol.Test/MessageBody/JT808_0x8202Test.cs +++ b/src/JT808.Protocol.Test/MessageBody/JT808_0x8202Test.cs @@ -27,5 +27,11 @@ namespace JT808.Protocol.Test.MessageBody Assert.Equal(69, jT808_0X8108.Interval); Assert.Equal(123, jT808_0X8108.LocationTrackingValidity); } + [Fact] + public void Test3() + { + byte[] bytes = "00 45 00 00 00 7B".ToHexBytes(); + string json = JT808Serializer.Analyze(bytes); + } } } diff --git a/src/JT808.Protocol.Test/MessageBody/JT808_0x8203Test.cs b/src/JT808.Protocol.Test/MessageBody/JT808_0x8203Test.cs index aff2b6d..3203ade 100644 --- a/src/JT808.Protocol.Test/MessageBody/JT808_0x8203Test.cs +++ b/src/JT808.Protocol.Test/MessageBody/JT808_0x8203Test.cs @@ -27,5 +27,12 @@ namespace JT808.Protocol.Test.MessageBody Assert.Equal(5554, jT808_0X8203.AlarmMsgNum); Assert.Equal((uint)123, jT808_0X8203.ManualConfirmAlarmType); } + + [Fact] + public void Test3() + { + byte[] bytes = "15B20000007B".ToHexBytes(); + string json = JT808Serializer.Analyze(bytes); + } } } diff --git a/src/JT808.Protocol.Test/MessageBody/JT808_0x8300Test.cs b/src/JT808.Protocol.Test/MessageBody/JT808_0x8300Test.cs index d8f6982..2aa7e6c 100644 --- a/src/JT808.Protocol.Test/MessageBody/JT808_0x8300Test.cs +++ b/src/JT808.Protocol.Test/MessageBody/JT808_0x8300Test.cs @@ -76,5 +76,12 @@ namespace JT808.Protocol.Test.MessageBody Assert.Equal(5, jT808TextSend.TextFlag); Assert.Equal(1, jT808TextSend.TextType); } + + [Fact] + public void Test_2019_3() + { + byte[] bytes = "7E8300400E010000000001234567890000010501736D616C6C63686920353138417E".ToHexBytes(); + string json = JT808Serializer.Analyze(bytes); + } } } diff --git a/src/JT808.Protocol.Test/MessageBody/JT808_0x8301Test.cs b/src/JT808.Protocol.Test/MessageBody/JT808_0x8301Test.cs index 50feb44..ab41ffa 100644 --- a/src/JT808.Protocol.Test/MessageBody/JT808_0x8301Test.cs +++ b/src/JT808.Protocol.Test/MessageBody/JT808_0x8301Test.cs @@ -48,5 +48,12 @@ namespace JT808.Protocol.Test.MessageBody Assert.Equal(6, jT808_0X8301.EventItems[1].EventContentLength); Assert.Equal("789456", jT808_0X8301.EventItems[1].EventContent); } + + [Fact] + public void Test1_2() + { + byte[] bytes = "000201063132333435360206373839343536".ToHexBytes(); + string json = JT808Serializer.Analyze(bytes); + } } } diff --git a/src/JT808.Protocol.Test/MessageBody/JT808_0x8302Test.cs b/src/JT808.Protocol.Test/MessageBody/JT808_0x8302Test.cs index 73bb36f..8c791c4 100644 --- a/src/JT808.Protocol.Test/MessageBody/JT808_0x8302Test.cs +++ b/src/JT808.Protocol.Test/MessageBody/JT808_0x8302Test.cs @@ -59,5 +59,12 @@ namespace JT808.Protocol.Test.MessageBody Assert.Equal(127, jT808_0X8302.Answers[1].Id); Assert.Equal("123457", jT808_0X8302.Answers[1].Content); } + + [Fact] + public void Test1_2() + { + byte[] bytes = "0107736464646166668000063132333435367F0006313233343537".ToHexBytes(); + string json = JT808Serializer.Analyze(bytes); + } } } diff --git a/src/JT808.Protocol.Test/MessageBody/JT808_0x8303Test.cs b/src/JT808.Protocol.Test/MessageBody/JT808_0x8303Test.cs index 34bd866..0dd689d 100644 --- a/src/JT808.Protocol.Test/MessageBody/JT808_0x8303Test.cs +++ b/src/JT808.Protocol.Test/MessageBody/JT808_0x8303Test.cs @@ -47,5 +47,12 @@ namespace JT808.Protocol.Test.MessageBody Assert.Equal("smallchi2", jT808_0X8303.InformationItems[1].InformationName); Assert.Equal(9, jT808_0X8303.InformationItems[1].InformationLength); } + + [Fact] + public void Test3() + { + byte[] bytes = "00020B0009736D616C6C63686931160009736D616C6C63686932".ToHexBytes(); + string json = JT808Serializer.Analyze(bytes); + } } } diff --git a/src/JT808.Protocol.Test/MessageBody/JT808_0x8304Test.cs b/src/JT808.Protocol.Test/MessageBody/JT808_0x8304Test.cs index 1c6d616..b9104f6 100644 --- a/src/JT808.Protocol.Test/MessageBody/JT808_0x8304Test.cs +++ b/src/JT808.Protocol.Test/MessageBody/JT808_0x8304Test.cs @@ -28,5 +28,12 @@ namespace JT808.Protocol.Test.MessageBody Assert.Equal("信息内容", jT808_0X8304.InformationContent); Assert.Equal(8, jT808_0X8304.InformationLength); } + + [Fact] + public void Test3() + { + byte[] bytes = "7B0008D0C5CFA2C4DAC8DD".ToHexBytes(); + string json = JT808Serializer.Analyze(bytes); + } } } diff --git a/src/JT808.Protocol.Test/MessageBody/JT808_0x8400Test.cs b/src/JT808.Protocol.Test/MessageBody/JT808_0x8400Test.cs index cab7b55..bfcace4 100644 --- a/src/JT808.Protocol.Test/MessageBody/JT808_0x8400Test.cs +++ b/src/JT808.Protocol.Test/MessageBody/JT808_0x8400Test.cs @@ -27,5 +27,12 @@ namespace JT808.Protocol.Test.MessageBody Assert.Equal(Enums.JT808CallBackType.普通通话, jT808_0X8400.CallBack); Assert.Equal("12345679810", jT808_0X8400.PhoneNumber); } + + [Fact] + public void Test3() + { + var bytes = "00 31 32 33 34 35 36 37 39 38 31 30".ToHexBytes(); + string json = JT808Serializer.Analyze(bytes); + } } } diff --git a/src/JT808.Protocol.Test/MessageBody/JT808_0x8401Test.cs b/src/JT808.Protocol.Test/MessageBody/JT808_0x8401Test.cs index 3416f48..412945b 100644 --- a/src/JT808.Protocol.Test/MessageBody/JT808_0x8401Test.cs +++ b/src/JT808.Protocol.Test/MessageBody/JT808_0x8401Test.cs @@ -52,5 +52,12 @@ namespace JT808.Protocol.Test.MessageBody Assert.Equal("koike", jT808_0X8401.JT808ContactProperties[1].Contact); } + + [Fact] + public void Test3() + { + var bytes = "02 02 01 0C 31 33 34 35 36 73 6D 61 6C 6C 63 68 08 73 6D 61 6C 6C 63 68 69 03 0B 6B 6F 69 6B 65 31 32 33 34 35 36 05 6B 6F 69 6B 65".ToHexBytes(); + string json = JT808Serializer.Analyze(bytes); + } } } diff --git a/src/JT808.Protocol.Test/MessageBody/JT808_0x8500Test.cs b/src/JT808.Protocol.Test/MessageBody/JT808_0x8500Test.cs index 8e1953b..2e4d730 100644 --- a/src/JT808.Protocol.Test/MessageBody/JT808_0x8500Test.cs +++ b/src/JT808.Protocol.Test/MessageBody/JT808_0x8500Test.cs @@ -80,6 +80,13 @@ namespace JT808.Protocol.Test.MessageBody Assert.Equal(0xF001, jT808_0x8500_0xF001.ControlTypeId); Assert.Equal(1, jT808_0x8500_0xF001.ControlTypeParameter); } + + [Fact] + public void Test_2019_3() + { + var bytes = "0002000100F00101".ToHexBytes(); + string json = JT808Serializer.Analyze(bytes, JT808Version.JTT2019); + } } /// diff --git a/src/JT808.Protocol/JT808.Protocol.xml b/src/JT808.Protocol/JT808.Protocol.xml index d89f4aa..98b5486 100644 --- a/src/JT808.Protocol/JT808.Protocol.xml +++ b/src/JT808.Protocol/JT808.Protocol.xml @@ -4284,11 +4284,22 @@ 平台通用应答 + + + 应答消息流水号 + + + 应答消息Id + + + + + 补传分包请求 @@ -5753,12 +5764,12 @@ 命令参数 - + 命令参数 - + 连接控制 0:切换到指定监管平台服务器,连接到该服务器后即进入应急状态, @@ -5766,70 +5777,70 @@ 1:切换回原缺省监控平台服务器,并恢复正常状态。 - + 拨号点名称 一般为服务器 APN,无线通信拨号访问点,若网络制式为 CDMA,则该值为 PPP 连接拨号号码 - + 拨号用户名 服务器无线通信拨号用户名 - + 拨号密码 服务器无线通信拨号密码 - + 服务器地址 服务器地址;IP 或域名 - + TCP端口 - + UDP端口 - + - 制造商 ID BYTE[5] + 制造商ID 终端制造商编码 - + 监管平台鉴权码 监管平台下发的鉴权码,仅用于终端连接到监管平台之后的鉴权,终端连接回原监控平台还用原鉴权码 - + 硬件版本 终端的硬件版本号,由制造商自定 - + 固件版本 终端的固件版本号,由制造商自定 - + URL 地址 完整 URL 地址 - + 连接到指定服务器时限 单位:分(min),值非 0 后的有效期截止前,终端应连回原地址。 @@ -6886,7 +6897,7 @@ - 经 GBK 编码 + 联系人 经 GBK 编码 diff --git a/src/JT808.Protocol/MessageBody/JT808_0x8001.cs b/src/JT808.Protocol/MessageBody/JT808_0x8001.cs index adf5183..f8ee148 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x8001.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x8001.cs @@ -1,29 +1,51 @@ using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; using JT808.Protocol.MessagePack; +using System.Text.Json; namespace JT808.Protocol.MessageBody { /// /// 平台通用应答 /// - public class JT808_0x8001 : JT808Bodies, IJT808MessagePackFormatter + public class JT808_0x8001 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze { public override ushort MsgId { get; } = 0x8001; public override string Description => "平台通用应答"; + /// + /// 应答消息流水号 + /// public ushort MsgNum { get; set; } /// + /// 应答消息Id /// /// public ushort AckMsgId { get; set; } + /// + /// + /// public JT808PlatformResult JT808PlatformResult { get; set; } + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + JT808_0x8001 value = new JT808_0x8001(); + value.MsgNum = reader.ReadUInt16(); + writer.WriteNumber($"[{value.MsgNum.ReadNumber()}]应答消息流水号", value.MsgNum); + value.AckMsgId = reader.ReadUInt16(); + writer.WriteNumber($"[{value.AckMsgId.ReadNumber()}]应答消息Id", value.AckMsgId); + value.JT808PlatformResult = (JT808PlatformResult)reader.ReadByte(); + writer.WriteNumber($"[{((byte)value.JT808PlatformResult).ReadNumber()}]结果-{value.JT808PlatformResult.ToString()}", (byte)value.JT808PlatformResult); + } + public JT808_0x8001 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) { - JT808_0x8001 jT808_0X8001 = new JT808_0x8001(); - jT808_0X8001.MsgNum = reader.ReadUInt16(); - jT808_0X8001.AckMsgId = reader.ReadUInt16(); - jT808_0X8001.JT808PlatformResult = (JT808PlatformResult)reader.ReadByte(); - return jT808_0X8001; + JT808_0x8001 value = new JT808_0x8001(); + value.MsgNum = reader.ReadUInt16(); + value.AckMsgId = reader.ReadUInt16(); + value.JT808PlatformResult = (JT808PlatformResult)reader.ReadByte(); + return value; } public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8001 value, IJT808Config config) diff --git a/src/JT808.Protocol/MessageBody/JT808_0x8003.cs b/src/JT808.Protocol/MessageBody/JT808_0x8003.cs index 4c49465..224c154 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x8003.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x8003.cs @@ -1,5 +1,8 @@ -using JT808.Protocol.Formatters; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; using JT808.Protocol.MessagePack; +using System.Text.Json; namespace JT808.Protocol.MessageBody { @@ -7,7 +10,7 @@ namespace JT808.Protocol.MessageBody /// 补传分包请求 /// 0x8003 /// - public class JT808_0x8003 : JT808Bodies, IJT808MessagePackFormatter + public class JT808_0x8003 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze { public override ushort MsgId { get; } = 0x8003; public override string Description => "补传分包请求"; @@ -27,13 +30,32 @@ namespace JT808.Protocol.MessageBody /// 重传包序号顺序排列,如“包 ID1 包 ID2......包 IDn”。 /// public byte[] AgainPackageData { get; set; } + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + JT808_0x8003 value = new JT808_0x8003(); + value.OriginalMsgNum = reader.ReadUInt16(); + writer.WriteNumber($"[{value.OriginalMsgNum.ReadNumber()}]原始消息流水号", value.OriginalMsgNum); + value.AgainPackageCount = reader.ReadByte(); + writer.WriteNumber($"[{value.AgainPackageCount.ReadNumber()}]重传包总数", value.AgainPackageCount); + writer.WriteStartArray("重传包ID列表"); + for(int i=0;i< value.AgainPackageCount; i++) + { + writer.WriteStartObject(); + var idBuffer=reader.ReadArray(2).ToArray(); + writer.WriteString($"Id{i+1}", idBuffer.ToHexString()); + writer.WriteEndObject(); + } + writer.WriteEndArray(); + } + public JT808_0x8003 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) { - JT808_0x8003 jT808_0X8003 = new JT808_0x8003(); - jT808_0X8003.OriginalMsgNum = reader.ReadUInt16(); - jT808_0X8003.AgainPackageCount = reader.ReadByte(); - jT808_0X8003.AgainPackageData = reader.ReadArray(jT808_0X8003.AgainPackageCount * 2).ToArray(); - return jT808_0X8003; + JT808_0x8003 value = new JT808_0x8003(); + value.OriginalMsgNum = reader.ReadUInt16(); + value.AgainPackageCount = reader.ReadByte(); + value.AgainPackageData = reader.ReadArray(value.AgainPackageCount * 2).ToArray(); + return value; } public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8003 value, IJT808Config config) diff --git a/src/JT808.Protocol/MessageBody/JT808_0x8004.cs b/src/JT808.Protocol/MessageBody/JT808_0x8004.cs index 83e38f1..21b1178 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x8004.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x8004.cs @@ -2,6 +2,7 @@ using JT808.Protocol.Interfaces; using JT808.Protocol.MessagePack; using System; +using System.Text.Json; namespace JT808.Protocol.MessageBody { @@ -9,13 +10,19 @@ namespace JT808.Protocol.MessageBody /// 查询服务器时间应答 /// 2019版本 /// - public class JT808_0x8004 : JT808Bodies, IJT808MessagePackFormatter, IJT808_2019_Version + public class JT808_0x8004 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze, IJT808_2019_Version { public override ushort MsgId { get; } = 0x8004; public override string Description => "查询服务器时间应答"; public DateTime Time { get; set; } = DateTime.Now; + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + var datetime= reader.ReadDateTime6(); + writer.WriteString($"[{ datetime.ToString("yyMMddHHmmss")}]查询服务器时间应答", datetime.ToString("yyyy-MM-dd HH:mm:ss")); + } + public JT808_0x8004 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) { JT808_0x8004 value = new JT808_0x8004(); diff --git a/src/JT808.Protocol/MessageBody/JT808_0x8100.cs b/src/JT808.Protocol/MessageBody/JT808_0x8100.cs index 1b0b2c6..d6502f7 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x8100.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x8100.cs @@ -1,13 +1,16 @@ using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; using JT808.Protocol.MessagePack; +using System.Text.Json; namespace JT808.Protocol.MessageBody { /// /// 终端注册应答 /// - public class JT808_0x8100 : JT808Bodies, IJT808MessagePackFormatter + public class JT808_0x8100 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze { public override ushort MsgId { get; } = 0x8100; public override string Description => "终端注册应答"; @@ -28,17 +31,33 @@ namespace JT808.Protocol.MessageBody /// public string Code { get; set; } + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + JT808_0x8100 value = new JT808_0x8100(); + value.AckMsgNum = reader.ReadUInt16(); + writer.WriteNumber($"[{ value.AckMsgNum.ReadNumber()}]应答流水号", value.AckMsgNum); + value.JT808TerminalRegisterResult = (JT808TerminalRegisterResult)reader.ReadByte(); + writer.WriteNumber($"[{ ((byte)value.JT808TerminalRegisterResult).ReadNumber()}]结果-{value.JT808TerminalRegisterResult.ToString()}", (byte)value.JT808TerminalRegisterResult); + // 只有在成功后才有该字段 + if (value.JT808TerminalRegisterResult == JT808TerminalRegisterResult.成功) + { + var codeBuffer = reader.ReadVirtualArray(reader.ReadCurrentRemainContentLength()).ToArray(); + value.Code = reader.ReadRemainStringContent(); + writer.WriteString($"[{codeBuffer.ToHexString()}]鉴权码", value.Code); + } + } + public JT808_0x8100 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) { - JT808_0x8100 jT808_0X8100 = new JT808_0x8100(); - jT808_0X8100.AckMsgNum = reader.ReadUInt16(); - jT808_0X8100.JT808TerminalRegisterResult = (JT808TerminalRegisterResult)reader.ReadByte(); + JT808_0x8100 value = new JT808_0x8100(); + value.AckMsgNum = reader.ReadUInt16(); + value.JT808TerminalRegisterResult = (JT808TerminalRegisterResult)reader.ReadByte(); // 只有在成功后才有该字段 - if (jT808_0X8100.JT808TerminalRegisterResult == JT808TerminalRegisterResult.成功) + if (value.JT808TerminalRegisterResult == JT808TerminalRegisterResult.成功) { - jT808_0X8100.Code = reader.ReadRemainStringContent(); + value.Code = reader.ReadRemainStringContent(); } - return jT808_0X8100; + return value; } public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8100 value, IJT808Config config) diff --git a/src/JT808.Protocol/MessageBody/JT808_0x8105.cs b/src/JT808.Protocol/MessageBody/JT808_0x8105.cs index 4f04061..4909c5d 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x8105.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x8105.cs @@ -1,14 +1,16 @@ -using JT808.Protocol.Formatters; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; using JT808.Protocol.Interfaces; using JT808.Protocol.MessagePack; using System; +using System.Text.Json; namespace JT808.Protocol.MessageBody { /// /// 终端控制 /// - public class JT808_0x8105 : JT808Bodies, IJT808MessagePackFormatter, IJT808_2019_Version + public class JT808_0x8105 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze, IJT808_2019_Version { public override ushort MsgId { get; } = 0x8105; public override string Description => "终端控制"; @@ -43,135 +45,272 @@ namespace JT808.Protocol.MessageBody writer.WriteString(value.CommandValue.ToString()); } } - } - /// - /// 命令参数 - /// - public class CommandParams - { - /// - /// 连接控制 - /// 0:切换到指定监管平台服务器,连接到该服务器后即进入应急状态, - ///此状态下仅有下发控制指令的监管平台可发送包括短信在内的控制指令; - ///1:切换回原缺省监控平台服务器,并恢复正常状态。 - /// - public byte? ConnectionControl { get; set; } - /// - /// 拨号点名称 - /// 一般为服务器 APN,无线通信拨号访问点,若网络制式为 CDMA,则该值为 PPP 连接拨号号码 - /// - public string DialPointName { get; set; } - /// - /// 拨号用户名 - /// 服务器无线通信拨号用户名 - /// - public string DialUserName { get; set; } - /// - /// 拨号密码 - /// 服务器无线通信拨号密码 - /// - public string DialPwd { get; set; } - /// - /// 服务器地址 - /// 服务器地址;IP 或域名 - /// - public string ServerUrl { get; set; } - /// - /// TCP端口 - /// - public UInt16? TCPPort { get; set; } - /// - /// UDP端口 - /// - public UInt16? UDPPort { get; set; } - /// - /// 制造商 ID BYTE[5] - /// 终端制造商编码 - /// - public long? ManufacturerCode { get; set; } - /// - /// 监管平台鉴权码 - /// 监管平台下发的鉴权码,仅用于终端连接到监管平台之后的鉴权,终端连接回原监控平台还用原鉴权码 - /// - public string MonitoringPlatformAuthenticationCode { get; set; } - /// - /// 硬件版本 - /// 终端的硬件版本号,由制造商自定 - /// - public string HardwareVersion { get; set; } - /// - /// 固件版本 - /// 终端的固件版本号,由制造商自定 - /// - public string FirmwareVersion { get; set; } - /// - /// URL 地址 完整 URL 地址 - /// - public string URL { get; set; } - /// - /// 连接到指定服务器时限 - /// 单位:分(min),值非 0 后的有效期截止前,终端应连回原地址。 - /// 若值为 0,则表示一直连接指 定服务器 - /// - public UInt16? ConnectTimeLimit { get; set; } - public override string ToString() - { - return $"{ConnectionControl};{DialPointName};{DialUserName};{DialPwd};{ServerUrl};{TCPPort};{UDPPort};{ManufacturerCode};{MonitoringPlatformAuthenticationCode};{HardwareVersion};{FirmwareVersion};{URL};{ConnectTimeLimit}"; - } - public void SetCommandParams(string commandValue) + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) { - var values = commandValue.Split(';'); - if (!string.IsNullOrEmpty(values[0])) - { - ConnectionControl = byte.Parse(values[0]); - } - if (!string.IsNullOrEmpty(values[1])) - { - DialPointName = values[1]; - } - if (!string.IsNullOrEmpty(values[2])) - { - DialUserName = values[2]; - } - if (!string.IsNullOrEmpty(values[3])) - { - DialPwd = values[3]; - } - if (!string.IsNullOrEmpty(values[4])) - { - ServerUrl = values[4]; - } - if (!string.IsNullOrEmpty(values[5])) - { - TCPPort = UInt16.Parse(values[5]); - } - if (!string.IsNullOrEmpty(values[6])) - { - UDPPort = UInt16.Parse(values[6]); - } - if (!string.IsNullOrEmpty(values[7])) - { - ManufacturerCode = long.Parse(values[7]); - } - if (!string.IsNullOrEmpty(values[8])) - { - MonitoringPlatformAuthenticationCode = values[8]; - } - if (!string.IsNullOrEmpty(values[9])) + JT808_0x8105 value = new JT808_0x8105 { - HardwareVersion = values[9]; - } - if (!string.IsNullOrEmpty(values[10])) + CommandWord = reader.ReadByte() + }; + writer.WriteNumber($"[{ value.CommandWord.ReadNumber()}]命令字", value.CommandWord); + if (value.CommandWord == 1 || value.CommandWord == 2) { - FirmwareVersion = values[10]; + value.CommandValue = new CommandParams(); + var commandValueBuffer = reader.ReadVirtualArray(reader.ReadCurrentRemainContentLength()).ToArray(); + string commandValue=reader.ReadRemainStringContent(); + writer.WriteString($"[{ commandValueBuffer.ToHexString()}]命令参数", commandValue); + writer.WriteStartObject("命令参数对象"); + var values = commandValue.Split(';'); + if (!string.IsNullOrEmpty(values[0])) + { + var connectionControl = byte.Parse(values[0]); + writer.WriteNumber("连接控制", connectionControl); + } + else + { + writer.WriteNull("连接控制"); + } + if (!string.IsNullOrEmpty(values[1])) + { + var dialPointName = values[1]; + writer.WriteString("拨号点名称", dialPointName); + } + else + { + writer.WriteNull("拨号点名称"); + } + if (!string.IsNullOrEmpty(values[2])) + { + var dialUserName = values[2]; + writer.WriteString("拨号用户名", dialUserName); + } + else + { + writer.WriteNull("拨号用户名"); + } + if (!string.IsNullOrEmpty(values[3])) + { + var dialPwd = values[3]; + writer.WriteString("拨号密码", dialPwd); + } + else + { + writer.WriteNull("拨号密码"); + } + if (!string.IsNullOrEmpty(values[4])) + { + var serverUrl = values[4]; + writer.WriteString("服务器地址", serverUrl); + } + else + { + writer.WriteNull("服务器地址"); + } + if (!string.IsNullOrEmpty(values[5])) + { + var tcpPort = ushort.Parse(values[5]); + writer.WriteNumber("TCP端口", tcpPort); + } + else + { + writer.WriteNull("TCP端口"); + } + if (!string.IsNullOrEmpty(values[6])) + { + var udpPort = ushort.Parse(values[6]); + writer.WriteNumber("UDP端口", udpPort); + } + else + { + writer.WriteNull("UDP端口"); + } + if (!string.IsNullOrEmpty(values[7])) + { + var manufacturerCode = long.Parse(values[7]); + writer.WriteNumber("制造商ID", manufacturerCode); + } + else + { + writer.WriteNull("制造商ID"); + } + if (!string.IsNullOrEmpty(values[8])) + { + var monitoringPlatformAuthenticationCode = values[8]; + writer.WriteString("监管平台鉴权码", monitoringPlatformAuthenticationCode); + } + else + { + writer.WriteNull("监管平台鉴权码"); + } + if (!string.IsNullOrEmpty(values[9])) + { + var hardwareVersion = values[9]; + writer.WriteString("硬件版本号", hardwareVersion); + } + else + { + writer.WriteNull("硬件版本号"); + } + if (!string.IsNullOrEmpty(values[10])) + { + var firmwareVersion = values[10]; + writer.WriteString("固件版本号", firmwareVersion); + } + else + { + writer.WriteNull("固件版本号"); + } + if (!string.IsNullOrEmpty(values[11])) + { + var url = values[11]; + writer.WriteString("URL地址", url); + } + else + { + writer.WriteNull("URL地址"); + } + if (!string.IsNullOrEmpty(values[12])) + { + var connectTimeLimit = ushort.Parse(values[12]); + writer.WriteNumber("连接到指定服务器时限", connectTimeLimit); + } + else + { + writer.WriteNull("连接到指定服务器时限"); + } + writer.WriteEndObject(); } - if (!string.IsNullOrEmpty(values[11])) + } + + /// + /// 命令参数 + /// + public class CommandParams + { + /// + /// 连接控制 + /// 0:切换到指定监管平台服务器,连接到该服务器后即进入应急状态, + ///此状态下仅有下发控制指令的监管平台可发送包括短信在内的控制指令; + ///1:切换回原缺省监控平台服务器,并恢复正常状态。 + /// + public byte? ConnectionControl { get; set; } + /// + /// 拨号点名称 + /// 一般为服务器 APN,无线通信拨号访问点,若网络制式为 CDMA,则该值为 PPP 连接拨号号码 + /// + public string DialPointName { get; set; } + /// + /// 拨号用户名 + /// 服务器无线通信拨号用户名 + /// + public string DialUserName { get; set; } + /// + /// 拨号密码 + /// 服务器无线通信拨号密码 + /// + public string DialPwd { get; set; } + /// + /// 服务器地址 + /// 服务器地址;IP 或域名 + /// + public string ServerUrl { get; set; } + /// + /// TCP端口 + /// + public ushort? TCPPort { get; set; } + /// + /// UDP端口 + /// + public ushort? UDPPort { get; set; } + /// + /// 制造商ID + /// 终端制造商编码 + /// + public long? ManufacturerCode { get; set; } + /// + /// 监管平台鉴权码 + /// 监管平台下发的鉴权码,仅用于终端连接到监管平台之后的鉴权,终端连接回原监控平台还用原鉴权码 + /// + public string MonitoringPlatformAuthenticationCode { get; set; } + /// + /// 硬件版本 + /// 终端的硬件版本号,由制造商自定 + /// + public string HardwareVersion { get; set; } + /// + /// 固件版本 + /// 终端的固件版本号,由制造商自定 + /// + public string FirmwareVersion { get; set; } + /// + /// URL 地址 完整 URL 地址 + /// + public string URL { get; set; } + /// + /// 连接到指定服务器时限 + /// 单位:分(min),值非 0 后的有效期截止前,终端应连回原地址。 + /// 若值为 0,则表示一直连接指 定服务器 + /// + public ushort? ConnectTimeLimit { get; set; } + public override string ToString() { - URL = values[11]; + return $"{ConnectionControl};{DialPointName};{DialUserName};{DialPwd};{ServerUrl};{TCPPort};{UDPPort};{ManufacturerCode};{MonitoringPlatformAuthenticationCode};{HardwareVersion};{FirmwareVersion};{URL};{ConnectTimeLimit}"; } - if (!string.IsNullOrEmpty(values[12])) + public void SetCommandParams(string commandValue) { - ConnectTimeLimit = UInt16.Parse(values[12]); + var values = commandValue.Split(';'); + if (!string.IsNullOrEmpty(values[0])) + { + ConnectionControl = byte.Parse(values[0]); + } + if (!string.IsNullOrEmpty(values[1])) + { + DialPointName = values[1]; + } + if (!string.IsNullOrEmpty(values[2])) + { + DialUserName = values[2]; + } + if (!string.IsNullOrEmpty(values[3])) + { + DialPwd = values[3]; + } + if (!string.IsNullOrEmpty(values[4])) + { + ServerUrl = values[4]; + } + if (!string.IsNullOrEmpty(values[5])) + { + TCPPort = ushort.Parse(values[5]); + } + if (!string.IsNullOrEmpty(values[6])) + { + UDPPort = ushort.Parse(values[6]); + } + if (!string.IsNullOrEmpty(values[7])) + { + ManufacturerCode = long.Parse(values[7]); + } + if (!string.IsNullOrEmpty(values[8])) + { + MonitoringPlatformAuthenticationCode = values[8]; + } + if (!string.IsNullOrEmpty(values[9])) + { + HardwareVersion = values[9]; + } + if (!string.IsNullOrEmpty(values[10])) + { + FirmwareVersion = values[10]; + } + if (!string.IsNullOrEmpty(values[11])) + { + URL = values[11]; + } + if (!string.IsNullOrEmpty(values[12])) + { + ConnectTimeLimit = ushort.Parse(values[12]); + } } } } diff --git a/src/JT808.Protocol/MessageBody/JT808_0x8106.cs b/src/JT808.Protocol/MessageBody/JT808_0x8106.cs index 742ced1..307415f 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x8106.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x8106.cs @@ -1,6 +1,9 @@ -using JT808.Protocol.Formatters; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; using JT808.Protocol.MessagePack; using System; +using System.Text.Json; namespace JT808.Protocol.MessageBody { @@ -8,7 +11,7 @@ namespace JT808.Protocol.MessageBody /// 查询指定终端参数 /// 0x8106 /// - public class JT808_0x8106 : JT808Bodies, IJT808MessagePackFormatter + public class JT808_0x8106 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze { public override ushort MsgId { get; } = 0x8106; public override string Description => "查询指定终端参数"; @@ -43,6 +46,20 @@ namespace JT808.Protocol.MessageBody writer.WriteUInt32(value.Parameters[i]); } } - + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + JT808_0x8106 value = new JT808_0x8106(); + value.ParameterCount = reader.ReadByte(); + writer.WriteNumber($"[{ value.ParameterCount.ReadNumber()}]参数总数", value.ParameterCount); + writer.WriteStartArray("参数ID列表"); + for (int i = 0; i < value.ParameterCount; i++) + { + writer.WriteStartObject(); + uint parameterId = reader.ReadUInt32(); + writer.WriteNumber($"[{parameterId.ReadNumber()}]Id{i+1}",parameterId); + writer.WriteEndObject(); + } + writer.WriteEndArray(); + } } } diff --git a/src/JT808.Protocol/MessageBody/JT808_0x8108.cs b/src/JT808.Protocol/MessageBody/JT808_0x8108.cs index 1c6036c..3115e34 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x8108.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x8108.cs @@ -1,14 +1,16 @@ using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; using JT808.Protocol.Formatters; using JT808.Protocol.Interfaces; using JT808.Protocol.MessagePack; +using System.Text.Json; namespace JT808.Protocol.MessageBody { /// /// 下发终端升级包 /// - public class JT808_0x8108 : JT808Bodies, IJT808MessagePackFormatter, IJT808_2019_Version + public class JT808_0x8108 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze, IJT808_2019_Version { public override ushort MsgId { get; } = 0x8108; @@ -75,5 +77,33 @@ namespace JT808.Protocol.MessageBody writer.WriteInt32(value.UpgradePackage.Length); writer.WriteArray(value.UpgradePackage); } + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + JT808_0x8108 value = new JT808_0x8108(); + value.UpgradeType = (JT808UpgradeType)reader.ReadByte(); + writer.WriteNumber($"[{ ((byte)value.UpgradeType).ReadNumber()}]升级类型-{value.UpgradeType.ToString()}", (byte)value.UpgradeType); + if (reader.Version == JT808Version.JTT2019) + { + var makerIdBuffer = reader.ReadVirtualArray(11).ToArray(); + value.MakerId = reader.ReadString(11); + writer.WriteString($"[{makerIdBuffer.ToHexString()}]制造商ID", value.MakerId); + } + else + { + var makerIdBuffer = reader.ReadVirtualArray(5).ToArray(); + value.MakerId = reader.ReadString(5); + writer.WriteString($"[{makerIdBuffer.ToHexString()}]制造商ID", value.MakerId); + } + value.VersionNumLength = reader.ReadByte(); + writer.WriteNumber($"[{value.VersionNumLength.ReadNumber()}]版本号长度",value.VersionNumLength); + var versionNumBuffer = reader.ReadVirtualArray(value.VersionNumLength).ToArray(); + value.VersionNum = reader.ReadString(value.VersionNumLength); + writer.WriteString($"[{versionNumBuffer.ToHexString()}]版本号", value.VersionNum); + value.UpgradePackageLength = reader.ReadInt32(); + writer.WriteNumber($"[{value.UpgradePackageLength.ReadNumber()}]升级数据包长度", value.UpgradePackageLength); + value.UpgradePackage = reader.ReadArray(value.UpgradePackageLength).ToArray(); + writer.WriteString($"升级数据包", value.UpgradePackage.ToHexString()); + } } } diff --git a/src/JT808.Protocol/MessageBody/JT808_0x8202.cs b/src/JT808.Protocol/MessageBody/JT808_0x8202.cs index 1b8edb7..aea8ae3 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x8202.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x8202.cs @@ -1,12 +1,15 @@ -using JT808.Protocol.Formatters; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; using JT808.Protocol.MessagePack; +using System.Text.Json; namespace JT808.Protocol.MessageBody { /// /// 临时位置跟踪控制 /// - public class JT808_0x8202 : JT808Bodies, IJT808MessagePackFormatter + public class JT808_0x8202 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze { public override ushort MsgId { get; } = 0x8202; @@ -22,6 +25,7 @@ namespace JT808.Protocol.MessageBody /// 单位为秒(s),终端在接收到位置跟踪控制消息后,在有效期截止时间之前,依据消息中的时间间隔发送位置汇报 /// public int LocationTrackingValidity { get; set; } + public JT808_0x8202 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) { JT808_0x8202 jT808_0X8202 = new JT808_0x8202(); @@ -35,5 +39,14 @@ namespace JT808.Protocol.MessageBody writer.WriteUInt16(value.Interval); writer.WriteInt32(value.LocationTrackingValidity); } + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + JT808_0x8202 value = new JT808_0x8202(); + value.Interval = reader.ReadUInt16(); + writer.WriteNumber($"[{ value.Interval.ReadNumber()}]时间间隔", value.Interval); + value.LocationTrackingValidity = reader.ReadInt32(); + writer.WriteNumber($"[{ value.LocationTrackingValidity.ReadNumber()}]位置跟踪有效期", value.LocationTrackingValidity); + } } } diff --git a/src/JT808.Protocol/MessageBody/JT808_0x8203.cs b/src/JT808.Protocol/MessageBody/JT808_0x8203.cs index 32c2504..7b48349 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x8203.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x8203.cs @@ -1,5 +1,8 @@ -using JT808.Protocol.Formatters; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; using JT808.Protocol.MessagePack; +using System.Text.Json; namespace JT808.Protocol.MessageBody { @@ -7,7 +10,7 @@ namespace JT808.Protocol.MessageBody /// 人工确认报警消息 /// 0x8203 /// - public class JT808_0x8203 : JT808Bodies, IJT808MessagePackFormatter + public class JT808_0x8203 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze { public override ushort MsgId { get; } = 0x8203; public override string Description => "人工确认报警消息"; @@ -34,5 +37,14 @@ namespace JT808.Protocol.MessageBody writer.WriteUInt16(value.AlarmMsgNum); writer.WriteUInt32(value.ManualConfirmAlarmType); } + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + JT808_0x8203 value = new JT808_0x8203(); + value.AlarmMsgNum = reader.ReadUInt16(); + writer.WriteNumber($"[{ value.AlarmMsgNum.ReadNumber()}]报警消息流水号", value.AlarmMsgNum); + value.ManualConfirmAlarmType = reader.ReadUInt32(); + writer.WriteNumber($"[{ value.ManualConfirmAlarmType.ReadNumber()}]人工确认报警类型", value.ManualConfirmAlarmType); + } } } diff --git a/src/JT808.Protocol/MessageBody/JT808_0x8300.cs b/src/JT808.Protocol/MessageBody/JT808_0x8300.cs index af32c00..572a2b8 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x8300.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x8300.cs @@ -1,15 +1,17 @@ using JT808.Protocol.Attributes; using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; using JT808.Protocol.Formatters; using JT808.Protocol.Interfaces; using JT808.Protocol.MessagePack; +using System.Text.Json; namespace JT808.Protocol.MessageBody { /// /// 文本信息下发 /// - public class JT808_0x8300 : JT808Bodies, IJT808MessagePackFormatter, IJT808_2019_Version + public class JT808_0x8300 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze, IJT808_2019_Version { public override ushort MsgId { get; } = 0x8300; public override string Description => "文本信息下发"; @@ -50,5 +52,20 @@ namespace JT808.Protocol.MessageBody } writer.WriteString(value.TextInfo); } + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + JT808_0x8300 jT808_0X8300 = new JT808_0x8300(); + jT808_0X8300.TextFlag = reader.ReadByte(); + writer.WriteNumber($"[{ jT808_0X8300.TextFlag.ReadNumber()}]文本信息标志位", jT808_0X8300.TextFlag); + if (reader.Version == JT808Version.JTT2019) + { + jT808_0X8300.TextType = reader.ReadByte(); + writer.WriteNumber($"[{ jT808_0X8300.TextType.ReadNumber()}]文本类型-{(jT808_0X8300.TextType==1? "通知":"服务")}", jT808_0X8300.TextType); + } + var txtBuffer = reader.ReadVirtualArray(reader.ReadCurrentRemainContentLength()).ToArray(); + jT808_0X8300.TextInfo = reader.ReadRemainStringContent(); + writer.WriteString($"[{txtBuffer.ToHexString()}]答案内容", jT808_0X8300.TextInfo); + } } } diff --git a/src/JT808.Protocol/MessageBody/JT808_0x8301.cs b/src/JT808.Protocol/MessageBody/JT808_0x8301.cs index dd40024..cce7848 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x8301.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x8301.cs @@ -1,9 +1,11 @@ -using JT808.Protocol.Formatters; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; using JT808.Protocol.Interfaces; using JT808.Protocol.MessagePack; using JT808.Protocol.Metadata; using System; using System.Collections.Generic; +using System.Text.Json; namespace JT808.Protocol.MessageBody { @@ -12,7 +14,7 @@ namespace JT808.Protocol.MessageBody /// 0x8301 /// [Obsolete("2019版本已作删除")] - public class JT808_0x8301 : JT808Bodies, IJT808MessagePackFormatter,IJT808_2019_Version + public class JT808_0x8301 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze, IJT808_2019_Version { public override ushort MsgId { get; } = 0x8301; public override string Description => "事件设置"; @@ -64,5 +66,30 @@ namespace JT808.Protocol.MessageBody } } } + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + JT808_0x8301 value = new JT808_0x8301(); + value.SettingType = reader.ReadByte(); + writer.WriteNumber($"[{value.SettingType.ReadNumber()}]设置类型", value.SettingType); + value.SettingCount = reader.ReadByte(); + writer.WriteNumber($"[{value.SettingCount.ReadNumber()}]设置总数", value.SettingCount); + writer.WriteStartArray("事件项"); + for (var i = 0; i < value.SettingCount; i++) + { + writer.WriteStartObject(); + JT808EventProperty jT808EventProperty = new JT808EventProperty(); + jT808EventProperty.EventId = reader.ReadByte(); + writer.WriteNumber($"[{jT808EventProperty.EventId.ReadNumber()}]事件ID ", jT808EventProperty.EventId); + jT808EventProperty.EventContentLength = reader.ReadByte(); + writer.WriteNumber($"[{jT808EventProperty.EventContentLength.ReadNumber()}]事件内容长度", jT808EventProperty.EventContentLength); + var eventContenBuffer = reader.ReadVirtualArray(jT808EventProperty.EventContentLength).ToArray(); + jT808EventProperty.EventContent = reader.ReadString(jT808EventProperty.EventContentLength); + writer.WriteString($"[{eventContenBuffer.ToHexString()}]事件内容", jT808EventProperty.EventContent); + writer.WriteEndObject(); + } + writer.WriteEndArray(); + } + } } diff --git a/src/JT808.Protocol/MessageBody/JT808_0x8302.cs b/src/JT808.Protocol/MessageBody/JT808_0x8302.cs index 812928d..1487a6c 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x8302.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x8302.cs @@ -1,8 +1,10 @@ -using JT808.Protocol.Formatters; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; using JT808.Protocol.Interfaces; using JT808.Protocol.MessagePack; using System; using System.Collections.Generic; +using System.Text.Json; namespace JT808.Protocol.MessageBody { @@ -11,7 +13,7 @@ namespace JT808.Protocol.MessageBody /// 0x8302 /// [Obsolete("2019版本已作删除")] - public class JT808_0x8302 : JT808Bodies, IJT808MessagePackFormatter, IJT808_2019_Version + public class JT808_0x8302 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze, IJT808_2019_Version { public override ushort MsgId { get; } = 0x8302; public override string Description => "提问下发"; @@ -97,5 +99,32 @@ namespace JT808.Protocol.MessageBody } } } + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + JT808_0x8302 value = new JT808_0x8302(); + value.Flag = reader.ReadByte(); + writer.WriteNumber($"[{value.Flag.ReadNumber()}]标志", value.Flag); + value.IssueContentLength = reader.ReadByte(); + writer.WriteNumber($"[{value.IssueContentLength.ReadNumber()}]问题内容长度", value.IssueContentLength); + var issueBuffer= reader.ReadVirtualArray(value.IssueContentLength).ToArray(); + value.Issue = reader.ReadString(value.IssueContentLength); + writer.WriteString($"[{issueBuffer.ToHexString()}]问题文本", value.Issue); + writer.WriteStartArray("候选答案列表"); + while (reader.ReadCurrentRemainContentLength() > 0) + { + writer.WriteStartObject(); + JT808_0x8302.Answer answer = new JT808_0x8302.Answer(); + answer.Id = reader.ReadByte(); + writer.WriteNumber($"[{answer.Id.ReadNumber()}]答案ID", answer.Id); + answer.ContentLength = reader.ReadUInt16(); + writer.WriteNumber($"[{answer.ContentLength.ReadNumber()}]答案内容长度", answer.ContentLength); + var answerBuffer = reader.ReadVirtualArray(answer.ContentLength).ToArray(); + answer.Content = reader.ReadString(answer.ContentLength); + writer.WriteString($"[{answerBuffer.ToHexString()}]答案内容", answer.Content); + writer.WriteEndObject(); + } + writer.WriteEndArray(); + } } } diff --git a/src/JT808.Protocol/MessageBody/JT808_0x8303.cs b/src/JT808.Protocol/MessageBody/JT808_0x8303.cs index 2cd5a33..ce2e9d0 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x8303.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x8303.cs @@ -1,9 +1,11 @@ -using JT808.Protocol.Formatters; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; using JT808.Protocol.Interfaces; using JT808.Protocol.MessagePack; using JT808.Protocol.Metadata; using System; using System.Collections.Generic; +using System.Text.Json; namespace JT808.Protocol.MessageBody { @@ -12,7 +14,7 @@ namespace JT808.Protocol.MessageBody /// 0x8303 /// [Obsolete("2019版本已作删除")] - public class JT808_0x8303 : JT808Bodies, IJT808MessagePackFormatter, IJT808_2019_Version + public class JT808_0x8303 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze, IJT808_2019_Version { public override ushort MsgId { get; } = 0x8303; public override string Description => "信息点播菜单设置"; @@ -30,6 +32,7 @@ namespace JT808.Protocol.MessageBody /// 信息项列表 /// public List InformationItems { get; set; } + public JT808_0x8303 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) { JT808_0x8303 jT808_0X8303 = new JT808_0x8303(); @@ -61,5 +64,29 @@ namespace JT808.Protocol.MessageBody writer.WriteUInt16Return(length, position); } } + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + JT808_0x8303 value = new JT808_0x8303(); + value.SettingType = reader.ReadByte(); + writer.WriteNumber($"[{value.SettingType.ReadNumber()}]设置类型", value.SettingType); + value.InformationItemCount = reader.ReadByte(); + writer.WriteNumber($"[{value.InformationItemCount.ReadNumber()}]信息项总数", value.InformationItemCount); + writer.WriteStartArray("信息项列表"); + for (var i = 0; i < value.InformationItemCount; i++) + { + writer.WriteStartObject(); + JT808InformationItemProperty jT808InformationItemProperty = new JT808InformationItemProperty(); + jT808InformationItemProperty.InformationType = reader.ReadByte(); + writer.WriteNumber($"[{jT808InformationItemProperty.InformationType.ReadNumber()}]信息类型", jT808InformationItemProperty.InformationType); + jT808InformationItemProperty.InformationLength = reader.ReadUInt16(); + writer.WriteNumber($"[{jT808InformationItemProperty.InformationLength.ReadNumber()}]信息名称长度", jT808InformationItemProperty.InformationLength); + var infoBuffer = reader.ReadVirtualArray(jT808InformationItemProperty.InformationLength).ToArray(); + jT808InformationItemProperty.InformationName = reader.ReadString(jT808InformationItemProperty.InformationLength); + writer.WriteString($"[{infoBuffer.ToHexString()}]信息名称", jT808InformationItemProperty.InformationName); + writer.WriteEndObject(); + } + writer.WriteEndArray(); + } } } diff --git a/src/JT808.Protocol/MessageBody/JT808_0x8304.cs b/src/JT808.Protocol/MessageBody/JT808_0x8304.cs index f5502d4..4d584b6 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x8304.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x8304.cs @@ -1,7 +1,9 @@ -using JT808.Protocol.Formatters; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; using JT808.Protocol.Interfaces; using JT808.Protocol.MessagePack; using System; +using System.Text.Json; namespace JT808.Protocol.MessageBody { @@ -10,7 +12,7 @@ namespace JT808.Protocol.MessageBody /// 0x8304 /// [Obsolete("2019版本已作删除")] - public class JT808_0x8304 : JT808Bodies, IJT808MessagePackFormatter, IJT808_2019_Version + public class JT808_0x8304 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze, IJT808_2019_Version { public override ushort MsgId { get; } = 0x8304; public override string Description => "信息服务"; @@ -45,6 +47,16 @@ namespace JT808.Protocol.MessageBody ushort length = (ushort)(writer.GetCurrentPosition() - position - 2); writer.WriteUInt16Return(length, position); } - + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + JT808_0x8304 value = new JT808_0x8304(); + value.InformationType = reader.ReadByte(); + writer.WriteNumber($"[{value.InformationType.ReadNumber()}]信息类型", value.InformationType); + value.InformationLength = reader.ReadUInt16(); + writer.WriteNumber($"[{value.InformationLength.ReadNumber()}]信息长度", value.InformationLength); + var infoBuffer = reader.ReadVirtualArray(value.InformationLength).ToArray(); + value.InformationContent = reader.ReadString(value.InformationLength); + writer.WriteString($"[{infoBuffer.ToHexString()}]信息内容", value.InformationContent); + } } } diff --git a/src/JT808.Protocol/MessageBody/JT808_0x8400.cs b/src/JT808.Protocol/MessageBody/JT808_0x8400.cs index e7c08b1..fb23448 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x8400.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x8400.cs @@ -1,13 +1,16 @@ using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; using JT808.Protocol.MessagePack; +using System.Text.Json; namespace JT808.Protocol.MessageBody { /// /// 电话回拨 /// - public class JT808_0x8400 : JT808Bodies, IJT808MessagePackFormatter + public class JT808_0x8400 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze { public override ushort MsgId { get; } = 0x8400; public override string Description => "电话回拨"; @@ -35,5 +38,16 @@ namespace JT808.Protocol.MessageBody writer.WriteByte((byte)value.CallBack); writer.WriteString(value.PhoneNumber); } + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + JT808_0x8400 value = new JT808_0x8400(); + value.CallBack = (JT808CallBackType)reader.ReadByte(); + writer.WriteNumber($"[{((byte)value.CallBack).ReadNumber()}]{value.CallBack.ToString()}", (byte)value.CallBack); + // 最长为 20 字节 + var pnoBuffer = reader.ReadVirtualArray(reader.ReadCurrentRemainContentLength()).ToArray(); + value.PhoneNumber = reader.ReadRemainStringContent(); + writer.WriteString($"[{pnoBuffer.ToHexString()}]电话号码", value.PhoneNumber); + } } } diff --git a/src/JT808.Protocol/MessageBody/JT808_0x8401.cs b/src/JT808.Protocol/MessageBody/JT808_0x8401.cs index 465f7e4..e7a799a 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x8401.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x8401.cs @@ -1,15 +1,18 @@ using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; using JT808.Protocol.MessagePack; using JT808.Protocol.Metadata; using System.Collections.Generic; +using System.Text.Json; namespace JT808.Protocol.MessageBody { /// /// 设置电话本 /// - public class JT808_0x8401 : JT808Bodies, IJT808MessagePackFormatter + public class JT808_0x8401 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze { public override ushort MsgId { get; } = 0x8401; public override string Description => "设置电话本"; @@ -25,6 +28,7 @@ namespace JT808.Protocol.MessageBody /// 联系人项 /// public IList JT808ContactProperties { get; set; } + public JT808_0x8401 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) { JT808_0x8401 jT808_0X8401 = new JT808_0x8401(); @@ -58,5 +62,34 @@ namespace JT808.Protocol.MessageBody writer.WriteString(item.Contact); } } + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + JT808_0x8401 value = new JT808_0x8401(); + value.SettingTelephoneBook = (JT808SettingTelephoneBook)reader.ReadByte(); + writer.WriteNumber($"[{((byte)value.SettingTelephoneBook).ReadNumber()}]设置类型",(byte) value.SettingTelephoneBook); + value.ContactCount = reader.ReadByte(); + writer.WriteNumber($"[{value.ContactCount.ReadNumber()}]联系人总数", value.ContactCount); + writer.WriteStartArray("联系人项"); + for (var i = 0; i < value.ContactCount; i++) + { + writer.WriteStartObject(); + JT808ContactProperty jT808ContactProperty = new JT808ContactProperty(); + jT808ContactProperty.TelephoneBookContactType = (JT808TelephoneBookContactType)reader.ReadByte(); + writer.WriteNumber($"[{((byte)jT808ContactProperty.TelephoneBookContactType).ReadNumber()}]{jT808ContactProperty.TelephoneBookContactType.ToString()}", (byte)jT808ContactProperty.TelephoneBookContactType); + jT808ContactProperty.PhoneNumberLength = reader.ReadByte(); + writer.WriteNumber($"[{jT808ContactProperty.PhoneNumberLength.ReadNumber()}]号码长度", jT808ContactProperty.PhoneNumberLength); + var pnoBuffer = reader.ReadVirtualArray(jT808ContactProperty.PhoneNumberLength); + jT808ContactProperty.PhoneNumber = reader.ReadString(jT808ContactProperty.PhoneNumberLength); + writer.WriteString($"[{pnoBuffer.ToArray().ToHexString()}]电话号码", jT808ContactProperty.PhoneNumber); + jT808ContactProperty.ContactLength = reader.ReadByte(); + writer.WriteNumber($"[{jT808ContactProperty.ContactLength.ReadNumber()}]联系人长度", jT808ContactProperty.ContactLength); + var contactBuffer = reader.ReadVirtualArray(jT808ContactProperty.ContactLength); + jT808ContactProperty.Contact = reader.ReadString(jT808ContactProperty.ContactLength); + writer.WriteString($"[{contactBuffer.ToArray().ToHexString()}]联系人", jT808ContactProperty.Contact); + writer.WriteEndObject(); + } + writer.WriteEndArray(); + } } } diff --git a/src/JT808.Protocol/MessageBody/JT808_0x8500.cs b/src/JT808.Protocol/MessageBody/JT808_0x8500.cs index 92ef3c8..a8e3300 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x8500.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x8500.cs @@ -4,13 +4,14 @@ using JT808.Protocol.Formatters; using JT808.Protocol.Interfaces; using JT808.Protocol.MessagePack; using System.Collections.Generic; +using System.Text.Json; namespace JT808.Protocol.MessageBody { /// /// 车辆控制 /// - public class JT808_0x8500 : JT808Bodies, IJT808MessagePackFormatter, IJT808_2019_Version + public class JT808_0x8500 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze, IJT808_2019_Version { public override ushort MsgId { get; } = 0x8500; public override string Description => "车辆控制"; @@ -34,6 +35,24 @@ namespace JT808.Protocol.MessageBody /// public List ControlTypes { get; set; } + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + JT808_0x8500 value = new JT808_0x8500(); + if (reader.Version == JT808Version.JTT2019) + { + value.ControlTypeCount = reader.ReadUInt16(); + writer.WriteNumber($"[{ value.ControlTypeCount.ReadNumber()}]控制类型数量", value.ControlTypeCount); + //todo:待完善 + value.ControlTypeBuffer = reader.ReadArray(reader.ReadCurrentRemainContentLength()).ToArray(); + writer.WriteString($"控制类型", value.ControlTypeBuffer.ToHexString()); + } + else + { + value.ControlFlag = reader.ReadByte(); + writer.WriteNumber($"[{ value.ControlFlag.ReadNumber()}]控制标志", value.ControlFlag); + } + } + public JT808_0x8500 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) { JT808_0x8500 value = new JT808_0x8500(); diff --git a/src/JT808.Protocol/MessageBody/JT808_0x8500_0x0001.cs b/src/JT808.Protocol/MessageBody/JT808_0x8500_0x0001.cs index f0da6c6..5b316b9 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x8500_0x0001.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x8500_0x0001.cs @@ -1,21 +1,32 @@ -using JT808.Protocol.Formatters; +using JT808.Protocol.Extensions; +using JT808.Protocol.Formatters; using JT808.Protocol.Interfaces; using JT808.Protocol.MessagePack; using System; using System.Collections.Generic; using System.Text; +using System.Text.Json; namespace JT808.Protocol.MessageBody { /// /// 控制类型 /// - public class JT808_0x8500_0x0001 : JT808_0x8500_ControlType, IJT808MessagePackFormatter + public class JT808_0x8500_0x0001 : JT808_0x8500_ControlType, IJT808MessagePackFormatter, IJT808Analyze { public override ushort ControlTypeId { get; set; } = 0x0001; public byte ControlTypeParameter { get; set; } + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + JT808_0x8500_0x0001 value = new JT808_0x8500_0x0001(); + value.ControlTypeId = reader.ReadUInt16(); + writer.WriteNumber($"[{ value.ControlTypeId.ReadNumber()}]控制类型Id", value.ControlTypeId); + value.ControlTypeParameter = reader.ReadByte(); + writer.WriteNumber($"[{ value.ControlTypeParameter.ReadNumber()}]控制类型参数", value.ControlTypeParameter); + } + public JT808_0x8500_0x0001 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) { JT808_0x8500_0x0001 value = new JT808_0x8500_0x0001(); diff --git a/src/JT808.Protocol/Metadata/JT808ContactProperty.cs b/src/JT808.Protocol/Metadata/JT808ContactProperty.cs index e1940c2..592b3c3 100644 --- a/src/JT808.Protocol/Metadata/JT808ContactProperty.cs +++ b/src/JT808.Protocol/Metadata/JT808ContactProperty.cs @@ -24,7 +24,7 @@ namespace JT808.Protocol.Metadata /// public byte ContactLength { get; set; } /// - /// 经 GBK 编码 + /// 联系人 经 GBK 编码 /// public string Contact { get; set; } }