From 3d257942a33d41ab93db2ba70635cea1539d7533 Mon Sep 17 00:00:00 2001 From: "SmallChi(Koike)" <564952747@qq.com> Date: Tue, 12 May 2020 09:53:47 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E5=A4=8D=E7=94=9F=E6=88=90=E5=8C=85?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=E6=B6=88=E6=81=AFId=E6=9C=AA?= =?UTF-8?q?=E5=AF=B9=E5=BA=94=E6=95=B0=E6=8D=AE=E4=BD=93=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=202.=E5=B0=86=E5=8E=9F=E5=85=88=E7=9A=84=E5=BA=8F=E5=88=97?= =?UTF-8?q?=E5=8F=B7=E5=99=A8=E6=89=A9=E5=B1=95=E7=A7=BB=E5=85=A5=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=89=A9=E5=B1=95=E9=87=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/JT809.Protocol/Enums/JT809BusinessType.cs | 4 +- .../Extensions/JT809ConfigExtensions.cs | 13 +++ .../JT809MessagePackFormatterExtensions.cs | 48 ----------- .../JT809PackageExtensionsTemplate.cs | 85 +++++++++---------- src/JT809.Protocol/JT809.Protocol.csproj | 2 +- src/JT809.Protocol/JT809.Protocol.xml | 16 ++-- src/JT809.Protocol/JT809Serializer.cs | 4 +- 7 files changed, 68 insertions(+), 104 deletions(-) delete mode 100644 src/JT809.Protocol/Extensions/JT809MessagePackFormatterExtensions.cs diff --git a/src/JT809.Protocol/Enums/JT809BusinessType.cs b/src/JT809.Protocol/Enums/JT809BusinessType.cs index 9053aff..878583e 100644 --- a/src/JT809.Protocol/Enums/JT809BusinessType.cs +++ b/src/JT809.Protocol/Enums/JT809BusinessType.cs @@ -180,7 +180,7 @@ namespace JT809.Protocol.Enums ///UP_MANAGE_MSG_SN_INFORM /// [Description("上传平台间消息序列号通知消息_2019")] - [JT809BodiesType(typeof(JT809_0x1102))] + [JT809BodiesType(typeof(JT809_0x1103))] [JT809BusinessTypeDescription("UP_MANAGE_MSG_SN_INFORM", "上传平台间消息序列号通知消息")] 上传平台间消息序列号通知消息_2019 = 0x1103, /// @@ -188,7 +188,7 @@ namespace JT809.Protocol.Enums ///UP_MANAGE_MSG_SN_INFORM /// [Description("下发平台间消息序列号通知消息_2019")] - [JT809BodiesType(typeof(JT809_0x1102))] + [JT809BodiesType(typeof(JT809_0x9103))] [JT809BusinessTypeDescription("DOWN_MANAGE_MSG_SN_INFORM", "下发平台间消息序列号通知消息_2019")] 下发平台间消息序列号通知消息_2019 = 0x9103, #endregion diff --git a/src/JT809.Protocol/Extensions/JT809ConfigExtensions.cs b/src/JT809.Protocol/Extensions/JT809ConfigExtensions.cs index d28c93f..020f3a3 100644 --- a/src/JT809.Protocol/Extensions/JT809ConfigExtensions.cs +++ b/src/JT809.Protocol/Extensions/JT809ConfigExtensions.cs @@ -1,6 +1,7 @@ using JT809.Protocol.Enums; using JT809.Protocol.Exceptions; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using System; using System.Collections.Concurrent; @@ -31,5 +32,17 @@ namespace JT809.Protocol } return serializer; } + public static object GetAnalyzeByType(this IJT809Config config, Type type) + { + if (!config.FormatterFactory.FormatterDict.TryGetValue(type.GUID, out var analyze)) + { + throw new JT809Exception(JT809ErrorCode.NotGlobalRegisterFormatterAssembly, type.FullName); + } + return analyze; + } + public static IJT809Analyze GetAnalyze(this IJT809Config config) + { + return (IJT809Analyze)GetAnalyzeByType(config, typeof(T)); + } } } diff --git a/src/JT809.Protocol/Extensions/JT809MessagePackFormatterExtensions.cs b/src/JT809.Protocol/Extensions/JT809MessagePackFormatterExtensions.cs deleted file mode 100644 index ef6dcdb..0000000 --- a/src/JT809.Protocol/Extensions/JT809MessagePackFormatterExtensions.cs +++ /dev/null @@ -1,48 +0,0 @@ -using JT809.Protocol.Enums; -using JT809.Protocol.Exceptions; -using JT809.Protocol.Formatters; -using JT809.Protocol.Interfaces; -using System; -using System.Collections.Concurrent; -using System.Reflection; - -namespace JT809.Protocol.Extensions -{ - public static class JT809MessagePackFormatterExtensions - { - private readonly static ConcurrentDictionary jT809SerializerDict = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); - public static IJT809MessagePackFormatter GetMessagePackFormatter(this IJT809Config config) - { - return (IJT809MessagePackFormatter)GetMessagePackFormatterByType(config, typeof(T)); - } - public static object GetMessagePackFormatterByType(this IJT809Config config, Type type) - { - if (!config.FormatterFactory.FormatterDict.TryGetValue(type.GUID, out var formatter)) - { - throw new JT809Exception(JT809ErrorCode.NotGlobalRegisterFormatterAssembly, type.FullName); - } - return formatter; - } - public static object GetAnalyzeByType(this IJT809Config config, Type type) - { - if (!config.FormatterFactory.FormatterDict.TryGetValue(type.GUID, out var analyze)) - { - throw new JT809Exception(JT809ErrorCode.NotGlobalRegisterFormatterAssembly, type.FullName); - } - return analyze; - } - public static IJT809Analyze GetAnalyze(this IJT809Config config) - { - return (IJT809Analyze)GetAnalyzeByType(config, typeof(T)); - } - public static JT809Serializer GetSerializer(this IJT809Config config) - { - if (!jT809SerializerDict.TryGetValue(config.ConfigId, out var serializer)) - { - serializer = new JT809Serializer(config); - jT809SerializerDict.TryAdd(config.ConfigId, serializer); - } - return serializer; - } - } -} diff --git a/src/JT809.Protocol/Extensions/JT809PackageExtensionsTemplate.cs b/src/JT809.Protocol/Extensions/JT809PackageExtensionsTemplate.cs index de904ac..d217c51 100644 --- a/src/JT809.Protocol/Extensions/JT809PackageExtensionsTemplate.cs +++ b/src/JT809.Protocol/Extensions/JT809PackageExtensionsTemplate.cs @@ -6,7 +6,7 @@ namespace JT809.Protocol.Extensions { public static partial class JT809PackageExtensions { - /// + /// /// UP_CONNECT_REQ - 主链路登录请求消息 /// auto-generated /// @@ -32,7 +32,7 @@ namespace JT809.Protocol.Extensions { return Create(jT809BusinessType,jT809Header,bodies); } - /// + /// /// UP_CONNECT_RSP - 主链路登录应答消息 /// auto-generated /// @@ -58,7 +58,7 @@ namespace JT809.Protocol.Extensions { return Create(jT809BusinessType,jT809Header,bodies); } - /// + /// /// UP_DISCONNECT_REQ - 主链路注销请求消息 /// auto-generated /// @@ -84,7 +84,7 @@ namespace JT809.Protocol.Extensions { return Create(jT809BusinessType,jT809Header,bodies); } - /// + /// /// UP_DISCONNECT_RSP - 主链路注销应答消息 /// auto-generated /// @@ -110,7 +110,7 @@ namespace JT809.Protocol.Extensions { return Create(jT809BusinessType,jT809Header,bodies); } - /// + /// /// UP_LINKTEST_REQ - 主链路连接保持请求消息 /// auto-generated /// @@ -136,7 +136,7 @@ namespace JT809.Protocol.Extensions { return Create(jT809BusinessType,jT809Header,bodies); } - /// + /// /// UP_LINKTEST_RSP - 主链路连接保持应答消息 /// auto-generated /// @@ -162,7 +162,7 @@ namespace JT809.Protocol.Extensions { return Create(jT809BusinessType,jT809Header,bodies); } - /// + /// /// UP_DISCONNECT_INFORM - 主链路断开通知消息 /// auto-generated /// @@ -188,7 +188,7 @@ namespace JT809.Protocol.Extensions { return Create(jT809BusinessType,jT809Header,bodies); } - /// + /// /// UP_CLOSELINK_INFORM - 下级平台主动关闭主从链路通知消息 /// auto-generated /// @@ -214,7 +214,7 @@ namespace JT809.Protocol.Extensions { return Create(jT809BusinessType,jT809Header,bodies); } - /// + /// /// UP_MANAGE_MSG_RSP - 平台链路连接情况与车辆定位消息传输情况上报应答消息_2019 /// auto-generated /// @@ -240,14 +240,6 @@ namespace JT809.Protocol.Extensions { return Create(jT809BusinessType,jT809Header,bodies); } - /// - /// UP_MANAGE_MSG_SN_INFORM - 上传平台间消息序列号通知消息_2019 - /// auto-generated - /// - public static JT809Package Create_上传平台间消息序列号通知消息_2019(this JT809BusinessType jT809BusinessType,JT809.Protocol.MessageBody.JT809_0x1102 bodies) - { - return Create(jT809BusinessType,bodies); - } /// /// UP_MANAGE_MSG_SN_INFORM - 上传平台间消息序列号通知消息_2019 @@ -257,7 +249,7 @@ namespace JT809.Protocol.Extensions { return Create(jT809BusinessType,jT809Header,bodies); } - /// + /// /// UP_EXG_MSG - 主链路车辆动态信息交换业务 /// auto-generated /// @@ -283,7 +275,7 @@ namespace JT809.Protocol.Extensions { return Create(jT809BusinessType,jT809Header,bodies); } - /// + /// /// UP_PLATFORM_MSG - 主链路平台间信息交互消息 /// auto-generated /// @@ -309,7 +301,7 @@ namespace JT809.Protocol.Extensions { return Create(jT809BusinessType,jT809Header,bodies); } - /// + /// /// UP_WARN_MSG - 主链路报警信息交互消息 /// auto-generated /// @@ -335,7 +327,7 @@ namespace JT809.Protocol.Extensions { return Create(jT809BusinessType,jT809Header,bodies); } - /// + /// /// UP_CTRL_MSG - 主链路车辆监管消息 /// auto-generated /// @@ -361,7 +353,7 @@ namespace JT809.Protocol.Extensions { return Create(jT809BusinessType,jT809Header,bodies); } - /// + /// /// UP_BASE_MSG - 主链路静态信息交换消息 /// auto-generated /// @@ -387,7 +379,7 @@ namespace JT809.Protocol.Extensions { return Create(jT809BusinessType,jT809Header,bodies); } - /// + /// /// DOWN_CONNECT_REQ - 从链路连接请求消息 /// auto-generated /// @@ -413,7 +405,7 @@ namespace JT809.Protocol.Extensions { return Create(jT809BusinessType,jT809Header,bodies); } - /// + /// /// DOWN_CONNECT_RSP - 从链路连接应答信息 /// auto-generated /// @@ -439,7 +431,7 @@ namespace JT809.Protocol.Extensions { return Create(jT809BusinessType,jT809Header,bodies); } - /// + /// /// DOWN_DISCONNECT_REQ - 从链路注销请求消息 /// auto-generated /// @@ -465,7 +457,7 @@ namespace JT809.Protocol.Extensions { return Create(jT809BusinessType,jT809Header,bodies); } - /// + /// /// DOWN_DISCONNECT_RSP - 从链路注销应答消息 /// auto-generated /// @@ -491,7 +483,7 @@ namespace JT809.Protocol.Extensions { return Create(jT809BusinessType,jT809Header,bodies); } - /// + /// /// DOWN_LINKTEST_REQ - 从链路连接保持请求消息 /// auto-generated /// @@ -517,7 +509,7 @@ namespace JT809.Protocol.Extensions { return Create(jT809BusinessType,jT809Header,bodies); } - /// + /// /// DOWN_LINKTEST_RSP - 从链路连接保持应答消息 /// auto-generated /// @@ -543,7 +535,7 @@ namespace JT809.Protocol.Extensions { return Create(jT809BusinessType,jT809Header,bodies); } - /// + /// /// DOWN_DISCONNECT_INFORM - 从链路断开通知消息 /// auto-generated /// @@ -569,7 +561,7 @@ namespace JT809.Protocol.Extensions { return Create(jT809BusinessType,jT809Header,bodies); } - /// + /// /// DOWN_CLOSELINK_INFORM - 上级平台主动关闭链路通知消息 /// auto-generated /// @@ -595,7 +587,6 @@ namespace JT809.Protocol.Extensions { return Create(jT809BusinessType,jT809Header,bodies); } - /// /// DOWN_TOTAL_RECV_BACK_MSG - 发送车辆定位信息数据量通知消息_2019 /// auto-generated @@ -618,11 +609,10 @@ namespace JT809.Protocol.Extensions /// DOWN_TOTAL_RECV_BACK_MSG - 发送车辆定位信息数据量通知消息_2019 /// auto-generated /// - public static JT809Package Create_发送车辆定位信息数据量通知消息_2019(this JT809BusinessType jT809BusinessType,JT809Header jT809Header, JT809.Protocol.MessageBody.JT809_2019_0x9101 bodies) + public static JT809Package Create_发送车辆定位信息数据量通知消息(this JT809BusinessType jT809BusinessType,JT809Header jT809Header, JT809.Protocol.MessageBody.JT809_0x9101 bodies) { - return Create(jT809BusinessType,jT809Header,bodies); + return Create(jT809BusinessType,jT809Header,bodies); } - /// /// DOWN_TOTAL_RECV_BACK_MSG - 接收车辆定位信息数量通知消息 /// auto-generated @@ -645,11 +635,11 @@ namespace JT809.Protocol.Extensions /// DOWN_TOTAL_RECV_BACK_MSG - 接收车辆定位信息数量通知消息 /// auto-generated /// - public static JT809Package Create_接收车辆定位信息数量通知消息(this JT809BusinessType jT809BusinessType,JT809Header jT809Header, JT809.Protocol.MessageBody.JT809_0x9101 bodies) + public static JT809Package Create_接收车辆定位信息数量通知消息(this JT809BusinessType jT809BusinessType,JT809Header jT809Header, JT809.Protocol.MessageBody.JT809_2019_0x9101 bodies) { - return Create(jT809BusinessType,jT809Header,bodies); + return Create(jT809BusinessType,jT809Header,bodies); } - /// + /// /// DOWN_MANAGE_MSG_REQ - 平台链路连接情况与车辆定位消息传输情况上报请求消息_2019 /// auto-generated /// @@ -658,6 +648,15 @@ namespace JT809.Protocol.Extensions return Create(jT809BusinessType,bodies); } + /// + /// DOWN_MANAGE_MSG_REQ - 平台链路连接情况与车辆定位消息传输情况上报请求消息_2019 + /// auto-generated + /// + public static JT809Package Create(this JT809BusinessType jT809BusinessType, JT809.Protocol.MessageBody.JT809_0x9102 bodies) + { + return Create(jT809BusinessType,bodies); + } + /// /// DOWN_MANAGE_MSG_REQ - 平台链路连接情况与车辆定位消息传输情况上报请求消息_2019 /// auto-generated @@ -666,7 +665,7 @@ namespace JT809.Protocol.Extensions { return Create(jT809BusinessType,jT809Header,bodies); } - /// + /// /// DOWN_MANAGE_MSG_SN_INFORM - 下发平台间消息序列号通知消息_2019 /// auto-generated /// @@ -683,7 +682,7 @@ namespace JT809.Protocol.Extensions { return Create(jT809BusinessType,jT809Header,bodies); } - /// + /// /// DOWN_EXG_MSG - 从链路车辆动态信息交换业务 /// auto-generated /// @@ -709,7 +708,7 @@ namespace JT809.Protocol.Extensions { return Create(jT809BusinessType,jT809Header,bodies); } - /// + /// /// DOWN_PLATFORM_MSG - 从链路平台间信息交互业务 /// auto-generated /// @@ -735,7 +734,7 @@ namespace JT809.Protocol.Extensions { return Create(jT809BusinessType,jT809Header,bodies); } - /// + /// /// DOWN_WARN_MSG - 从链路报警信息交互消息 /// auto-generated /// @@ -761,7 +760,7 @@ namespace JT809.Protocol.Extensions { return Create(jT809BusinessType,jT809Header,bodies); } - /// + /// /// DOWN_CTRL_MSG - 从链路车辆监管消息 /// auto-generated /// @@ -787,7 +786,7 @@ namespace JT809.Protocol.Extensions { return Create(jT809BusinessType,jT809Header,bodies); } - /// + /// /// DOWN_BASE_MSG - 从链路静态信息交换消息 /// auto-generated /// diff --git a/src/JT809.Protocol/JT809.Protocol.csproj b/src/JT809.Protocol/JT809.Protocol.csproj index 4615208..494b645 100644 --- a/src/JT809.Protocol/JT809.Protocol.csproj +++ b/src/JT809.Protocol/JT809.Protocol.csproj @@ -14,7 +14,7 @@ https://github.com/SmallChi/JT809 https://github.com/SmallChi/JT809/blob/master/LICENSE false - 2.1.4-preview1 + 2.1.4-preview2 LICENSE diff --git a/src/JT809.Protocol/JT809.Protocol.xml b/src/JT809.Protocol/JT809.Protocol.xml index 29a8cc6..4e75a74 100644 --- a/src/JT809.Protocol/JT809.Protocol.xml +++ b/src/JT809.Protocol/JT809.Protocol.xml @@ -328,12 +328,6 @@ auto-generated - - - UP_MANAGE_MSG_SN_INFORM - 上传平台间消息序列号通知消息_2019 - auto-generated - - UP_MANAGE_MSG_SN_INFORM - 上传平台间消息序列号通知消息_2019 @@ -586,7 +580,7 @@ auto-generated - + DOWN_TOTAL_RECV_BACK_MSG - 发送车辆定位信息数据量通知消息_2019 auto-generated @@ -604,7 +598,7 @@ auto-generated - + DOWN_TOTAL_RECV_BACK_MSG - 接收车辆定位信息数量通知消息 auto-generated @@ -616,6 +610,12 @@ auto-generated + + + DOWN_MANAGE_MSG_REQ - 平台链路连接情况与车辆定位消息传输情况上报请求消息_2019 + auto-generated + + DOWN_MANAGE_MSG_REQ - 平台链路连接情况与车辆定位消息传输情况上报请求消息_2019 diff --git a/src/JT809.Protocol/JT809Serializer.cs b/src/JT809.Protocol/JT809Serializer.cs index 0b86056..35bbd17 100644 --- a/src/JT809.Protocol/JT809Serializer.cs +++ b/src/JT809.Protocol/JT809Serializer.cs @@ -69,7 +69,7 @@ namespace JT809.Protocol try { JT809MessagePackWriter jT809MessagePackWriter = new JT809MessagePackWriter(buffer); - JT809MessagePackFormatterExtensions.GetMessagePackFormatter(jT809Config).Serialize(ref jT809MessagePackWriter, obj,jT809Config); + jT809Config.GetMessagePackFormatter().Serialize(ref jT809MessagePackWriter, obj,jT809Config); return jT809MessagePackWriter.FlushAndGetEncodingArray(); } finally @@ -85,7 +85,7 @@ namespace JT809.Protocol JT809MessagePackReader jT809MessagePackReader = new JT809MessagePackReader(bytes); if (CheckPackageType(typeof(T))) jT809MessagePackReader.Decode(buffer); - return JT809MessagePackFormatterExtensions.GetMessagePackFormatter(jT809Config).Deserialize(ref jT809MessagePackReader, jT809Config); + return jT809Config.GetMessagePackFormatter().Deserialize(ref jT809MessagePackReader, jT809Config); } finally {