diff --git a/src/JT809.Protocol.Test/JT1078/JT808_JT1078_0x1700.cs b/src/JT809.Protocol.Test/JT1078/JT808_JT1078_0x1700.cs index f5c306d..e3b0398 100644 --- a/src/JT809.Protocol.Test/JT1078/JT808_JT1078_0x1700.cs +++ b/src/JT809.Protocol.Test/JT1078/JT808_JT1078_0x1700.cs @@ -1,14 +1,16 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Formatters; +using JT809.Protocol.Enums; using System; using System.Collections.Generic; using System.Text; namespace JT809.Protocol.Test.JT1078 { - [JT809Formatter(typeof(JT809BodiesFormatter))] - public class JT808_JT1078_0x1700: JT809ExchangeMessageBodies + public class JT808_JT1078_0x1700 : JT809ExchangeMessageBodies { + public override ushort MsgId => throw new NotImplementedException(); + public override JT809_LinkType LinkType => throw new NotImplementedException(); + + public override string Description => throw new NotImplementedException(); } } diff --git a/src/JT809.Protocol.Test/JT1078/JT808_JT1078_0x1700_0x1701.cs b/src/JT809.Protocol.Test/JT1078/JT808_JT1078_0x1700_0x1701.cs index 4125976..c029ae3 100644 --- a/src/JT809.Protocol.Test/JT1078/JT808_JT1078_0x1700_0x1701.cs +++ b/src/JT809.Protocol.Test/JT1078/JT808_JT1078_0x1700_0x1701.cs @@ -1,11 +1,9 @@ -using JT809.Protocol.Attributes; -using System; +using System; using System.Collections.Generic; using System.Text; namespace JT809.Protocol.Test.JT1078 { - [JT809Formatter(typeof(JT808_JT1078_0x1700_0x1701_Formatter))] public class JT808_JT1078_0x1700_0x1701 : JT809SubBodies { /// diff --git a/src/JT809.Protocol/Attributes/JT809FormatterAttribute.cs b/src/JT809.Protocol/Attributes/JT809FormatterAttribute.cs deleted file mode 100644 index 4b33038..0000000 --- a/src/JT809.Protocol/Attributes/JT809FormatterAttribute.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Attributes -{ - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, AllowMultiple = false, Inherited = true)] - public sealed class JT809FormatterAttribute:Attribute - { - public Type FormatterType { get; private set; } - - public object[] Arguments { get; private set; } - - public JT809FormatterAttribute(Type formatterType) - { - this.FormatterType = formatterType; - } - - public JT809FormatterAttribute(Type formatterType, params object[] arguments) - { - this.FormatterType = formatterType; - this.Arguments = arguments; - } - } -} diff --git a/src/JT809.Protocol/Enums/JT809BusinessType.cs b/src/JT809.Protocol/Enums/JT809BusinessType.cs index b747987..6821493 100644 --- a/src/JT809.Protocol/Enums/JT809BusinessType.cs +++ b/src/JT809.Protocol/Enums/JT809BusinessType.cs @@ -70,13 +70,13 @@ namespace JT809.Protocol.Enums [JT809BusinessTypeDescription("UP_DISCONNECT_INFORM", "主链路断开通知消息")] 主链路断开通知消息 = 0x1007, /// - ///下级平台主动关闭链路通知消息 + ///下级平台主动关闭主从链路通知消息 ///UP_CLOSELINK_INFORM /// - [Description("下级平台主动关闭链路通知消息")] + [Description("下级平台主动关闭主从链路通知消息")] [JT809BodiesType(typeof(JT809_0x1008))] - [JT809BusinessTypeDescription("UP_CLOSELINK_INFORM", "下级平台主动关闭链路通知消息")] - 下级平台主动关闭链路通知消息 = 0x1008, + [JT809BusinessTypeDescription("UP_CLOSELINK_INFORM", "下级平台主动关闭主从链路通知消息")] + 下级平台主动关闭主从链路通知消息 = 0x1008, /// ///从链路连接请求消息 ///DOWN_CONNECT_REQ @@ -86,13 +86,13 @@ namespace JT809.Protocol.Enums [JT809BusinessTypeDescription("DOWN_CONNECT_REQ", "从链路连接请求消息")] 从链路连接请求消息 = 0x9001, /// - ///从链路连接应答消息 + ///从链路连接应答信息 ///DOWN_CONNECT_RSP /// - [Description("从链路连接应答消息")] + [Description("从链路连接应答信息")] [JT809BodiesType(typeof(JT809_0x9002))] - [JT809BusinessTypeDescription("DOWN_CONNECT_RSP", "从链路连接应答消息")] - 从链路连接应答消息 = 0x9002, + [JT809BusinessTypeDescription("DOWN_CONNECT_RSP", "从链路连接应答信息")] + 从链路连接应答信息 = 0x9002, /// ///从链路注销请求消息 ///DOWN_DISCONNECT_REQ @@ -144,31 +144,31 @@ namespace JT809.Protocol.Enums #endregion #region 信息统计类 /// - ///接收定位信息数量通知消息 + ///接收车辆定位信息数量通知消息 ///DOWN_TOTAL_RECV_BACK_MSG /// - [Description("接收定位信息数量通知消息")] + [Description("接收车辆定位信息数量通知消息")] [JT809BodiesType(typeof(JT809_0x9101))] - [JT809BusinessTypeDescription("DOWN_TOTAL_RECV_BACK_MSG", "接收定位信息数量通知消息")] - 接收定位信息数量通知消息 = 0x9101, + [JT809BusinessTypeDescription("DOWN_TOTAL_RECV_BACK_MSG", "接收车辆定位信息数量通知消息")] + 接收车辆定位信息数量通知消息 = 0x9101, #endregion #region 车辆动态信息交换 /// ///主链路动态信息交换消息 ///UP_EXG_MSG /// - [Description("主链路动态信息交换消息")] + [Description("主链路车辆动态信息交换业务")] [JT809BodiesType(typeof(JT809_0x1200))] - [JT809BusinessTypeDescription("UP_EXG_MSG", "主链路动态信息交换消息")] - 主链路动态信息交换消息 = 0x1200, + [JT809BusinessTypeDescription("UP_EXG_MSG", "主链路车辆动态信息交换业务")] + 主链路车辆动态信息交换业务 = 0x1200, /// - ///从链路动态信息交换消息 + ///从链路车辆动态信息交换业务 ///DOWN_EXG_MSG /// - [Description("从链路动态信息交换消息")] + [Description("从链路车辆动态信息交换业务")] [JT809BodiesType(typeof(JT809_0x9200))] - [JT809BusinessTypeDescription("DOWN_EXG_MSG", "从链路动态信息交换消息")] - 从链路动态信息交换消息 = 0x9200, + [JT809BusinessTypeDescription("DOWN_EXG_MSG", "从链路车辆动态信息交换业务")] + 从链路车辆动态信息交换业务 = 0x9200, #endregion #region 平台间信息交互类 /// @@ -180,13 +180,13 @@ namespace JT809.Protocol.Enums [JT809BusinessTypeDescription("UP_PLATFORM_MSG", "主链路平台间信息交互消息")] 主链路平台间信息交互消息 = 0x1300, /// - ///从链路平台间信息交互消息 + ///从链路平台间信息交互业务 ///DOWN_PLATFORM_MSG /// - [Description("从链路平台间信息交互消息")] + [Description("从链路平台间信息交互业务")] [JT809BodiesType(typeof(JT809_0x9300))] - [JT809BusinessTypeDescription("DOWN_PLATFORM_MSG", "从链路平台间信息交互消息")] - 从链路平台间信息交互消息 = 0x9300, + [JT809BusinessTypeDescription("DOWN_PLATFORM_MSG", "从链路平台间信息交互业务")] + 从链路平台间信息交互业务 = 0x9300, #endregion #region 车辆报警信息交互类 /// diff --git a/src/JT809.Protocol/Enums/JT809ErrorCode.cs b/src/JT809.Protocol/Enums/JT809ErrorCode.cs index 0f436cc..f4f0685 100644 --- a/src/JT809.Protocol/Enums/JT809ErrorCode.cs +++ b/src/JT809.Protocol/Enums/JT809ErrorCode.cs @@ -15,7 +15,6 @@ namespace JT809.Protocol.Enums BodiesParseError=1007, SubBodiesParseError = 1008, GetAttributeError=1009, - GetFormatterAttributeError=1010, NotGlobalRegisterFormatterAssembly=1011, } } diff --git a/src/JT809.Protocol/Enums/JT809SubBusinessType.cs b/src/JT809.Protocol/Enums/JT809SubBusinessType.cs index 7fbc926..5a0bb63 100644 --- a/src/JT809.Protocol/Enums/JT809SubBusinessType.cs +++ b/src/JT809.Protocol/Enums/JT809SubBusinessType.cs @@ -17,7 +17,7 @@ namespace JT809.Protocol.Enums /// [Description("上传车辆注册信息")] [JT809BodiesType(typeof(JT809_0x1200_0x1201))] - [JT809SubBusinessTypeDescription("UP_EXG_MSG_REGISTER", "上传车辆注册信息", JT809BusinessType.主链路动态信息交换消息)] + [JT809SubBusinessTypeDescription("UP_EXG_MSG_REGISTER", "上传车辆注册信息", JT809BusinessType.主链路车辆动态信息交换业务)] 上传车辆注册信息 = 0x1201, /// ///实时上传车辆定位信息 @@ -25,7 +25,7 @@ namespace JT809.Protocol.Enums /// [Description("实时上传车辆定位信息")] [JT809BodiesType(typeof(JT809_0x1200_0x1202))] - [JT809SubBusinessTypeDescription("UP_EXG_MSG_REAL_LOCATION", "实时上传车辆定位信息", JT809BusinessType.主链路动态信息交换消息)] + [JT809SubBusinessTypeDescription("UP_EXG_MSG_REAL_LOCATION", "实时上传车辆定位信息", JT809BusinessType.主链路车辆动态信息交换业务)] 实时上传车辆定位信息 = 0x1202, /// ///车辆定位信息自动补报 @@ -33,7 +33,7 @@ namespace JT809.Protocol.Enums /// [Description("车辆定位信息自动补报")] [JT809BodiesType(typeof(JT809_0x1200_0x1203))] - [JT809SubBusinessTypeDescription("UP_EXG_MSG_HISTORY_LOCATION", "车辆定位信息自动补报", JT809BusinessType.主链路动态信息交换消息)] + [JT809SubBusinessTypeDescription("UP_EXG_MSG_HISTORY_LOCATION", "车辆定位信息自动补报", JT809BusinessType.主链路车辆动态信息交换业务)] 车辆定位信息自动补报 = 0x1203, /// ///启动车辆定位信息交换应答 @@ -41,7 +41,7 @@ namespace JT809.Protocol.Enums /// [Description("启动车辆定位信息交换应答")] [JT809BodiesType(typeof(JT809_0x1200_0x1205))] - [JT809SubBusinessTypeDescription("UP_EXG_MSG_RETURN_STARTUP_ACK", "启动车辆定位信息交换应答", JT809BusinessType.主链路动态信息交换消息)] + [JT809SubBusinessTypeDescription("UP_EXG_MSG_RETURN_STARTUP_ACK", "启动车辆定位信息交换应答", JT809BusinessType.主链路车辆动态信息交换业务)] 启动车辆定位信息交换应答 = 0x1205, /// ///结束车辆定位信息交换应答 @@ -49,7 +49,7 @@ namespace JT809.Protocol.Enums /// [Description("结束车辆定位信息交换应答")] [JT809BodiesType(typeof(JT809_0x1200_0x1206))] - [JT809SubBusinessTypeDescription("UP_EXG_MSG_RETURN_END_ACK", "结束车辆定位信息交换应答", JT809BusinessType.主链路动态信息交换消息)] + [JT809SubBusinessTypeDescription("UP_EXG_MSG_RETURN_END_ACK", "结束车辆定位信息交换应答", JT809BusinessType.主链路车辆动态信息交换业务)] 结束车辆定位信息交换应答 = 0x1206, /// ///申请交换指定车辆定位信息请求 @@ -57,7 +57,7 @@ namespace JT809.Protocol.Enums /// [Description("申请交换指定车辆定位信息请求")] [JT809BodiesType(typeof(JT809_0x1200_0x1207))] - [JT809SubBusinessTypeDescription("UP_EXG_MSG_APPLY_FOR_MONITOR_STARTUP", "申请交换指定车辆定位信息请求", JT809BusinessType.主链路动态信息交换消息)] + [JT809SubBusinessTypeDescription("UP_EXG_MSG_APPLY_FOR_MONITOR_STARTUP", "申请交换指定车辆定位信息请求", JT809BusinessType.主链路车辆动态信息交换业务)] 申请交换指定车辆定位信息请求 = 0x1207, /// ///取消交换指定车辆定位信息请求 @@ -65,7 +65,7 @@ namespace JT809.Protocol.Enums /// [Description("取消交换指定车辆定位信息请求")] [JT809BodiesType(typeof(JT809_0x1200_0x1208))] - [JT809SubBusinessTypeDescription("UP_EXG_MSG_APPLY_FOR_MONITOR_END", "取消交换指定车辆定位信息请求", JT809BusinessType.主链路动态信息交换消息)] + [JT809SubBusinessTypeDescription("UP_EXG_MSG_APPLY_FOR_MONITOR_END", "取消交换指定车辆定位信息请求", JT809BusinessType.主链路车辆动态信息交换业务)] 取消交换指定车辆定位信息请求 = 0x1208, /// ///补发车辆定位信息请求 @@ -73,7 +73,7 @@ namespace JT809.Protocol.Enums /// [Description("补发车辆定位信息请求")] [JT809BodiesType(typeof(JT809_0x1200_0x1209))] - [JT809SubBusinessTypeDescription("UP_EXG_MSG_APPLY_HISGNSSDATA_REQ", "补发车辆定位信息请求", JT809BusinessType.主链路动态信息交换消息)] + [JT809SubBusinessTypeDescription("UP_EXG_MSG_APPLY_HISGNSSDATA_REQ", "补发车辆定位信息请求", JT809BusinessType.主链路车辆动态信息交换业务)] 补发车辆定位信息请求 = 0x1209, /// ///上报车辆驾驶员身份识别信息应答 @@ -81,7 +81,7 @@ namespace JT809.Protocol.Enums /// [Description("上报车辆驾驶员身份识别信息应答")] [JT809BodiesType(typeof(JT809_0x1200_0x120A))] - [JT809SubBusinessTypeDescription("UP_EXG_MSG_REPORT_DRIVER_INFO_ACK", "上报车辆驾驶员身份识别信息应答", JT809BusinessType.主链路动态信息交换消息)] + [JT809SubBusinessTypeDescription("UP_EXG_MSG_REPORT_DRIVER_INFO_ACK", "上报车辆驾驶员身份识别信息应答", JT809BusinessType.主链路车辆动态信息交换业务)] 上报车辆驾驶员身份识别信息应答 = 0x120A, /// ///上报车辆电子运单应答 @@ -89,7 +89,7 @@ namespace JT809.Protocol.Enums /// [Description("上报车辆电子运单应答")] [JT809BodiesType(typeof(JT809_0x1200_0x120B))] - [JT809SubBusinessTypeDescription("UP_EXG_MSG_TAKE_EWAYBILL_ACK", "上报车辆电子运单应答", JT809BusinessType.主链路动态信息交换消息)] + [JT809SubBusinessTypeDescription("UP_EXG_MSG_TAKE_EWAYBILL_ACK", "上报车辆电子运单应答", JT809BusinessType.主链路车辆动态信息交换业务)] 上报车辆电子运单应答 = 0x120B, /// ///主动上报驾驶员身份信息 @@ -97,7 +97,7 @@ namespace JT809.Protocol.Enums /// [Description("主动上报驾驶员身份信息")] [JT809BodiesType(typeof(JT809_0x1200_0x120C))] - [JT809SubBusinessTypeDescription("UP_EXG_MSG_REPORT_DRIVER_INFO", "主动上报驾驶员身份信息", JT809BusinessType.主链路动态信息交换消息)] + [JT809SubBusinessTypeDescription("UP_EXG_MSG_REPORT_DRIVER_INFO", "主动上报驾驶员身份信息", JT809BusinessType.主链路车辆动态信息交换业务)] 主动上报驾驶员身份信息 = 0x120C, /// ///主动上报车辆电子运单信息 @@ -105,7 +105,7 @@ namespace JT809.Protocol.Enums /// [Description("主动上报车辆电子运单信息")] [JT809BodiesType(typeof(JT809_0x1200_0x120D))] - [JT809SubBusinessTypeDescription("UP_EXG_MSG_REPORT_EWAYBILL_INFO", "主动上报车辆电子运单信息", JT809BusinessType.主链路动态信息交换消息)] + [JT809SubBusinessTypeDescription("UP_EXG_MSG_REPORT_EWAYBILL_INFO", "主动上报车辆电子运单信息", JT809BusinessType.主链路车辆动态信息交换业务)] 主动上报车辆电子运单信息 = 0x120D, #endregion @@ -116,7 +116,7 @@ namespace JT809.Protocol.Enums /// [Description("交换车辆定位信息")] [JT809BodiesType(typeof(JT809_0x9200_0x9202))] - [JT809SubBusinessTypeDescription("DOWN_EXG_MSG_CAR_LOCATION", "交换车辆定位信息", JT809BusinessType.从链路动态信息交换消息)] + [JT809SubBusinessTypeDescription("DOWN_EXG_MSG_CAR_LOCATION", "交换车辆定位信息", JT809BusinessType.从链路车辆动态信息交换业务)] 交换车辆定位信息 = 0x9202, /// ///车辆定位信息交换补发 @@ -124,7 +124,7 @@ namespace JT809.Protocol.Enums /// [Description("车辆定位信息交换补发")] [JT809BodiesType(typeof(JT809_0x9200_0x9203))] - [JT809SubBusinessTypeDescription("DOWN_EXG_MSG_HISTORY_ARCOSSAREA", "车辆定位信息交换补发", JT809BusinessType.从链路动态信息交换消息)] + [JT809SubBusinessTypeDescription("DOWN_EXG_MSG_HISTORY_ARCOSSAREA", "车辆定位信息交换补发", JT809BusinessType.从链路车辆动态信息交换业务)] 车辆定位信息交换补发 = 0x9203, /// ///交换车辆静态信息 @@ -132,7 +132,7 @@ namespace JT809.Protocol.Enums /// [Description("交换车辆静态信息")] [JT809BodiesType(typeof(JT809_0x9200_0x9204))] - [JT809SubBusinessTypeDescription("DOWN_EXG_MSG_CAR_INFO", "交换车辆静态信息", JT809BusinessType.从链路动态信息交换消息)] + [JT809SubBusinessTypeDescription("DOWN_EXG_MSG_CAR_INFO", "交换车辆静态信息", JT809BusinessType.从链路车辆动态信息交换业务)] 交换车辆静态信息 = 0x9204, /// ///启动车辆定位信息交换请求 @@ -140,14 +140,14 @@ namespace JT809.Protocol.Enums /// [Description("启动车辆定位信息交换请求")] [JT809BodiesType(typeof(JT809_0x9200_0x9205))] - [JT809SubBusinessTypeDescription("DOWN_EXG_MSG_RETURN_STARTUP", "启动车辆定位信息交换请求", JT809BusinessType.从链路动态信息交换消息)] + [JT809SubBusinessTypeDescription("DOWN_EXG_MSG_RETURN_STARTUP", "启动车辆定位信息交换请求", JT809BusinessType.从链路车辆动态信息交换业务)] 启动车辆定位信息交换请求 = 0x9205, /// ///结束车辆定位信息交换请求 /// [Description("结束车辆定位信息交换请求")] [JT809BodiesType(typeof(JT809_0x9200_0x9206))] - [JT809SubBusinessTypeDescription("DOWN_EXG_MSG_RETURN_END", "结束车辆定位信息交换请求", JT809BusinessType.从链路动态信息交换消息)] + [JT809SubBusinessTypeDescription("DOWN_EXG_MSG_RETURN_END", "结束车辆定位信息交换请求", JT809BusinessType.从链路车辆动态信息交换业务)] 结束车辆定位信息交换请求 = 0x9206, /// ///申请交换指定车辆定位信息应答 @@ -155,7 +155,7 @@ namespace JT809.Protocol.Enums /// [Description("申请交换指定车辆定位信息应答")] [JT809BodiesType(typeof(JT809_0x9200_0x9207))] - [JT809SubBusinessTypeDescription("DOWN_EXG_MSG_APPLY_FOR_MONITOR_STARTUP_ACK", "申请交换指定车辆定位信息应答", JT809BusinessType.从链路动态信息交换消息)] + [JT809SubBusinessTypeDescription("DOWN_EXG_MSG_APPLY_FOR_MONITOR_STARTUP_ACK", "申请交换指定车辆定位信息应答", JT809BusinessType.从链路车辆动态信息交换业务)] 申请交换指定车辆定位信息应答 = 0x9207, /// ///取消交换指定车辆定位信息应答 @@ -163,7 +163,7 @@ namespace JT809.Protocol.Enums /// [Description("取消交换指定车辆定位信息应答")] [JT809BodiesType(typeof(JT809_0x9200_0x9208))] - [JT809SubBusinessTypeDescription("DOWN_EXG_MSG_APPLY_FOR_MONITOR_END_ACK", "取消交换指定车辆定位信息应答", JT809BusinessType.从链路动态信息交换消息)] + [JT809SubBusinessTypeDescription("DOWN_EXG_MSG_APPLY_FOR_MONITOR_END_ACK", "取消交换指定车辆定位信息应答", JT809BusinessType.从链路车辆动态信息交换业务)] 取消交换指定车辆定位信息应答 = 0x9208, /// ///补发车辆定位信息应答 @@ -171,7 +171,7 @@ namespace JT809.Protocol.Enums /// [Description("补发车辆定位信息应答")] [JT809BodiesType(typeof(JT809_0x9200_0x9209))] - [JT809SubBusinessTypeDescription("DOWN_EXG_MSG_APPLY_HISGNSSDATA_ACK", "补发车辆定位信息应答", JT809BusinessType.从链路动态信息交换消息)] + [JT809SubBusinessTypeDescription("DOWN_EXG_MSG_APPLY_HISGNSSDATA_ACK", "补发车辆定位信息应答", JT809BusinessType.从链路车辆动态信息交换业务)] 补发车辆定位信息应答 = 0x9209, /// ///上报车辆驾驶员身份识别信息请求 @@ -179,7 +179,7 @@ namespace JT809.Protocol.Enums /// [Description("上报车辆驾驶员身份识别信息请求")] [JT809BodiesType(typeof(JT809_0x9200_0x920A))] - [JT809SubBusinessTypeDescription("DOWN_EXG_MSG_REPORT_DRIVER_INFO", "上报车辆驾驶员身份识别信息请求", JT809BusinessType.从链路动态信息交换消息)] + [JT809SubBusinessTypeDescription("DOWN_EXG_MSG_REPORT_DRIVER_INFO", "上报车辆驾驶员身份识别信息请求", JT809BusinessType.从链路车辆动态信息交换业务)] 上报车辆驾驶员身份识别信息请求 = 0x920A, /// ///上报车辆电子运单请求 @@ -187,7 +187,7 @@ namespace JT809.Protocol.Enums /// [Description("上报车辆电子运单请求")] [JT809BodiesType(typeof(JT809_0x9200_0x920B))] - [JT809SubBusinessTypeDescription("DOWN_EXG_MSG_TAKE_EWAYBILL_REQ", "上报车辆电子运单请求", JT809BusinessType.从链路动态信息交换消息)] + [JT809SubBusinessTypeDescription("DOWN_EXG_MSG_TAKE_EWAYBILL_REQ", "上报车辆电子运单请求", JT809BusinessType.从链路车辆动态信息交换业务)] 上报车辆电子运单请求 = 0x920B, #endregion @@ -217,7 +217,7 @@ namespace JT809.Protocol.Enums /// [Description("平台查岗请求")] [JT809BodiesType(typeof(JT809_0x9300_0x9301))] - [JT809SubBusinessTypeDescription("DOWN_PLATFORM_MSG_POST_QUERY_REQ", "平台查岗请求", JT809BusinessType.从链路平台间信息交互消息)] + [JT809SubBusinessTypeDescription("DOWN_PLATFORM_MSG_POST_QUERY_REQ", "平台查岗请求", JT809BusinessType.从链路平台间信息交互业务)] 平台查岗请求 = 0x9301, /// ///下发平台间报文请求 @@ -225,7 +225,7 @@ namespace JT809.Protocol.Enums /// [Description("下发平台间报文请求")] [JT809BodiesType(typeof(JT809_0x9300_0x9302))] - [JT809SubBusinessTypeDescription("DOWN_PLATFORM_MSG_INFO_REQ", "下发平台间报文请求", JT809BusinessType.从链路平台间信息交互消息)] + [JT809SubBusinessTypeDescription("DOWN_PLATFORM_MSG_INFO_REQ", "下发平台间报文请求", JT809BusinessType.从链路平台间信息交互业务)] 下发平台间报文请求 = 0x9302, #endregion diff --git a/src/JT809.Protocol/Enums/JT809Version.cs b/src/JT809.Protocol/Enums/JT809Version.cs new file mode 100644 index 0000000..577bdc8 --- /dev/null +++ b/src/JT809.Protocol/Enums/JT809Version.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Enums +{ + public enum JT809Version:byte + { + JTT2013=1, + JTT2019=2, + } +} diff --git a/src/JT809.Protocol/Enums/JT809_LinkType.cs b/src/JT809.Protocol/Enums/JT809_LinkType.cs new file mode 100644 index 0000000..7840dd9 --- /dev/null +++ b/src/JT809.Protocol/Enums/JT809_LinkType.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Enums +{ + /// + /// 链路类型 + /// + public enum JT809_LinkType:byte + { + /// + /// 主链路 + /// + main, + /// + /// 从链路 + /// + subordinate + } +} diff --git a/src/JT809.Protocol/Extensions/JT809MessagePackFormatterExtensions.cs b/src/JT809.Protocol/Extensions/JT809MessagePackFormatterExtensions.cs index df4a281..ef6dcdb 100644 --- a/src/JT809.Protocol/Extensions/JT809MessagePackFormatterExtensions.cs +++ b/src/JT809.Protocol/Extensions/JT809MessagePackFormatterExtensions.cs @@ -1,7 +1,7 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; +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; @@ -10,33 +10,39 @@ namespace JT809.Protocol.Extensions { public static class JT809MessagePackFormatterExtensions { - private readonly static ConcurrentDictionary cache = new ConcurrentDictionary(); - - public static IJT809MessagePackFormatter GetFormatter() + private readonly static ConcurrentDictionary jT809SerializerDict = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); + public static IJT809MessagePackFormatter GetMessagePackFormatter(this IJT809Config config) { - return (IJT809MessagePackFormatter) GetFormatter(typeof(T)); + return (IJT809MessagePackFormatter)GetMessagePackFormatterByType(config, typeof(T)); } - - public static object GetFormatter(Type type) + public static object GetMessagePackFormatterByType(this IJT809Config config, Type type) { - if(!cache.TryGetValue(type.GUID,out object formatter)) + if (!config.FormatterFactory.FormatterDict.TryGetValue(type.GUID, out var formatter)) { - var attr = type.GetTypeInfo().GetCustomAttribute(); - if (attr == null) - { - throw new JT809Exception(JT809ErrorCode.GetFormatterError, $"该类{type.FullName}没有标记JT809FormatterAttribute"); - } - if (attr.Arguments == null) - { - formatter = Activator.CreateInstance(attr.FormatterType); - } - else - { - formatter = Activator.CreateInstance(attr.FormatterType, attr.Arguments); - } - cache.TryAdd(type.GUID, 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/Formatters/IJT809FormatterFactory.cs b/src/JT809.Protocol/Formatters/IJT809FormatterFactory.cs index 204371c..3aa378e 100644 --- a/src/JT809.Protocol/Formatters/IJT809FormatterFactory.cs +++ b/src/JT809.Protocol/Formatters/IJT809FormatterFactory.cs @@ -1,4 +1,5 @@ using JT809.Protocol; +using JT809.Protocol.Formatters; using JT809.Protocol.Interfaces; using System; using System.Collections.Generic; @@ -10,9 +11,7 @@ namespace JT808.Protocol.Formatters public interface IJT809FormatterFactory : IJT809ExternalRegister { Dictionary FormatterDict { get;} - IJT809FormatterFactory SetMap() - where TJT809Bodies : JT809Bodies; - IJT809FormatterFactory SetSubMap() - where TJT809SubBodies : JT809SubBodies; + IJT809FormatterFactory SetMap() + where TIJT809Formatter : IJT809Formatter; } } diff --git a/src/JT809.Protocol/Formatters/IJT809FormatterOfT.cs b/src/JT809.Protocol/Formatters/IJT809FormatterOfT.cs deleted file mode 100644 index 5407d31..0000000 --- a/src/JT809.Protocol/Formatters/IJT809FormatterOfT.cs +++ /dev/null @@ -1,15 +0,0 @@ -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; -using System; -using System.Buffers; - -namespace JT809.Protocol.Formatters -{ - [Obsolete("请使用 IJT809MessagePackFormatter")] - public interface IJT809Formatter: IJT809Formatter - { - T Deserialize(ReadOnlySpan bytes, out int readSize); - - int Serialize(ref byte[] bytes, int offset, T value); - } -} diff --git a/src/JT809.Protocol/Formatters/JT809HeaderFormatter.cs b/src/JT809.Protocol/Formatters/JT809HeaderFormatter.cs deleted file mode 100644 index 3ebb0eb..0000000 --- a/src/JT809.Protocol/Formatters/JT809HeaderFormatter.cs +++ /dev/null @@ -1,40 +0,0 @@ -using JT809.Protocol.Enums; -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters -{ - public class JT809HeaderFormatter : IJT809MessagePackFormatter - { - public readonly static JT809HeaderFormatter Instance = new JT809HeaderFormatter(); - - public JT809Header Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809Header jT809Header = new JT809Header(); - jT809Header.MsgLength = reader.ReadUInt32(); - jT809Header.MsgSN = reader.ReadUInt32(); - jT809Header.BusinessType = reader.ReadUInt16(); - jT809Header.MsgGNSSCENTERID = reader.ReadUInt32(); - jT809Header.Version = new JT809Header_Version(reader.ReadArray(JT809Header_Version.FixedByteLength)); - jT809Header.EncryptFlag = (JT809Header_Encrypt)reader.ReadByte(); - jT809Header.EncryptKey = reader.ReadUInt32(); - return jT809Header; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809Header value, IJT809Config config) - { - writer.WriteUInt32(value.MsgLength); - writer.WriteUInt32( value.MsgSN); - writer.WriteUInt16(value.BusinessType); - writer.WriteUInt32(value.MsgGNSSCENTERID); - writer.WriteArray(value.Version.Buffer); - writer.WriteByte((byte)value.EncryptFlag); - writer.WriteUInt32(value.EncryptKey); - } - } -} diff --git a/src/JT809.Protocol/Formatters/JT809HeaderPackageFormatter.cs b/src/JT809.Protocol/Formatters/JT809HeaderPackageFormatter.cs deleted file mode 100644 index 3004c92..0000000 --- a/src/JT809.Protocol/Formatters/JT809HeaderPackageFormatter.cs +++ /dev/null @@ -1,72 +0,0 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Exceptions; -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; -using System; - -namespace JT809.Protocol.Formatters -{ - public class JT809HeaderPackageFormatter : IJT809MessagePackFormatter - { - public readonly static JT809HeaderPackageFormatter Instance = new JT809HeaderPackageFormatter(); - public JT809HeaderPackage Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - // 1. 验证校验码 - if (!config.SkipCRCCode) - { - // 1.2. 验证校验码 - if (!reader.CheckXorCodeVali) - { - throw new JT809Exception(JT809ErrorCode.CRC16CheckInvalid, $"{reader.CalculateCheckXorCode.ToString()}!={reader.RealCheckXorCode.ToString()}"); - } - } - JT809HeaderPackage jT809Package = new JT809HeaderPackage(); - // 2.读取起始头 - jT809Package.BeginFlag = reader.ReadStart(); - // 3.初始化消息头 - try - { - jT809Package.Header = JT809HeaderFormatter.Instance.Deserialize(ref reader, config); - } - catch (Exception ex) - { - throw new JT809Exception(JT809ErrorCode.HeaderParseError, $"offset>{reader.ReadCurrentRemainContentLength().ToString()}", ex); - } - // 5.数据体处理 - // 5.1 判断是否有数据体(总长度-固定长度)> 0 - if ((jT809Package.Header.MsgLength - JT809Package.FixedByteLength) > 0) - { - try - { - // 5.2 是否加密 - switch (jT809Package.Header.EncryptFlag) - { - case JT809Header_Encrypt.None: - // 5.3 处理消息体 - jT809Package.Bodies = reader.ReadContent().ToArray(); - break; - case JT809Header_Encrypt.Common: - // 5.4. 处理加密消息体 - byte[] bodiesData = config.Encrypt.Decrypt(reader.ReadContent(), config.EncryptOptions, jT809Package.Header.EncryptKey); - jT809Package.Bodies = bodiesData; - break; - } - } - catch (Exception ex) - { - throw new JT809Exception(JT809ErrorCode.BodiesParseError, $"offset>{reader.ReadCurrentRemainContentLength().ToString()}", ex); - } - } - jT809Package.CRCCode = reader.CalculateCheckXorCode; - jT809Package.EndFlag = reader.ReadEnd(); - return jT809Package; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809HeaderPackage value, IJT809Config config) - { - throw new NotImplementedException("只适用反序列化"); - } - } -} diff --git a/src/JT809.Protocol/Formatters/JT809PackageFormatter.cs b/src/JT809.Protocol/Formatters/JT809PackageFormatter.cs deleted file mode 100644 index 15a6e0b..0000000 --- a/src/JT809.Protocol/Formatters/JT809PackageFormatter.cs +++ /dev/null @@ -1,157 +0,0 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Exceptions; -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.Internal; -using JT809.Protocol.MessagePack; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters -{ - public class JT809PackageFormatter : IJT809MessagePackFormatter - { - public readonly static JT809PackageFormatter Instance = new JT809PackageFormatter(); - public JT809Package Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - // 1. 验证校验码 - if (!config.SkipCRCCode) - { - // 1.2. 验证校验码 - if (!reader.CheckXorCodeVali) - { - throw new JT809Exception(JT809ErrorCode.CRC16CheckInvalid, $"{reader.CalculateCheckXorCode.ToString()}!={reader.RealCheckXorCode.ToString()}"); - } - } - JT809Package jT809Package = new JT809Package(); - // 2.读取起始头 - jT809Package.BeginFlag = reader.ReadStart(); - // 3.初始化消息头 - try - { - jT809Package.Header = JT809HeaderFormatter.Instance.Deserialize(ref reader, config); - } - catch (Exception ex) - { - throw new JT809Exception(JT809ErrorCode.HeaderParseError, $"offset>{reader.ReadCurrentRemainContentLength().ToString()}", ex); - } - // 5.数据体处理 - // 5.1 判断是否有数据体(总长度-固定长度)> 0 - if ((jT809Package.Header.MsgLength - JT809Package.FixedByteLength) > 0) - { - try - { - Type jT809BodiesImplType = config.BusinessTypeFactory.GetBodiesImplTypeByBusinessType(jT809Package.Header.BusinessType, jT809Package.Header.MsgGNSSCENTERID); - if (jT809BodiesImplType != null) - { - // 5.2 是否加密 - switch (jT809Package.Header.EncryptFlag) - { - case JT809Header_Encrypt.None: - // 5.3 处理消息体 - jT809Package.Bodies = JT809MessagePackFormatterResolverExtensions.JT809DynamicDeserialize( - config.GetMessagePackFormatterByType(jT809BodiesImplType), - ref reader, config); - break; - case JT809Header_Encrypt.Common: - // 5.4. 处理加密消息体 - byte[] bodiesData = config.Encrypt.Decrypt(reader.ReadContent(), config.EncryptOptions, jT809Package.Header.EncryptKey); - JT809MessagePackReader bodiesReader = new JT809MessagePackReader(bodiesData); - jT809Package.Bodies = JT809MessagePackFormatterResolverExtensions.JT809DynamicDeserialize( - config.GetMessagePackFormatterByType(jT809BodiesImplType), - ref bodiesReader, config); - break; - } - } - } - catch (Exception ex) - { - throw new JT809Exception(JT809ErrorCode.BodiesParseError, $"offset>{reader.ReadCurrentRemainContentLength().ToString()}", ex); - } - } - jT809Package.CRCCode = reader.CalculateCheckXorCode; - jT809Package.EndFlag = reader.ReadEnd(); - return jT809Package; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809Package value, IJT809Config config) - { - // -----------开始组包---------- - // 1.起始符 - writer.WriteByte(value.BeginFlag); - // 2.写入头部数据 - // 2.1.跳过数据长度的写入 - writer.Skip(4, out int lengthPosition); - // 2.2.报文序列号 - value.Header.MsgSN = value.Header.MsgSN > 0 ? value.Header.MsgSN : config.MsgSNDistributed.Increment(); - writer.WriteUInt32(value.Header.MsgSN); - // 2.3.业务数据类型 - writer.WriteUInt16(value.Header.BusinessType); - // 2.4.下级平台接入码 - writer.WriteUInt32(value.Header.MsgGNSSCENTERID); - // 2.5.版本号 - writer.WriteArray(value.Header.Version.Buffer); - // 2.6.报文加密 - writer.WriteByte((byte)value.Header.EncryptFlag); - // 2.7.数据加密密钥 - writer.WriteUInt32(value.Header.EncryptKey); - // 3.写入数据体 - // 3.1.记录当前开始位置 - int startIndex = writer.GetCurrentPosition(); - // 3.2.写入数据对应数据体 - if (value.Bodies != null) - { - JT809MessagePackFormatterResolverExtensions.JT809DynamicSerialize( - config.GetMessagePackFormatterByType(value.Bodies.GetType()), - ref writer, value.Bodies, - config); - } - // 3.3.记录当前结束位置 - int endIndex = writer.GetCurrentPosition(); - int contentLength = endIndex - startIndex; - if (contentLength > 0) - { - // 3.4. 数据加密 - switch (value.Header.EncryptFlag) - { - case JT809Header_Encrypt.None: - break; - case JT809Header_Encrypt.Common: - // 3.5. 提取数据体并进行加密处理 - byte[] messageBodyDatEncrypted = config.Encrypt.Encrypt(writer.Extract(startIndex), config.EncryptOptions, value.Header.EncryptKey); - int flagLength = messageBodyDatEncrypted.Length - contentLength; - if (flagLength == 0) - { - // 相等复制 - writer.CopyTo(messageBodyDatEncrypted, startIndex); - } - else if (flagLength > 0) - { - // 扩容 - writer.Skip(flagLength, out _); - writer.CopyTo(messageBodyDatEncrypted, startIndex); - } - else - { - // 缩减 - writer.CopyTo(messageBodyDatEncrypted, startIndex); - writer.Shrink(-flagLength); - } - break; - } - } - // 4.计算内容的总长度(校验码2+终止符1=3) - writer.WriteInt32Return(writer.GetCurrentPosition() + 3, lengthPosition); - // 5.校验码 - writer.WriteCRC16(); - // 6.终止符 - writer.WriteByte(value.EndFlag); - // 7.转义 - writer.WriteEncode(); - // -----------组包完成---------- - } - } -} diff --git a/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x1001_Formatter.cs b/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x1001_Formatter.cs deleted file mode 100644 index 50eaf6c..0000000 --- a/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x1001_Formatter.cs +++ /dev/null @@ -1,34 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessageBody; -using JT809.Protocol.MessagePack; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.MessageBodyFormatters -{ - public class JT809_0x1001_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x1001_Formatter Instance = new JT809_0x1001_Formatter(); - - 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.DownLinkIP = reader.ReadString(32); - jT809_0X1001.DownLinkPort = reader.ReadUInt16(); - return jT809_0X1001; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1001 value, IJT809Config config) - { - writer.WriteUInt32(value.UserId); - writer.WriteStringPadRight(value.Password, 8); - writer.WriteStringPadRight(value.DownLinkIP, 32); - writer.WriteUInt16(value.DownLinkPort); - } - } -} diff --git a/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x1002_Formatter.cs b/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x1002_Formatter.cs deleted file mode 100644 index 47e8d35..0000000 --- a/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x1002_Formatter.cs +++ /dev/null @@ -1,31 +0,0 @@ -using JT809.Protocol.Enums; -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessageBody; -using JT809.Protocol.MessagePack; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.MessageBodyFormatters -{ - public class JT809_0x1002_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x1002_Formatter Instance = new JT809_0x1002_Formatter(); - - 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; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1002 value, IJT809Config config) - { - writer.WriteByte((byte)value.Result); - writer.WriteUInt32(value.VerifyCode); - } - } -} diff --git a/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x1003_Formatter.cs b/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x1003_Formatter.cs deleted file mode 100644 index 4477136..0000000 --- a/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x1003_Formatter.cs +++ /dev/null @@ -1,29 +0,0 @@ -using JT809.Protocol.Enums; -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessageBody; -using JT809.Protocol.MessagePack; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.MessageBodyFormatters -{ - public class JT809_0x1003_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x1003_Formatter Instance = new JT809_0x1003_Formatter(); - 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; - } - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1003 value, IJT809Config config) - { - writer.WriteUInt32(value.UserId); - writer.WriteStringPadLeft(value.Password, 8); - } - } -} diff --git a/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x1007_Formatter.cs b/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x1007_Formatter.cs deleted file mode 100644 index 30f8b96..0000000 --- a/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x1007_Formatter.cs +++ /dev/null @@ -1,29 +0,0 @@ -using JT809.Protocol.Enums; -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessageBody; -using JT809.Protocol.MessagePack; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.MessageBodyFormatters -{ - public class JT809_0x1007_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x1007_Formatter Instance = new JT809_0x1007_Formatter(); - - 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; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1007 value, IJT809Config config) - { - writer.WriteByte((byte)value.ErrorCode); - } - } -} diff --git a/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x1008_Formatter.cs b/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x1008_Formatter.cs deleted file mode 100644 index a15227b..0000000 --- a/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x1008_Formatter.cs +++ /dev/null @@ -1,29 +0,0 @@ -using JT809.Protocol.Enums; -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessageBody; -using JT809.Protocol.MessagePack; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.MessageBodyFormatters -{ - public class JT809_0x1008_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x1008_Formatter Instance = new JT809_0x1008_Formatter(); - - 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; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1008 value, IJT809Config config) - { - writer.WriteByte((byte)value.ReasonCode); - } - } -} diff --git a/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x1300_Formatter.cs b/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x1300_Formatter.cs deleted file mode 100644 index 1b675a3..0000000 --- a/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x1300_Formatter.cs +++ /dev/null @@ -1,64 +0,0 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Exceptions; -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessageBody; -using JT809.Protocol.MessagePack; -using JT809.Protocol.Internal; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.MessageBodyFormatters -{ - public class JT809_0x1300_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x1300_Formatter Instance = new JT809_0x1300_Formatter(); - - public JT809_0x1300 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x1300 jT809_0X1300 = new JT809_0x1300(); - jT809_0X1300.SubBusinessType = reader.ReadUInt16(); - jT809_0X1300.DataLength = reader.ReadUInt32(); - try - { - //JT809.Protocol.Enums.JT809BusinessType 映射对应消息特性 - Type jT809SubBodiesImplType = config.SubBusinessTypeFactory.GetSubBodiesImplTypeBySubBusinessType(jT809_0X1300.SubBusinessType); - if (jT809SubBodiesImplType != null) - jT809_0X1300.SubBodies = JT809MessagePackFormatterResolverExtensions.JT809DynamicDeserialize( - config.GetMessagePackFormatterByType(jT809SubBodiesImplType), - ref reader, config); - } - catch - { - throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{jT809_0X1300.SubBusinessType.ToString()}"); - } - return jT809_0X1300; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1300 value, IJT809Config config) - { - writer.WriteUInt16(value.SubBusinessType); - //JT809.Protocol.Enums.JT809BusinessType 映射对应消息特性 - try - { - // 先写入内容,然后在根据内容反写内容长度 - writer.Skip(4, out int subContentLengthPosition); - if (value.SubBodies != null) - { - JT809MessagePackFormatterResolverExtensions.JT809DynamicSerialize( - config.GetMessagePackFormatterByType(value.SubBodies.GetType()), - ref writer, value.SubBodies, - config); - } - writer.WriteInt32Return(writer.GetCurrentPosition() - subContentLengthPosition - 4, subContentLengthPosition); - } - catch(Exception ex) - { - throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}",ex); - } - } - } -} diff --git a/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x9001_Formatter.cs b/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x9001_Formatter.cs deleted file mode 100644 index 5b7feaf..0000000 --- a/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x9001_Formatter.cs +++ /dev/null @@ -1,28 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessageBody; -using JT809.Protocol.MessagePack; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.MessageBodyFormatters -{ - public class JT809_0x9001_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x9001_Formatter Instance = new JT809_0x9001_Formatter(); - - public JT809_0x9001 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x9001 jT809_0X9001 = new JT809_0x9001(); - jT809_0X9001.VerifyCode = reader.ReadUInt32(); - return jT809_0X9001; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9001 value, IJT809Config config) - { - writer.WriteUInt32(value.VerifyCode); - } - } -} diff --git a/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x9002_Formatter.cs b/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x9002_Formatter.cs deleted file mode 100644 index 62aebc4..0000000 --- a/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x9002_Formatter.cs +++ /dev/null @@ -1,29 +0,0 @@ -using JT809.Protocol.Enums; -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessageBody; -using JT809.Protocol.MessagePack; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.MessageBodyFormatters -{ - public class JT809_0x9002_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x9002_Formatter Instance = new JT809_0x9002_Formatter(); - - 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; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9002 value, IJT809Config config) - { - writer.WriteByte((byte)value.Result); - } - } -} diff --git a/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x9003_Formatter.cs b/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x9003_Formatter.cs deleted file mode 100644 index 551f30b..0000000 --- a/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x9003_Formatter.cs +++ /dev/null @@ -1,28 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessageBody; -using JT809.Protocol.MessagePack; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.MessageBodyFormatters -{ - public class JT809_0x9003_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x9003_Formatter Instance = new JT809_0x9003_Formatter(); - - public JT809_0x9003 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x9003 jT809_0X9003 = new JT809_0x9003(); - jT809_0X9003.VerifyCode = reader.ReadUInt32(); - return jT809_0X9003; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9003 value, IJT809Config config) - { - writer.WriteUInt32(value.VerifyCode); - } - } -} diff --git a/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x9007_Formatter.cs b/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x9007_Formatter.cs deleted file mode 100644 index ccd49fa..0000000 --- a/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x9007_Formatter.cs +++ /dev/null @@ -1,29 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Enums; -using JT809.Protocol.MessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; - -namespace JT809.Protocol.Formatters.MessageBodyFormatters -{ - public class JT809_0x9007_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x9007_Formatter Instance = new JT809_0x9007_Formatter(); - - 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; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9007 value, IJT809Config config) - { - writer.WriteByte((byte)value.ReasonCode); - } - } -} diff --git a/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x9008_Formatter.cs b/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x9008_Formatter.cs deleted file mode 100644 index 30062ea..0000000 --- a/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x9008_Formatter.cs +++ /dev/null @@ -1,29 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Enums; -using JT809.Protocol.MessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; - -namespace JT809.Protocol.Formatters.MessageBodyFormatters -{ - public class JT809_0x9008_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x9008_Formatter Instance = new JT809_0x9008_Formatter(); - - 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; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9008 value, IJT809Config config) - { - writer.WriteByte((byte)value.ReasonCode); - } - } -} diff --git a/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x9101_Formatter.cs b/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x9101_Formatter.cs deleted file mode 100644 index bb01f20..0000000 --- a/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x9101_Formatter.cs +++ /dev/null @@ -1,32 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessageBody; -using JT809.Protocol.MessagePack; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.MessageBodyFormatters -{ - public class JT809_0x9101_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x9101_Formatter Instance = new JT809_0x9101_Formatter(); - - public JT809_0x9101 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x9101 jT809_0X9101 = new JT809_0x9101(); - jT809_0X9101.DynamicInfoTotal = reader.ReadUInt32(); - jT809_0X9101.StartTime = reader.ReadUInt64(); - jT809_0X9101.EndTime = reader.ReadUInt64(); - return jT809_0X9101; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9101 value, IJT809Config config) - { - writer.WriteUInt32(value.DynamicInfoTotal); - writer.WriteUInt64(value.StartTime); - writer.WriteUInt64(value.EndTime); - } - } -} diff --git a/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x9300_Formatter.cs b/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x9300_Formatter.cs deleted file mode 100644 index ce1bf39..0000000 --- a/src/JT809.Protocol/Formatters/MessageBodyFormatters/JT809_0x9300_Formatter.cs +++ /dev/null @@ -1,64 +0,0 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Exceptions; -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.Internal; -using JT809.Protocol.MessageBody; -using JT809.Protocol.MessagePack; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.MessageBodyFormatters -{ - public class JT809_0x9300_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x9300_Formatter Instance = new JT809_0x9300_Formatter(); - - public JT809_0x9300 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x9300 jT809_0X9300 = new JT809_0x9300(); - jT809_0X9300.SubBusinessType =reader.ReadUInt16(); - jT809_0X9300.DataLength = reader.ReadUInt32(); - //JT809.Protocol.Enums.JT809BusinessType 映射对应消息特性 - try - { - Type jT809SubBodiesImplType = config.SubBusinessTypeFactory.GetSubBodiesImplTypeBySubBusinessType(jT809_0X9300.SubBusinessType); - if (jT809SubBodiesImplType != null) - jT809_0X9300.SubBodies = JT809MessagePackFormatterResolverExtensions.JT809DynamicDeserialize( - config.GetMessagePackFormatterByType(jT809SubBodiesImplType), - ref reader, config); - } - catch - { - throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{jT809_0X9300.SubBusinessType.ToString()}"); - } - return jT809_0X9300; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9300 value, IJT809Config config) - { - writer.WriteUInt16(value.SubBusinessType); - //JT809.Protocol.Enums.JT809BusinessType 映射对应消息特性 - try - { - // 先写入内容,然后在根据内容反写内容长度 - writer.Skip(4, out int subContentLengthPosition); - if (value.SubBodies != null) - { - JT809MessagePackFormatterResolverExtensions.JT809DynamicSerialize( - config.GetMessagePackFormatterByType(value.SubBodies.GetType()), - ref writer, value.SubBodies, - config); - } - writer.WriteInt32Return(writer.GetCurrentPosition() - subContentLengthPosition - 4, subContentLengthPosition); - } - catch - { - throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}"); - } - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1200_0x1201_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1200_0x1201_Formatter.cs deleted file mode 100644 index 275016a..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1200_0x1201_Formatter.cs +++ /dev/null @@ -1,38 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.SubMessageBody; -using JT809.Protocol.Enums; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x1200_0x1201_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x1200_0x1201_Formatter Instance = new JT809_0x1200_0x1201_Formatter(); - - public JT809_0x1200_0x1201 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x1200_0x1201 jT809_0X1200_0X1201 = new JT809_0x1200_0x1201(); - jT809_0X1200_0X1201.PlateformId = reader.ReadBigNumber(11); - jT809_0X1200_0X1201.ProducerId = reader.ReadBigNumber(11); - jT809_0X1200_0X1201.TerminalModelType = reader.ReadString(20); - jT809_0X1200_0X1201.TerminalId = reader.ReadString(7); - jT809_0X1200_0X1201.TerminalId = jT809_0X1200_0X1201.TerminalId.ToUpper(); - jT809_0X1200_0X1201.TerminalSimCode = reader.ReadString(12); - return jT809_0X1200_0X1201; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1200_0x1201 value, IJT809Config config) - { - writer.WriteBigNumber(value.PlateformId, 11); - writer.WriteBigNumber(value.ProducerId, 11); - writer.WriteStringPadRight(value.TerminalModelType, 20); - writer.WriteStringPadRight(value.TerminalId.ToUpper(), 7); - writer.WriteStringPadRight(value.TerminalSimCode, 12); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1200_0x1202_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1200_0x1202_Formatter.cs deleted file mode 100644 index 46c0cd1..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1200_0x1202_Formatter.cs +++ /dev/null @@ -1,59 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.SubMessageBody; -using JT809.Protocol.Enums; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x1200_0x1202_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x1200_0x1202_Formatter Instance = new JT809_0x1200_0x1202_Formatter(); - - public JT809_0x1200_0x1202 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x1200_0x1202 jT809_0X1200_0X1202 = new JT809_0x1200_0x1202(); - jT809_0X1200_0X1202.VehiclePosition.Encrypt = (JT809_VehiclePositionEncrypt)reader.ReadByte(); - jT809_0X1200_0X1202.VehiclePosition.Day = reader.ReadByte(); - jT809_0X1200_0X1202.VehiclePosition.Month = reader.ReadByte(); - jT809_0X1200_0X1202.VehiclePosition.Year = reader.ReadUInt16(); - jT809_0X1200_0X1202.VehiclePosition.Hour = reader.ReadByte(); - jT809_0X1200_0X1202.VehiclePosition.Minute = reader.ReadByte(); - jT809_0X1200_0X1202.VehiclePosition.Second = reader.ReadByte(); - jT809_0X1200_0X1202.VehiclePosition.Lon = reader.ReadUInt32(); - jT809_0X1200_0X1202.VehiclePosition.Lat = reader.ReadUInt32(); - jT809_0X1200_0X1202.VehiclePosition.Vec1 = reader.ReadUInt16(); - jT809_0X1200_0X1202.VehiclePosition.Vec2 = reader.ReadUInt16(); - jT809_0X1200_0X1202.VehiclePosition.Vec3 = reader.ReadUInt32(); - jT809_0X1200_0X1202.VehiclePosition.Direction = reader.ReadUInt16(); - jT809_0X1200_0X1202.VehiclePosition.Altitude = reader.ReadUInt16(); - jT809_0X1200_0X1202.VehiclePosition.State = reader.ReadUInt32(); - jT809_0X1200_0X1202.VehiclePosition.Alarm = reader.ReadUInt32(); - return jT809_0X1200_0X1202; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1200_0x1202 value, IJT809Config config) - { - writer.WriteByte((byte)value.VehiclePosition.Encrypt); - writer.WriteByte(value.VehiclePosition.Day); - writer.WriteByte(value.VehiclePosition.Month); - writer.WriteUInt16(value.VehiclePosition.Year); - writer.WriteByte(value.VehiclePosition.Hour); - writer.WriteByte(value.VehiclePosition.Minute); - writer.WriteByte(value.VehiclePosition.Second); - writer.WriteUInt32(value.VehiclePosition.Lon); - writer.WriteUInt32(value.VehiclePosition.Lat); - writer.WriteUInt16(value.VehiclePosition.Vec1); - writer.WriteUInt16(value.VehiclePosition.Vec2); - writer.WriteUInt32(value.VehiclePosition.Vec3); - writer.WriteUInt16(value.VehiclePosition.Direction); - writer.WriteUInt16(value.VehiclePosition.Altitude); - writer.WriteUInt32(value.VehiclePosition.State); - writer.WriteUInt32(value.VehiclePosition.Alarm); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1200_0x1203_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1200_0x1203_Formatter.cs deleted file mode 100644 index b2da99c..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1200_0x1203_Formatter.cs +++ /dev/null @@ -1,58 +0,0 @@ -using JT809.Protocol.Enums; -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; -using JT809.Protocol.Metadata; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x1200_0x1203_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x1200_0x1203_Formatter Instance = new JT809_0x1200_0x1203_Formatter(); - - public JT809_0x1200_0x1203 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x1200_0x1203 jT809_0X1200_0X1203 = new JT809_0x1200_0x1203(); - jT809_0X1200_0X1203.GNSSCount = reader.ReadByte(); - jT809_0X1200_0X1203.GNSS = new List(); - if (jT809_0X1200_0X1203.GNSSCount > 0) - { - for (int i = 0; i < jT809_0X1200_0X1203.GNSSCount; i++) - { - try - { - JT809MessagePackReader jT809_0x1200_0x1202Reader = new JT809MessagePackReader(reader.ReadArray(36)); - var jT809_0x1200_0x1202= JT809_0x1200_0x1202_Formatter.Instance.Deserialize(ref jT809_0x1200_0x1202Reader, config); - jT809_0X1200_0X1203.GNSS.Add(jT809_0x1200_0x1202); - } - catch (Exception) - { - - } - } - } - return jT809_0X1200_0X1203; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1200_0x1203 value, IJT809Config config) - { - writer.WriteByte((byte)value.GNSS.Count); - foreach (var item in value.GNSS) - { - try - { - JT809_0x1200_0x1202_Formatter.Instance.Serialize(ref writer, item, config); - } - catch (Exception ex) - { - - } - } - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1200_0x1207_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1200_0x1207_Formatter.cs deleted file mode 100644 index 211b245..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1200_0x1207_Formatter.cs +++ /dev/null @@ -1,30 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x1200_0x1207_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x1200_0x1207_Formatter Instance = new JT809_0x1200_0x1207_Formatter(); - - public JT809_0x1200_0x1207 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x1200_0x1207 jT809_0X1200_0X1207 = new JT809_0x1200_0x1207(); - jT809_0X1200_0X1207.StartTime = reader.ReadUTCDateTime(); - jT809_0X1200_0X1207.EndTime = reader.ReadUTCDateTime(); - return jT809_0X1200_0X1207; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1200_0x1207 value, IJT809Config config) - { - writer.WriteUTCDateTime(value.StartTime); - writer.WriteUTCDateTime(value.EndTime); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1200_0x1209_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1200_0x1209_Formatter.cs deleted file mode 100644 index 6fbbd11..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1200_0x1209_Formatter.cs +++ /dev/null @@ -1,30 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x1200_0x1209_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x1200_0x1209_Formatter Instance = new JT809_0x1200_0x1209_Formatter(); - - public JT809_0x1200_0x1209 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x1200_0x1209 jT809_0X1200_0X1207 = new JT809_0x1200_0x1209(); - jT809_0X1200_0X1207.StartTime = reader.ReadUTCDateTime(); - jT809_0X1200_0X1207.EndTime = reader.ReadUTCDateTime(); - return jT809_0X1200_0X1207; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1200_0x1209 value, IJT809Config config) - { - writer.WriteUTCDateTime(value.StartTime); - writer.WriteUTCDateTime(value.EndTime); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1200_0x120A_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1200_0x120A_Formatter.cs deleted file mode 100644 index a596065..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1200_0x120A_Formatter.cs +++ /dev/null @@ -1,34 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x1200_0x120A_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x1200_0x120A_Formatter Instance = new JT809_0x1200_0x120A_Formatter(); - - public JT809_0x1200_0x120A Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x1200_0x120A jT809_0X1200_0X120A = new JT809_0x1200_0x120A(); - jT809_0X1200_0X120A.DriverName = reader.ReadString(16); - jT809_0X1200_0X120A.DriverID = reader.ReadString(20); - jT809_0X1200_0X120A.Licence = reader.ReadString(40); - jT809_0X1200_0X120A.OrgName = reader.ReadString(200); - return jT809_0X1200_0X120A; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1200_0x120A value, IJT809Config config) - { - writer.WriteStringPadRight(value.DriverName, 16); - writer.WriteStringPadRight(value.DriverID, 20); - writer.WriteStringPadRight(value.Licence, 40); - writer.WriteStringPadRight(value.OrgName, 200); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1200_0x120B_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1200_0x120B_Formatter.cs deleted file mode 100644 index 99c181f..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1200_0x120B_Formatter.cs +++ /dev/null @@ -1,30 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x1200_0x120B_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x1200_0x120B_Formatter Instance = new JT809_0x1200_0x120B_Formatter(); - - public JT809_0x1200_0x120B Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x1200_0x120B jT809_0X1200_0X120B = new JT809_0x1200_0x120B(); - jT809_0X1200_0X120B.EwaybillLength = reader.ReadUInt32(); - jT809_0X1200_0X120B.EwaybillInfo = reader.ReadString((int)jT809_0X1200_0X120B.EwaybillLength); - return jT809_0X1200_0X120B; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1200_0x120B value, IJT809Config config) - { - writer.WriteUInt32((uint)value.EwaybillInfo.Length); - writer.WriteString(value.EwaybillInfo); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1200_0x120C_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1200_0x120C_Formatter.cs deleted file mode 100644 index 4b3f70e..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1200_0x120C_Formatter.cs +++ /dev/null @@ -1,34 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x1200_0x120C_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x1200_0x120C_Formatter Instance = new JT809_0x1200_0x120C_Formatter(); - - public JT809_0x1200_0x120C Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x1200_0x120C jT809_0X1200_0X120C = new JT809_0x1200_0x120C(); - jT809_0X1200_0X120C.DriverName = reader.ReadString(16); - jT809_0X1200_0X120C.DriverID = reader.ReadString(20); - jT809_0X1200_0X120C.Licence = reader.ReadString(40); - jT809_0X1200_0X120C.OrgName = reader.ReadString(200); - return jT809_0X1200_0X120C; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1200_0x120C value, IJT809Config config) - { - writer.WriteStringPadRight(value.DriverName, 16); - writer.WriteStringPadRight(value.DriverID, 20); - writer.WriteStringPadRight(value.Licence, 40); - writer.WriteStringPadRight(value.OrgName, 200); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1200_0x120D_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1200_0x120D_Formatter.cs deleted file mode 100644 index b767fe9..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1200_0x120D_Formatter.cs +++ /dev/null @@ -1,30 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x1200_0x120D_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x1200_0x120D_Formatter Instance = new JT809_0x1200_0x120D_Formatter(); - - public JT809_0x1200_0x120D Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x1200_0x120D jT809_0X1200_0X120D = new JT809_0x1200_0x120D(); - jT809_0X1200_0X120D.EwaybillLength = reader.ReadUInt32(); - jT809_0X1200_0X120D.EwaybillInfo = reader.ReadString((int)jT809_0X1200_0X120D.EwaybillLength); - return jT809_0X1200_0X120D; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1200_0x120D value, IJT809Config config) - { - writer.WriteUInt32((uint)value.EwaybillInfo.Length); - writer.WriteString(value.EwaybillInfo); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1300_0x1301_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1300_0x1301_Formatter.cs deleted file mode 100644 index d3dbc48..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1300_0x1301_Formatter.cs +++ /dev/null @@ -1,39 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Enums; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x1300_0x1301_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x1300_0x1301_Formatter Instance = new JT809_0x1300_0x1301_Formatter(); - - public JT809_0x1300_0x1301 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x1300_0x1301 jT809_0X1200_0X1301 = new JT809_0x1300_0x1301(); - jT809_0X1200_0X1301.ObjectType = (JT809_0x1301_ObjectType)reader.ReadByte(); - jT809_0X1200_0X1301.ObjectID = reader.ReadString(12); - jT809_0X1200_0X1301.InfoID = reader.ReadUInt32(); - jT809_0X1200_0X1301.InfoLength = reader.ReadUInt32(); - jT809_0X1200_0X1301.InfoContent = reader.ReadString((int)jT809_0X1200_0X1301.InfoLength); - return jT809_0X1200_0X1301; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1300_0x1301 value, IJT809Config config) - { - writer.WriteByte((byte)value.ObjectType); - writer.WriteStringPadRight(value.ObjectID, 12); - writer.WriteUInt32(value.InfoID); - // 先计算内容长度(汉字为两个字节) - writer.Skip(4, out int lengthPosition); - writer.WriteString(value.InfoContent); - writer.WriteInt32Return(writer.GetCurrentPosition() - lengthPosition - 4, lengthPosition); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1300_0x1302_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1300_0x1302_Formatter.cs deleted file mode 100644 index 572d420..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1300_0x1302_Formatter.cs +++ /dev/null @@ -1,28 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x1300_0x1302_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x1300_0x1302_Formatter Instance = new JT809_0x1300_0x1302_Formatter(); - - public JT809_0x1300_0x1302 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x1300_0x1302 jT809_0X1200_0X1302 = new JT809_0x1300_0x1302(); - jT809_0X1200_0X1302.InfoID = reader.ReadUInt32(); - return jT809_0X1200_0X1302; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1300_0x1302 value, IJT809Config config) - { - writer.WriteUInt32(value.InfoID); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1400_0x1401_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1400_0x1401_Formatter.cs deleted file mode 100644 index 5c30359..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1400_0x1401_Formatter.cs +++ /dev/null @@ -1,31 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Enums; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x1400_0x1401_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x1400_0x1401_Formatter Instance = new JT809_0x1400_0x1401_Formatter(); - - public JT809_0x1400_0x1401 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x1400_0x1401 jT809_0X1400_0X1401 = new JT809_0x1400_0x1401(); - jT809_0X1400_0X1401.SupervisionID = reader.ReadUInt32(); - jT809_0X1400_0X1401.Result = (JT809_0x1401_Result)reader.ReadByte(); - return jT809_0X1400_0X1401; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1400_0x1401 value, IJT809Config config) - { - writer.WriteUInt32(value.SupervisionID); - writer.WriteByte((byte)value.Result); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1400_0x1402_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1400_0x1402_Formatter.cs deleted file mode 100644 index 87e8c83..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1400_0x1402_Formatter.cs +++ /dev/null @@ -1,41 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Enums; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x1400_0x1402_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x1400_0x1402_Formatter Instance = new JT809_0x1400_0x1402_Formatter(); - - public JT809_0x1400_0x1402 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x1400_0x1402 jT809_0X1400_0X1402 = new JT809_0x1400_0x1402(); - jT809_0X1400_0X1402.WarnSrc = (JT809WarnSrc)reader.ReadByte(); - jT809_0X1400_0X1402.WarnType = (JT809WarnType)reader.ReadUInt16(); - jT809_0X1400_0X1402.WarnTime = reader.ReadUTCDateTime(); - jT809_0X1400_0X1402.InfoID = reader.ReadUInt32(); - jT809_0X1400_0X1402.InfoLength = reader.ReadUInt32(); - jT809_0X1400_0X1402.InfoContent = reader.ReadString((int)jT809_0X1400_0X1402.InfoLength); - return jT809_0X1400_0X1402; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1400_0x1402 value, IJT809Config config) - { - writer.WriteByte((byte)value.WarnSrc); - writer.WriteUInt16((ushort)value.WarnType); - writer.WriteUTCDateTime(value.WarnTime); - writer.WriteUInt32(value.InfoID); - // 先计算内容长度(汉字为两个字节) - writer.Skip(4, out int lengthPosition); - writer.WriteString(value.InfoContent); - writer.WriteInt32Return(writer.GetCurrentPosition() - lengthPosition - 4, lengthPosition); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1400_0x1403_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1400_0x1403_Formatter.cs deleted file mode 100644 index ec5ed21..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1400_0x1403_Formatter.cs +++ /dev/null @@ -1,31 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Enums; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x1400_0x1403_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x1400_0x1403_Formatter Instance = new JT809_0x1400_0x1403_Formatter(); - - public JT809_0x1400_0x1403 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x1400_0x1403 jT809_0X1400_0X1403 = new JT809_0x1400_0x1403(); - jT809_0X1400_0X1403.InfoID = reader.ReadUInt32(); - jT809_0X1400_0X1403.Result = (JT809_0x1403_Result)reader.ReadByte(); - return jT809_0X1400_0X1403; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1400_0x1403 value, IJT809Config config) - { - writer.WriteUInt32(value.InfoID); - writer.WriteByte((byte)value.Result); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1500_0x1501_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1500_0x1501_Formatter.cs deleted file mode 100644 index 5a4103b..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1500_0x1501_Formatter.cs +++ /dev/null @@ -1,29 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Enums; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x1500_0x1501_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x1500_0x1501_Formatter Instance = new JT809_0x1500_0x1501_Formatter(); - - public JT809_0x1500_0x1501 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x1500_0x1501 jT809_0X1500_0X1501 = new JT809_0x1500_0x1501(); - jT809_0X1500_0X1501.Result = (JT809_0x1501_Result)reader.ReadByte(); - return jT809_0X1500_0X1501; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1500_0x1501 value, IJT809Config config) - { - writer.WriteByte((byte)value.Result); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1500_0x1502_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1500_0x1502_Formatter.cs deleted file mode 100644 index 38a9de4..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1500_0x1502_Formatter.cs +++ /dev/null @@ -1,78 +0,0 @@ -using JT809.Protocol.Enums; -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x1500_0x1502_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x1500_0x1502_Formatter Instance = new JT809_0x1500_0x1502_Formatter(); - - public JT809_0x1500_0x1502 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x1500_0x1502 jT809_0X1500_0X1502 = new JT809_0x1500_0x1502(); - jT809_0X1500_0X1502.PhotoRspFlag = (JT809_0x1502_PhotoRspFlag)reader.ReadByte(); - jT809_0X1500_0X1502.VehiclePosition.Encrypt = (JT809_VehiclePositionEncrypt)reader.ReadByte(); - jT809_0X1500_0X1502.VehiclePosition.Day = reader.ReadByte(); - jT809_0X1500_0X1502.VehiclePosition.Month = reader.ReadByte(); - jT809_0X1500_0X1502.VehiclePosition.Year = reader.ReadUInt16(); - jT809_0X1500_0X1502.VehiclePosition.Hour = reader.ReadByte(); - jT809_0X1500_0X1502.VehiclePosition.Minute = reader.ReadByte(); - jT809_0X1500_0X1502.VehiclePosition.Second = reader.ReadByte(); - jT809_0X1500_0X1502.VehiclePosition.Lon = reader.ReadUInt32(); - jT809_0X1500_0X1502.VehiclePosition.Lat = reader.ReadUInt32(); - jT809_0X1500_0X1502.VehiclePosition.Vec1 = reader.ReadUInt16(); - jT809_0X1500_0X1502.VehiclePosition.Vec2 = reader.ReadUInt16(); - jT809_0X1500_0X1502.VehiclePosition.Vec3 = reader.ReadUInt32(); - jT809_0X1500_0X1502.VehiclePosition.Direction = reader.ReadUInt16(); - jT809_0X1500_0X1502.VehiclePosition.Altitude = reader.ReadUInt16(); - jT809_0X1500_0X1502.VehiclePosition.State = reader.ReadUInt32(); - jT809_0X1500_0X1502.VehiclePosition.Alarm = reader.ReadUInt32(); - jT809_0X1500_0X1502.LensID = reader.ReadByte(); - jT809_0X1500_0X1502.PhotoLen = reader.ReadUInt32(); - jT809_0X1500_0X1502.SizeType = reader.ReadByte(); - jT809_0X1500_0X1502.Type = reader.ReadByte(); - if (jT809_0X1500_0X1502.PhotoLen > 0) - { - jT809_0X1500_0X1502.Photo = reader.ReadArray((int)jT809_0X1500_0X1502.PhotoLen).ToArray(); - } - return jT809_0X1500_0X1502; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1500_0x1502 value, IJT809Config config) - { - writer.WriteByte((byte)value.PhotoRspFlag); - writer.WriteByte((byte)value.VehiclePosition.Encrypt); - writer.WriteByte(value.VehiclePosition.Day); - writer.WriteByte(value.VehiclePosition.Month); - writer.WriteUInt16(value.VehiclePosition.Year); - writer.WriteByte(value.VehiclePosition.Hour); - writer.WriteByte(value.VehiclePosition.Minute); - writer.WriteByte(value.VehiclePosition.Second); - writer.WriteUInt32(value.VehiclePosition.Lon); - writer.WriteUInt32(value.VehiclePosition.Lat); - writer.WriteUInt16(value.VehiclePosition.Vec1); - writer.WriteUInt16(value.VehiclePosition.Vec2); - writer.WriteUInt32(value.VehiclePosition.Vec3); - writer.WriteUInt16(value.VehiclePosition.Direction); - writer.WriteUInt16(value.VehiclePosition.Altitude); - writer.WriteUInt32(value.VehiclePosition.State); - writer.WriteUInt32(value.VehiclePosition.Alarm); - writer.WriteByte(value.LensID); - bool isPhoto = (value.Photo != null && value.Photo.Length > 0); - writer.WriteUInt32(isPhoto ? (uint)value.Photo.Length : 0); - writer.WriteByte(value.SizeType); - writer.WriteByte(value.Type); - if (isPhoto) - { - writer.WriteArray(value.Photo); - } - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1500_0x1503_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1500_0x1503_Formatter.cs deleted file mode 100644 index b58c7fc..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1500_0x1503_Formatter.cs +++ /dev/null @@ -1,31 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Enums; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x1500_0x1503_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x1500_0x1503_Formatter Instance = new JT809_0x1500_0x1503_Formatter(); - - public JT809_0x1500_0x1503 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x1500_0x1503 jT809_0X1500_0X1503 = new JT809_0x1500_0x1503(); - jT809_0X1500_0X1503.MsgID = reader.ReadUInt32(); - jT809_0X1500_0X1503.Result = (JT809_0x1503_Result)reader.ReadByte(); - return jT809_0X1500_0X1503; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1500_0x1503 value, IJT809Config config) - { - writer.WriteUInt32(value.MsgID); - writer.WriteByte((byte)value.Result); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1500_0x1504_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1500_0x1504_Formatter.cs deleted file mode 100644 index d8d1d5c..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1500_0x1504_Formatter.cs +++ /dev/null @@ -1,35 +0,0 @@ -using JT809.Protocol.Enums; -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x1500_0x1504_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x1500_0x1504_Formatter Instance = new JT809_0x1500_0x1504_Formatter(); - - public JT809_0x1500_0x1504 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x1500_0x1504 jT809_0X1500_0X1504 = new JT809_0x1500_0x1504(); - jT809_0X1500_0X1504.CommandType = (JT809CommandType)reader.ReadByte(); - jT809_0X1500_0X1504.TraveldataLength = reader.ReadUInt32(); - jT809_0X1500_0X1504.TraveldataInfo = reader.ReadString((int)jT809_0X1500_0X1504.TraveldataLength); - return jT809_0X1500_0X1504; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1500_0x1504 value, IJT809Config config) - { - writer.WriteByte((byte)value.CommandType); - // 先计算内容长度(汉字为两个字节) - writer.Skip(4, out int lengthPosition); - writer.WriteString(value.TraveldataInfo); - writer.WriteInt32Return(writer.GetCurrentPosition() - lengthPosition - 4, lengthPosition); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1500_0x1505_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1500_0x1505_Formatter.cs deleted file mode 100644 index 346ef5b..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1500_0x1505_Formatter.cs +++ /dev/null @@ -1,29 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Enums; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x1500_0x1505_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x1500_0x1505_Formatter Instance = new JT809_0x1500_0x1505_Formatter(); - - public JT809_0x1500_0x1505 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x1500_0x1505 jT809_0X1500_0X1505 = new JT809_0x1500_0x1505(); - jT809_0X1500_0X1505.Result = (JT809_0x1505_Result)reader.ReadByte(); - return jT809_0X1500_0X1505; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1500_0x1505 value, IJT809Config config) - { - writer.WriteByte((byte)value.Result); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1600_0x1601_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1600_0x1601_Formatter.cs deleted file mode 100644 index 83a3015..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x1600_0x1601_Formatter.cs +++ /dev/null @@ -1,28 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x1600_0x1601_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x1600_0x1601_Formatter Instance = new JT809_0x1600_0x1601_Formatter(); - - public JT809_0x1600_0x1601 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x1600_0x1601 jT809_0X9600_0X1601 = new JT809_0x1600_0x1601(); - jT809_0X9600_0X1601.CarInfo = reader.ReadRemainStringContent(); - return jT809_0X9600_0X1601; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1600_0x1601 value, IJT809Config config) - { - writer.WriteString(value.CarInfo); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9200_0x9202_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9200_0x9202_Formatter.cs deleted file mode 100644 index 5356b83..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9200_0x9202_Formatter.cs +++ /dev/null @@ -1,59 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.SubMessageBody; -using JT809.Protocol.Enums; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x9200_0x9202_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x9200_0x9202_Formatter Instance = new JT809_0x9200_0x9202_Formatter(); - - public JT809_0x9200_0x9202 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x9200_0x9202 jT809_0X1200_0x9202 = new JT809_0x9200_0x9202(); - jT809_0X1200_0x9202.VehiclePosition.Encrypt = (JT809_VehiclePositionEncrypt)reader.ReadByte(); - jT809_0X1200_0x9202.VehiclePosition.Day = reader.ReadByte(); - jT809_0X1200_0x9202.VehiclePosition.Month = reader.ReadByte(); - jT809_0X1200_0x9202.VehiclePosition.Year = reader.ReadUInt16(); - jT809_0X1200_0x9202.VehiclePosition.Hour = reader.ReadByte(); - jT809_0X1200_0x9202.VehiclePosition.Minute = reader.ReadByte(); - jT809_0X1200_0x9202.VehiclePosition.Second = reader.ReadByte(); - jT809_0X1200_0x9202.VehiclePosition.Lon = reader.ReadUInt32(); - jT809_0X1200_0x9202.VehiclePosition.Lat = reader.ReadUInt32(); - jT809_0X1200_0x9202.VehiclePosition.Vec1 = reader.ReadUInt16(); - jT809_0X1200_0x9202.VehiclePosition.Vec2 = reader.ReadUInt16(); - jT809_0X1200_0x9202.VehiclePosition.Vec3 = reader.ReadUInt32(); - jT809_0X1200_0x9202.VehiclePosition.Direction = reader.ReadUInt16(); - jT809_0X1200_0x9202.VehiclePosition.Altitude = reader.ReadUInt16(); - jT809_0X1200_0x9202.VehiclePosition.State = reader.ReadUInt32(); - jT809_0X1200_0x9202.VehiclePosition.Alarm = reader.ReadUInt32(); - return jT809_0X1200_0x9202; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9200_0x9202 value, IJT809Config config) - { - writer.WriteByte((byte)value.VehiclePosition.Encrypt); - writer.WriteByte(value.VehiclePosition.Day); - writer.WriteByte(value.VehiclePosition.Month); - writer.WriteUInt16(value.VehiclePosition.Year); - writer.WriteByte(value.VehiclePosition.Hour); - writer.WriteByte(value.VehiclePosition.Minute); - writer.WriteByte(value.VehiclePosition.Second); - writer.WriteUInt32(value.VehiclePosition.Lon); - writer.WriteUInt32(value.VehiclePosition.Lat); - writer.WriteUInt16(value.VehiclePosition.Vec1); - writer.WriteUInt16(value.VehiclePosition.Vec2); - writer.WriteUInt32(value.VehiclePosition.Vec3); - writer.WriteUInt16(value.VehiclePosition.Direction); - writer.WriteUInt16(value.VehiclePosition.Altitude); - writer.WriteUInt32(value.VehiclePosition.State); - writer.WriteUInt32(value.VehiclePosition.Alarm); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9200_0x9203_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9200_0x9203_Formatter.cs deleted file mode 100644 index e11f6ab..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9200_0x9203_Formatter.cs +++ /dev/null @@ -1,57 +0,0 @@ -using JT809.Protocol.Enums; -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; -using JT809.Protocol.Metadata; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x9200_0x9203_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x9200_0x9203_Formatter Instance = new JT809_0x9200_0x9203_Formatter(); - - public JT809_0x9200_0x9203 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x9200_0x9203 jT809_0X1200_0x9203 = new JT809_0x9200_0x9203(); - jT809_0X1200_0x9203.GNSSCount = reader.ReadByte(); - jT809_0X1200_0x9203.GNSS = new List(); - if (jT809_0X1200_0x9203.GNSSCount > 0) - { - for (int i = 0; i < jT809_0X1200_0x9203.GNSSCount; i++) - { - try - { - JT809MessagePackReader jT809_0x9200_0x9202Reader = new JT809MessagePackReader(reader.ReadArray(36)); - JT809_0x9200_0x9202 jT809_0x1200_0x1202 = JT809_0x9200_0x9202_Formatter.Instance.Deserialize(ref jT809_0x9200_0x9202Reader, config); - jT809_0X1200_0x9203.GNSS.Add(jT809_0x1200_0x1202); - } - catch (Exception) - { - } - } - } - return jT809_0X1200_0x9203; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9200_0x9203 value, IJT809Config config) - { - writer.WriteByte((byte)value.GNSS.Count); - foreach (var item in value.GNSS) - { - try - { - JT809_0x9200_0x9202_Formatter.Instance.Serialize(ref writer, item, config); - } - catch (Exception ex) - { - - } - } - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9200_0x9204_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9200_0x9204_Formatter.cs deleted file mode 100644 index 5143974..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9200_0x9204_Formatter.cs +++ /dev/null @@ -1,28 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x9200_0x9204_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x9200_0x9204_Formatter Instance = new JT809_0x9200_0x9204_Formatter(); - - public JT809_0x9200_0x9204 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x9200_0x9204 jT809_0X1200_0x9204 = new JT809_0x9200_0x9204(); - jT809_0X1200_0x9204.CarInfo = reader.ReadRemainStringContent(); - return jT809_0X1200_0x9204; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9200_0x9204 value, IJT809Config config) - { - writer.WriteString(value.CarInfo); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9200_0x9205_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9200_0x9205_Formatter.cs deleted file mode 100644 index 214b291..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9200_0x9205_Formatter.cs +++ /dev/null @@ -1,29 +0,0 @@ -using JT809.Protocol.Enums; -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x9200_0x9205_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x9200_0x9205_Formatter Instance = new JT809_0x9200_0x9205_Formatter(); - - public JT809_0x9200_0x9205 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x9200_0x9205 jT809_0X1200_0x9205 = new JT809_0x9200_0x9205(); - jT809_0X1200_0x9205.ReasonCode = (JT809_0x9205_ReasonCode)reader.ReadByte(); - return jT809_0X1200_0x9205; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9200_0x9205 value, IJT809Config config) - { - writer.WriteByte((byte)value.ReasonCode); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9200_0x9206_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9200_0x9206_Formatter.cs deleted file mode 100644 index d0a62d8..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9200_0x9206_Formatter.cs +++ /dev/null @@ -1,29 +0,0 @@ -using JT809.Protocol.Enums; -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x9200_0x9206_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x9200_0x9206_Formatter Instance = new JT809_0x9200_0x9206_Formatter(); - - public JT809_0x9200_0x9206 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x9200_0x9206 jT809_0X1200_0x9206 = new JT809_0x9200_0x9206(); - jT809_0X1200_0x9206.ReasonCode = (JT809_0x9206_ReasonCode)reader.ReadByte(); - return jT809_0X1200_0x9206; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9200_0x9206 value, IJT809Config config) - { - writer.WriteByte((byte)value.ReasonCode); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9200_0x9207_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9200_0x9207_Formatter.cs deleted file mode 100644 index 54c2271..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9200_0x9207_Formatter.cs +++ /dev/null @@ -1,29 +0,0 @@ -using JT809.Protocol.Enums; -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x9200_0x9207_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x9200_0x9207_Formatter Instance = new JT809_0x9200_0x9207_Formatter(); - - public JT809_0x9200_0x9207 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x9200_0x9207 jT809_0X1200_0x9207 = new JT809_0x9200_0x9207(); - jT809_0X1200_0x9207.Result = (JT809_0x9207_Result)reader.ReadByte(); - return jT809_0X1200_0x9207; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9200_0x9207 value, IJT809Config config) - { - writer.WriteByte((byte)value.Result); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9200_0x9208_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9200_0x9208_Formatter.cs deleted file mode 100644 index 2e7c51f..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9200_0x9208_Formatter.cs +++ /dev/null @@ -1,29 +0,0 @@ -using JT809.Protocol.Enums; -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x9200_0x9208_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x9200_0x9208_Formatter Instance = new JT809_0x9200_0x9208_Formatter(); - - public JT809_0x9200_0x9208 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x9200_0x9208 jT809_0X1200_0x9208 = new JT809_0x9200_0x9208(); - jT809_0X1200_0x9208.Result = (JT809_0x9208_Result)reader.ReadByte(); - return jT809_0X1200_0x9208; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9200_0x9208 value, IJT809Config config) - { - writer.WriteByte((byte)value.Result); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9200_0x9209_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9200_0x9209_Formatter.cs deleted file mode 100644 index 0289f6d..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9200_0x9209_Formatter.cs +++ /dev/null @@ -1,29 +0,0 @@ -using JT809.Protocol.Enums; -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x9200_0x9209_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x9200_0x9209_Formatter Instance = new JT809_0x9200_0x9209_Formatter(); - - public JT809_0x9200_0x9209 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x9200_0x9209 jT809_0X1200_0x9209 = new JT809_0x9200_0x9209(); - jT809_0X1200_0x9209.Result = (JT809_0x9209_Result)reader.ReadByte(); - return jT809_0X1200_0x9209; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9200_0x9209 value, IJT809Config config) - { - writer.WriteByte((byte)value.Result); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9300_0x9301_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9300_0x9301_Formatter.cs deleted file mode 100644 index 2d41b28..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9300_0x9301_Formatter.cs +++ /dev/null @@ -1,40 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Enums; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x9300_0x9301_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x9300_0x9301_Formatter Instance = new JT809_0x9300_0x9301_Formatter(); - - public JT809_0x9300_0x9301 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x9300_0x9301 jT809_0X9300_0X9301 = new JT809_0x9300_0x9301(); - jT809_0X9300_0X9301.ObjectType = (JT809_0x9301_ObjectType)reader.ReadByte(); - jT809_0X9300_0X9301.ObjectID = reader.ReadString(12); - jT809_0X9300_0X9301.InfoID = reader.ReadUInt32(); - jT809_0X9300_0X9301.InfoLength = reader.ReadUInt32(); - jT809_0X9300_0X9301.InfoContent = reader.ReadString((int)jT809_0X9300_0X9301.InfoLength); - return jT809_0X9300_0X9301; - } - - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9300_0x9301 value, IJT809Config config) - { - writer.WriteByte((byte)value.ObjectType); - writer.WriteStringPadRight(value.ObjectID, 12); - writer.WriteUInt32(value.InfoID); - // 先计算内容长度(汉字为两个字节) - writer.Skip(4, out int lengthPosition); - writer.WriteString(value.InfoContent); - writer.WriteInt32Return(writer.GetCurrentPosition() - lengthPosition - 4, lengthPosition); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9300_0x9302_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9300_0x9302_Formatter.cs deleted file mode 100644 index 6f1ebef..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9300_0x9302_Formatter.cs +++ /dev/null @@ -1,39 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Enums; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x9300_0x9302_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x9300_0x9302_Formatter Instance = new JT809_0x9300_0x9302_Formatter(); - - public JT809_0x9300_0x9302 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x9300_0x9302 jT809_0X9300_0X9302 = new JT809_0x9300_0x9302(); - jT809_0X9300_0X9302.ObjectType = (JT809_0x9302_ObjectType)reader.ReadByte(); - jT809_0X9300_0X9302.ObjectID = reader.ReadString(12); - jT809_0X9300_0X9302.InfoID = reader.ReadUInt32(); - jT809_0X9300_0X9302.InfoLength = reader.ReadUInt32(); - jT809_0X9300_0X9302.InfoContent = reader.ReadString((int)jT809_0X9300_0X9302.InfoLength); - return jT809_0X9300_0X9302; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9300_0x9302 value, IJT809Config config) - { - writer.WriteByte((byte)value.ObjectType); - writer.WriteStringPadRight(value.ObjectID, 12); - writer.WriteUInt32( value.InfoID); - // 先计算内容长度(汉字为两个字节) - writer.Skip(4, out int lengthPosition); - writer.WriteString(value.InfoContent); - writer.WriteInt32Return(writer.GetCurrentPosition() - lengthPosition - 4, lengthPosition); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9400_0x9401_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9400_0x9401_Formatter.cs deleted file mode 100644 index 006a1eb..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9400_0x9401_Formatter.cs +++ /dev/null @@ -1,45 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Enums; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x9400_0x9401_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x9400_0x9401_Formatter Instance = new JT809_0x9400_0x9401_Formatter(); - - public JT809_0x9400_0x9401 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x9400_0x9401 jT809_0X9400_0X9401 = new JT809_0x9400_0x9401(); - jT809_0X9400_0X9401.WarnSrc = (JT809WarnSrc)reader.ReadByte(); - jT809_0X9400_0X9401.WarnType =reader.ReadUInt16(); - jT809_0X9400_0X9401.WarnTime = reader.ReadUTCDateTime(); - jT809_0X9400_0X9401.SupervisionID = reader.ReadHex(4); - jT809_0X9400_0X9401.SupervisionEndTime = reader.ReadUTCDateTime(); - jT809_0X9400_0X9401.SupervisionLevel = reader.ReadByte(); - jT809_0X9400_0X9401.Supervisor = reader.ReadString(16); - jT809_0X9400_0X9401.SupervisorTel = reader.ReadString(20); - jT809_0X9400_0X9401.SupervisorEmail = reader.ReadString(32); - return jT809_0X9400_0X9401; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9400_0x9401 value, IJT809Config config) - { - writer.WriteByte((byte)value.WarnSrc); - writer.WriteUInt16((ushort)value.WarnType); - writer.WriteUTCDateTime(value.WarnTime); - writer.WriteHex(value.SupervisionID, 4); - writer.WriteUTCDateTime(value.SupervisionEndTime); - writer.WriteByte(value.SupervisionLevel); - writer.WriteStringPadRight(value.Supervisor, 16); - writer.WriteStringPadRight(value.SupervisorTel, 20); - writer.WriteStringPadRight(value.SupervisorEmail, 32); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9400_0x9402_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9400_0x9402_Formatter.cs deleted file mode 100644 index 25ce0e2..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9400_0x9402_Formatter.cs +++ /dev/null @@ -1,39 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Enums; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x9400_0x9402_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x9400_0x9402_Formatter Instance = new JT809_0x9400_0x9402_Formatter(); - - public JT809_0x9400_0x9402 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x9400_0x9402 jT809_0X9400_0X9402 = new JT809_0x9400_0x9402(); - jT809_0X9400_0X9402.WarnSrc = (JT809WarnSrc)reader.ReadByte(); - jT809_0X9400_0X9402.WarnType = (JT809WarnType)reader.ReadUInt16(); - jT809_0X9400_0X9402.WarnTime = reader.ReadUTCDateTime(); - jT809_0X9400_0X9402.WarnLength = reader.ReadUInt32(); - jT809_0X9400_0X9402.WarnContent = reader.ReadString( (int)jT809_0X9400_0X9402.WarnLength); - return jT809_0X9400_0X9402; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9400_0x9402 value, IJT809Config config) - { - writer.WriteByte((byte)value.WarnSrc); - writer.WriteUInt16((ushort)value.WarnType); - writer.WriteUTCDateTime(value.WarnTime); - // 先计算内容长度(汉字为两个字节) - writer.Skip(4, out int lengthPosition); - writer.WriteString(value.WarnContent); - writer.WriteInt32Return(writer.GetCurrentPosition() - lengthPosition - 4, lengthPosition); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9400_0x9403_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9400_0x9403_Formatter.cs deleted file mode 100644 index 0838674..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9400_0x9403_Formatter.cs +++ /dev/null @@ -1,39 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Enums; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x9400_0x9403_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x9400_0x9403_Formatter Instance = new JT809_0x9400_0x9403_Formatter(); - - public JT809_0x9400_0x9403 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x9400_0x9403 jT809_0X9400_0X9403 = new JT809_0x9400_0x9403(); - jT809_0X9400_0X9403.WarnSrc = (JT809WarnSrc)reader.ReadByte(); - jT809_0X9400_0X9403.WarnType = (JT809WarnType)reader.ReadUInt16(); - jT809_0X9400_0X9403.WarnTime = reader.ReadUTCDateTime(); - jT809_0X9400_0X9403.WarnLength = reader.ReadUInt32(); - jT809_0X9400_0X9403.WarnContent = reader.ReadString((int)jT809_0X9400_0X9403.WarnLength); - return jT809_0X9400_0X9403; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9400_0x9403 value, IJT809Config config) - { - writer.WriteByte( (byte)value.WarnSrc); - writer.WriteUInt16((ushort)value.WarnType); - writer.WriteUTCDateTime(value.WarnTime); - // 先计算内容长度(汉字为两个字节) - writer.Skip(4, out int lengthPosition); - writer.WriteString(value.WarnContent); - writer.WriteInt32Return(writer.GetCurrentPosition() - lengthPosition - 4, lengthPosition); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9500_0x9501_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9500_0x9501_Formatter.cs deleted file mode 100644 index c01dc83..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9500_0x9501_Formatter.cs +++ /dev/null @@ -1,28 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x9500_0x9501_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x9500_0x9501_Formatter Instance = new JT809_0x9500_0x9501_Formatter(); - - public JT809_0x9500_0x9501 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x9500_0x9501 jT809_0X9500_0X9501 = new JT809_0x9500_0x9501(); - jT809_0X9500_0X9501.MonitorTel = reader.ReadString(20); - return jT809_0X9500_0X9501; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9500_0x9501 value, IJT809Config config) - { - writer.WriteStringPadRight(value.MonitorTel, 20); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9500_0x9502_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9500_0x9502_Formatter.cs deleted file mode 100644 index 47ba036..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9500_0x9502_Formatter.cs +++ /dev/null @@ -1,30 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x9500_0x9502_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x9500_0x9502_Formatter Instance = new JT809_0x9500_0x9502_Formatter(); - - public JT809_0x9500_0x9502 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x9500_0x9502 jT809_0X9500_0X9502 = new JT809_0x9500_0x9502(); - jT809_0X9500_0X9502.LensID = reader.ReadByte(); - jT809_0X9500_0X9502.SizeType = reader.ReadByte(); - return jT809_0X9500_0X9502; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9500_0x9502 value, IJT809Config config) - { - writer.WriteByte(value.LensID); - writer.WriteByte(value.SizeType); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9500_0x9503_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9500_0x9503_Formatter.cs deleted file mode 100644 index 8ddcd62..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9500_0x9503_Formatter.cs +++ /dev/null @@ -1,36 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x9500_0x9503_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x9500_0x9503_Formatter Instance = new JT809_0x9500_0x9503_Formatter(); - - public JT809_0x9500_0x9503 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x9500_0x9503 jT809_0X9500_0X9503 = new JT809_0x9500_0x9503(); - jT809_0X9500_0X9503.MsgSequence = reader.ReadUInt32(); - jT809_0X9500_0X9503.MsgPriority = reader.ReadByte(); - jT809_0X9500_0X9503.MsgLength = reader.ReadUInt32(); - jT809_0X9500_0X9503.MsgContent = reader.ReadString((int)jT809_0X9500_0X9503.MsgLength); - return jT809_0X9500_0X9503; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9500_0x9503 value, IJT809Config config) - { - writer.WriteUInt32(value.MsgSequence); - writer.WriteByte(value.MsgPriority); - // 先计算内容长度(汉字为两个字节) - writer.Skip(4, out int lengthPosition); - writer.WriteString(value.MsgContent); - writer.WriteInt32Return(writer.GetCurrentPosition() - lengthPosition - 4, lengthPosition); - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9500_0x9504_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9500_0x9504_Formatter.cs deleted file mode 100644 index da5979d..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9500_0x9504_Formatter.cs +++ /dev/null @@ -1,77 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Enums; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x9500_0x9504_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x9500_0x9504_Formatter Instance = new JT809_0x9500_0x9504_Formatter(); - - public JT809_0x9500_0x9504 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x9500_0x9504 jT809_0X9500_0X9504 = new JT809_0x9500_0x9504(); - jT809_0X9500_0X9504.Command = (JT809CommandType)reader.ReadByte(); - switch (jT809_0X9500_0X9504.Command) - { - case JT809CommandType.记录仪标准版本: - case JT809CommandType.当前驾驶人信息: - case JT809CommandType.记录仪时间: - case JT809CommandType.记录仪累计行驶里程: - case JT809CommandType.记录仪脉冲系数: - case JT809CommandType.车辆信息: - case JT809CommandType.记录仪状态信号配置信息: - case JT809CommandType.记录仪唯一性编号: - break; - case JT809CommandType.采集记录仪行驶记录: - case JT809CommandType.采集记录仪位置信息记录: - case JT809CommandType.采集记录仪事故疑点记录: - case JT809CommandType.采集记录仪超时驾驶记录: - case JT809CommandType.采集记录仪驾驶人身份记录: - case JT809CommandType.采集记录仪外部供电记录: - case JT809CommandType.采集记录仪参数修改记录: - case JT809CommandType.采集记录仪速度状态日志: - jT809_0X9500_0X9504.StartTime = reader.ReadDateTime6(); - jT809_0X9500_0X9504.EndTime = reader.ReadDateTime6(); - jT809_0X9500_0X9504.Max = reader.ReadUInt16(); - break; - } - return jT809_0X9500_0X9504; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9500_0x9504 value, IJT809Config config) - { - writer.WriteByte((byte)value.Command); - switch (value.Command) - { - case JT809CommandType.记录仪标准版本: - case JT809CommandType.当前驾驶人信息: - case JT809CommandType.记录仪时间: - case JT809CommandType.记录仪累计行驶里程: - case JT809CommandType.记录仪脉冲系数: - case JT809CommandType.车辆信息: - case JT809CommandType.记录仪状态信号配置信息: - case JT809CommandType.记录仪唯一性编号: - break; - case JT809CommandType.采集记录仪行驶记录: - case JT809CommandType.采集记录仪位置信息记录: - case JT809CommandType.采集记录仪事故疑点记录: - case JT809CommandType.采集记录仪超时驾驶记录: - case JT809CommandType.采集记录仪驾驶人身份记录: - case JT809CommandType.采集记录仪外部供电记录: - case JT809CommandType.采集记录仪参数修改记录: - case JT809CommandType.采集记录仪速度状态日志: - writer.WriteDateTime6(value.StartTime); - writer.WriteDateTime6(value.EndTime); - writer.WriteUInt16(value.Max); - break; - } - } - } -} diff --git a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9500_0x9505_Formatter.cs b/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9500_0x9505_Formatter.cs deleted file mode 100644 index 0213025..0000000 --- a/src/JT809.Protocol/Formatters/SubMessageBodyFormatters/JT809_0x9500_0x9505_Formatter.cs +++ /dev/null @@ -1,42 +0,0 @@ -using JT809.Protocol.Extensions; -using JT809.Protocol.Interfaces; -using JT809.Protocol.MessagePack; -using JT809.Protocol.SubMessageBody; -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol.Formatters.SubMessageBodyFormatters -{ - public class JT809_0x9500_0x9505_Formatter : IJT809MessagePackFormatter - { - public readonly static JT809_0x9500_0x9505_Formatter Instance = new JT809_0x9500_0x9505_Formatter(); - - public JT809_0x9500_0x9505 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) - { - JT809_0x9500_0x9505 jT809_0X9500_0X9505 = new JT809_0x9500_0x9505(); - jT809_0X9500_0X9505.AuthenticationCode = reader.ReadBCD(20); - jT809_0X9500_0X9505.AccessPointName = reader.ReadString(20); - jT809_0X9500_0X9505.UserName = reader.ReadString(49); - jT809_0X9500_0X9505.Password = reader.ReadString(22); - jT809_0X9500_0X9505.ServerIP = reader.ReadString(32); - jT809_0X9500_0X9505.TcpPort = reader.ReadUInt16(); - jT809_0X9500_0X9505.UdpPort = reader.ReadUInt16(); - jT809_0X9500_0X9505.EndTime = reader.ReadUTCDateTime(); - return jT809_0X9500_0X9505; - } - - public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9500_0x9505 value, IJT809Config config) - { - writer.WriteBCD(value.AuthenticationCode, 20); - writer.WriteStringPadRight(value.AccessPointName, 20); - writer.WriteStringPadRight(value.UserName, 49); - writer.WriteStringPadRight(value.Password, 22); - writer.WriteStringPadRight(value.ServerIP, 32); - writer.WriteUInt16(value.TcpPort); - writer.WriteUInt16(value.UdpPort); - writer.WriteUTCDateTime(value.EndTime); - } - } -} diff --git a/src/JT809.Protocol/Interfaces/IJT809Analyze.cs b/src/JT809.Protocol/Interfaces/IJT809Analyze.cs new file mode 100644 index 0000000..9d3050e --- /dev/null +++ b/src/JT809.Protocol/Interfaces/IJT809Analyze.cs @@ -0,0 +1,11 @@ +using JT809.Protocol.MessagePack; +using System; +using System.Text.Json; + +namespace JT809.Protocol.Interfaces +{ + public interface IJT809Analyze + { + void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config); + } +} diff --git a/src/JT809.Protocol/Interfaces/IJT809Description.cs b/src/JT809.Protocol/Interfaces/IJT809Description.cs new file mode 100644 index 0000000..6e2ae52 --- /dev/null +++ b/src/JT809.Protocol/Interfaces/IJT809Description.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Interfaces +{ + public interface IJT809Description + { + string Description { get;} + } +} diff --git a/src/JT809.Protocol/Interfaces/IJT809_2019_Version.cs b/src/JT809.Protocol/Interfaces/IJT809_2019_Version.cs new file mode 100644 index 0000000..2bfa214 --- /dev/null +++ b/src/JT809.Protocol/Interfaces/IJT809_2019_Version.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Interfaces +{ + /// + /// 只用来标识2019版本增删改情况 + /// + public interface IJT809_2019_Version + { + } +} diff --git a/src/JT809.Protocol/Internal/JT809FormatterFactory.cs b/src/JT809.Protocol/Internal/JT809FormatterFactory.cs index 1702534..e301295 100644 --- a/src/JT809.Protocol/Internal/JT809FormatterFactory.cs +++ b/src/JT809.Protocol/Internal/JT809FormatterFactory.cs @@ -24,30 +24,30 @@ namespace JT809.Protocol.Internal private void Init(Assembly assembly) { - foreach (var type in assembly.GetTypes()) + foreach (var type in assembly.GetTypes().Where(w => w.GetInterfaces().Contains(typeof(IJT809Formatter)))) { - var attr = type.GetCustomAttribute(); - if (attr != null) + var implTypes = type.GetInterfaces(); + if (implTypes != null && implTypes.Length > 1) { - if (!FormatterDict.ContainsKey(type.GUID)) + var firstType = implTypes.FirstOrDefault(f => f.Name == typeof(IJT809MessagePackFormatter<>).Name); + var genericImplType = firstType.GetGenericArguments().FirstOrDefault(); + if (genericImplType != null) { - FormatterDict.Add(type.GUID, Activator.CreateInstance(attr.FormatterType)); + if (!FormatterDict.ContainsKey(genericImplType.GUID)) + { + FormatterDict.Add(genericImplType.GUID, Activator.CreateInstance(genericImplType)); + } } } } } - public IJT809FormatterFactory SetMap() where TJT809Bodies : JT809Bodies + public IJT809FormatterFactory SetMap() where TIJT809Formatter : IJT809Formatter { - Type bodiesType = typeof(TJT809Bodies); - var attr = bodiesType.GetTypeInfo().GetCustomAttribute(); - if (attr == null) + Type type = typeof(TIJT809Formatter); + if (!FormatterDict.ContainsKey(type.GUID)) { - throw new JT809Exception(JT809ErrorCode.GetFormatterAttributeError, bodiesType.FullName); - } - if (!FormatterDict.ContainsKey(bodiesType.GUID)) - { - FormatterDict.Add(bodiesType.GUID, Activator.CreateInstance(attr.FormatterType)); + FormatterDict.Add(type.GUID, Activator.CreateInstance(type)); } return this; } @@ -56,20 +56,5 @@ namespace JT809.Protocol.Internal { Init(externalAssembly); } - - public IJT809FormatterFactory SetSubMap() where TJT809SubBodies : JT809SubBodies - { - Type bodiesType = typeof(TJT809SubBodies); - var attr = bodiesType.GetTypeInfo().GetCustomAttribute(); - if (attr == null) - { - throw new JT809Exception(JT809ErrorCode.GetFormatterAttributeError, bodiesType.FullName); - } - if (!FormatterDict.ContainsKey(bodiesType.GUID)) - { - FormatterDict.Add(bodiesType.GUID, Activator.CreateInstance(attr.FormatterType)); - } - return this; - } } } diff --git a/src/JT809.Protocol/JT809.Protocol.csproj b/src/JT809.Protocol/JT809.Protocol.csproj index ec0c144..95c6ed5 100644 --- a/src/JT809.Protocol/JT809.Protocol.csproj +++ b/src/JT809.Protocol/JT809.Protocol.csproj @@ -57,6 +57,7 @@ + @@ -86,6 +87,7 @@ + @@ -114,6 +116,7 @@ + diff --git a/src/JT809.Protocol/JT809Bodies.cs b/src/JT809.Protocol/JT809Bodies.cs index 25a4c09..411dacf 100644 --- a/src/JT809.Protocol/JT809Bodies.cs +++ b/src/JT809.Protocol/JT809Bodies.cs @@ -1,14 +1,21 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Formatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Enums; +using JT809.Protocol.Interfaces; namespace JT809.Protocol { - public abstract class JT809Bodies + public abstract class JT809Bodies: IJT809Description { + /// + /// 跳过数据体序列化 + /// 默认不跳过 + /// 当数据体为空的时候,使用null作为空包感觉不适合,所以就算使用空包也需要new一下来表达意思。 + /// + public virtual bool SkipSerialization { get; set; } = false; + public abstract ushort MsgId { get; } + + public abstract JT809_LinkType LinkType { get; } + + public abstract string Description { get; } } } diff --git a/src/JT809.Protocol/JT809Header.cs b/src/JT809.Protocol/JT809Header.cs index 2553cb2..a152f58 100644 --- a/src/JT809.Protocol/JT809Header.cs +++ b/src/JT809.Protocol/JT809Header.cs @@ -1,14 +1,9 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Formatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol { - [JT809Formatter(typeof(JT809HeaderFormatter))] - public class JT809Header + public class JT809Header: IJT809MessagePackFormatter { /// /// 固定为22个字节长度 @@ -49,5 +44,29 @@ namespace JT809.Protocol /// 数据加密的密匙,长度为 4 个字节 /// public uint EncryptKey { get; set; } + + public JT809Header Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809Header jT809Header = new JT809Header(); + jT809Header.MsgLength = reader.ReadUInt32(); + jT809Header.MsgSN = reader.ReadUInt32(); + jT809Header.BusinessType = reader.ReadUInt16(); + jT809Header.MsgGNSSCENTERID = reader.ReadUInt32(); + jT809Header.Version = new JT809Header_Version(reader.ReadArray(JT809Header_Version.FixedByteLength)); + jT809Header.EncryptFlag = (JT809Header_Encrypt)reader.ReadByte(); + jT809Header.EncryptKey = reader.ReadUInt32(); + return jT809Header; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809Header value, IJT809Config config) + { + writer.WriteUInt32(value.MsgLength); + writer.WriteUInt32(value.MsgSN); + writer.WriteUInt16(value.BusinessType); + writer.WriteUInt32(value.MsgGNSSCENTERID); + writer.WriteArray(value.Version.Buffer); + writer.WriteByte((byte)value.EncryptFlag); + writer.WriteUInt32(value.EncryptKey); + } } } diff --git a/src/JT809.Protocol/JT809HeaderPackage.cs b/src/JT809.Protocol/JT809HeaderPackage.cs index 4f46968..232ded1 100644 --- a/src/JT809.Protocol/JT809HeaderPackage.cs +++ b/src/JT809.Protocol/JT809HeaderPackage.cs @@ -1,5 +1,7 @@ -using JT809.Protocol.Attributes; +using JT809.Protocol.Enums; +using JT809.Protocol.Exceptions; using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; using System; using System.Collections.Generic; using System.Text; @@ -9,8 +11,7 @@ namespace JT809.Protocol /// /// JT809头部数据包 /// - [JT809Formatter(typeof(JT809HeaderPackageFormatter))] - public class JT809HeaderPackage + public class JT809HeaderPackage: IJT809MessagePackFormatter { public byte BeginFlag { get; set; } = JT809Package.BEGINFLAG; @@ -21,5 +22,64 @@ namespace JT809.Protocol public ushort CRCCode { get; set; } public byte EndFlag { get; set; } = JT809Package.ENDFLAG; + + public JT809HeaderPackage Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + // 1. 验证校验码 + if (!config.SkipCRCCode) + { + // 1.2. 验证校验码 + if (!reader.CheckXorCodeVali) + { + throw new JT809Exception(JT809ErrorCode.CRC16CheckInvalid, $"{reader.CalculateCheckXorCode.ToString()}!={reader.RealCheckXorCode.ToString()}"); + } + } + JT809HeaderPackage jT809Package = new JT809HeaderPackage(); + // 2.读取起始头 + jT809Package.BeginFlag = reader.ReadStart(); + // 3.初始化消息头 + try + { + //todo:JT809HeaderFormatter + //jT809Package.Header = JT809HeaderFormatter.Instance.Deserialize(ref reader, config); + } + catch (Exception ex) + { + throw new JT809Exception(JT809ErrorCode.HeaderParseError, $"offset>{reader.ReadCurrentRemainContentLength().ToString()}", ex); + } + // 5.数据体处理 + // 5.1 判断是否有数据体(总长度-固定长度)> 0 + if ((jT809Package.Header.MsgLength - JT809Package.FixedByteLength) > 0) + { + try + { + // 5.2 是否加密 + switch (jT809Package.Header.EncryptFlag) + { + case JT809Header_Encrypt.None: + // 5.3 处理消息体 + jT809Package.Bodies = reader.ReadContent().ToArray(); + break; + case JT809Header_Encrypt.Common: + // 5.4. 处理加密消息体 + byte[] bodiesData = config.Encrypt.Decrypt(reader.ReadContent(), config.EncryptOptions, jT809Package.Header.EncryptKey); + jT809Package.Bodies = bodiesData; + break; + } + } + catch (Exception ex) + { + throw new JT809Exception(JT809ErrorCode.BodiesParseError, $"offset>{reader.ReadCurrentRemainContentLength().ToString()}", ex); + } + } + jT809Package.CRCCode = reader.CalculateCheckXorCode; + jT809Package.EndFlag = reader.ReadEnd(); + return jT809Package; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809HeaderPackage value, IJT809Config config) + { + throw new NotImplementedException("只适用反序列化"); + } } } diff --git a/src/JT809.Protocol/JT809Package.cs b/src/JT809.Protocol/JT809Package.cs index ed6e05b..890036c 100644 --- a/src/JT809.Protocol/JT809Package.cs +++ b/src/JT809.Protocol/JT809Package.cs @@ -1,13 +1,13 @@ -using JT809.Protocol.Attributes; +using JT809.Protocol.Enums; +using JT809.Protocol.Exceptions; +using JT809.Protocol.Extensions; using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; using System; -using System.Collections.Generic; -using System.Text; namespace JT809.Protocol { - [JT809Formatter(typeof(JT809PackageFormatter))] - public class JT809Package + public class JT809Package:IJT809MessagePackFormatter { public const byte BEGINFLAG = 0X5B; @@ -29,5 +29,145 @@ namespace JT809.Protocol public ushort CRCCode { get; set; } public byte EndFlag { get; set; } = ENDFLAG; + + public JT809Package Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + // 1. 验证校验码 + if (!config.SkipCRCCode) + { + // 1.2. 验证校验码 + if (!reader.CheckXorCodeVali) + { + throw new JT809Exception(JT809ErrorCode.CRC16CheckInvalid, $"{reader.CalculateCheckXorCode.ToString()}!={reader.RealCheckXorCode.ToString()}"); + } + } + JT809Package jT809Package = new JT809Package(); + // 2.读取起始头 + jT809Package.BeginFlag = reader.ReadStart(); + // 3.初始化消息头 + try + { + //todo:JT809HeaderFormatter + //jT809Package.Header = JT809HeaderFormatter.Instance.Deserialize(ref reader, config); + } + catch (Exception ex) + { + throw new JT809Exception(JT809ErrorCode.HeaderParseError, $"offset>{reader.ReadCurrentRemainContentLength().ToString()}", ex); + } + // 5.数据体处理 + // 5.1 判断是否有数据体(总长度-固定长度)> 0 + if ((jT809Package.Header.MsgLength - JT809Package.FixedByteLength) > 0) + { + try + { + Type jT809BodiesImplType = config.BusinessTypeFactory.GetBodiesImplTypeByBusinessType(jT809Package.Header.BusinessType, jT809Package.Header.MsgGNSSCENTERID); + if (jT809BodiesImplType != null) + { + // 5.2 是否加密 + switch (jT809Package.Header.EncryptFlag) + { + case JT809Header_Encrypt.None: + // 5.3 处理消息体 + jT809Package.Bodies = JT809MessagePackFormatterResolverExtensions.JT809DynamicDeserialize( + config.GetMessagePackFormatterByType(jT809BodiesImplType), + ref reader, config); + break; + case JT809Header_Encrypt.Common: + // 5.4. 处理加密消息体 + byte[] bodiesData = config.Encrypt.Decrypt(reader.ReadContent(), config.EncryptOptions, jT809Package.Header.EncryptKey); + JT809MessagePackReader bodiesReader = new JT809MessagePackReader(bodiesData); + jT809Package.Bodies = JT809MessagePackFormatterResolverExtensions.JT809DynamicDeserialize( + config.GetMessagePackFormatterByType(jT809BodiesImplType), + ref bodiesReader, config); + break; + } + } + } + catch (Exception ex) + { + throw new JT809Exception(JT809ErrorCode.BodiesParseError, $"offset>{reader.ReadCurrentRemainContentLength().ToString()}", ex); + } + } + jT809Package.CRCCode = reader.CalculateCheckXorCode; + jT809Package.EndFlag = reader.ReadEnd(); + return jT809Package; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809Package value, IJT809Config config) + { + // -----------开始组包---------- + // 1.起始符 + writer.WriteByte(value.BeginFlag); + // 2.写入头部数据 + // 2.1.跳过数据长度的写入 + writer.Skip(4, out int lengthPosition); + // 2.2.报文序列号 + value.Header.MsgSN = value.Header.MsgSN > 0 ? value.Header.MsgSN : config.MsgSNDistributed.Increment(); + writer.WriteUInt32(value.Header.MsgSN); + // 2.3.业务数据类型 + writer.WriteUInt16(value.Header.BusinessType); + // 2.4.下级平台接入码 + writer.WriteUInt32(value.Header.MsgGNSSCENTERID); + // 2.5.版本号 + writer.WriteArray(value.Header.Version.Buffer); + // 2.6.报文加密 + writer.WriteByte((byte)value.Header.EncryptFlag); + // 2.7.数据加密密钥 + writer.WriteUInt32(value.Header.EncryptKey); + // 3.写入数据体 + // 3.1.记录当前开始位置 + int startIndex = writer.GetCurrentPosition(); + // 3.2.写入数据对应数据体 + if (value.Bodies != null) + { + JT809MessagePackFormatterResolverExtensions.JT809DynamicSerialize( + config.GetMessagePackFormatterByType(value.Bodies.GetType()), + ref writer, value.Bodies, + config); + } + // 3.3.记录当前结束位置 + int endIndex = writer.GetCurrentPosition(); + int contentLength = endIndex - startIndex; + if (contentLength > 0) + { + // 3.4. 数据加密 + switch (value.Header.EncryptFlag) + { + case JT809Header_Encrypt.None: + break; + case JT809Header_Encrypt.Common: + // 3.5. 提取数据体并进行加密处理 + byte[] messageBodyDatEncrypted = config.Encrypt.Encrypt(writer.Extract(startIndex), config.EncryptOptions, value.Header.EncryptKey); + int flagLength = messageBodyDatEncrypted.Length - contentLength; + if (flagLength == 0) + { + // 相等复制 + writer.CopyTo(messageBodyDatEncrypted, startIndex); + } + else if (flagLength > 0) + { + // 扩容 + writer.Skip(flagLength, out _); + writer.CopyTo(messageBodyDatEncrypted, startIndex); + } + else + { + // 缩减 + writer.CopyTo(messageBodyDatEncrypted, startIndex); + writer.Shrink(-flagLength); + } + break; + } + } + // 4.计算内容的总长度(校验码2+终止符1=3) + writer.WriteInt32Return(writer.GetCurrentPosition() + 3, lengthPosition); + // 5.校验码 + writer.WriteCRC16(); + // 6.终止符 + writer.WriteByte(value.EndFlag); + // 7.转义 + writer.WriteEncode(); + // -----------组包完成---------- + } } } diff --git a/src/JT809.Protocol/JT809Serializer.cs b/src/JT809.Protocol/JT809Serializer.cs index 324b713..798061c 100644 --- a/src/JT809.Protocol/JT809Serializer.cs +++ b/src/JT809.Protocol/JT809Serializer.cs @@ -35,7 +35,8 @@ namespace JT809.Protocol try { JT809MessagePackWriter jT809MessagePackWriter = new JT809MessagePackWriter(buffer); - JT809PackageFormatter.Instance.Serialize(ref jT809MessagePackWriter,jT809Package, jT809Config); + //todo:JT809PackageFormatter + //JT809PackageFormatter.Instance.Serialize(ref jT809MessagePackWriter,jT809Package, jT809Config); return jT809MessagePackWriter.FlushAndGetEncodingArray(); } finally @@ -51,7 +52,9 @@ namespace JT809.Protocol { JT809MessagePackReader jT809MessagePackReader = new JT809MessagePackReader(bytes); jT809MessagePackReader.Decode(buffer); - return JT809PackageFormatter.Instance.Deserialize(ref jT809MessagePackReader, jT809Config); + //todo:JT809PackageFormatter + return default; + //return JT809PackageFormatter.Instance.Deserialize(ref jT809MessagePackReader, jT809Config); } finally { @@ -70,7 +73,8 @@ namespace JT809.Protocol try { JT809MessagePackWriter jT809MessagePackWriter = new JT809MessagePackWriter(buffer); - JT809MessagePackFormatterExtensions.GetFormatter().Serialize(ref jT809MessagePackWriter, obj,jT809Config); + //todo:JT809MessagePackFormatterExtensions + //JT809MessagePackFormatterExtensions.GetFormatter().Serialize(ref jT809MessagePackWriter, obj,jT809Config); return jT809MessagePackWriter.FlushAndGetEncodingArray(); } finally @@ -87,7 +91,8 @@ namespace JT809.Protocol JT809MessagePackReader jT809MessagePackReader = new JT809MessagePackReader(bytes); if (CheckPackageType(typeof(T))) jT809MessagePackReader.Decode(buffer); - return JT809MessagePackFormatterExtensions.GetFormatter().Deserialize(ref jT809MessagePackReader, jT809Config); + return default; + //return JT809MessagePackFormatterExtensions.GetFormatter().Deserialize(ref jT809MessagePackReader, jT809Config); } finally { @@ -102,7 +107,9 @@ namespace JT809.Protocol { JT809MessagePackReader jT808MessagePackReader = new JT809MessagePackReader(bytes); jT808MessagePackReader.Decode(buffer); - return JT809HeaderPackageFormatter.Instance.Deserialize(ref jT808MessagePackReader, jT809Config); + //todo:JT809HeaderPackageFormatter + return default; + //return JT809HeaderPackageFormatter.Instance.Deserialize(ref jT808MessagePackReader, jT809Config); } finally { diff --git a/src/JT809.Protocol/JT809SubBodies.cs b/src/JT809.Protocol/JT809SubBodies.cs index dac3ce8..788b7db 100644 --- a/src/JT809.Protocol/JT809SubBodies.cs +++ b/src/JT809.Protocol/JT809SubBodies.cs @@ -1,9 +1,4 @@ -using JT809.Protocol.Enums; -using System; -using System.Collections.Generic; -using System.Text; - -namespace JT809.Protocol +namespace JT809.Protocol { /// /// 子业务数据体 diff --git a/src/JT809.Protocol/JT809Util.cs b/src/JT809.Protocol/JT809Util.cs index ddaf8ad..32ff774 100644 --- a/src/JT809.Protocol/JT809Util.cs +++ b/src/JT809.Protocol/JT809Util.cs @@ -4,7 +4,7 @@ using System.Text; namespace JT809.Protocol { - public static class HexUtil + internal static class HexUtil { static readonly char[] HexdumpTable = new char[256 * 4]; static HexUtil() diff --git a/src/JT809.Protocol/MessageBody/JT809_0x1001.cs b/src/JT809.Protocol/MessageBody/JT809_0x1001.cs index 326d863..d6b8f32 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x1001.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x1001.cs @@ -1,8 +1,8 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Formatters.MessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Enums; +using JT809.Protocol.Extensions; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; + namespace JT809.Protocol.MessageBody { @@ -13,8 +13,7 @@ namespace JT809.Protocol.MessageBody /// 业务数据类型标识: UP-CONNECT-REQ /// 描述:下级平台向上级平台发送用户名和密码等登录信息 /// - [JT809Formatter(typeof(JT809_0x1001_Formatter))] - public class JT809_0x1001: JT809Bodies + public class JT809_0x1001: JT809Bodies,IJT809MessagePackFormatter { /// /// 用户名 @@ -34,5 +33,29 @@ namespace JT809.Protocol.MessageBody /// 下级平台提供对应的从链路服务器端口号 /// public ushort DownLinkPort { get; set; } + + public override ushort MsgId => JT809BusinessType.主链路登录请求消息.ToUInt16Value(); + + public override string Description => "主链路登录请求消息"; + + public override JT809_LinkType LinkType => JT809_LinkType.main; + + 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.DownLinkIP = reader.ReadString(32); + jT809_0X1001.DownLinkPort = reader.ReadUInt16(); + return jT809_0X1001; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1001 value, IJT809Config config) + { + writer.WriteUInt32(value.UserId); + writer.WriteStringPadRight(value.Password, 8); + writer.WriteStringPadRight(value.DownLinkIP, 32); + writer.WriteUInt16(value.DownLinkPort); + } } } diff --git a/src/JT809.Protocol/MessageBody/JT809_0x1002.cs b/src/JT809.Protocol/MessageBody/JT809_0x1002.cs index 130e599..e701cf3 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x1002.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x1002.cs @@ -1,6 +1,7 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Formatters.MessageBodyFormatters; +using JT809.Protocol.Enums; +using JT809.Protocol.Extensions; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; using System; using System.Collections.Generic; using System.Text; @@ -14,9 +15,13 @@ namespace JT809.Protocol.MessageBody /// 业务数据类型标识:UP_CONNCCT_RSP /// 描述:上级平台对下级平台登录请求信息、进行安全验证后,返回相应的验证结果。 /// - [JT809Formatter(typeof(JT809_0x1002_Formatter))] - public class JT809_0x1002 : JT809Bodies + public class JT809_0x1002 : JT809Bodies, IJT809MessagePackFormatter { + public override ushort MsgId => JT809BusinessType.主链路登录应答消息.ToUInt16Value(); + + public override string Description => "主链路登录应答消息"; + + public override JT809_LinkType LinkType => JT809_LinkType.main; /// /// 验证结果,定义如下: /// 0x00:成功; @@ -32,5 +37,17 @@ namespace JT809.Protocol.MessageBody /// 校验码 /// public uint VerifyCode { get; set; } + 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; + } + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1002 value, IJT809Config config) + { + writer.WriteByte((byte)value.Result); + writer.WriteUInt32(value.VerifyCode); + } } } diff --git a/src/JT809.Protocol/MessageBody/JT809_0x1003.cs b/src/JT809.Protocol/MessageBody/JT809_0x1003.cs index 919f270..0161528 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x1003.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x1003.cs @@ -1,5 +1,7 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Formatters.MessageBodyFormatters; +using JT809.Protocol.Enums; +using JT809.Protocol.Extensions; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; using System; using System.Collections.Generic; using System.Text; @@ -13,9 +15,13 @@ namespace JT809.Protocol.MessageBody /// 业务数据类型标识:UP-DISCONNECT-REQ /// 描述:下级平台在中断与上级平台的主链路连接时,应向上级平台发送主链路注销请求消息。 /// - [JT809Formatter(typeof(JT809_0x1003_Formatter))] - public class JT809_0x1003 : JT809Bodies + public class JT809_0x1003 : JT809Bodies, IJT809MessagePackFormatter { + public override ushort MsgId => JT809BusinessType.主链路注销请求消息.ToUInt16Value(); + + public override string Description => "主链路注销请求消息"; + + public override JT809_LinkType LinkType => JT809_LinkType.main; /// /// 用户名 /// @@ -24,5 +30,17 @@ namespace JT809.Protocol.MessageBody /// 密码 /// public string Password { get; set; } + 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; + } + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1003 value, IJT809Config config) + { + writer.WriteUInt32(value.UserId); + writer.WriteStringPadLeft(value.Password, 8); + } } } diff --git a/src/JT809.Protocol/MessageBody/JT809_0x1004.cs b/src/JT809.Protocol/MessageBody/JT809_0x1004.cs index 93b475e..192c639 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x1004.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x1004.cs @@ -1,4 +1,5 @@ -using JT809.Protocol.Attributes; +using JT809.Protocol.Enums; +using JT809.Protocol.Extensions; using System; using System.Collections.Generic; using System.Text; @@ -15,6 +16,9 @@ namespace JT809.Protocol.MessageBody /// public class JT809_0x1004 : JT809Bodies { - + public override bool SkipSerialization => true; + public override ushort MsgId => JT809BusinessType.主链路注销应答消息.ToUInt16Value(); + public override string Description => "主链路注销应答消息"; + public override JT809_LinkType LinkType => JT809_LinkType.main; } } diff --git a/src/JT809.Protocol/MessageBody/JT809_0x1005.cs b/src/JT809.Protocol/MessageBody/JT809_0x1005.cs index 9bd11f0..551e12e 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x1005.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x1005.cs @@ -1,4 +1,6 @@ -using System; +using JT809.Protocol.Enums; +using JT809.Protocol.Extensions; +using System; using System.Collections.Generic; using System.Text; @@ -14,5 +16,9 @@ namespace JT809.Protocol.MessageBody /// public class JT809_0x1005:JT809Bodies { + public override bool SkipSerialization => true; + public override ushort MsgId => JT809BusinessType.主链路连接保持请求消息.ToUInt16Value(); + public override string Description => "主链路连接保持请求消息"; + public override JT809_LinkType LinkType => JT809_LinkType.main; } } diff --git a/src/JT809.Protocol/MessageBody/JT809_0x1006.cs b/src/JT809.Protocol/MessageBody/JT809_0x1006.cs index 0f154d6..932732f 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x1006.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x1006.cs @@ -1,4 +1,5 @@ -using JT809.Protocol.Attributes; +using JT809.Protocol.Enums; +using JT809.Protocol.Extensions; using JT809.Protocol.Formatters; namespace JT809.Protocol.MessageBody @@ -13,6 +14,9 @@ namespace JT809.Protocol.MessageBody /// public class JT809_0x1006:JT809Bodies { - + public override bool SkipSerialization => true; + public override ushort MsgId => JT809BusinessType.主链路连接保持应答消息.ToUInt16Value(); + public override string Description => "主链路连接保持应答消息"; + public override JT809_LinkType LinkType => JT809_LinkType.main; } } diff --git a/src/JT809.Protocol/MessageBody/JT809_0x1007.cs b/src/JT809.Protocol/MessageBody/JT809_0x1007.cs index 58f28f8..c266e2f 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x1007.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x1007.cs @@ -1,9 +1,7 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Formatters.MessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Enums; +using JT809.Protocol.Extensions; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.MessageBody { @@ -16,12 +14,25 @@ namespace JT809.Protocol.MessageBody /// 主链路连接保持应答消息,数据体为空 /// 本条消息无需被通知方应答 /// - [JT809Formatter(typeof(JT809_0x1007_Formatter))] - public class JT809_0x1007:JT809Bodies + public class JT809_0x1007:JT809Bodies, IJT809MessagePackFormatter { + public override ushort MsgId => JT809BusinessType.主链路断开通知消息.ToUInt16Value(); + public override string Description => "主链路断开通知消息"; + public override JT809_LinkType LinkType => JT809_LinkType.subordinate; /// /// 错误代码 /// public JT809_0x1007_ErrorCode ErrorCode { get; set; } + 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; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1007 value, IJT809Config config) + { + writer.WriteByte((byte)value.ErrorCode); + } } } diff --git a/src/JT809.Protocol/MessageBody/JT809_0x1008.cs b/src/JT809.Protocol/MessageBody/JT809_0x1008.cs index 3da5305..d5e0681 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x1008.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x1008.cs @@ -1,9 +1,7 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Formatters.MessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Enums; +using JT809.Protocol.Extensions; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.MessageBody { @@ -14,12 +12,25 @@ namespace JT809.Protocol.MessageBody /// 业务数据类型标识:UP_CLOSELINIC INFORM /// 描述:下级平台作为服务端,发现从链路出现异常时,下级平台通过从链路向上级平台发送本消息,通知上级平台下级平台即将关闭主从链路 /// - [JT809Formatter(typeof(JT809_0x1008_Formatter))] - public class JT809_0x1008:JT809Bodies + public class JT809_0x1008:JT809Bodies, IJT809MessagePackFormatter { + public override ushort MsgId => JT809BusinessType.下级平台主动关闭主从链路通知消息.ToUInt16Value(); + public override string Description => "下级平台主动关闭主从链路通知消息"; + public override JT809_LinkType LinkType => JT809_LinkType.subordinate; /// /// 错误代码 /// public JT809_0x1008_ReasonCode ReasonCode { get; set; } + 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; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1008 value, IJT809Config config) + { + writer.WriteByte((byte)value.ReasonCode); + } } } diff --git a/src/JT809.Protocol/MessageBody/JT809_0x1200.cs b/src/JT809.Protocol/MessageBody/JT809_0x1200.cs index dea4c1f..83232ba 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x1200.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x1200.cs @@ -1,6 +1,6 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Formatters; - + +using JT809.Protocol.Enums; +using JT809.Protocol.Extensions; namespace JT809.Protocol.MessageBody { @@ -11,9 +11,10 @@ namespace JT809.Protocol.MessageBody /// 业务数据类型标识:UP_EXG_MSG /// 描述:下级平台向上级平台发送车辆动态信息交换业务数据包 /// - [JT809Formatter(typeof(JT809BodiesFormatter))] public class JT809_0x1200: JT809ExchangeMessageBodies { - + public override ushort MsgId => JT809BusinessType.主链路车辆动态信息交换业务.ToUInt16Value(); + public override string Description => "主链路车辆动态信息交换业务"; + public override JT809_LinkType LinkType => JT809_LinkType.main; } } diff --git a/src/JT809.Protocol/MessageBody/JT809_0x1300.cs b/src/JT809.Protocol/MessageBody/JT809_0x1300.cs index 0bf854c..00a756a 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x1300.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x1300.cs @@ -1,6 +1,9 @@ -using JT809.Protocol.Attributes; +using JT809.Protocol.Enums; +using JT809.Protocol.Exceptions; +using JT809.Protocol.Extensions; using JT809.Protocol.Formatters; -using JT809.Protocol.Formatters.MessageBodyFormatters; +using JT809.Protocol.MessagePack; +using System; namespace JT809.Protocol.MessageBody { @@ -11,9 +14,53 @@ namespace JT809.Protocol.MessageBody /// 业务数据类型标识:UP_PLATFORM_MSG /// 描述:下级平台向上级平台发送平台间交互信息 /// - [JT809Formatter(typeof(JT809_0x1300_Formatter))] - public class JT809_0x1300: JT809ExchangeMessageBodies + public class JT809_0x1300: JT809ExchangeMessageBodies, IJT809MessagePackFormatter { - + public override ushort MsgId => JT809BusinessType.主链路平台间信息交互消息.ToUInt16Value(); + public override string Description => "主链路平台间信息交互消息"; + public override JT809_LinkType LinkType => JT809_LinkType.main; + public JT809_0x1300 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x1300 jT809_0X1300 = new JT809_0x1300(); + jT809_0X1300.SubBusinessType = reader.ReadUInt16(); + jT809_0X1300.DataLength = reader.ReadUInt32(); + try + { + //JT809.Protocol.Enums.JT809BusinessType 映射对应消息特性 + Type jT809SubBodiesImplType = config.SubBusinessTypeFactory.GetSubBodiesImplTypeBySubBusinessType(jT809_0X1300.SubBusinessType); + if (jT809SubBodiesImplType != null) + jT809_0X1300.SubBodies = JT809MessagePackFormatterResolverExtensions.JT809DynamicDeserialize( + config.GetMessagePackFormatterByType(jT809SubBodiesImplType), + ref reader, config); + } + catch + { + throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{jT809_0X1300.SubBusinessType.ToString()}"); + } + return jT809_0X1300; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1300 value, IJT809Config config) + { + writer.WriteUInt16(value.SubBusinessType); + //JT809.Protocol.Enums.JT809BusinessType 映射对应消息特性 + try + { + // 先写入内容,然后在根据内容反写内容长度 + writer.Skip(4, out int subContentLengthPosition); + if (value.SubBodies != null) + { + JT809MessagePackFormatterResolverExtensions.JT809DynamicSerialize( + config.GetMessagePackFormatterByType(value.SubBodies.GetType()), + ref writer, value.SubBodies, + config); + } + writer.WriteInt32Return(writer.GetCurrentPosition() - subContentLengthPosition - 4, subContentLengthPosition); + } + catch (Exception ex) + { + throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}", ex); + } + } } } diff --git a/src/JT809.Protocol/MessageBody/JT809_0x1400.cs b/src/JT809.Protocol/MessageBody/JT809_0x1400.cs index e285608..bdc7c6e 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x1400.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x1400.cs @@ -1,6 +1,5 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Formatters; - +using JT809.Protocol.Enums; +using JT809.Protocol.Extensions; namespace JT809.Protocol.MessageBody { @@ -12,9 +11,10 @@ namespace JT809.Protocol.MessageBody /// 业务数据类型标识:UP_WARN_MSG /// 描述:下级平台向上级平台发送车辆报警信息业务 /// - [JT809Formatter(typeof(JT809BodiesFormatter))] public class JT809_0x1400: JT809ExchangeMessageBodies { - + public override ushort MsgId => JT809BusinessType.主链路报警信息交互消息.ToUInt16Value(); + public override string Description => "主链路报警信息交互消息"; + public override JT809_LinkType LinkType => JT809_LinkType.main; } } diff --git a/src/JT809.Protocol/MessageBody/JT809_0x1500.cs b/src/JT809.Protocol/MessageBody/JT809_0x1500.cs index 6d9850a..0775753 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x1500.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x1500.cs @@ -1,6 +1,5 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Formatters; - +using JT809.Protocol.Enums; +using JT809.Protocol.Extensions; namespace JT809.Protocol.MessageBody { @@ -11,9 +10,10 @@ namespace JT809.Protocol.MessageBody /// 业务数据类型标识:UP_CTRL_MSG /// 描述:下级平台向上级平台发送车辆监管业务 /// - [JT809Formatter(typeof(JT809BodiesFormatter))] public class JT809_0x1500: JT809ExchangeMessageBodies { - + public override ushort MsgId => JT809BusinessType.主链路车辆监管消息.ToUInt16Value(); + public override string Description => "主链路车辆监管消息"; + public override JT809_LinkType LinkType => JT809_LinkType.main; } } diff --git a/src/JT809.Protocol/MessageBody/JT809_0x1600.cs b/src/JT809.Protocol/MessageBody/JT809_0x1600.cs index 0cbe802..c9d80e0 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x1600.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x1600.cs @@ -1,6 +1,5 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Formatters; - +using JT809.Protocol.Enums; +using JT809.Protocol.Extensions; namespace JT809.Protocol.MessageBody { @@ -11,9 +10,10 @@ namespace JT809.Protocol.MessageBody /// 消息方向:下级平台往上级平台 /// 描述:下级平台向上级平台发送车辆睁态信息交换业务 /// - [JT809Formatter(typeof(JT809BodiesFormatter))] public class JT809_0x1600: JT809ExchangeMessageBodies { - + public override ushort MsgId => JT809BusinessType.主链路静态信息交换消息.ToUInt16Value(); + public override string Description => "主链路静态信息交换消息"; + public override JT809_LinkType LinkType => JT809_LinkType.main; } } diff --git a/src/JT809.Protocol/MessageBody/JT809_0x9001.cs b/src/JT809.Protocol/MessageBody/JT809_0x9001.cs index 9239dd0..35ce346 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x9001.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x9001.cs @@ -1,8 +1,7 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Formatters.MessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Enums; +using JT809.Protocol.Extensions; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.MessageBody { @@ -14,12 +13,26 @@ namespace JT809.Protocol.MessageBody /// 描述:主链路建立连接后,上级平台向下级平台发送从链路连接清求消息,以建立从链路连接 /// 下级平台在收到本息后,根据本校验码 VERIFY CODE 来实现数据的校验,校验后,则返回DOWN CONNECT RSP 消息 /// - [JT809Formatter(typeof(JT809_0x9001_Formatter))] - public class JT809_0x9001 : JT809Bodies + public class JT809_0x9001 : JT809Bodies, IJT809MessagePackFormatter { + public override ushort MsgId => JT809BusinessType.从链路连接请求消息.ToUInt16Value(); + public override string Description => "从链路连接请求消息"; + public override JT809_LinkType LinkType => JT809_LinkType.subordinate; /// /// 4.5.1.2 对应的校验码 /// public uint VerifyCode { get; set; } + + public JT809_0x9001 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x9001 jT809_0X9001 = new JT809_0x9001(); + jT809_0X9001.VerifyCode = reader.ReadUInt32(); + return jT809_0X9001; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9001 value, IJT809Config config) + { + writer.WriteUInt32(value.VerifyCode); + } } } diff --git a/src/JT809.Protocol/MessageBody/JT809_0x9002.cs b/src/JT809.Protocol/MessageBody/JT809_0x9002.cs index 13751cf..e1860a4 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x9002.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x9002.cs @@ -1,9 +1,7 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Formatters.MessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Enums; +using JT809.Protocol.Extensions; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.MessageBody { @@ -14,12 +12,25 @@ namespace JT809.Protocol.MessageBody /// 业务数据类型标识:DOWN_CONNNECT_RSP /// 描述:下级平台作为服务器端向上级平台客户端返回从链路连接应答消息,上级平台在接收到该应答消息结果后 /// - [JT809Formatter(typeof(JT809_0x9002_Formatter))] - public class JT809_0x9002:JT809Bodies + public class JT809_0x9002:JT809Bodies, IJT809MessagePackFormatter { + public override ushort MsgId => JT809BusinessType.从链路连接应答信息.ToUInt16Value(); + public override string Description => "从链路连接应答信息"; + public override JT809_LinkType LinkType => JT809_LinkType.subordinate; /// /// 验证结果 /// public JT809_0x9002_Result Result { get; set; } + 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; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9002 value, IJT809Config config) + { + writer.WriteByte((byte)value.Result); + } } } diff --git a/src/JT809.Protocol/MessageBody/JT809_0x9003.cs b/src/JT809.Protocol/MessageBody/JT809_0x9003.cs index fe5f55a..f070f1b 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x9003.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x9003.cs @@ -1,8 +1,7 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Formatters.MessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Enums; +using JT809.Protocol.Extensions; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.MessageBody { @@ -13,12 +12,26 @@ namespace JT809.Protocol.MessageBody ///业务数据类型标识:DOWN_DISCONNIrCT_REQ ///描述:从链路建立后,上级平台在取消该链路时,应向下级平台发送从链路注销请求消息 /// - [JT809Formatter(typeof(JT809_0x9003_Formatter))] - public class JT809_0x9003: JT809Bodies + public class JT809_0x9003: JT809Bodies, IJT809MessagePackFormatter { + public override ushort MsgId => JT809BusinessType.从链路注销请求消息.ToUInt16Value(); + public override string Description => "从链路注销请求消息"; + public override JT809_LinkType LinkType => JT809_LinkType.subordinate; /// /// 校验码 /// public uint VerifyCode { get; set; } + + public JT809_0x9003 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x9003 jT809_0X9003 = new JT809_0x9003(); + jT809_0X9003.VerifyCode = reader.ReadUInt32(); + return jT809_0X9003; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9003 value, IJT809Config config) + { + writer.WriteUInt32(value.VerifyCode); + } } } diff --git a/src/JT809.Protocol/MessageBody/JT809_0x9004.cs b/src/JT809.Protocol/MessageBody/JT809_0x9004.cs index 3a30aa3..fb1dc21 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x9004.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x9004.cs @@ -1,4 +1,6 @@ -using System; +using JT809.Protocol.Enums; +using JT809.Protocol.Extensions; +using System; using System.Collections.Generic; using System.Text; @@ -14,5 +16,8 @@ namespace JT809.Protocol.MessageBody /// public class JT809_0x9004:JT809Bodies { + public override ushort MsgId => JT809BusinessType.从链路注销应答消息.ToUInt16Value(); + public override string Description => "从链路注销应答消息"; + public override JT809_LinkType LinkType => JT809_LinkType.subordinate; } } diff --git a/src/JT809.Protocol/MessageBody/JT809_0x9005.cs b/src/JT809.Protocol/MessageBody/JT809_0x9005.cs index 2812e02..69c58a1 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x9005.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x9005.cs @@ -1,4 +1,6 @@ -using System; +using JT809.Protocol.Enums; +using JT809.Protocol.Extensions; +using System; using System.Collections.Generic; using System.Text; @@ -14,6 +16,8 @@ namespace JT809.Protocol.MessageBody /// public class JT809_0x9005:JT809Bodies { - + public override ushort MsgId => JT809BusinessType.从链路连接保持请求消息.ToUInt16Value(); + public override string Description => "从链路连接保持请求消息"; + public override JT809_LinkType LinkType => JT809_LinkType.subordinate; } } diff --git a/src/JT809.Protocol/MessageBody/JT809_0x9006.cs b/src/JT809.Protocol/MessageBody/JT809_0x9006.cs index 33d5c20..cafb771 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x9006.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x9006.cs @@ -1,4 +1,6 @@ -using System; +using JT809.Protocol.Enums; +using JT809.Protocol.Extensions; +using System; using System.Collections.Generic; using System.Text; @@ -14,5 +16,8 @@ namespace JT809.Protocol.MessageBody /// public class JT809_0x9006:JT809Bodies { + public override ushort MsgId => JT809BusinessType.从链路连接保持应答消息.ToUInt16Value(); + public override string Description => "从链路连接保持应答消息"; + public override JT809_LinkType LinkType => JT809_LinkType.subordinate; } } diff --git a/src/JT809.Protocol/MessageBody/JT809_0x9007.cs b/src/JT809.Protocol/MessageBody/JT809_0x9007.cs index 62145cd..9f3a0d8 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x9007.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x9007.cs @@ -1,9 +1,7 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Formatters.MessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Enums; +using JT809.Protocol.Extensions; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.MessageBody { @@ -18,12 +16,24 @@ namespace JT809.Protocol.MessageBody /// /// 本条消息无需被通知方应答 /// - [JT809Formatter(typeof(JT809_0x9007_Formatter))] - public class JT809_0x9007:JT809Bodies + public class JT809_0x9007:JT809Bodies, IJT809MessagePackFormatter { + public override ushort MsgId => JT809BusinessType.从链路断开通知消息.ToUInt16Value(); + public override string Description => "从链路断开通知消息"; + public override JT809_LinkType LinkType => JT809_LinkType.main; /// /// 错误代码 /// public JT809_0x9007_ReasonCode ReasonCode { get; set; } + 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; + } + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9007 value, IJT809Config config) + { + writer.WriteByte((byte)value.ReasonCode); + } } } diff --git a/src/JT809.Protocol/MessageBody/JT809_0x9008.cs b/src/JT809.Protocol/MessageBody/JT809_0x9008.cs index 3f480c8..515f3b0 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x9008.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x9008.cs @@ -1,9 +1,7 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Formatters.MessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Enums; +using JT809.Protocol.Extensions; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.MessageBody { @@ -11,12 +9,26 @@ namespace JT809.Protocol.MessageBody /// 上级平台主动关闭链路通知消息 /// 业务数据类型标识:DOWN_CLOSELINK_INFORM /// - [JT809Formatter(typeof(JT809_0x9008_Formatter))] - public class JT809_0x9008:JT809Bodies + public class JT809_0x9008:JT809Bodies, IJT809MessagePackFormatter { + public override ushort MsgId => JT809BusinessType.上级平台主动关闭链路通知消息.ToUInt16Value(); + public override string Description => "上级平台主动关闭链路通知消息"; +#warning 待验证主从链路 + public override JT809_LinkType LinkType => JT809_LinkType.subordinate; /// /// 错误代码 /// public JT809_0x9008_ReasonCode ReasonCode { get; set; } + 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; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9008 value, IJT809Config config) + { + writer.WriteByte((byte)value.ReasonCode); + } } } diff --git a/src/JT809.Protocol/MessageBody/JT809_0x9101.cs b/src/JT809.Protocol/MessageBody/JT809_0x9101.cs index 7f1b243..ec31bed 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x9101.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x9101.cs @@ -1,5 +1,7 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Formatters.MessageBodyFormatters; +using JT809.Protocol.Enums; +using JT809.Protocol.Extensions; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; using System; using System.Collections.Generic; using System.Text; @@ -14,9 +16,11 @@ namespace JT809.Protocol.MessageBody /// 描述:上级平台向下级平台定星通知已经收到下级平台上传的车辆定位信息数量(如:每收到10,000 条车辆定位信息通知一次) /// 本条消息不需下级平台应答。 /// - [JT809Formatter(typeof(JT809_0x9101_Formatter))] - public class JT809_0x9101:JT809Bodies + public class JT809_0x9101:JT809Bodies, IJT809MessagePackFormatter { + public override ushort MsgId => JT809BusinessType.接收车辆定位信息数量通知消息.ToUInt16Value(); + public override string Description => "接收车辆定位信息数量通知消息"; + public override JT809_LinkType LinkType => JT809_LinkType.subordinate; /// /// START_TIME_END_TIME共收到的车辆定位信息数量 /// @@ -31,5 +35,20 @@ namespace JT809.Protocol.MessageBody /// 注:采用 UTC 时间表示,如 2010-1-10 9:7:54 的 UTC 值为 1263085674,其在协议中表示为0x000000004B49286A. /// public ulong EndTime { get; set; } + public JT809_0x9101 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x9101 jT809_0X9101 = new JT809_0x9101(); + jT809_0X9101.DynamicInfoTotal = reader.ReadUInt32(); + jT809_0X9101.StartTime = reader.ReadUInt64(); + jT809_0X9101.EndTime = reader.ReadUInt64(); + return jT809_0X9101; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9101 value, IJT809Config config) + { + writer.WriteUInt32(value.DynamicInfoTotal); + writer.WriteUInt64(value.StartTime); + writer.WriteUInt64(value.EndTime); + } } } diff --git a/src/JT809.Protocol/MessageBody/JT809_0x9200.cs b/src/JT809.Protocol/MessageBody/JT809_0x9200.cs index bdc4f7c..f1dc60d 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x9200.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x9200.cs @@ -1,6 +1,5 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Formatters; - +using JT809.Protocol.Enums; +using JT809.Protocol.Extensions; namespace JT809.Protocol.MessageBody { @@ -11,9 +10,10 @@ namespace JT809.Protocol.MessageBody /// 业务数据类型标识:DOWN_EXG_MSG /// 描述:上级平台作为客户端向下级平台服务端发送车辆动态信息交换业务 /// - [JT809Formatter(typeof(JT809BodiesFormatter))] public class JT809_0x9200: JT809ExchangeMessageBodies { - + public override ushort MsgId => JT809BusinessType.从链路车辆动态信息交换业务.ToUInt16Value(); + public override string Description => "从链路车辆动态信息交换业务"; + public override JT809_LinkType LinkType => JT809_LinkType.subordinate; } } diff --git a/src/JT809.Protocol/MessageBody/JT809_0x9300.cs b/src/JT809.Protocol/MessageBody/JT809_0x9300.cs index af799c0..28e506a 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x9300.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x9300.cs @@ -1,6 +1,9 @@ -using JT809.Protocol.Attributes; +using JT809.Protocol.Enums; +using JT809.Protocol.Exceptions; +using JT809.Protocol.Extensions; using JT809.Protocol.Formatters; -using JT809.Protocol.Formatters.MessageBodyFormatters; +using JT809.Protocol.MessagePack; +using System; namespace JT809.Protocol.MessageBody { @@ -11,9 +14,53 @@ namespace JT809.Protocol.MessageBody /// 业务数据类型标识:DOWN_PLATFORM_MSG /// 描述:上级平台向下级平台发送平台问交互信息 /// - [JT809Formatter(typeof(JT809_0x9300_Formatter))] - public class JT809_0x9300: JT809ExchangeMessageBodies + public class JT809_0x9300: JT809ExchangeMessageBodies, IJT809MessagePackFormatter { - + public override ushort MsgId => JT809BusinessType.从链路平台间信息交互业务.ToUInt16Value(); + public override string Description => "从链路平台间信息交互业务"; + public override JT809_LinkType LinkType => JT809_LinkType.subordinate; + public JT809_0x9300 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x9300 jT809_0X9300 = new JT809_0x9300(); + jT809_0X9300.SubBusinessType = reader.ReadUInt16(); + jT809_0X9300.DataLength = reader.ReadUInt32(); + //JT809.Protocol.Enums.JT809BusinessType 映射对应消息特性 + try + { + Type jT809SubBodiesImplType = config.SubBusinessTypeFactory.GetSubBodiesImplTypeBySubBusinessType(jT809_0X9300.SubBusinessType); + if (jT809SubBodiesImplType != null) + jT809_0X9300.SubBodies = JT809MessagePackFormatterResolverExtensions.JT809DynamicDeserialize( + config.GetMessagePackFormatterByType(jT809SubBodiesImplType), + ref reader, config); + } + catch + { + throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{jT809_0X9300.SubBusinessType.ToString()}"); + } + return jT809_0X9300; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9300 value, IJT809Config config) + { + writer.WriteUInt16(value.SubBusinessType); + //JT809.Protocol.Enums.JT809BusinessType 映射对应消息特性 + try + { + // 先写入内容,然后在根据内容反写内容长度 + writer.Skip(4, out int subContentLengthPosition); + if (value.SubBodies != null) + { + JT809MessagePackFormatterResolverExtensions.JT809DynamicSerialize( + config.GetMessagePackFormatterByType(value.SubBodies.GetType()), + ref writer, value.SubBodies, + config); + } + writer.WriteInt32Return(writer.GetCurrentPosition() - subContentLengthPosition - 4, subContentLengthPosition); + } + catch + { + throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}"); + } + } } } diff --git a/src/JT809.Protocol/MessageBody/JT809_0x9400.cs b/src/JT809.Protocol/MessageBody/JT809_0x9400.cs index 8f20136..af3826f 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x9400.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x9400.cs @@ -1,10 +1,6 @@ -using JT809.Protocol.Attributes; + using JT809.Protocol.Enums; -using JT809.Protocol.Formatters; -using JT809.Protocol.Formatters.MessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Extensions; namespace JT809.Protocol.MessageBody { @@ -15,9 +11,10 @@ namespace JT809.Protocol.MessageBody /// 业务数据类型标识:DOWN_WARN_MSG /// 描述:上级平台向下级平台发送报瞥信息业务 /// - [JT809Formatter(typeof(JT809BodiesFormatter))] public class JT809_0x9400: JT809ExchangeMessageBodies { - + public override ushort MsgId => JT809BusinessType.从链路报警信息交互消息.ToUInt16Value(); + public override string Description => "从链路报警信息交互消息"; + public override JT809_LinkType LinkType => JT809_LinkType.subordinate; } } diff --git a/src/JT809.Protocol/MessageBody/JT809_0x9500.cs b/src/JT809.Protocol/MessageBody/JT809_0x9500.cs index b5d279e..0be655d 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x9500.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x9500.cs @@ -1,6 +1,5 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Formatters; - +using JT809.Protocol.Enums; +using JT809.Protocol.Extensions; namespace JT809.Protocol.MessageBody { @@ -11,9 +10,10 @@ namespace JT809.Protocol.MessageBody /// 业务数据类型标识:DOWN_CTRL_MSG /// 描述:上级平台向下级平台发送车辆监监管业务 /// - [JT809Formatter(typeof(JT809BodiesFormatter))] public class JT809_0x9500: JT809ExchangeMessageBodies { - + public override ushort MsgId => JT809BusinessType.从链路车辆监管消息.ToUInt16Value(); + public override string Description => "从链路车辆监管消息"; + public override JT809_LinkType LinkType => JT809_LinkType.subordinate; } } diff --git a/src/JT809.Protocol/MessageBody/JT809_0x9600.cs b/src/JT809.Protocol/MessageBody/JT809_0x9600.cs index 44c717e..2d4413e 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x9600.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x9600.cs @@ -1,10 +1,6 @@ -using JT809.Protocol.Attributes; + using JT809.Protocol.Enums; -using JT809.Protocol.Formatters; -using JT809.Protocol.Formatters.MessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Extensions; namespace JT809.Protocol.MessageBody { @@ -15,9 +11,10 @@ namespace JT809.Protocol.MessageBody /// 业务数据类型标识:DOWN_BASE_MSG /// 描述:上级平台向下级平台发送车辆静态信息交换业务 /// - [JT809Formatter(typeof(JT809BodiesFormatter))] public class JT809_0x9600: JT809ExchangeMessageBodies { - + public override ushort MsgId => JT809BusinessType.从链路静态信息交换消息.ToUInt16Value(); + public override string Description => "从链路静态信息交换消息"; + public override JT809_LinkType LinkType => JT809_LinkType.subordinate; } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x1201.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x1201.cs index e6de76b..13f2233 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x1201.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x1201.cs @@ -1,9 +1,5 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.SubMessageBody { @@ -13,8 +9,7 @@ namespace JT809.Protocol.SubMessageBody /// 描述:监控平台收到车载终端鉴权信息后,启动本命令向上级监管平台上传该车辆注册信息.各级监管平台再逐级向上级平台上传该信息 /// 本条消息服务端无需应答 /// - [JT809Formatter(typeof(JT809_0x1200_0x1201_Formatter))] - public class JT809_0x1200_0x1201:JT809SubBodies + public class JT809_0x1200_0x1201:JT809SubBodies, IJT809MessagePackFormatter { /// /// 平台唯一编码 @@ -36,5 +31,25 @@ namespace JT809.Protocol.SubMessageBody /// 车载终端 SIM 卡电话号码。号码不是12 位,则在前补充数字 0. /// public string TerminalSimCode { get; set; } + public JT809_0x1200_0x1201 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x1200_0x1201 jT809_0X1200_0X1201 = new JT809_0x1200_0x1201(); + jT809_0X1200_0X1201.PlateformId = reader.ReadBigNumber(11); + jT809_0X1200_0X1201.ProducerId = reader.ReadBigNumber(11); + jT809_0X1200_0X1201.TerminalModelType = reader.ReadString(20); + jT809_0X1200_0X1201.TerminalId = reader.ReadString(7); + jT809_0X1200_0X1201.TerminalId = jT809_0X1200_0X1201.TerminalId.ToUpper(); + jT809_0X1200_0X1201.TerminalSimCode = reader.ReadString(12); + return jT809_0X1200_0X1201; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1200_0x1201 value, IJT809Config config) + { + writer.WriteBigNumber(value.PlateformId, 11); + writer.WriteBigNumber(value.ProducerId, 11); + writer.WriteStringPadRight(value.TerminalModelType, 20); + writer.WriteStringPadRight(value.TerminalId.ToUpper(), 7); + writer.WriteStringPadRight(value.TerminalSimCode, 12); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x1202.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x1202.cs index 2ab9938..1f0d502 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x1202.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x1202.cs @@ -1,9 +1,7 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; +using JT809.Protocol.Enums; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; using JT809.Protocol.Metadata; -using System; -using System.Collections.Generic; -using System.Text; namespace JT809.Protocol.SubMessageBody { @@ -11,8 +9,7 @@ namespace JT809.Protocol.SubMessageBody /// 实时上传车辆定位信息 /// 子业务类型标识:UP_EXG_MSG_REAL_LOCATION /// - [JT809Formatter(typeof(JT809_0x1200_0x1202_Formatter))] - public class JT809_0x1200_0x1202:JT809SubBodies + public class JT809_0x1200_0x1202:JT809SubBodies, IJT809MessagePackFormatter { public JT809_0x1200_0x1202() { @@ -22,5 +19,47 @@ namespace JT809.Protocol.SubMessageBody /// 车辆定位信息 /// public JT809VehiclePositionProperties VehiclePosition { get; set; } + + public JT809_0x1200_0x1202 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x1200_0x1202 jT809_0X1200_0X1202 = new JT809_0x1200_0x1202(); + jT809_0X1200_0X1202.VehiclePosition.Encrypt = (JT809_VehiclePositionEncrypt)reader.ReadByte(); + jT809_0X1200_0X1202.VehiclePosition.Day = reader.ReadByte(); + jT809_0X1200_0X1202.VehiclePosition.Month = reader.ReadByte(); + jT809_0X1200_0X1202.VehiclePosition.Year = reader.ReadUInt16(); + jT809_0X1200_0X1202.VehiclePosition.Hour = reader.ReadByte(); + jT809_0X1200_0X1202.VehiclePosition.Minute = reader.ReadByte(); + jT809_0X1200_0X1202.VehiclePosition.Second = reader.ReadByte(); + jT809_0X1200_0X1202.VehiclePosition.Lon = reader.ReadUInt32(); + jT809_0X1200_0X1202.VehiclePosition.Lat = reader.ReadUInt32(); + jT809_0X1200_0X1202.VehiclePosition.Vec1 = reader.ReadUInt16(); + jT809_0X1200_0X1202.VehiclePosition.Vec2 = reader.ReadUInt16(); + jT809_0X1200_0X1202.VehiclePosition.Vec3 = reader.ReadUInt32(); + jT809_0X1200_0X1202.VehiclePosition.Direction = reader.ReadUInt16(); + jT809_0X1200_0X1202.VehiclePosition.Altitude = reader.ReadUInt16(); + jT809_0X1200_0X1202.VehiclePosition.State = reader.ReadUInt32(); + jT809_0X1200_0X1202.VehiclePosition.Alarm = reader.ReadUInt32(); + return jT809_0X1200_0X1202; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1200_0x1202 value, IJT809Config config) + { + writer.WriteByte((byte)value.VehiclePosition.Encrypt); + writer.WriteByte(value.VehiclePosition.Day); + writer.WriteByte(value.VehiclePosition.Month); + writer.WriteUInt16(value.VehiclePosition.Year); + writer.WriteByte(value.VehiclePosition.Hour); + writer.WriteByte(value.VehiclePosition.Minute); + writer.WriteByte(value.VehiclePosition.Second); + writer.WriteUInt32(value.VehiclePosition.Lon); + writer.WriteUInt32(value.VehiclePosition.Lat); + writer.WriteUInt16(value.VehiclePosition.Vec1); + writer.WriteUInt16(value.VehiclePosition.Vec2); + writer.WriteUInt32(value.VehiclePosition.Vec3); + writer.WriteUInt16(value.VehiclePosition.Direction); + writer.WriteUInt16(value.VehiclePosition.Altitude); + writer.WriteUInt32(value.VehiclePosition.State); + writer.WriteUInt32(value.VehiclePosition.Alarm); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x1203.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x1203.cs index b5264c8..b301b20 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x1203.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x1203.cs @@ -1,5 +1,5 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; using JT809.Protocol.Metadata; using System; using System.Collections.Generic; @@ -16,8 +16,7 @@ namespace JT809.Protocol.SubMessageBody /// 本条消息上级平台采用定量回复,即收到一定数量的数据后,即通过从链路应答数据量。 /// /// - [JT809Formatter(typeof(JT809_0x1200_0x1203_Formatter))] - public class JT809_0x1200_0x1203 : JT809SubBodies + public class JT809_0x1200_0x1203 : JT809SubBodies, IJT809MessagePackFormatter { /// /// 卫星定位数据个数 1大于GNSS_CNT小于5 @@ -27,5 +26,47 @@ namespace JT809.Protocol.SubMessageBody /// 卫星定位数据集合 /// public List GNSS { get; set; } + + public JT809_0x1200_0x1203 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x1200_0x1203 jT809_0X1200_0X1203 = new JT809_0x1200_0x1203(); + jT809_0X1200_0X1203.GNSSCount = reader.ReadByte(); + jT809_0X1200_0X1203.GNSS = new List(); + if (jT809_0X1200_0X1203.GNSSCount > 0) + { + for (int i = 0; i < jT809_0X1200_0X1203.GNSSCount; i++) + { + try + { + JT809MessagePackReader jT809_0x1200_0x1202Reader = new JT809MessagePackReader(reader.ReadArray(36)); + //todo:JT809_0x1200_0x1202_Formatter + //var jT809_0x1200_0x1202 = JT809_0x1200_0x1202_Formatter.Instance.Deserialize(ref jT809_0x1200_0x1202Reader, config); + //jT809_0X1200_0X1203.GNSS.Add(jT809_0x1200_0x1202); + } + catch (Exception) + { + + } + } + } + return jT809_0X1200_0X1203; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1200_0x1203 value, IJT809Config config) + { + writer.WriteByte((byte)value.GNSS.Count); + foreach (var item in value.GNSS) + { + try + { + //todo:JT809_0x1200_0x1202_Formatter + //JT809_0x1200_0x1202_Formatter.Instance.Serialize(ref writer, item, config); + } + catch (Exception ex) + { + + } + } + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x1207.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x1207.cs index 07cc8f5..44fece2 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x1207.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x1207.cs @@ -1,8 +1,6 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; using System; -using System.Collections.Generic; -using System.Text; namespace JT809.Protocol.SubMessageBody { @@ -11,8 +9,7 @@ namespace JT809.Protocol.SubMessageBody /// 子业务类型标识:UP_EXG_MSG_APPLY-FOR_MONITOR_STARTUP /// 描述:当下级平台需要在特定时问段内监控特殊车辆时,可上传此命令到上级平台申请对该车辆定位数据交换到下级平台,申请成功后,此车辆定位数据将在指定时间内交换到该平台(即使该车没有进入该平台所属区域也会交换) /// - [JT809Formatter(typeof(JT809_0x1200_0x1207_Formatter))] - public class JT809_0x1200_0x1207:JT809SubBodies + public class JT809_0x1200_0x1207:JT809SubBodies, IJT809MessagePackFormatter { /// /// 开始时间,用 UTC 时间表示 @@ -22,5 +19,20 @@ namespace JT809.Protocol.SubMessageBody /// 结束时间,用 UTC 时间表示 /// public DateTime EndTime { get; set; } + + + public JT809_0x1200_0x1207 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x1200_0x1207 jT809_0X1200_0X1207 = new JT809_0x1200_0x1207(); + jT809_0X1200_0X1207.StartTime = reader.ReadUTCDateTime(); + jT809_0X1200_0X1207.EndTime = reader.ReadUTCDateTime(); + return jT809_0X1200_0X1207; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1200_0x1207 value, IJT809Config config) + { + writer.WriteUTCDateTime(value.StartTime); + writer.WriteUTCDateTime(value.EndTime); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x1209.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x1209.cs index 9f0ed55..f9c69e9 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x1209.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x1209.cs @@ -1,8 +1,6 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; using System; -using System.Collections.Generic; -using System.Text; namespace JT809.Protocol.SubMessageBody { @@ -11,8 +9,7 @@ namespace JT809.Protocol.SubMessageBody /// 子业务类型标识:UP_EXG_MSG_APPLY_HISGNSSDATA_REQ /// 描述:在平台间传输链路中断并重新建立连接后,下级平台向上级平台请求中断期间内上级平台需交换至下级平台的车辆定位信息时,向上级平台发出补发车辆定位信息请求,上级平台对请求应答后进行“补发车辆定位信息” /// - [JT809Formatter(typeof(JT809_0x1200_0x1209_Formatter))] - public class JT809_0x1200_0x1209:JT809SubBodies + public class JT809_0x1200_0x1209:JT809SubBodies, IJT809MessagePackFormatter { /// /// 开始时间,用 UTC 时间表示 @@ -22,5 +19,19 @@ namespace JT809.Protocol.SubMessageBody /// 结束时间,用 UTC 时间表示 /// public DateTime EndTime { get; set; } + + public JT809_0x1200_0x1209 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x1200_0x1209 jT809_0X1200_0X1207 = new JT809_0x1200_0x1209(); + jT809_0X1200_0X1207.StartTime = reader.ReadUTCDateTime(); + jT809_0X1200_0X1207.EndTime = reader.ReadUTCDateTime(); + return jT809_0X1200_0X1207; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1200_0x1209 value, IJT809Config config) + { + writer.WriteUTCDateTime(value.StartTime); + writer.WriteUTCDateTime(value.EndTime); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x120A.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x120A.cs index beb57aa..2a6c90d 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x120A.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x120A.cs @@ -1,8 +1,5 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.SubMessageBody { @@ -11,8 +8,7 @@ namespace JT809.Protocol.SubMessageBody /// 子业务类型标识:UP_EXG_MSG_REPORT_DRIVER_INFO_ACK /// 描述:下级平台应答上级平台发送的上报驾驶员身份识别信息请求消息,上传指定车辆的驾驶员身份识别信息数据 /// - [JT809Formatter(typeof(JT809_0x1200_0x120A_Formatter))] - public class JT809_0x1200_0x120A:JT809SubBodies + public class JT809_0x1200_0x120A:JT809SubBodies, IJT809MessagePackFormatter { /// /// 驾驶员姓名 @@ -30,5 +26,23 @@ namespace JT809.Protocol.SubMessageBody /// 发证机构名称(备用) /// public string OrgName { get; set; } + + public JT809_0x1200_0x120A Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x1200_0x120A jT809_0X1200_0X120A = new JT809_0x1200_0x120A(); + jT809_0X1200_0X120A.DriverName = reader.ReadString(16); + jT809_0X1200_0X120A.DriverID = reader.ReadString(20); + jT809_0X1200_0X120A.Licence = reader.ReadString(40); + jT809_0X1200_0X120A.OrgName = reader.ReadString(200); + return jT809_0X1200_0X120A; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1200_0x120A value, IJT809Config config) + { + writer.WriteStringPadRight(value.DriverName, 16); + writer.WriteStringPadRight(value.DriverID, 20); + writer.WriteStringPadRight(value.Licence, 40); + writer.WriteStringPadRight(value.OrgName, 200); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x120B.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x120B.cs index d45236c..0bfe638 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x120B.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x120B.cs @@ -1,8 +1,5 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.SubMessageBody { @@ -11,8 +8,7 @@ namespace JT809.Protocol.SubMessageBody /// 子业务类型标识:UP_CXG_MSG_TAKE_EWAYBILL_ACK /// 描述:下级平台应答上级平台发送的上报车辆电子运单请求消息,向上级平台上传车辆当前电子运单 /// - [JT809Formatter(typeof(JT809_0x1200_0x120B_Formatter))] - public class JT809_0x1200_0x120B:JT809SubBodies + public class JT809_0x1200_0x120B:JT809SubBodies, IJT809MessagePackFormatter { /// /// 电子运单数据体长度 @@ -22,5 +18,18 @@ namespace JT809.Protocol.SubMessageBody /// 电子运单数据内容 /// public string EwaybillInfo { get; set; } + public JT809_0x1200_0x120B Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x1200_0x120B jT809_0X1200_0X120B = new JT809_0x1200_0x120B(); + jT809_0X1200_0X120B.EwaybillLength = reader.ReadUInt32(); + jT809_0X1200_0X120B.EwaybillInfo = reader.ReadString((int)jT809_0X1200_0X120B.EwaybillLength); + return jT809_0X1200_0X120B; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1200_0x120B value, IJT809Config config) + { + writer.WriteUInt32((uint)value.EwaybillInfo.Length); + writer.WriteString(value.EwaybillInfo); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x120C.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x120C.cs index 292623e..3602265 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x120C.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x120C.cs @@ -1,8 +1,5 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.SubMessageBody { @@ -10,8 +7,7 @@ namespace JT809.Protocol.SubMessageBody /// 主动上报驾驶员身份信息消息 /// 子业务类型标识:UP_EXG_MSG_REPORT_DRIVER_INFO /// - [JT809Formatter(typeof(JT809_0x1200_0x120C_Formatter))] - public class JT809_0x1200_0x120C:JT809SubBodies + public class JT809_0x1200_0x120C:JT809SubBodies, IJT809MessagePackFormatter { /// /// 驾驶员姓名 @@ -29,5 +25,23 @@ namespace JT809.Protocol.SubMessageBody /// 发证机构名称(备用) /// public string OrgName { get; set; } + + public JT809_0x1200_0x120C Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x1200_0x120C jT809_0X1200_0X120C = new JT809_0x1200_0x120C(); + jT809_0X1200_0X120C.DriverName = reader.ReadString(16); + jT809_0X1200_0X120C.DriverID = reader.ReadString(20); + jT809_0X1200_0X120C.Licence = reader.ReadString(40); + jT809_0X1200_0X120C.OrgName = reader.ReadString(200); + return jT809_0X1200_0X120C; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1200_0x120C value, IJT809Config config) + { + writer.WriteStringPadRight(value.DriverName, 16); + writer.WriteStringPadRight(value.DriverID, 20); + writer.WriteStringPadRight(value.Licence, 40); + writer.WriteStringPadRight(value.OrgName, 200); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x120D.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x120D.cs index 794f013..b60dfd0 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x120D.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x120D.cs @@ -1,8 +1,5 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.SubMessageBody { @@ -10,8 +7,7 @@ namespace JT809.Protocol.SubMessageBody /// 主动上报车辆电子运单信息 /// 子业务类型标识:UP_EXG_MSG_REPORT_EWAYBILL_INFO /// - [JT809Formatter(typeof(JT809_0x1200_0x120D_Formatter))] - public class JT809_0x1200_0x120D:JT809SubBodies + public class JT809_0x1200_0x120D:JT809SubBodies, IJT809MessagePackFormatter { /// /// 电子运单数据体长度 @@ -21,5 +17,18 @@ namespace JT809.Protocol.SubMessageBody /// 电子运单数据内容 /// public string EwaybillInfo { get; set; } + public JT809_0x1200_0x120D Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x1200_0x120D jT809_0X1200_0X120D = new JT809_0x1200_0x120D(); + jT809_0X1200_0X120D.EwaybillLength = reader.ReadUInt32(); + jT809_0X1200_0X120D.EwaybillInfo = reader.ReadString((int)jT809_0X1200_0X120D.EwaybillLength); + return jT809_0X1200_0X120D; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1200_0x120D value, IJT809Config config) + { + writer.WriteUInt32((uint)value.EwaybillInfo.Length); + writer.WriteString(value.EwaybillInfo); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x1300_0x1301.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x1300_0x1301.cs index e4e03ac..f2f9249 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x1300_0x1301.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x1300_0x1301.cs @@ -1,9 +1,6 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Enums; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.SubMessageBody { @@ -12,8 +9,7 @@ namespace JT809.Protocol.SubMessageBody /// 子业务类型标识:UP_PLATFORM_MSG_POST_QUERY_ACK /// 描述:下级平台应答上级平台发送的不定期平台查岗消息 /// - [JT809Formatter(typeof(JT809_0x1300_0x1301_Formatter))] - public class JT809_0x1300_0x1301:JT809SubBodies + public class JT809_0x1300_0x1301:JT809SubBodies, IJT809MessagePackFormatter { /// /// 查岗对象的类型 @@ -35,5 +31,26 @@ namespace JT809.Protocol.SubMessageBody /// 应答内容 /// public string InfoContent { get; set; } + public JT809_0x1300_0x1301 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x1300_0x1301 jT809_0X1200_0X1301 = new JT809_0x1300_0x1301(); + jT809_0X1200_0X1301.ObjectType = (JT809_0x1301_ObjectType)reader.ReadByte(); + jT809_0X1200_0X1301.ObjectID = reader.ReadString(12); + jT809_0X1200_0X1301.InfoID = reader.ReadUInt32(); + jT809_0X1200_0X1301.InfoLength = reader.ReadUInt32(); + jT809_0X1200_0X1301.InfoContent = reader.ReadString((int)jT809_0X1200_0X1301.InfoLength); + return jT809_0X1200_0X1301; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1300_0x1301 value, IJT809Config config) + { + writer.WriteByte((byte)value.ObjectType); + writer.WriteStringPadRight(value.ObjectID, 12); + writer.WriteUInt32(value.InfoID); + // 先计算内容长度(汉字为两个字节) + writer.Skip(4, out int lengthPosition); + writer.WriteString(value.InfoContent); + writer.WriteInt32Return(writer.GetCurrentPosition() - lengthPosition - 4, lengthPosition); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x1300_0x1302.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x1300_0x1302.cs index c095478..b71f3d1 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x1300_0x1302.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x1300_0x1302.cs @@ -1,8 +1,5 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.SubMessageBody { @@ -11,12 +8,22 @@ namespace JT809.Protocol.SubMessageBody /// 子业务类型标识:UP_PLATFORM_MSG_INFO_ACK /// 描述:下级平台收到上级平台发送的下发平台间报文请求消息后,发送应答消息 /// - [JT809Formatter(typeof(JT809_0x1300_0x1302_Formatter))] - public class JT809_0x1300_0x1302:JT809SubBodies + public class JT809_0x1300_0x1302:JT809SubBodies, IJT809MessagePackFormatter { /// /// 信息ID /// public uint InfoID { get; set; } + public JT809_0x1300_0x1302 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x1300_0x1302 jT809_0X1200_0X1302 = new JT809_0x1300_0x1302(); + jT809_0X1200_0X1302.InfoID = reader.ReadUInt32(); + return jT809_0X1200_0X1302; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1300_0x1302 value, IJT809Config config) + { + writer.WriteUInt32(value.InfoID); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x1400_0x1401.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x1400_0x1401.cs index 2601730..616c1fa 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x1400_0x1401.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x1400_0x1401.cs @@ -1,9 +1,6 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Enums; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.SubMessageBody { @@ -12,8 +9,7 @@ namespace JT809.Protocol.SubMessageBody /// 子业务类型标识:UP_WARN_MSG_URGE_TODO_ACK /// 描述:下级平台应答上级平台下发的报警督办请求消息,向上.级平台上报车辆的报瞥处理结果 /// - [JT809Formatter(typeof(JT809_0x1400_0x1401_Formatter))] - public class JT809_0x1400_0x1401:JT809SubBodies + public class JT809_0x1400_0x1401:JT809SubBodies, IJT809MessagePackFormatter { /// /// 报警督办 ID @@ -23,5 +19,18 @@ namespace JT809.Protocol.SubMessageBody /// 报警处理结果 /// public JT809_0x1401_Result Result { get; set; } + public JT809_0x1400_0x1401 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x1400_0x1401 jT809_0X1400_0X1401 = new JT809_0x1400_0x1401(); + jT809_0X1400_0X1401.SupervisionID = reader.ReadUInt32(); + jT809_0X1400_0X1401.Result = (JT809_0x1401_Result)reader.ReadByte(); + return jT809_0X1400_0X1401; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1400_0x1401 value, IJT809Config config) + { + writer.WriteUInt32(value.SupervisionID); + writer.WriteByte((byte)value.Result); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x1400_0x1402.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x1400_0x1402.cs index 4d2734a..b568992 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x1400_0x1402.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x1400_0x1402.cs @@ -1,9 +1,7 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; +using JT809.Protocol.Enums; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; using System; -using System.Collections.Generic; -using System.Text; namespace JT809.Protocol.SubMessageBody { @@ -13,8 +11,7 @@ namespace JT809.Protocol.SubMessageBody /// 描述:下级平台向上级平台上报某车辆的报警信息 /// 本条消息上级平台无需应答 /// - [JT809Formatter(typeof(JT809_0x1400_0x1402_Formatter))] - public class JT809_0x1400_0x1402:JT809SubBodies + public class JT809_0x1400_0x1402:JT809SubBodies, IJT809MessagePackFormatter { /// /// 报警信息来源 @@ -40,5 +37,28 @@ namespace JT809.Protocol.SubMessageBody /// 数据长度 /// public string InfoContent { get; set; } + public JT809_0x1400_0x1402 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x1400_0x1402 jT809_0X1400_0X1402 = new JT809_0x1400_0x1402(); + jT809_0X1400_0X1402.WarnSrc = (JT809WarnSrc)reader.ReadByte(); + jT809_0X1400_0X1402.WarnType = (JT809WarnType)reader.ReadUInt16(); + jT809_0X1400_0X1402.WarnTime = reader.ReadUTCDateTime(); + jT809_0X1400_0X1402.InfoID = reader.ReadUInt32(); + jT809_0X1400_0X1402.InfoLength = reader.ReadUInt32(); + jT809_0X1400_0X1402.InfoContent = reader.ReadString((int)jT809_0X1400_0X1402.InfoLength); + return jT809_0X1400_0X1402; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1400_0x1402 value, IJT809Config config) + { + writer.WriteByte((byte)value.WarnSrc); + writer.WriteUInt16((ushort)value.WarnType); + writer.WriteUTCDateTime(value.WarnTime); + writer.WriteUInt32(value.InfoID); + // 先计算内容长度(汉字为两个字节) + writer.Skip(4, out int lengthPosition); + writer.WriteString(value.InfoContent); + writer.WriteInt32Return(writer.GetCurrentPosition() - lengthPosition - 4, lengthPosition); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x1400_0x1403.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x1400_0x1403.cs index a78f2dd..85a1825 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x1400_0x1403.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x1400_0x1403.cs @@ -1,9 +1,6 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Enums; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.SubMessageBody { @@ -13,8 +10,7 @@ namespace JT809.Protocol.SubMessageBody /// 描述:下级平台向上级平台上报报警处理结果 /// 本条消息上级平台无需应答 /// - [JT809Formatter(typeof(JT809_0x1400_0x1403_Formatter))] - public class JT809_0x1400_0x1403:JT809SubBodies + public class JT809_0x1400_0x1403:JT809SubBodies, IJT809MessagePackFormatter { /// /// 报警信息ID @@ -24,5 +20,18 @@ namespace JT809.Protocol.SubMessageBody /// 处理结果 /// public JT809_0x1403_Result Result { get; set; } + public JT809_0x1400_0x1403 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x1400_0x1403 jT809_0X1400_0X1403 = new JT809_0x1400_0x1403(); + jT809_0X1400_0X1403.InfoID = reader.ReadUInt32(); + jT809_0X1400_0X1403.Result = (JT809_0x1403_Result)reader.ReadByte(); + return jT809_0X1400_0X1403; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1400_0x1403 value, IJT809Config config) + { + writer.WriteUInt32(value.InfoID); + writer.WriteByte((byte)value.Result); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x1500_0x1501.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x1500_0x1501.cs index 9920553..c5840d4 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x1500_0x1501.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x1500_0x1501.cs @@ -1,9 +1,6 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Enums; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.SubMessageBody { @@ -12,12 +9,22 @@ namespace JT809.Protocol.SubMessageBody /// 子业务类型标识:UP_CTRL_MSG_MONITOR_VEHTCLE_ACK /// 描述:下级平台向上级平台上传车辆单向监听请求消息的应答 /// - [JT809Formatter(typeof(JT809_0x1500_0x1501_Formatter))] - public class JT809_0x1500_0x1501:JT809SubBodies + public class JT809_0x1500_0x1501:JT809SubBodies, IJT809MessagePackFormatter { /// /// 应答结果 /// public JT809_0x1501_Result Result { get; set; } + public JT809_0x1500_0x1501 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x1500_0x1501 jT809_0X1500_0X1501 = new JT809_0x1500_0x1501(); + jT809_0X1500_0X1501.Result = (JT809_0x1501_Result)reader.ReadByte(); + return jT809_0X1500_0X1501; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1500_0x1501 value, IJT809Config config) + { + writer.WriteByte((byte)value.Result); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x1500_0x1502.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x1500_0x1502.cs index 98d87c9..346a570 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x1500_0x1502.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x1500_0x1502.cs @@ -1,6 +1,6 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; +using JT809.Protocol.Enums; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; using JT809.Protocol.Metadata; using System; using System.Collections.Generic; @@ -13,8 +13,7 @@ namespace JT809.Protocol.SubMessageBody /// 子业务类型标识:UP_ CTRL_ MSG _TAKE_ PHOTO_ ACK /// 描述:下级平台应答上级平台发送的车辆拍照请求消息,上传图片信息到上级平台 /// - [JT809Formatter(typeof(JT809_0x1500_0x1502_Formatter))] - public class JT809_0x1500_0x1502:JT809SubBodies + public class JT809_0x1500_0x1502:JT809SubBodies, IJT809MessagePackFormatter { public JT809_0x1500_0x1502() { @@ -49,5 +48,65 @@ namespace JT809.Protocol.SubMessageBody /// 图片内容 /// public byte[] Photo { get; set; } + public JT809_0x1500_0x1502 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x1500_0x1502 jT809_0X1500_0X1502 = new JT809_0x1500_0x1502(); + jT809_0X1500_0X1502.PhotoRspFlag = (JT809_0x1502_PhotoRspFlag)reader.ReadByte(); + jT809_0X1500_0X1502.VehiclePosition.Encrypt = (JT809_VehiclePositionEncrypt)reader.ReadByte(); + jT809_0X1500_0X1502.VehiclePosition.Day = reader.ReadByte(); + jT809_0X1500_0X1502.VehiclePosition.Month = reader.ReadByte(); + jT809_0X1500_0X1502.VehiclePosition.Year = reader.ReadUInt16(); + jT809_0X1500_0X1502.VehiclePosition.Hour = reader.ReadByte(); + jT809_0X1500_0X1502.VehiclePosition.Minute = reader.ReadByte(); + jT809_0X1500_0X1502.VehiclePosition.Second = reader.ReadByte(); + jT809_0X1500_0X1502.VehiclePosition.Lon = reader.ReadUInt32(); + jT809_0X1500_0X1502.VehiclePosition.Lat = reader.ReadUInt32(); + jT809_0X1500_0X1502.VehiclePosition.Vec1 = reader.ReadUInt16(); + jT809_0X1500_0X1502.VehiclePosition.Vec2 = reader.ReadUInt16(); + jT809_0X1500_0X1502.VehiclePosition.Vec3 = reader.ReadUInt32(); + jT809_0X1500_0X1502.VehiclePosition.Direction = reader.ReadUInt16(); + jT809_0X1500_0X1502.VehiclePosition.Altitude = reader.ReadUInt16(); + jT809_0X1500_0X1502.VehiclePosition.State = reader.ReadUInt32(); + jT809_0X1500_0X1502.VehiclePosition.Alarm = reader.ReadUInt32(); + jT809_0X1500_0X1502.LensID = reader.ReadByte(); + jT809_0X1500_0X1502.PhotoLen = reader.ReadUInt32(); + jT809_0X1500_0X1502.SizeType = reader.ReadByte(); + jT809_0X1500_0X1502.Type = reader.ReadByte(); + if (jT809_0X1500_0X1502.PhotoLen > 0) + { + jT809_0X1500_0X1502.Photo = reader.ReadArray((int)jT809_0X1500_0X1502.PhotoLen).ToArray(); + } + return jT809_0X1500_0X1502; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1500_0x1502 value, IJT809Config config) + { + writer.WriteByte((byte)value.PhotoRspFlag); + writer.WriteByte((byte)value.VehiclePosition.Encrypt); + writer.WriteByte(value.VehiclePosition.Day); + writer.WriteByte(value.VehiclePosition.Month); + writer.WriteUInt16(value.VehiclePosition.Year); + writer.WriteByte(value.VehiclePosition.Hour); + writer.WriteByte(value.VehiclePosition.Minute); + writer.WriteByte(value.VehiclePosition.Second); + writer.WriteUInt32(value.VehiclePosition.Lon); + writer.WriteUInt32(value.VehiclePosition.Lat); + writer.WriteUInt16(value.VehiclePosition.Vec1); + writer.WriteUInt16(value.VehiclePosition.Vec2); + writer.WriteUInt32(value.VehiclePosition.Vec3); + writer.WriteUInt16(value.VehiclePosition.Direction); + writer.WriteUInt16(value.VehiclePosition.Altitude); + writer.WriteUInt32(value.VehiclePosition.State); + writer.WriteUInt32(value.VehiclePosition.Alarm); + writer.WriteByte(value.LensID); + bool isPhoto = (value.Photo != null && value.Photo.Length > 0); + writer.WriteUInt32(isPhoto ? (uint)value.Photo.Length : 0); + writer.WriteByte(value.SizeType); + writer.WriteByte(value.Type); + if (isPhoto) + { + writer.WriteArray(value.Photo); + } + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x1500_0x1503.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x1500_0x1503.cs index 0ea98ad..35e68c3 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x1500_0x1503.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x1500_0x1503.cs @@ -1,9 +1,6 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Enums; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.SubMessageBody { @@ -12,8 +9,7 @@ namespace JT809.Protocol.SubMessageBody /// 子业务类型标识:UP_CTRL_MSG_TEXT_INFO_ACK /// 描述:下级平台应答上级平台下发的报文是否成功到达指定车辆 /// - [JT809Formatter(typeof(JT809_0x1500_0x1503_Formatter))] - public class JT809_0x1500_0x1503:JT809SubBodies + public class JT809_0x1500_0x1503:JT809SubBodies, IJT809MessagePackFormatter { /// /// 消息ID @@ -24,5 +20,18 @@ namespace JT809.Protocol.SubMessageBody /// 应答结果 /// public JT809_0x1503_Result Result { get; set; } + public JT809_0x1500_0x1503 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x1500_0x1503 jT809_0X1500_0X1503 = new JT809_0x1500_0x1503(); + jT809_0X1500_0X1503.MsgID = reader.ReadUInt32(); + jT809_0X1500_0X1503.Result = (JT809_0x1503_Result)reader.ReadByte(); + return jT809_0X1500_0X1503; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1500_0x1503 value, IJT809Config config) + { + writer.WriteUInt32(value.MsgID); + writer.WriteByte((byte)value.Result); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x1500_0x1504.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x1500_0x1504.cs index 393297a..43dee09 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x1500_0x1504.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x1500_0x1504.cs @@ -1,9 +1,6 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Enums; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.SubMessageBody { @@ -12,8 +9,7 @@ namespace JT809.Protocol.SubMessageBody /// 子业务类型标识:UP_CTRL_MSG_TAKE_T'RAVEL_ACK /// 描述:下级平台应答上级平台下发的上报车辆行驶记录请求消息,将车辆行驶记录数据上传至上级平台 /// - [JT809Formatter(typeof(JT809_0x1500_0x1504_Formatter))] - public class JT809_0x1500_0x1504:JT809SubBodies + public class JT809_0x1500_0x1504:JT809SubBodies, IJT809MessagePackFormatter { /// /// 命令字 @@ -27,5 +23,22 @@ namespace JT809.Protocol.SubMessageBody /// 车辆行驶记录信息 /// public string TraveldataInfo { get; set; } + public JT809_0x1500_0x1504 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x1500_0x1504 jT809_0X1500_0X1504 = new JT809_0x1500_0x1504(); + jT809_0X1500_0X1504.CommandType = (JT809CommandType)reader.ReadByte(); + jT809_0X1500_0X1504.TraveldataLength = reader.ReadUInt32(); + jT809_0X1500_0X1504.TraveldataInfo = reader.ReadString((int)jT809_0X1500_0X1504.TraveldataLength); + return jT809_0X1500_0X1504; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1500_0x1504 value, IJT809Config config) + { + writer.WriteByte((byte)value.CommandType); + // 先计算内容长度(汉字为两个字节) + writer.Skip(4, out int lengthPosition); + writer.WriteString(value.TraveldataInfo); + writer.WriteInt32Return(writer.GetCurrentPosition() - lengthPosition - 4, lengthPosition); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x1500_0x1505.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x1500_0x1505.cs index b327eb2..1e16c89 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x1500_0x1505.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x1500_0x1505.cs @@ -1,9 +1,6 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Enums; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.SubMessageBody { @@ -12,12 +9,22 @@ namespace JT809.Protocol.SubMessageBody /// 子业务类型标识: UP_CTRL_MSG_EMERGENCY_MONITORING_ACK /// 描述:下级平台应答上级平台下发的车辆应急接入监管平台请求消息应答 /// - [JT809Formatter(typeof(JT809_0x1500_0x1505_Formatter))] - public class JT809_0x1500_0x1505:JT809SubBodies + public class JT809_0x1500_0x1505:JT809SubBodies, IJT809MessagePackFormatter { /// /// 应答结果 /// public JT809_0x1505_Result Result { get; set; } + public JT809_0x1500_0x1505 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x1500_0x1505 jT809_0X1500_0X1505 = new JT809_0x1500_0x1505(); + jT809_0X1500_0X1505.Result = (JT809_0x1505_Result)reader.ReadByte(); + return jT809_0X1500_0X1505; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1500_0x1505 value, IJT809Config config) + { + writer.WriteByte((byte)value.Result); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x1600_0x1601.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x1600_0x1601.cs index 0d201d5..2765e02 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x1600_0x1601.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x1600_0x1601.cs @@ -1,8 +1,5 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.SubMessageBody { @@ -11,12 +8,22 @@ namespace JT809.Protocol.SubMessageBody /// 子业务类型标识:UP_BASE_MSG_VEHICLE_ADDED_ACK /// 描述:上级平台应答下级平台发送的补报车辆静态信息清求消息 /// - [JT809Formatter(typeof(JT809_0x1600_0x1601_Formatter))] - public class JT809_0x1600_0x1601:JT809SubBodies + public class JT809_0x1600_0x1601:JT809SubBodies, IJT809MessagePackFormatter { /// /// 车辆信息 /// public string CarInfo { get; set; } + public JT809_0x1600_0x1601 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x1600_0x1601 jT809_0X9600_0X1601 = new JT809_0x1600_0x1601(); + jT809_0X9600_0X1601.CarInfo = reader.ReadRemainStringContent(); + return jT809_0X9600_0X1601; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1600_0x1601 value, IJT809Config config) + { + writer.WriteString(value.CarInfo); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9202.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9202.cs index 13e4709..bfdd8c1 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9202.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9202.cs @@ -1,9 +1,7 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; +using JT809.Protocol.Enums; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; using JT809.Protocol.Metadata; -using System; -using System.Collections.Generic; -using System.Text; namespace JT809.Protocol.SubMessageBody { @@ -12,8 +10,7 @@ namespace JT809.Protocol.SubMessageBody /// 子业务类型标识:DOWN_EXG_MSG_CAR_LOCATION /// 描述:上级平台通过该消息不间断地向车辆驶入区域所属的下级平台发送车辆定位信息,直到该车驶离该区域 /// - [JT809Formatter(typeof(JT809_0x9200_0x9202_Formatter))] - public class JT809_0x9200_0x9202:JT809SubBodies + public class JT809_0x9200_0x9202:JT809SubBodies, IJT809MessagePackFormatter { public JT809_0x9200_0x9202() { @@ -23,5 +20,47 @@ namespace JT809.Protocol.SubMessageBody /// 车辆定位信息 /// public JT809VehiclePositionProperties VehiclePosition { get; set; } + + public JT809_0x9200_0x9202 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x9200_0x9202 jT809_0X1200_0x9202 = new JT809_0x9200_0x9202(); + jT809_0X1200_0x9202.VehiclePosition.Encrypt = (JT809_VehiclePositionEncrypt)reader.ReadByte(); + jT809_0X1200_0x9202.VehiclePosition.Day = reader.ReadByte(); + jT809_0X1200_0x9202.VehiclePosition.Month = reader.ReadByte(); + jT809_0X1200_0x9202.VehiclePosition.Year = reader.ReadUInt16(); + jT809_0X1200_0x9202.VehiclePosition.Hour = reader.ReadByte(); + jT809_0X1200_0x9202.VehiclePosition.Minute = reader.ReadByte(); + jT809_0X1200_0x9202.VehiclePosition.Second = reader.ReadByte(); + jT809_0X1200_0x9202.VehiclePosition.Lon = reader.ReadUInt32(); + jT809_0X1200_0x9202.VehiclePosition.Lat = reader.ReadUInt32(); + jT809_0X1200_0x9202.VehiclePosition.Vec1 = reader.ReadUInt16(); + jT809_0X1200_0x9202.VehiclePosition.Vec2 = reader.ReadUInt16(); + jT809_0X1200_0x9202.VehiclePosition.Vec3 = reader.ReadUInt32(); + jT809_0X1200_0x9202.VehiclePosition.Direction = reader.ReadUInt16(); + jT809_0X1200_0x9202.VehiclePosition.Altitude = reader.ReadUInt16(); + jT809_0X1200_0x9202.VehiclePosition.State = reader.ReadUInt32(); + jT809_0X1200_0x9202.VehiclePosition.Alarm = reader.ReadUInt32(); + return jT809_0X1200_0x9202; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9200_0x9202 value, IJT809Config config) + { + writer.WriteByte((byte)value.VehiclePosition.Encrypt); + writer.WriteByte(value.VehiclePosition.Day); + writer.WriteByte(value.VehiclePosition.Month); + writer.WriteUInt16(value.VehiclePosition.Year); + writer.WriteByte(value.VehiclePosition.Hour); + writer.WriteByte(value.VehiclePosition.Minute); + writer.WriteByte(value.VehiclePosition.Second); + writer.WriteUInt32(value.VehiclePosition.Lon); + writer.WriteUInt32(value.VehiclePosition.Lat); + writer.WriteUInt16(value.VehiclePosition.Vec1); + writer.WriteUInt16(value.VehiclePosition.Vec2); + writer.WriteUInt32(value.VehiclePosition.Vec3); + writer.WriteUInt16(value.VehiclePosition.Direction); + writer.WriteUInt16(value.VehiclePosition.Altitude); + writer.WriteUInt32(value.VehiclePosition.State); + writer.WriteUInt32(value.VehiclePosition.Alarm); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9203.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9203.cs index 1c6b775..c0d831e 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9203.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9203.cs @@ -1,8 +1,7 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; using System; using System.Collections.Generic; -using System.Text; namespace JT809.Protocol.SubMessageBody { @@ -11,8 +10,7 @@ namespace JT809.Protocol.SubMessageBody /// 子业务类型标识:DOWN_EXG_MSG_HISTORY_ARCOSSAREA /// 描述:本业务在 DOWN_EXG_MSG_APPLY_HISGNSSDATA_ACK 应答成功后,立即开始交换。如果申请失败,则不进行数据转发 /// - [JT809Formatter(typeof(JT809_0x9200_0x9203_Formatter))] - public class JT809_0x9200_0x9203:JT809SubBodies + public class JT809_0x9200_0x9203:JT809SubBodies, IJT809MessagePackFormatter { /// /// 卫星定位数据个数 1大于GNSS_CNT小于5 @@ -22,5 +20,46 @@ namespace JT809.Protocol.SubMessageBody /// 卫星定位数据集合 /// public List GNSS { get; set; } + + public JT809_0x9200_0x9203 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x9200_0x9203 jT809_0X1200_0x9203 = new JT809_0x9200_0x9203(); + jT809_0X1200_0x9203.GNSSCount = reader.ReadByte(); + jT809_0X1200_0x9203.GNSS = new List(); + if (jT809_0X1200_0x9203.GNSSCount > 0) + { + for (int i = 0; i < jT809_0X1200_0x9203.GNSSCount; i++) + { + try + { + JT809MessagePackReader jT809_0x9200_0x9202Reader = new JT809MessagePackReader(reader.ReadArray(36)); + //todo:JT809_0x9200_0x9202 + //JT809_0x9200_0x9202 jT809_0x1200_0x1202 = JT809_0x9200_0x9202_Formatter.Instance.Deserialize(ref jT809_0x9200_0x9202Reader, config); + //jT809_0X1200_0x9203.GNSS.Add(jT809_0x1200_0x1202); + } + catch (Exception) + { + } + } + } + return jT809_0X1200_0x9203; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9200_0x9203 value, IJT809Config config) + { + writer.WriteByte((byte)value.GNSS.Count); + foreach (var item in value.GNSS) + { + try + { + //todo:JT809_0x9200_0x9202 + //JT809_0x9200_0x9202_Formatter.Instance.Serialize(ref writer, item, config); + } + catch (Exception ex) + { + + } + } + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9204.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9204.cs index 704d7e1..de4800f 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9204.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9204.cs @@ -1,8 +1,5 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.SubMessageBody { @@ -11,12 +8,23 @@ namespace JT809.Protocol.SubMessageBody /// 子业务类型标识:DOWN_EXG_MSG_CAR_INFO /// 描述:在首次启动跨域车辆定位信息交换,或者以后交换过程中车辆静态信息有更新时,由上级平台向下级平台下发一次车辆静态信息。下.级平台接收后自行更新该车辆静态信息 /// - [JT809Formatter(typeof(JT809_0x9200_0x9204_Formatter))] - public class JT809_0x9200_0x9204:JT809SubBodies + public class JT809_0x9200_0x9204:JT809SubBodies, IJT809MessagePackFormatter { /// /// 车辆信息 /// public string CarInfo { get; set; } + + public JT809_0x9200_0x9204 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x9200_0x9204 jT809_0X1200_0x9204 = new JT809_0x9200_0x9204(); + jT809_0X1200_0x9204.CarInfo = reader.ReadRemainStringContent(); + return jT809_0X1200_0x9204; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9200_0x9204 value, IJT809Config config) + { + writer.WriteString(value.CarInfo); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9205.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9205.cs index df704ae..bb36259 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9205.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9205.cs @@ -1,9 +1,6 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Enums; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.SubMessageBody { @@ -12,12 +9,22 @@ namespace JT809.Protocol.SubMessageBody /// 子业务类型标识:DOWN_EXG_MSG_RETURN_STARTUP /// 描述:在有车辆进入非归属地区地理区域、人工指定车辆定位信息交换和应急状态监控车辆时,上级平台向下级平台发出启动车辆定位信息交换清求消息。下级平台收到此命令后需要回复启动车辆定位信息交换应答消息给上级平台,即UP_EXG_MSG-RETURN-STARTUP_ ACK /// - [JT809Formatter(typeof(JT809_0x9200_0x9205_Formatter))] - public class JT809_0x9200_0x9205:JT809SubBodies + public class JT809_0x9200_0x9205:JT809SubBodies, IJT809MessagePackFormatter { /// /// 错误代码 /// public JT809_0x9205_ReasonCode ReasonCode { get; set; } + public JT809_0x9200_0x9205 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x9200_0x9205 jT809_0X1200_0x9205 = new JT809_0x9200_0x9205(); + jT809_0X1200_0x9205.ReasonCode = (JT809_0x9205_ReasonCode)reader.ReadByte(); + return jT809_0X1200_0x9205; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9200_0x9205 value, IJT809Config config) + { + writer.WriteByte((byte)value.ReasonCode); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9206.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9206.cs index 3332b55..b575d50 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9206.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9206.cs @@ -1,9 +1,6 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Enums; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.SubMessageBody { @@ -12,12 +9,23 @@ namespace JT809.Protocol.SubMessageBody /// 子业务类型标识:DOWN_EXG_MSG_RETURN_END /// 描述:在进入非归属地区地理区域的车辆离开该地理区域、人上取消指定车辆定位信息交换和应急状态结束时,上级平台向下级平台发出结束车辆定位信息交换请求消息。下级平台收到该命令后应回复结束车辆定位信息交换应答消息,即 UP_EXG_MSG_RE_TURN_END_ACK /// - [JT809Formatter(typeof(JT809_0x9200_0x9206_Formatter))] - public class JT809_0x9200_0x9206:JT809SubBodies + public class JT809_0x9200_0x9206:JT809SubBodies, IJT809MessagePackFormatter { /// /// 错误代码 /// public JT809_0x9206_ReasonCode ReasonCode { get; set; } + + public JT809_0x9200_0x9206 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x9200_0x9206 jT809_0X1200_0x9206 = new JT809_0x9200_0x9206(); + jT809_0X1200_0x9206.ReasonCode = (JT809_0x9206_ReasonCode)reader.ReadByte(); + return jT809_0X1200_0x9206; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9200_0x9206 value, IJT809Config config) + { + writer.WriteByte((byte)value.ReasonCode); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9207.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9207.cs index 352b79f..d8c3d38 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9207.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9207.cs @@ -1,9 +1,6 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Enums; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.SubMessageBody { @@ -12,12 +9,22 @@ namespace JT809.Protocol.SubMessageBody /// 子业务类型标识:DOWN_EXG_MSG_APPLY_FOR_MONITOR_STARTUP_ACK /// 描述:应答下级平台申请交换指定车辆定位信息,请求消息."即 UP_EXG_MSG_APPLY_FOR_MONITOR_STARTUP /// - [JT809Formatter(typeof(JT809_0x9200_0x9207_Formatter))] - public class JT809_0x9200_0x9207:JT809SubBodies + public class JT809_0x9200_0x9207:JT809SubBodies, IJT809MessagePackFormatter { /// /// 返回结果 /// public JT809_0x9207_Result Result { get; set; } + public JT809_0x9200_0x9207 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x9200_0x9207 jT809_0X1200_0x9207 = new JT809_0x9200_0x9207(); + jT809_0X1200_0x9207.Result = (JT809_0x9207_Result)reader.ReadByte(); + return jT809_0X1200_0x9207; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9200_0x9207 value, IJT809Config config) + { + writer.WriteByte((byte)value.Result); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9208.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9208.cs index 33b5e29..c966d84 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9208.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9208.cs @@ -1,9 +1,6 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Enums; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.SubMessageBody { @@ -11,12 +8,23 @@ namespace JT809.Protocol.SubMessageBody /// 取消交换指定车辆定位信息应答 /// 子业务类型标识:DOWN_EXG_MSG_APPLY_FOR_MONITOR_END_ACK /// - [JT809Formatter(typeof(JT809_0x9200_0x9208_Formatter))] - public class JT809_0x9200_0x9208:JT809SubBodies + public class JT809_0x9200_0x9208:JT809SubBodies, IJT809MessagePackFormatter { /// /// 返回结果 /// public JT809_0x9208_Result Result { get; set; } + + public JT809_0x9200_0x9208 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x9200_0x9208 jT809_0X1200_0x9208 = new JT809_0x9200_0x9208(); + jT809_0X1200_0x9208.Result = (JT809_0x9208_Result)reader.ReadByte(); + return jT809_0X1200_0x9208; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9200_0x9208 value, IJT809Config config) + { + writer.WriteByte((byte)value.Result); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9209.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9209.cs index 0ad6dbe..8225bf1 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9209.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x9209.cs @@ -1,9 +1,6 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Enums; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.SubMessageBody { @@ -11,12 +8,23 @@ namespace JT809.Protocol.SubMessageBody /// 取消交换指定车辆定位信息应答 /// 子业务类型标识:DOWN_EXG_MSG_APPLY_FOR_MONITOR_END_ACK /// - [JT809Formatter(typeof(JT809_0x9200_0x9209_Formatter))] - public class JT809_0x9200_0x9209: JT809SubBodies + public class JT809_0x9200_0x9209: JT809SubBodies, IJT809MessagePackFormatter { /// /// 返回结果 /// public JT809_0x9209_Result Result { get; set; } + + public JT809_0x9200_0x9209 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x9200_0x9209 jT809_0X1200_0x9209 = new JT809_0x9200_0x9209(); + jT809_0X1200_0x9209.Result = (JT809_0x9209_Result)reader.ReadByte(); + return jT809_0X1200_0x9209; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9200_0x9209 value, IJT809Config config) + { + writer.WriteByte((byte)value.Result); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x9300_0x9301.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x9300_0x9301.cs index 79e3ea8..3bc975d 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x9300_0x9301.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x9300_0x9301.cs @@ -1,9 +1,6 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Enums; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.SubMessageBody { @@ -12,8 +9,7 @@ namespace JT809.Protocol.SubMessageBody /// 子业务类型标识:DOWN_PLATFORM-MSG_POST_QUERY_REQ /// 描述:上级平台不定期向下级平台发送平台查岗信息 /// - [JT809Formatter(typeof(JT809_0x9300_0x9301_Formatter))] - public class JT809_0x9300_0x9301:JT809SubBodies + public class JT809_0x9300_0x9301:JT809SubBodies, IJT809MessagePackFormatter { /// /// 查岗对象的类型 @@ -35,5 +31,27 @@ namespace JT809.Protocol.SubMessageBody /// 应答内容 /// public string InfoContent { get; set; } + public JT809_0x9300_0x9301 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x9300_0x9301 jT809_0X9300_0X9301 = new JT809_0x9300_0x9301(); + jT809_0X9300_0X9301.ObjectType = (JT809_0x9301_ObjectType)reader.ReadByte(); + jT809_0X9300_0X9301.ObjectID = reader.ReadString(12); + jT809_0X9300_0X9301.InfoID = reader.ReadUInt32(); + jT809_0X9300_0X9301.InfoLength = reader.ReadUInt32(); + jT809_0X9300_0X9301.InfoContent = reader.ReadString((int)jT809_0X9300_0X9301.InfoLength); + return jT809_0X9300_0X9301; + } + + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9300_0x9301 value, IJT809Config config) + { + writer.WriteByte((byte)value.ObjectType); + writer.WriteStringPadRight(value.ObjectID, 12); + writer.WriteUInt32(value.InfoID); + // 先计算内容长度(汉字为两个字节) + writer.Skip(4, out int lengthPosition); + writer.WriteString(value.InfoContent); + writer.WriteInt32Return(writer.GetCurrentPosition() - lengthPosition - 4, lengthPosition); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x9300_0x9302.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x9300_0x9302.cs index f32bb37..80c2623 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x9300_0x9302.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x9300_0x9302.cs @@ -1,9 +1,6 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Enums; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.SubMessageBody { @@ -12,8 +9,7 @@ namespace JT809.Protocol.SubMessageBody /// 子业务类型标识:DOWN_PLATFORM_MSG_INFO_REQ /// 描述:上级平台不定期向下级平台下发平台间报文 /// - [JT809Formatter(typeof(JT809_0x9300_0x9302_Formatter))] - public class JT809_0x9300_0x9302:JT809SubBodies + public class JT809_0x9300_0x9302:JT809SubBodies, IJT809MessagePackFormatter { /// /// 查岗对象的类型 @@ -35,5 +31,26 @@ namespace JT809.Protocol.SubMessageBody /// 应答内容 /// public string InfoContent { get; set; } + public JT809_0x9300_0x9302 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x9300_0x9302 jT809_0X9300_0X9302 = new JT809_0x9300_0x9302(); + jT809_0X9300_0X9302.ObjectType = (JT809_0x9302_ObjectType)reader.ReadByte(); + jT809_0X9300_0X9302.ObjectID = reader.ReadString(12); + jT809_0X9300_0X9302.InfoID = reader.ReadUInt32(); + jT809_0X9300_0X9302.InfoLength = reader.ReadUInt32(); + jT809_0X9300_0X9302.InfoContent = reader.ReadString((int)jT809_0X9300_0X9302.InfoLength); + return jT809_0X9300_0X9302; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9300_0x9302 value, IJT809Config config) + { + writer.WriteByte((byte)value.ObjectType); + writer.WriteStringPadRight(value.ObjectID, 12); + writer.WriteUInt32(value.InfoID); + // 先计算内容长度(汉字为两个字节) + writer.Skip(4, out int lengthPosition); + writer.WriteString(value.InfoContent); + writer.WriteInt32Return(writer.GetCurrentPosition() - lengthPosition - 4, lengthPosition); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x9400_0x9401.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x9400_0x9401.cs index 8ff04a0..5741366 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x9400_0x9401.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x9400_0x9401.cs @@ -1,9 +1,7 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; +using JT809.Protocol.Enums; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; using System; -using System.Collections.Generic; -using System.Text; namespace JT809.Protocol.SubMessageBody { @@ -12,8 +10,7 @@ namespace JT809.Protocol.SubMessageBody /// 子业务类型标识:DOWN_WARN_MSG_URGE_TODO_REQ /// 描述:上级平台向车辆归属下级平台下发本消息,催促其及时处理相关车辆的报警信息 /// - [JT809Formatter(typeof(JT809_0x9400_0x9401_Formatter))] - public class JT809_0x9400_0x9401:JT809SubBodies + public class JT809_0x9400_0x9401:JT809SubBodies, IJT809MessagePackFormatter { /// /// 报警信息来源 @@ -51,5 +48,32 @@ namespace JT809.Protocol.SubMessageBody /// 督办联系电子邮件 /// public string SupervisorEmail { get; set; } + public JT809_0x9400_0x9401 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x9400_0x9401 jT809_0X9400_0X9401 = new JT809_0x9400_0x9401(); + jT809_0X9400_0X9401.WarnSrc = (JT809WarnSrc)reader.ReadByte(); + jT809_0X9400_0X9401.WarnType = reader.ReadUInt16(); + jT809_0X9400_0X9401.WarnTime = reader.ReadUTCDateTime(); + jT809_0X9400_0X9401.SupervisionID = reader.ReadHex(4); + jT809_0X9400_0X9401.SupervisionEndTime = reader.ReadUTCDateTime(); + jT809_0X9400_0X9401.SupervisionLevel = reader.ReadByte(); + jT809_0X9400_0X9401.Supervisor = reader.ReadString(16); + jT809_0X9400_0X9401.SupervisorTel = reader.ReadString(20); + jT809_0X9400_0X9401.SupervisorEmail = reader.ReadString(32); + return jT809_0X9400_0X9401; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9400_0x9401 value, IJT809Config config) + { + writer.WriteByte((byte)value.WarnSrc); + writer.WriteUInt16((ushort)value.WarnType); + writer.WriteUTCDateTime(value.WarnTime); + writer.WriteHex(value.SupervisionID, 4); + writer.WriteUTCDateTime(value.SupervisionEndTime); + writer.WriteByte(value.SupervisionLevel); + writer.WriteStringPadRight(value.Supervisor, 16); + writer.WriteStringPadRight(value.SupervisorTel, 20); + writer.WriteStringPadRight(value.SupervisorEmail, 32); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x9400_0x9402.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x9400_0x9402.cs index 91cf26c..8df114b 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x9400_0x9402.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x9400_0x9402.cs @@ -1,9 +1,7 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; +using JT809.Protocol.Enums; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; using System; -using System.Collections.Generic; -using System.Text; namespace JT809.Protocol.SubMessageBody { @@ -13,8 +11,7 @@ namespace JT809.Protocol.SubMessageBody /// 描述:用于上级平台向车辆归属或车辆跨域下级平台下发相关车辆的报警顶警或运行提示信息 /// 本条消息下级平台无需应答 /// - [JT809Formatter(typeof(JT809_0x9400_0x9402_Formatter))] - public class JT809_0x9400_0x9402:JT809SubBodies + public class JT809_0x9400_0x9402:JT809SubBodies, IJT809MessagePackFormatter { /// /// 报警信息来源 @@ -36,5 +33,27 @@ namespace JT809.Protocol.SubMessageBody /// 报警描述 /// public string WarnContent { get; set; } + + public JT809_0x9400_0x9402 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x9400_0x9402 jT809_0X9400_0X9402 = new JT809_0x9400_0x9402(); + jT809_0X9400_0X9402.WarnSrc = (JT809WarnSrc)reader.ReadByte(); + jT809_0X9400_0X9402.WarnType = (JT809WarnType)reader.ReadUInt16(); + jT809_0X9400_0X9402.WarnTime = reader.ReadUTCDateTime(); + jT809_0X9400_0X9402.WarnLength = reader.ReadUInt32(); + jT809_0X9400_0X9402.WarnContent = reader.ReadString((int)jT809_0X9400_0X9402.WarnLength); + return jT809_0X9400_0X9402; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9400_0x9402 value, IJT809Config config) + { + writer.WriteByte((byte)value.WarnSrc); + writer.WriteUInt16((ushort)value.WarnType); + writer.WriteUTCDateTime(value.WarnTime); + // 先计算内容长度(汉字为两个字节) + writer.Skip(4, out int lengthPosition); + writer.WriteString(value.WarnContent); + writer.WriteInt32Return(writer.GetCurrentPosition() - lengthPosition - 4, lengthPosition); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x9400_0x9403.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x9400_0x9403.cs index 7cb0a1d..aa31715 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x9400_0x9403.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x9400_0x9403.cs @@ -1,9 +1,7 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; +using JT809.Protocol.Enums; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; using System; -using System.Collections.Generic; -using System.Text; namespace JT809.Protocol.SubMessageBody { @@ -13,8 +11,7 @@ namespace JT809.Protocol.SubMessageBody /// 描述:用于上级平台向车辆跨域目的地下级平台下发相关车辆的当前报警情况 /// 本条消息下级平台无需应答 /// - [JT809Formatter(typeof(JT809_0x9400_0x9403_Formatter))] - public class JT809_0x9400_0x9403:JT809SubBodies + public class JT809_0x9400_0x9403:JT809SubBodies, IJT809MessagePackFormatter { /// /// 报警信息来源 @@ -36,5 +33,26 @@ namespace JT809.Protocol.SubMessageBody /// 报警描述 /// public string WarnContent { get; set; } + public JT809_0x9400_0x9403 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x9400_0x9403 jT809_0X9400_0X9403 = new JT809_0x9400_0x9403(); + jT809_0X9400_0X9403.WarnSrc = (JT809WarnSrc)reader.ReadByte(); + jT809_0X9400_0X9403.WarnType = (JT809WarnType)reader.ReadUInt16(); + jT809_0X9400_0X9403.WarnTime = reader.ReadUTCDateTime(); + jT809_0X9400_0X9403.WarnLength = reader.ReadUInt32(); + jT809_0X9400_0X9403.WarnContent = reader.ReadString((int)jT809_0X9400_0X9403.WarnLength); + return jT809_0X9400_0X9403; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9400_0x9403 value, IJT809Config config) + { + writer.WriteByte((byte)value.WarnSrc); + writer.WriteUInt16((ushort)value.WarnType); + writer.WriteUTCDateTime(value.WarnTime); + // 先计算内容长度(汉字为两个字节) + writer.Skip(4, out int lengthPosition); + writer.WriteString(value.WarnContent); + writer.WriteInt32Return(writer.GetCurrentPosition() - lengthPosition - 4, lengthPosition); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x9500_0x9501.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x9500_0x9501.cs index bc67cf3..a227b84 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x9500_0x9501.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x9500_0x9501.cs @@ -1,8 +1,5 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.SubMessageBody { @@ -11,12 +8,22 @@ namespace JT809.Protocol.SubMessageBody /// 子业务类型标识:DOWN_CTRL_MSG_MONITOR_VEHICLE_REQ /// 描述:上级平台向下级平台下发车辆单向监听清求消息 /// - [JT809Formatter(typeof(JT809_0x9500_0x9501_Formatter))] - public class JT809_0x9500_0x9501:JT809SubBodies + public class JT809_0x9500_0x9501:JT809SubBodies, IJT809MessagePackFormatter { /// /// 回拨电话号码 /// public string MonitorTel { get; set; } + public JT809_0x9500_0x9501 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x9500_0x9501 jT809_0X9500_0X9501 = new JT809_0x9500_0x9501(); + jT809_0X9500_0X9501.MonitorTel = reader.ReadString(20); + return jT809_0X9500_0X9501; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9500_0x9501 value, IJT809Config config) + { + writer.WriteStringPadRight(value.MonitorTel, 20); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x9500_0x9502.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x9500_0x9502.cs index 0088b5e..d8bc901 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x9500_0x9502.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x9500_0x9502.cs @@ -1,8 +1,5 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.SubMessageBody { @@ -11,8 +8,7 @@ namespace JT809.Protocol.SubMessageBody /// 子业务类型标识:DOWN_CTRL_MSG_TAKE_PHOTO_REQ /// 描述:上级平台向下级平台下发对某指定车辆的拍照请求消息 /// - [JT809Formatter(typeof(JT809_0x9500_0x9502_Formatter))] - public class JT809_0x9500_0x9502:JT809SubBodies + public class JT809_0x9500_0x9502:JT809SubBodies, IJT809MessagePackFormatter { /// /// 镜头ID @@ -30,5 +26,17 @@ namespace JT809.Protocol.SubMessageBody /// Ox08:704576[DI] /// public byte SizeType { get; set; } + public JT809_0x9500_0x9502 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x9500_0x9502 jT809_0X9500_0X9502 = new JT809_0x9500_0x9502(); + jT809_0X9500_0X9502.LensID = reader.ReadByte(); + jT809_0X9500_0X9502.SizeType = reader.ReadByte(); + return jT809_0X9500_0X9502; + } + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9500_0x9502 value, IJT809Config config) + { + writer.WriteByte(value.LensID); + writer.WriteByte(value.SizeType); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x9500_0x9503.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x9500_0x9503.cs index 097bb6d..3db8c4b 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x9500_0x9503.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x9500_0x9503.cs @@ -1,8 +1,5 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; -using System; -using System.Collections.Generic; -using System.Text; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; namespace JT809.Protocol.SubMessageBody { @@ -11,8 +8,7 @@ namespace JT809.Protocol.SubMessageBody /// 子业务类型标识:DOWN_CTRL_MSG_TEXT_INFO /// 描述:用于上级平台向下级平台下发报文到某指定车辆 /// - [JT809Formatter(typeof(JT809_0x9500_0x9503_Formatter))] - public class JT809_0x9500_0x9503:JT809SubBodies + public class JT809_0x9500_0x9503:JT809SubBodies, IJT809MessagePackFormatter { /// /// 消息ID序号 @@ -30,5 +26,24 @@ namespace JT809.Protocol.SubMessageBody /// 报文信息内容 /// public string MsgContent { get; set; } + public JT809_0x9500_0x9503 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x9500_0x9503 jT809_0X9500_0X9503 = new JT809_0x9500_0x9503(); + jT809_0X9500_0X9503.MsgSequence = reader.ReadUInt32(); + jT809_0X9500_0X9503.MsgPriority = reader.ReadByte(); + jT809_0X9500_0X9503.MsgLength = reader.ReadUInt32(); + jT809_0X9500_0X9503.MsgContent = reader.ReadString((int)jT809_0X9500_0X9503.MsgLength); + return jT809_0X9500_0X9503; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9500_0x9503 value, IJT809Config config) + { + writer.WriteUInt32(value.MsgSequence); + writer.WriteByte(value.MsgPriority); + // 先计算内容长度(汉字为两个字节) + writer.Skip(4, out int lengthPosition); + writer.WriteString(value.MsgContent); + writer.WriteInt32Return(writer.GetCurrentPosition() - lengthPosition - 4, lengthPosition); + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x9500_0x9504.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x9500_0x9504.cs index d497a6a..c371469 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x9500_0x9504.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x9500_0x9504.cs @@ -1,9 +1,7 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Enums; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; +using JT809.Protocol.Enums; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; using System; -using System.Collections.Generic; -using System.Text; namespace JT809.Protocol.SubMessageBody { @@ -12,8 +10,7 @@ namespace JT809.Protocol.SubMessageBody /// 子业务类型标识:DOVJN_CTRL_MSG_TAKE_TRAVEL_REQ /// 描述:上级平台向下级平台下发上报车辆行驶记录请求消息 /// - [JT809Formatter(typeof(JT809_0x9500_0x9504_Formatter))] - public class JT809_0x9500_0x9504:JT809SubBodies + public class JT809_0x9500_0x9504:JT809SubBodies, IJT809MessagePackFormatter { /// /// 命令字ID @@ -31,5 +28,65 @@ namespace JT809.Protocol.SubMessageBody /// 最大数据数 /// public ushort Max { get; set; } + + public JT809_0x9500_0x9504 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x9500_0x9504 jT809_0X9500_0X9504 = new JT809_0x9500_0x9504(); + jT809_0X9500_0X9504.Command = (JT809CommandType)reader.ReadByte(); + switch (jT809_0X9500_0X9504.Command) + { + case JT809CommandType.记录仪标准版本: + case JT809CommandType.当前驾驶人信息: + case JT809CommandType.记录仪时间: + case JT809CommandType.记录仪累计行驶里程: + case JT809CommandType.记录仪脉冲系数: + case JT809CommandType.车辆信息: + case JT809CommandType.记录仪状态信号配置信息: + case JT809CommandType.记录仪唯一性编号: + break; + case JT809CommandType.采集记录仪行驶记录: + case JT809CommandType.采集记录仪位置信息记录: + case JT809CommandType.采集记录仪事故疑点记录: + case JT809CommandType.采集记录仪超时驾驶记录: + case JT809CommandType.采集记录仪驾驶人身份记录: + case JT809CommandType.采集记录仪外部供电记录: + case JT809CommandType.采集记录仪参数修改记录: + case JT809CommandType.采集记录仪速度状态日志: + jT809_0X9500_0X9504.StartTime = reader.ReadDateTime6(); + jT809_0X9500_0X9504.EndTime = reader.ReadDateTime6(); + jT809_0X9500_0X9504.Max = reader.ReadUInt16(); + break; + } + return jT809_0X9500_0X9504; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9500_0x9504 value, IJT809Config config) + { + writer.WriteByte((byte)value.Command); + switch (value.Command) + { + case JT809CommandType.记录仪标准版本: + case JT809CommandType.当前驾驶人信息: + case JT809CommandType.记录仪时间: + case JT809CommandType.记录仪累计行驶里程: + case JT809CommandType.记录仪脉冲系数: + case JT809CommandType.车辆信息: + case JT809CommandType.记录仪状态信号配置信息: + case JT809CommandType.记录仪唯一性编号: + break; + case JT809CommandType.采集记录仪行驶记录: + case JT809CommandType.采集记录仪位置信息记录: + case JT809CommandType.采集记录仪事故疑点记录: + case JT809CommandType.采集记录仪超时驾驶记录: + case JT809CommandType.采集记录仪驾驶人身份记录: + case JT809CommandType.采集记录仪外部供电记录: + case JT809CommandType.采集记录仪参数修改记录: + case JT809CommandType.采集记录仪速度状态日志: + writer.WriteDateTime6(value.StartTime); + writer.WriteDateTime6(value.EndTime); + writer.WriteUInt16(value.Max); + break; + } + } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x9500_0x9505.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x9500_0x9505.cs index 972e799..c2fb1b7 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x9500_0x9505.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x9500_0x9505.cs @@ -1,8 +1,6 @@ -using JT809.Protocol.Attributes; -using JT809.Protocol.Formatters.SubMessageBodyFormatters; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; using System; -using System.Collections.Generic; -using System.Text; namespace JT809.Protocol.SubMessageBody { @@ -11,8 +9,7 @@ namespace JT809.Protocol.SubMessageBody /// 子业务类型标识:UP_CTRL_MSG_EMERGENCY_MONITORING_REQ /// 描述:发生应急情况时,政府监管平台需要及时监控该车辆时,就向该车辆归属的下级平台发送该命令 /// - [JT809Formatter(typeof(JT809_0x9500_0x9505_Formatter))] - public class JT809_0x9500_0x9505:JT809SubBodies + public class JT809_0x9500_0x9505:JT809SubBodies, IJT809MessagePackFormatter { /// /// 监管平台下发的鉴权码 @@ -46,5 +43,31 @@ namespace JT809.Protocol.SubMessageBody /// 结束时间 /// public DateTime EndTime { get; set; } + + public JT809_0x9500_0x9505 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + JT809_0x9500_0x9505 jT809_0X9500_0X9505 = new JT809_0x9500_0x9505(); + jT809_0X9500_0X9505.AuthenticationCode = reader.ReadBCD(20); + jT809_0X9500_0X9505.AccessPointName = reader.ReadString(20); + jT809_0X9500_0X9505.UserName = reader.ReadString(49); + jT809_0X9500_0X9505.Password = reader.ReadString(22); + jT809_0X9500_0X9505.ServerIP = reader.ReadString(32); + jT809_0X9500_0X9505.TcpPort = reader.ReadUInt16(); + jT809_0X9500_0X9505.UdpPort = reader.ReadUInt16(); + jT809_0X9500_0X9505.EndTime = reader.ReadUTCDateTime(); + return jT809_0X9500_0X9505; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9500_0x9505 value, IJT809Config config) + { + writer.WriteBCD(value.AuthenticationCode, 20); + writer.WriteStringPadRight(value.AccessPointName, 20); + writer.WriteStringPadRight(value.UserName, 49); + writer.WriteStringPadRight(value.Password, 22); + writer.WriteStringPadRight(value.ServerIP, 32); + writer.WriteUInt16(value.TcpPort); + writer.WriteUInt16(value.UdpPort); + writer.WriteUTCDateTime(value.EndTime); + } } }