From 8fc90a77bee1361ed740b8b6240913857dd7ec01 Mon Sep 17 00:00:00 2001 From: "SmallChi(Koike)" <564952747@qq.com> Date: Mon, 25 May 2020 21:16:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D2011=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E7=9A=849007=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 24 ++++++------ .../JT809.Protocol.Benchmark.csproj | 2 +- .../JT809.Protocol.Test.csproj | 4 +- src/JT809.Protocol/JT809.Protocol.csproj | 12 +++--- src/JT809.Protocol/JT809.Protocol.xml | 12 ++++++ .../MessageBody/JT809_0x9007.cs | 37 ++++++++++++++++--- 6 files changed, 65 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index b62d9e9..faa6a1a 100644 --- a/README.md +++ b/README.md @@ -300,23 +300,23 @@ public class JT809_2019_Config : JT809GlobalConfigBase ``` ini -BenchmarkDotNet=v0.12.0, OS=Windows 10.0.18363 +BenchmarkDotNet=v0.12.1, OS=Windows 10.0.18363.836 (1909/November2018Update/19H2) Intel Core i7-8700K CPU 3.70GHz (Coffee Lake), 1 CPU, 12 logical and 6 physical cores -.NET Core SDK=3.1.201 - [Host] : .NET Core 3.1.3 (CoreCLR 4.700.20.11803, CoreFX 4.700.20.12001), X64 RyuJIT - Job-BAIJRX : .NET Core 3.1.3 (CoreCLR 4.700.20.11803, CoreFX 4.700.20.12001), X64 RyuJIT +.NET Core SDK=3.1.300 + [Host] : .NET Core 3.1.4 (CoreCLR 4.700.20.20201, CoreFX 4.700.20.22101), X64 RyuJIT + Job-WFPAJY : .NET Core 3.1.4 (CoreCLR 4.700.20.20201, CoreFX 4.700.20.22101), X64 RyuJIT Platform=AnyCpu Server=False Toolchain=.NET Core 3.1 ``` -| Method | N | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated | -|---------------------------------------- |------- |-------------:|------------:|------------:|-----------:|------:|------:|-------------:| -| **JT809_0x9400_0x9401_Package_Deserialize** | **100** | **509.5 us** | **2.50 us** | **2.22 us** | **15.6250** | **-** | **-** | **100.78 KB** | -| JT809_0x9400_0x9401_Package_Serialize | 100 | 203.6 us | 1.95 us | 1.82 us | 13.4277 | - | - | 83.59 KB | -| **JT809_0x9400_0x9401_Package_Deserialize** | **10000** | **48,343.9 us** | **580.83 us** | **543.31 us** | **1636.3636** | **-** | **-** | **10078.13 KB** | -| JT809_0x9400_0x9401_Package_Serialize | 10000 | 20,705.0 us | 165.58 us | 154.88 us | 1343.7500 | - | - | 8359.38 KB | -| **JT809_0x9400_0x9401_Package_Deserialize** | **100000** | **476,503.3 us** | **4,965.19 us** | **4,401.51 us** | **16000.0000** | **-** | **-** | **100781.25 KB** | -| JT809_0x9400_0x9401_Package_Serialize | 100000 | 207,481.3 us | 1,467.56 us | 1,372.76 us | 13333.3333 | - | - | 83594.04 KB | +| Method | N | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated | +|---------------------------------------- |------- |-------------:|------------:|------------:|-----------:|------:|------:|-----------:| +| **JT809_0x9400_0x9401_Package_Deserialize** | **100** | **494.2 μs** | **5.09 μs** | **4.76 μs** | **16.6016** | **-** | **-** | **103.13 KB** | +| JT809_0x9400_0x9401_Package_Serialize | 100 | 220.0 μs | 2.24 μs | 2.09 μs | 14.6484 | - | - | 90.63 KB | +| **JT809_0x9400_0x9401_Package_Deserialize** | **10000** | **49,835.5 μs** | **456.53 μs** | **404.71 μs** | **1636.3636** | **-** | **-** | **10312.5 KB** | +| JT809_0x9400_0x9401_Package_Serialize | 10000 | 21,843.2 μs | 161.08 μs | 142.80 μs | 1468.7500 | - | - | 9062.5 KB | +| **JT809_0x9400_0x9401_Package_Deserialize** | **100000** | **486,411.6 μs** | **5,499.89 μs** | **5,144.60 μs** | **16000.0000** | **-** | **-** | **103125 KB** | +| JT809_0x9400_0x9401_Package_Serialize | 100000 | 218,839.3 μs | 1,665.04 μs | 1,476.02 μs | 14666.6667 | - | - | 90625 KB | ## JT809协议消息对照表 diff --git a/src/JT809.Protocol.Benchmark/JT809.Protocol.Benchmark.csproj b/src/JT809.Protocol.Benchmark/JT809.Protocol.Benchmark.csproj index 6aabb38..8f11929 100644 --- a/src/JT809.Protocol.Benchmark/JT809.Protocol.Benchmark.csproj +++ b/src/JT809.Protocol.Benchmark/JT809.Protocol.Benchmark.csproj @@ -6,7 +6,7 @@ - + diff --git a/src/JT809.Protocol.Test/JT809.Protocol.Test.csproj b/src/JT809.Protocol.Test/JT809.Protocol.Test.csproj index 512c5f3..cead57d 100644 --- a/src/JT809.Protocol.Test/JT809.Protocol.Test.csproj +++ b/src/JT809.Protocol.Test/JT809.Protocol.Test.csproj @@ -12,8 +12,8 @@ - - + + all diff --git a/src/JT809.Protocol/JT809.Protocol.csproj b/src/JT809.Protocol/JT809.Protocol.csproj index 80f6975..3d0aab5 100644 --- a/src/JT809.Protocol/JT809.Protocol.csproj +++ b/src/JT809.Protocol/JT809.Protocol.csproj @@ -7,14 +7,14 @@ SmallChi JT809 JT809 - JT809协议、GB809协议、道路运输车辆卫星定位系统平台数据交换协议 - JT809协议、GB809协议、道路运输车辆卫星定位系统平台数据交换协议 + JT809协议、GB809协议、道路运输车辆卫星定位系统-平台数据交换协议(支持2011、2019版本) + JT809协议、GB809协议、道路运输车辆卫星定位系统-平台数据交换协议(支持2011、2019版本) true https://github.com/SmallChi/JT809 https://github.com/SmallChi/JT809 https://github.com/SmallChi/JT809/blob/master/LICENSE false - 2.1.4-preview3 + 2.1.4-preview4 LICENSE @@ -111,9 +111,9 @@ - - - + + + diff --git a/src/JT809.Protocol/JT809.Protocol.xml b/src/JT809.Protocol/JT809.Protocol.xml index 4e75a74..5541399 100644 --- a/src/JT809.Protocol/JT809.Protocol.xml +++ b/src/JT809.Protocol/JT809.Protocol.xml @@ -1159,6 +1159,12 @@ 当数据体为空的时候,使用null作为空包感觉不适合,所以就算使用空包也需要new一下来表达意思。 + + + 当外部注册的扩展809的消息Id跟国标的消息Id冲突时可以使用该字段替换国标的消息Id + 默认是false,不替换 + + 日期限制于2000年 @@ -1327,6 +1333,12 @@ 当数据体为空的时候,使用null作为空包感觉不适合,所以就算使用空包也需要new一下来表达意思。 + + + 当外部注册的扩展809的消息Id跟国标的消息Id冲突时可以使用该字段替换国标的消息Id + 默认是false,不替换 + + 主链路登录请求消息 diff --git a/src/JT809.Protocol/MessageBody/JT809_0x9007.cs b/src/JT809.Protocol/MessageBody/JT809_0x9007.cs index b4c15e4..7ffb576 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x9007.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x9007.cs @@ -24,26 +24,53 @@ namespace JT809.Protocol.MessageBody public override string Description => "从链路断开通知消息"; public override JT809_LinkType LinkType => JT809_LinkType.main; /// - /// 错误代码 + /// 错误代码 2019版本 /// public JT809_0x1007_ErrorCode ErrorCode { get; set; } + /// + /// 错误代码 + /// + public JT809_0x9007_ReasonCode ReasonCode { 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()); + if(config.Version== JT809Version.JTT2019) + { + value.ErrorCode = (JT809_0x1007_ErrorCode)reader.ReadByte(); + writer.WriteString($"[{value.ErrorCode.ToByteValue()}]错误代码", value.ErrorCode.ToString()); + } + else + { + value.ReasonCode = (JT809_0x9007_ReasonCode)reader.ReadByte(); + writer.WriteString($"[{value.ReasonCode.ToByteValue()}]错误代码", value.ReasonCode.ToString()); + } } public JT809_0x9007 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { JT809_0x9007 value = new JT809_0x9007(); - value.ErrorCode = (JT809_0x1007_ErrorCode)reader.ReadByte(); + if (config.Version == JT809Version.JTT2019) + { + value.ErrorCode = (JT809_0x1007_ErrorCode)reader.ReadByte(); + } + else + { + value.ReasonCode = (JT809_0x9007_ReasonCode)reader.ReadByte(); + } return value; } public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9007 value, IJT809Config config) { - writer.WriteByte((byte)value.ErrorCode); + if (config.Version == JT809Version.JTT2019) + { + writer.WriteByte((byte)value.ErrorCode); + } + else + { + writer.WriteByte((byte)value.ReasonCode); + } + } } }