@@ -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<JT808_JT1078_0x1700>))] | |||
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(); | |||
} | |||
} |
@@ -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 | |||
{ | |||
/// <summary> | |||
@@ -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; | |||
} | |||
} | |||
} |
@@ -70,13 +70,13 @@ namespace JT809.Protocol.Enums | |||
[JT809BusinessTypeDescription("UP_DISCONNECT_INFORM", "主链路断开通知消息")] | |||
主链路断开通知消息 = 0x1007, | |||
///<summary> | |||
///下级平台主动关闭链路通知消息 | |||
///下级平台主动关闭主从链路通知消息 | |||
///UP_CLOSELINK_INFORM | |||
///</summary> | |||
[Description("下级平台主动关闭链路通知消息")] | |||
[Description("下级平台主动关闭主从链路通知消息")] | |||
[JT809BodiesType(typeof(JT809_0x1008))] | |||
[JT809BusinessTypeDescription("UP_CLOSELINK_INFORM", "下级平台主动关闭链路通知消息")] | |||
下级平台主动关闭链路通知消息 = 0x1008, | |||
[JT809BusinessTypeDescription("UP_CLOSELINK_INFORM", "下级平台主动关闭主从链路通知消息")] | |||
下级平台主动关闭主从链路通知消息 = 0x1008, | |||
///<summary> | |||
///从链路连接请求消息 | |||
///DOWN_CONNECT_REQ | |||
@@ -86,13 +86,13 @@ namespace JT809.Protocol.Enums | |||
[JT809BusinessTypeDescription("DOWN_CONNECT_REQ", "从链路连接请求消息")] | |||
从链路连接请求消息 = 0x9001, | |||
///<summary> | |||
///从链路连接应答消息 | |||
///从链路连接应答信息 | |||
///DOWN_CONNECT_RSP | |||
///</summary> | |||
[Description("从链路连接应答消息")] | |||
[Description("从链路连接应答信息")] | |||
[JT809BodiesType(typeof(JT809_0x9002))] | |||
[JT809BusinessTypeDescription("DOWN_CONNECT_RSP", "从链路连接应答消息")] | |||
从链路连接应答消息 = 0x9002, | |||
[JT809BusinessTypeDescription("DOWN_CONNECT_RSP", "从链路连接应答信息")] | |||
从链路连接应答信息 = 0x9002, | |||
///<summary> | |||
///从链路注销请求消息 | |||
///DOWN_DISCONNECT_REQ | |||
@@ -144,31 +144,31 @@ namespace JT809.Protocol.Enums | |||
#endregion | |||
#region 信息统计类 | |||
///<summary> | |||
///接收定位信息数量通知消息 | |||
///接收车辆定位信息数量通知消息 | |||
///DOWN_TOTAL_RECV_BACK_MSG | |||
///</summary> | |||
[Description("接收定位信息数量通知消息")] | |||
[Description("接收车辆定位信息数量通知消息")] | |||
[JT809BodiesType(typeof(JT809_0x9101))] | |||
[JT809BusinessTypeDescription("DOWN_TOTAL_RECV_BACK_MSG", "接收定位信息数量通知消息")] | |||
接收定位信息数量通知消息 = 0x9101, | |||
[JT809BusinessTypeDescription("DOWN_TOTAL_RECV_BACK_MSG", "接收车辆定位信息数量通知消息")] | |||
接收车辆定位信息数量通知消息 = 0x9101, | |||
#endregion | |||
#region 车辆动态信息交换 | |||
///<summary> | |||
///主链路动态信息交换消息 | |||
///UP_EXG_MSG | |||
///</summary> | |||
[Description("主链路动态信息交换消息")] | |||
[Description("主链路车辆动态信息交换业务")] | |||
[JT809BodiesType(typeof(JT809_0x1200))] | |||
[JT809BusinessTypeDescription("UP_EXG_MSG", "主链路动态信息交换消息")] | |||
主链路动态信息交换消息 = 0x1200, | |||
[JT809BusinessTypeDescription("UP_EXG_MSG", "主链路车辆动态信息交换业务")] | |||
主链路车辆动态信息交换业务 = 0x1200, | |||
///<summary> | |||
///从链路动态信息交换消息 | |||
///从链路车辆动态信息交换业务 | |||
///DOWN_EXG_MSG | |||
///</summary> | |||
[Description("从链路动态信息交换消息")] | |||
[Description("从链路车辆动态信息交换业务")] | |||
[JT809BodiesType(typeof(JT809_0x9200))] | |||
[JT809BusinessTypeDescription("DOWN_EXG_MSG", "从链路动态信息交换消息")] | |||
从链路动态信息交换消息 = 0x9200, | |||
[JT809BusinessTypeDescription("DOWN_EXG_MSG", "从链路车辆动态信息交换业务")] | |||
从链路车辆动态信息交换业务 = 0x9200, | |||
#endregion | |||
#region 平台间信息交互类 | |||
///<summary> | |||
@@ -180,13 +180,13 @@ namespace JT809.Protocol.Enums | |||
[JT809BusinessTypeDescription("UP_PLATFORM_MSG", "主链路平台间信息交互消息")] | |||
主链路平台间信息交互消息 = 0x1300, | |||
///<summary> | |||
///从链路平台间信息交互消息 | |||
///从链路平台间信息交互业务 | |||
///DOWN_PLATFORM_MSG | |||
///</summary> | |||
[Description("从链路平台间信息交互消息")] | |||
[Description("从链路平台间信息交互业务")] | |||
[JT809BodiesType(typeof(JT809_0x9300))] | |||
[JT809BusinessTypeDescription("DOWN_PLATFORM_MSG", "从链路平台间信息交互消息")] | |||
从链路平台间信息交互消息 = 0x9300, | |||
[JT809BusinessTypeDescription("DOWN_PLATFORM_MSG", "从链路平台间信息交互业务")] | |||
从链路平台间信息交互业务 = 0x9300, | |||
#endregion | |||
#region 车辆报警信息交互类 | |||
///<summary> | |||
@@ -15,7 +15,6 @@ namespace JT809.Protocol.Enums | |||
BodiesParseError=1007, | |||
SubBodiesParseError = 1008, | |||
GetAttributeError=1009, | |||
GetFormatterAttributeError=1010, | |||
NotGlobalRegisterFormatterAssembly=1011, | |||
} | |||
} |
@@ -17,7 +17,7 @@ namespace JT809.Protocol.Enums | |||
/// </summary> | |||
[Description("上传车辆注册信息")] | |||
[JT809BodiesType(typeof(JT809_0x1200_0x1201))] | |||
[JT809SubBusinessTypeDescription("UP_EXG_MSG_REGISTER", "上传车辆注册信息", JT809BusinessType.主链路动态信息交换消息)] | |||
[JT809SubBusinessTypeDescription("UP_EXG_MSG_REGISTER", "上传车辆注册信息", JT809BusinessType.主链路车辆动态信息交换业务)] | |||
上传车辆注册信息 = 0x1201, | |||
///<summary> | |||
///实时上传车辆定位信息 | |||
@@ -25,7 +25,7 @@ namespace JT809.Protocol.Enums | |||
///</summary> | |||
[Description("实时上传车辆定位信息")] | |||
[JT809BodiesType(typeof(JT809_0x1200_0x1202))] | |||
[JT809SubBusinessTypeDescription("UP_EXG_MSG_REAL_LOCATION", "实时上传车辆定位信息", JT809BusinessType.主链路动态信息交换消息)] | |||
[JT809SubBusinessTypeDescription("UP_EXG_MSG_REAL_LOCATION", "实时上传车辆定位信息", JT809BusinessType.主链路车辆动态信息交换业务)] | |||
实时上传车辆定位信息 = 0x1202, | |||
///<summary> | |||
///车辆定位信息自动补报 | |||
@@ -33,7 +33,7 @@ namespace JT809.Protocol.Enums | |||
///</summary> | |||
[Description("车辆定位信息自动补报")] | |||
[JT809BodiesType(typeof(JT809_0x1200_0x1203))] | |||
[JT809SubBusinessTypeDescription("UP_EXG_MSG_HISTORY_LOCATION", "车辆定位信息自动补报", JT809BusinessType.主链路动态信息交换消息)] | |||
[JT809SubBusinessTypeDescription("UP_EXG_MSG_HISTORY_LOCATION", "车辆定位信息自动补报", JT809BusinessType.主链路车辆动态信息交换业务)] | |||
车辆定位信息自动补报 = 0x1203, | |||
///<summary> | |||
///启动车辆定位信息交换应答 | |||
@@ -41,7 +41,7 @@ namespace JT809.Protocol.Enums | |||
///</summary> | |||
[Description("启动车辆定位信息交换应答")] | |||
[JT809BodiesType(typeof(JT809_0x1200_0x1205))] | |||
[JT809SubBusinessTypeDescription("UP_EXG_MSG_RETURN_STARTUP_ACK", "启动车辆定位信息交换应答", JT809BusinessType.主链路动态信息交换消息)] | |||
[JT809SubBusinessTypeDescription("UP_EXG_MSG_RETURN_STARTUP_ACK", "启动车辆定位信息交换应答", JT809BusinessType.主链路车辆动态信息交换业务)] | |||
启动车辆定位信息交换应答 = 0x1205, | |||
///<summary> | |||
///结束车辆定位信息交换应答 | |||
@@ -49,7 +49,7 @@ namespace JT809.Protocol.Enums | |||
///</summary> | |||
[Description("结束车辆定位信息交换应答")] | |||
[JT809BodiesType(typeof(JT809_0x1200_0x1206))] | |||
[JT809SubBusinessTypeDescription("UP_EXG_MSG_RETURN_END_ACK", "结束车辆定位信息交换应答", JT809BusinessType.主链路动态信息交换消息)] | |||
[JT809SubBusinessTypeDescription("UP_EXG_MSG_RETURN_END_ACK", "结束车辆定位信息交换应答", JT809BusinessType.主链路车辆动态信息交换业务)] | |||
结束车辆定位信息交换应答 = 0x1206, | |||
///<summary> | |||
///申请交换指定车辆定位信息请求 | |||
@@ -57,7 +57,7 @@ namespace JT809.Protocol.Enums | |||
///</summary> | |||
[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, | |||
///<summary> | |||
///取消交换指定车辆定位信息请求 | |||
@@ -65,7 +65,7 @@ namespace JT809.Protocol.Enums | |||
///</summary> | |||
[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, | |||
///<summary> | |||
///补发车辆定位信息请求 | |||
@@ -73,7 +73,7 @@ namespace JT809.Protocol.Enums | |||
///</summary> | |||
[Description("补发车辆定位信息请求")] | |||
[JT809BodiesType(typeof(JT809_0x1200_0x1209))] | |||
[JT809SubBusinessTypeDescription("UP_EXG_MSG_APPLY_HISGNSSDATA_REQ", "补发车辆定位信息请求", JT809BusinessType.主链路动态信息交换消息)] | |||
[JT809SubBusinessTypeDescription("UP_EXG_MSG_APPLY_HISGNSSDATA_REQ", "补发车辆定位信息请求", JT809BusinessType.主链路车辆动态信息交换业务)] | |||
补发车辆定位信息请求 = 0x1209, | |||
///<summary> | |||
///上报车辆驾驶员身份识别信息应答 | |||
@@ -81,7 +81,7 @@ namespace JT809.Protocol.Enums | |||
///</summary> | |||
[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, | |||
///<summary> | |||
///上报车辆电子运单应答 | |||
@@ -89,7 +89,7 @@ namespace JT809.Protocol.Enums | |||
///</summary> | |||
[Description("上报车辆电子运单应答")] | |||
[JT809BodiesType(typeof(JT809_0x1200_0x120B))] | |||
[JT809SubBusinessTypeDescription("UP_EXG_MSG_TAKE_EWAYBILL_ACK", "上报车辆电子运单应答", JT809BusinessType.主链路动态信息交换消息)] | |||
[JT809SubBusinessTypeDescription("UP_EXG_MSG_TAKE_EWAYBILL_ACK", "上报车辆电子运单应答", JT809BusinessType.主链路车辆动态信息交换业务)] | |||
上报车辆电子运单应答 = 0x120B, | |||
///<summary> | |||
///主动上报驾驶员身份信息 | |||
@@ -97,7 +97,7 @@ namespace JT809.Protocol.Enums | |||
///</summary> | |||
[Description("主动上报驾驶员身份信息")] | |||
[JT809BodiesType(typeof(JT809_0x1200_0x120C))] | |||
[JT809SubBusinessTypeDescription("UP_EXG_MSG_REPORT_DRIVER_INFO", "主动上报驾驶员身份信息", JT809BusinessType.主链路动态信息交换消息)] | |||
[JT809SubBusinessTypeDescription("UP_EXG_MSG_REPORT_DRIVER_INFO", "主动上报驾驶员身份信息", JT809BusinessType.主链路车辆动态信息交换业务)] | |||
主动上报驾驶员身份信息 = 0x120C, | |||
///<summary> | |||
///主动上报车辆电子运单信息 | |||
@@ -105,7 +105,7 @@ namespace JT809.Protocol.Enums | |||
///</summary> | |||
[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 | |||
///</summary> | |||
[Description("交换车辆定位信息")] | |||
[JT809BodiesType(typeof(JT809_0x9200_0x9202))] | |||
[JT809SubBusinessTypeDescription("DOWN_EXG_MSG_CAR_LOCATION", "交换车辆定位信息", JT809BusinessType.从链路动态信息交换消息)] | |||
[JT809SubBusinessTypeDescription("DOWN_EXG_MSG_CAR_LOCATION", "交换车辆定位信息", JT809BusinessType.从链路车辆动态信息交换业务)] | |||
交换车辆定位信息 = 0x9202, | |||
///<summary> | |||
///车辆定位信息交换补发 | |||
@@ -124,7 +124,7 @@ namespace JT809.Protocol.Enums | |||
///</summary> | |||
[Description("车辆定位信息交换补发")] | |||
[JT809BodiesType(typeof(JT809_0x9200_0x9203))] | |||
[JT809SubBusinessTypeDescription("DOWN_EXG_MSG_HISTORY_ARCOSSAREA", "车辆定位信息交换补发", JT809BusinessType.从链路动态信息交换消息)] | |||
[JT809SubBusinessTypeDescription("DOWN_EXG_MSG_HISTORY_ARCOSSAREA", "车辆定位信息交换补发", JT809BusinessType.从链路车辆动态信息交换业务)] | |||
车辆定位信息交换补发 = 0x9203, | |||
///<summary> | |||
///交换车辆静态信息 | |||
@@ -132,7 +132,7 @@ namespace JT809.Protocol.Enums | |||
///</summary> | |||
[Description("交换车辆静态信息")] | |||
[JT809BodiesType(typeof(JT809_0x9200_0x9204))] | |||
[JT809SubBusinessTypeDescription("DOWN_EXG_MSG_CAR_INFO", "交换车辆静态信息", JT809BusinessType.从链路动态信息交换消息)] | |||
[JT809SubBusinessTypeDescription("DOWN_EXG_MSG_CAR_INFO", "交换车辆静态信息", JT809BusinessType.从链路车辆动态信息交换业务)] | |||
交换车辆静态信息 = 0x9204, | |||
///<summary> | |||
///启动车辆定位信息交换请求 | |||
@@ -140,14 +140,14 @@ namespace JT809.Protocol.Enums | |||
///</summary> | |||
[Description("启动车辆定位信息交换请求")] | |||
[JT809BodiesType(typeof(JT809_0x9200_0x9205))] | |||
[JT809SubBusinessTypeDescription("DOWN_EXG_MSG_RETURN_STARTUP", "启动车辆定位信息交换请求", JT809BusinessType.从链路动态信息交换消息)] | |||
[JT809SubBusinessTypeDescription("DOWN_EXG_MSG_RETURN_STARTUP", "启动车辆定位信息交换请求", JT809BusinessType.从链路车辆动态信息交换业务)] | |||
启动车辆定位信息交换请求 = 0x9205, | |||
///<summary> | |||
///结束车辆定位信息交换请求 | |||
///</summary> | |||
[Description("结束车辆定位信息交换请求")] | |||
[JT809BodiesType(typeof(JT809_0x9200_0x9206))] | |||
[JT809SubBusinessTypeDescription("DOWN_EXG_MSG_RETURN_END", "结束车辆定位信息交换请求", JT809BusinessType.从链路动态信息交换消息)] | |||
[JT809SubBusinessTypeDescription("DOWN_EXG_MSG_RETURN_END", "结束车辆定位信息交换请求", JT809BusinessType.从链路车辆动态信息交换业务)] | |||
结束车辆定位信息交换请求 = 0x9206, | |||
///<summary> | |||
///申请交换指定车辆定位信息应答 | |||
@@ -155,7 +155,7 @@ namespace JT809.Protocol.Enums | |||
///</summary> | |||
[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, | |||
///<summary> | |||
///取消交换指定车辆定位信息应答 | |||
@@ -163,7 +163,7 @@ namespace JT809.Protocol.Enums | |||
///</summary> | |||
[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, | |||
///<summary> | |||
///补发车辆定位信息应答 | |||
@@ -171,7 +171,7 @@ namespace JT809.Protocol.Enums | |||
///</summary> | |||
[Description("补发车辆定位信息应答")] | |||
[JT809BodiesType(typeof(JT809_0x9200_0x9209))] | |||
[JT809SubBusinessTypeDescription("DOWN_EXG_MSG_APPLY_HISGNSSDATA_ACK", "补发车辆定位信息应答", JT809BusinessType.从链路动态信息交换消息)] | |||
[JT809SubBusinessTypeDescription("DOWN_EXG_MSG_APPLY_HISGNSSDATA_ACK", "补发车辆定位信息应答", JT809BusinessType.从链路车辆动态信息交换业务)] | |||
补发车辆定位信息应答 = 0x9209, | |||
///<summary> | |||
///上报车辆驾驶员身份识别信息请求 | |||
@@ -179,7 +179,7 @@ namespace JT809.Protocol.Enums | |||
///</summary> | |||
[Description("上报车辆驾驶员身份识别信息请求")] | |||
[JT809BodiesType(typeof(JT809_0x9200_0x920A))] | |||
[JT809SubBusinessTypeDescription("DOWN_EXG_MSG_REPORT_DRIVER_INFO", "上报车辆驾驶员身份识别信息请求", JT809BusinessType.从链路动态信息交换消息)] | |||
[JT809SubBusinessTypeDescription("DOWN_EXG_MSG_REPORT_DRIVER_INFO", "上报车辆驾驶员身份识别信息请求", JT809BusinessType.从链路车辆动态信息交换业务)] | |||
上报车辆驾驶员身份识别信息请求 = 0x920A, | |||
///<summary> | |||
///上报车辆电子运单请求 | |||
@@ -187,7 +187,7 @@ namespace JT809.Protocol.Enums | |||
///</summary> | |||
[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 | |||
///</summary> | |||
[Description("平台查岗请求")] | |||
[JT809BodiesType(typeof(JT809_0x9300_0x9301))] | |||
[JT809SubBusinessTypeDescription("DOWN_PLATFORM_MSG_POST_QUERY_REQ", "平台查岗请求", JT809BusinessType.从链路平台间信息交互消息)] | |||
[JT809SubBusinessTypeDescription("DOWN_PLATFORM_MSG_POST_QUERY_REQ", "平台查岗请求", JT809BusinessType.从链路平台间信息交互业务)] | |||
平台查岗请求 = 0x9301, | |||
///<summary> | |||
///下发平台间报文请求 | |||
@@ -225,7 +225,7 @@ namespace JT809.Protocol.Enums | |||
///</summary> | |||
[Description("下发平台间报文请求")] | |||
[JT809BodiesType(typeof(JT809_0x9300_0x9302))] | |||
[JT809SubBusinessTypeDescription("DOWN_PLATFORM_MSG_INFO_REQ", "下发平台间报文请求", JT809BusinessType.从链路平台间信息交互消息)] | |||
[JT809SubBusinessTypeDescription("DOWN_PLATFORM_MSG_INFO_REQ", "下发平台间报文请求", JT809BusinessType.从链路平台间信息交互业务)] | |||
下发平台间报文请求 = 0x9302, | |||
#endregion | |||
@@ -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, | |||
} | |||
} |
@@ -0,0 +1,21 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
namespace JT809.Protocol.Enums | |||
{ | |||
/// <summary> | |||
/// 链路类型 | |||
/// </summary> | |||
public enum JT809_LinkType:byte | |||
{ | |||
/// <summary> | |||
/// 主链路 | |||
/// </summary> | |||
main, | |||
/// <summary> | |||
/// 从链路 | |||
/// </summary> | |||
subordinate | |||
} | |||
} |
@@ -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<Guid, object> cache = new ConcurrentDictionary<Guid, object>(); | |||
public static IJT809MessagePackFormatter<T> GetFormatter<T>() | |||
private readonly static ConcurrentDictionary<string, JT809Serializer> jT809SerializerDict = new ConcurrentDictionary<string, JT809Serializer>(StringComparer.OrdinalIgnoreCase); | |||
public static IJT809MessagePackFormatter<T> GetMessagePackFormatter<T>(this IJT809Config config) | |||
{ | |||
return (IJT809MessagePackFormatter<T>) GetFormatter(typeof(T)); | |||
return (IJT809MessagePackFormatter<T>)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<JT809FormatterAttribute>(); | |||
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<T>(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; | |||
} | |||
} | |||
} |
@@ -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<Guid,object> FormatterDict { get;} | |||
IJT809FormatterFactory SetMap<TJT809Bodies>() | |||
where TJT809Bodies : JT809Bodies; | |||
IJT809FormatterFactory SetSubMap<TJT809SubBodies>() | |||
where TJT809SubBodies : JT809SubBodies; | |||
IJT809FormatterFactory SetMap<TIJT809Formatter>() | |||
where TIJT809Formatter : IJT809Formatter; | |||
} | |||
} |
@@ -1,15 +0,0 @@ | |||
using JT809.Protocol.Interfaces; | |||
using JT809.Protocol.MessagePack; | |||
using System; | |||
using System.Buffers; | |||
namespace JT809.Protocol.Formatters | |||
{ | |||
[Obsolete("请使用 IJT809MessagePackFormatter<T>")] | |||
public interface IJT809Formatter<T>: IJT809Formatter | |||
{ | |||
T Deserialize(ReadOnlySpan<byte> bytes, out int readSize); | |||
int Serialize(ref byte[] bytes, int offset, T value); | |||
} | |||
} |
@@ -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<JT809Header> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809HeaderPackage> | |||
{ | |||
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("只适用反序列化"); | |||
} | |||
} | |||
} |
@@ -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<JT809Package> | |||
{ | |||
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(); | |||
// -----------组包完成---------- | |||
} | |||
} | |||
} |
@@ -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<JT809_0x1001> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x1002> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x1003> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x1007> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x1008> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x1300> | |||
{ | |||
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); | |||
} | |||
} | |||
} | |||
} |
@@ -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<JT809_0x9001> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x9002> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x9003> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x9007> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x9008> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x9101> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x9300> | |||
{ | |||
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()}"); | |||
} | |||
} | |||
} | |||
} |
@@ -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<JT809_0x1200_0x1201> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x1200_0x1202> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x1200_0x1203> | |||
{ | |||
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<JT809_0x1200_0x1202>(); | |||
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) | |||
{ | |||
} | |||
} | |||
} | |||
} | |||
} |
@@ -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<JT809_0x1200_0x1207> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x1200_0x1209> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x1200_0x120A> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x1200_0x120B> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x1200_0x120C> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x1200_0x120D> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x1300_0x1301> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x1300_0x1302> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x1400_0x1401> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x1400_0x1402> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x1400_0x1403> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x1500_0x1501> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x1500_0x1502> | |||
{ | |||
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); | |||
} | |||
} | |||
} | |||
} |
@@ -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<JT809_0x1500_0x1503> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x1500_0x1504> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x1500_0x1505> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x1600_0x1601> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x9200_0x9202> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x9200_0x9203> | |||
{ | |||
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<JT809_0x9200_0x9202>(); | |||
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) | |||
{ | |||
} | |||
} | |||
} | |||
} | |||
} |
@@ -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<JT809_0x9200_0x9204> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x9200_0x9205> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x9200_0x9206> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x9200_0x9207> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x9200_0x9208> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x9200_0x9209> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x9300_0x9301> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x9300_0x9302> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x9400_0x9401> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x9400_0x9402> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x9400_0x9403> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x9500_0x9501> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x9500_0x9502> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x9500_0x9503> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT809_0x9500_0x9504> | |||
{ | |||
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; | |||
} | |||
} | |||
} | |||
} |
@@ -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<JT809_0x9500_0x9505> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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); | |||
} | |||
} |
@@ -0,0 +1,11 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
namespace JT809.Protocol.Interfaces | |||
{ | |||
public interface IJT809Description | |||
{ | |||
string Description { get;} | |||
} | |||
} |
@@ -0,0 +1,13 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
namespace JT809.Protocol.Interfaces | |||
{ | |||
/// <summary> | |||
/// 只用来标识2019版本增删改情况 | |||
/// </summary> | |||
public interface IJT809_2019_Version | |||
{ | |||
} | |||
} |
@@ -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<JT809FormatterAttribute>(); | |||
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<TJT809Bodies>() where TJT809Bodies : JT809Bodies | |||
public IJT809FormatterFactory SetMap<TIJT809Formatter>() where TIJT809Formatter : IJT809Formatter | |||
{ | |||
Type bodiesType = typeof(TJT809Bodies); | |||
var attr = bodiesType.GetTypeInfo().GetCustomAttribute<JT809FormatterAttribute>(); | |||
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<TJT809SubBodies>() where TJT809SubBodies : JT809SubBodies | |||
{ | |||
Type bodiesType = typeof(TJT809SubBodies); | |||
var attr = bodiesType.GetTypeInfo().GetCustomAttribute<JT809FormatterAttribute>(); | |||
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; | |||
} | |||
} | |||
} |
@@ -57,6 +57,7 @@ | |||
<ItemGroup> | |||
<Compile Include="Configs\JT809EncryptOptions.cs" /> | |||
<Compile Include="Configs\JT809HeaderOptions.cs" /> | |||
<Compile Include="Enums\JT809Version.cs" /> | |||
<Compile Include="Enums\JT808_Alarm.cs" /> | |||
<Compile Include="Enums\JT808_Status.cs" /> | |||
<Compile Include="Enums\JT809CommandType.cs" /> | |||
@@ -86,6 +87,7 @@ | |||
<Compile Include="Enums\JT809_0x1008_ReasonCode.cs" /> | |||
<Compile Include="Enums\JT809_0x9002_Result.cs" /> | |||
<Compile Include="Enums\JT809_0x9008_ReasonCode.cs" /> | |||
<Compile Include="Enums\JT809_LinkType.cs" /> | |||
<Compile Include="Enums\JT809_VehiclePositionEncrypt.cs" /> | |||
</ItemGroup> | |||
@@ -114,6 +116,7 @@ | |||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" /> | |||
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.7.0" /> | |||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.3" /> | |||
<PackageReference Include="System.Text.Json" Version="4.7.1" /> | |||
</ItemGroup> | |||
@@ -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 | |||
{ | |||
/// <summary> | |||
/// 跳过数据体序列化 | |||
/// 默认不跳过 | |||
/// 当数据体为空的时候,使用null作为空包感觉不适合,所以就算使用空包也需要new一下来表达意思。 | |||
/// </summary> | |||
public virtual bool SkipSerialization { get; set; } = false; | |||
public abstract ushort MsgId { get; } | |||
public abstract JT809_LinkType LinkType { get; } | |||
public abstract string Description { get; } | |||
} | |||
} |
@@ -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<JT809Header> | |||
{ | |||
/// <summary> | |||
/// 固定为22个字节长度 | |||
@@ -49,5 +44,29 @@ namespace JT809.Protocol | |||
/// 数据加密的密匙,长度为 4 个字节 | |||
/// </summary> | |||
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); | |||
} | |||
} | |||
} |
@@ -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 | |||
/// <summary> | |||
/// JT809头部数据包 | |||
/// </summary> | |||
[JT809Formatter(typeof(JT809HeaderPackageFormatter))] | |||
public class JT809HeaderPackage | |||
public class JT809HeaderPackage: IJT809MessagePackFormatter<JT809HeaderPackage> | |||
{ | |||
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("只适用反序列化"); | |||
} | |||
} | |||
} |
@@ -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<JT809Package> | |||
{ | |||
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(); | |||
// -----------组包完成---------- | |||
} | |||
} | |||
} |
@@ -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<T>().Serialize(ref jT809MessagePackWriter, obj,jT809Config); | |||
//todo:JT809MessagePackFormatterExtensions | |||
//JT809MessagePackFormatterExtensions.GetFormatter<T>().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<T>().Deserialize(ref jT809MessagePackReader, jT809Config); | |||
return default; | |||
//return JT809MessagePackFormatterExtensions.GetFormatter<T>().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 | |||
{ | |||
@@ -1,9 +1,4 @@ | |||
using JT809.Protocol.Enums; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
namespace JT809.Protocol | |||
namespace JT809.Protocol | |||
{ | |||
/// <summary> | |||
/// 子业务数据体 | |||
@@ -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() | |||
@@ -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 | |||
/// <para>业务数据类型标识: UP-CONNECT-REQ</para> | |||
/// <para>描述:下级平台向上级平台发送用户名和密码等登录信息</para> | |||
/// </summary> | |||
[JT809Formatter(typeof(JT809_0x1001_Formatter))] | |||
public class JT809_0x1001: JT809Bodies | |||
public class JT809_0x1001: JT809Bodies,IJT809MessagePackFormatter<JT809_0x1001> | |||
{ | |||
/// <summary> | |||
/// 用户名 | |||
@@ -34,5 +33,29 @@ namespace JT809.Protocol.MessageBody | |||
/// 下级平台提供对应的从链路服务器端口号 | |||
/// </summary> | |||
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); | |||
} | |||
} | |||
} |
@@ -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 | |||
/// <para>业务数据类型标识:UP_CONNCCT_RSP</para> | |||
/// <para>描述:上级平台对下级平台登录请求信息、进行安全验证后,返回相应的验证结果。</para> | |||
/// </summary> | |||
[JT809Formatter(typeof(JT809_0x1002_Formatter))] | |||
public class JT809_0x1002 : JT809Bodies | |||
public class JT809_0x1002 : JT809Bodies, IJT809MessagePackFormatter<JT809_0x1002> | |||
{ | |||
public override ushort MsgId => JT809BusinessType.主链路登录应答消息.ToUInt16Value(); | |||
public override string Description => "主链路登录应答消息"; | |||
public override JT809_LinkType LinkType => JT809_LinkType.main; | |||
/// <summary> | |||
/// 验证结果,定义如下: | |||
/// 0x00:成功; | |||
@@ -32,5 +37,17 @@ namespace JT809.Protocol.MessageBody | |||
/// 校验码 | |||
/// </summary> | |||
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); | |||
} | |||
} | |||
} |
@@ -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 | |||
/// <para>业务数据类型标识:UP-DISCONNECT-REQ</para> | |||
/// <para>描述:下级平台在中断与上级平台的主链路连接时,应向上级平台发送主链路注销请求消息。</para> | |||
/// </summary> | |||
[JT809Formatter(typeof(JT809_0x1003_Formatter))] | |||
public class JT809_0x1003 : JT809Bodies | |||
public class JT809_0x1003 : JT809Bodies, IJT809MessagePackFormatter<JT809_0x1003> | |||
{ | |||
public override ushort MsgId => JT809BusinessType.主链路注销请求消息.ToUInt16Value(); | |||
public override string Description => "主链路注销请求消息"; | |||
public override JT809_LinkType LinkType => JT809_LinkType.main; | |||
/// <summary> | |||
/// 用户名 | |||
/// </summary> | |||
@@ -24,5 +30,17 @@ namespace JT809.Protocol.MessageBody | |||
/// 密码 | |||
/// </summary> | |||
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); | |||
} | |||
} | |||
} |
@@ -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 | |||
/// </summary> | |||
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; | |||
} | |||
} |
@@ -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 | |||
/// </summary> | |||
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; | |||
} | |||
} |
@@ -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 | |||
/// </summary> | |||
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; | |||
} | |||
} |
@@ -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 | |||
/// <para>主链路连接保持应答消息,数据体为空</para> | |||
/// <para>本条消息无需被通知方应答</para> | |||
/// </summary> | |||
[JT809Formatter(typeof(JT809_0x1007_Formatter))] | |||
public class JT809_0x1007:JT809Bodies | |||
public class JT809_0x1007:JT809Bodies, IJT809MessagePackFormatter<JT809_0x1007> | |||
{ | |||
public override ushort MsgId => JT809BusinessType.主链路断开通知消息.ToUInt16Value(); | |||
public override string Description => "主链路断开通知消息"; | |||
public override JT809_LinkType LinkType => JT809_LinkType.subordinate; | |||
/// <summary> | |||
/// 错误代码 | |||
/// </summary> | |||
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); | |||
} | |||
} | |||
} |
@@ -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 | |||
/// <para>业务数据类型标识:UP_CLOSELINIC INFORM</para> | |||
/// <para>描述:下级平台作为服务端,发现从链路出现异常时,下级平台通过从链路向上级平台发送本消息,通知上级平台下级平台即将关闭主从链路</para> | |||
/// </summary> | |||
[JT809Formatter(typeof(JT809_0x1008_Formatter))] | |||
public class JT809_0x1008:JT809Bodies | |||
public class JT809_0x1008:JT809Bodies, IJT809MessagePackFormatter<JT809_0x1008> | |||
{ | |||
public override ushort MsgId => JT809BusinessType.下级平台主动关闭主从链路通知消息.ToUInt16Value(); | |||
public override string Description => "下级平台主动关闭主从链路通知消息"; | |||
public override JT809_LinkType LinkType => JT809_LinkType.subordinate; | |||
/// <summary> | |||
/// 错误代码 | |||
/// </summary> | |||
public JT809_0x1008_ReasonCode ReasonCode { get; set; } | |||
public 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); | |||
} | |||
} | |||
} |
@@ -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 | |||
/// <para>业务数据类型标识:UP_EXG_MSG</para> | |||
/// <para>描述:下级平台向上级平台发送车辆动态信息交换业务数据包</para> | |||
/// </summary> | |||
[JT809Formatter(typeof(JT809BodiesFormatter<JT809_0x1200>))] | |||
public class JT809_0x1200: JT809ExchangeMessageBodies | |||
{ | |||
public override ushort MsgId => JT809BusinessType.主链路车辆动态信息交换业务.ToUInt16Value(); | |||
public override string Description => "主链路车辆动态信息交换业务"; | |||
public override JT809_LinkType LinkType => JT809_LinkType.main; | |||
} | |||
} |
@@ -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 | |||
/// <para>业务数据类型标识:UP_PLATFORM_MSG</para> | |||
/// <para>描述:下级平台向上级平台发送平台间交互信息</para> | |||
/// </summary> | |||
[JT809Formatter(typeof(JT809_0x1300_Formatter))] | |||
public class JT809_0x1300: JT809ExchangeMessageBodies | |||
public class JT809_0x1300: JT809ExchangeMessageBodies, IJT809MessagePackFormatter<JT809_0x1300> | |||
{ | |||
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); | |||
} | |||
} | |||
} | |||
} |
@@ -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 | |||
/// <para>业务数据类型标识:UP_WARN_MSG</para> | |||
/// <para>描述:下级平台向上级平台发送车辆报警信息业务</para> | |||
/// </summary> | |||
[JT809Formatter(typeof(JT809BodiesFormatter<JT809_0x1400>))] | |||
public class JT809_0x1400: JT809ExchangeMessageBodies | |||
{ | |||
public override ushort MsgId => JT809BusinessType.主链路报警信息交互消息.ToUInt16Value(); | |||
public override string Description => "主链路报警信息交互消息"; | |||
public override JT809_LinkType LinkType => JT809_LinkType.main; | |||
} | |||
} |
@@ -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 | |||
/// <para>业务数据类型标识:UP_CTRL_MSG</para> | |||
/// <para>描述:下级平台向上级平台发送车辆监管业务</para> | |||
/// </summary> | |||
[JT809Formatter(typeof(JT809BodiesFormatter<JT809_0x1500>))] | |||
public class JT809_0x1500: JT809ExchangeMessageBodies | |||
{ | |||
public override ushort MsgId => JT809BusinessType.主链路车辆监管消息.ToUInt16Value(); | |||
public override string Description => "主链路车辆监管消息"; | |||
public override JT809_LinkType LinkType => JT809_LinkType.main; | |||
} | |||
} |
@@ -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 | |||
/// <para>消息方向:下级平台往上级平台</para> | |||
/// <para>描述:下级平台向上级平台发送车辆睁态信息交换业务</para> | |||
/// </summary> | |||
[JT809Formatter(typeof(JT809BodiesFormatter<JT809_0x1600>))] | |||
public class JT809_0x1600: JT809ExchangeMessageBodies | |||
{ | |||
public override ushort MsgId => JT809BusinessType.主链路静态信息交换消息.ToUInt16Value(); | |||
public override string Description => "主链路静态信息交换消息"; | |||
public override JT809_LinkType LinkType => JT809_LinkType.main; | |||
} | |||
} |
@@ -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 | |||
/// <para>描述:主链路建立连接后,上级平台向下级平台发送从链路连接清求消息,以建立从链路连接</para> | |||
/// <para>下级平台在收到本息后,根据本校验码 VERIFY CODE 来实现数据的校验,校验后,则返回DOWN CONNECT RSP 消息</para> | |||
/// </summary> | |||
[JT809Formatter(typeof(JT809_0x9001_Formatter))] | |||
public class JT809_0x9001 : JT809Bodies | |||
public class JT809_0x9001 : JT809Bodies, IJT809MessagePackFormatter<JT809_0x9001> | |||
{ | |||
public override ushort MsgId => JT809BusinessType.从链路连接请求消息.ToUInt16Value(); | |||
public override string Description => "从链路连接请求消息"; | |||
public override JT809_LinkType LinkType => JT809_LinkType.subordinate; | |||
/// <summary> | |||
/// 4.5.1.2 对应的校验码 | |||
/// </summary> | |||
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); | |||
} | |||
} | |||
} |
@@ -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 | |||
/// <para>业务数据类型标识:DOWN_CONNNECT_RSP</para> | |||
/// <para>描述:下级平台作为服务器端向上级平台客户端返回从链路连接应答消息,上级平台在接收到该应答消息结果后</para> | |||
/// </summary> | |||
[JT809Formatter(typeof(JT809_0x9002_Formatter))] | |||
public class JT809_0x9002:JT809Bodies | |||
public class JT809_0x9002:JT809Bodies, IJT809MessagePackFormatter<JT809_0x9002> | |||
{ | |||
public override ushort MsgId => JT809BusinessType.从链路连接应答信息.ToUInt16Value(); | |||
public override string Description => "从链路连接应答信息"; | |||
public override JT809_LinkType LinkType => JT809_LinkType.subordinate; | |||
/// <summary> | |||
/// 验证结果 | |||
/// </summary> | |||
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); | |||
} | |||
} | |||
} |
@@ -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 | |||
///<para>业务数据类型标识:DOWN_DISCONNIrCT_REQ</para> | |||
///<para>描述:从链路建立后,上级平台在取消该链路时,应向下级平台发送从链路注销请求消息</para> | |||
/// </summary> | |||
[JT809Formatter(typeof(JT809_0x9003_Formatter))] | |||
public class JT809_0x9003: JT809Bodies | |||
public class JT809_0x9003: JT809Bodies, IJT809MessagePackFormatter<JT809_0x9003> | |||
{ | |||
public override ushort MsgId => JT809BusinessType.从链路注销请求消息.ToUInt16Value(); | |||
public override string Description => "从链路注销请求消息"; | |||
public override JT809_LinkType LinkType => JT809_LinkType.subordinate; | |||
/// <summary> | |||
/// 校验码 | |||
/// </summary> | |||
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); | |||
} | |||
} | |||
} |
@@ -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 | |||
/// </summary> | |||
public class JT809_0x9004:JT809Bodies | |||
{ | |||
public override ushort MsgId => JT809BusinessType.从链路注销应答消息.ToUInt16Value(); | |||
public override string Description => "从链路注销应答消息"; | |||
public override JT809_LinkType LinkType => JT809_LinkType.subordinate; | |||
} | |||
} |
@@ -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 | |||
/// </summary> | |||
public class JT809_0x9005:JT809Bodies | |||
{ | |||
public override ushort MsgId => JT809BusinessType.从链路连接保持请求消息.ToUInt16Value(); | |||
public override string Description => "从链路连接保持请求消息"; | |||
public override JT809_LinkType LinkType => JT809_LinkType.subordinate; | |||
} | |||
} |
@@ -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 | |||
/// </summary> | |||
public class JT809_0x9006:JT809Bodies | |||
{ | |||
public override ushort MsgId => JT809BusinessType.从链路连接保持应答消息.ToUInt16Value(); | |||
public override string Description => "从链路连接保持应答消息"; | |||
public override JT809_LinkType LinkType => JT809_LinkType.subordinate; | |||
} | |||
} |
@@ -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 | |||
/// </para> | |||
/// <para>本条消息无需被通知方应答</para> | |||
/// </summary> | |||
[JT809Formatter(typeof(JT809_0x9007_Formatter))] | |||
public class JT809_0x9007:JT809Bodies | |||
public class JT809_0x9007:JT809Bodies, IJT809MessagePackFormatter<JT809_0x9007> | |||
{ | |||
public override ushort MsgId => JT809BusinessType.从链路断开通知消息.ToUInt16Value(); | |||
public override string Description => "从链路断开通知消息"; | |||
public override JT809_LinkType LinkType => JT809_LinkType.main; | |||
/// <summary> | |||
/// 错误代码 | |||
/// </summary> | |||
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); | |||
} | |||
} | |||
} |
@@ -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 | |||
/// 上级平台主动关闭链路通知消息 | |||
/// <para>业务数据类型标识:DOWN_CLOSELINK_INFORM</para> | |||
/// </summary> | |||
[JT809Formatter(typeof(JT809_0x9008_Formatter))] | |||
public class JT809_0x9008:JT809Bodies | |||
public class JT809_0x9008:JT809Bodies, IJT809MessagePackFormatter<JT809_0x9008> | |||
{ | |||
public override ushort MsgId => JT809BusinessType.上级平台主动关闭链路通知消息.ToUInt16Value(); | |||
public override string Description => "上级平台主动关闭链路通知消息"; | |||
#warning 待验证主从链路 | |||
public override JT809_LinkType LinkType => JT809_LinkType.subordinate; | |||
/// <summary> | |||
/// 错误代码 | |||
/// </summary> | |||
public JT809_0x9008_ReasonCode ReasonCode { get; set; } | |||
public 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); | |||
} | |||
} | |||
} |
@@ -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 | |||
/// <para>描述:上级平台向下级平台定星通知已经收到下级平台上传的车辆定位信息数量(如:每收到10,000 条车辆定位信息通知一次)</para> | |||
/// <para>本条消息不需下级平台应答。</para> | |||
/// </summary> | |||
[JT809Formatter(typeof(JT809_0x9101_Formatter))] | |||
public class JT809_0x9101:JT809Bodies | |||
public class JT809_0x9101:JT809Bodies, IJT809MessagePackFormatter<JT809_0x9101> | |||
{ | |||
public override ushort MsgId => JT809BusinessType.接收车辆定位信息数量通知消息.ToUInt16Value(); | |||
public override string Description => "接收车辆定位信息数量通知消息"; | |||
public override JT809_LinkType LinkType => JT809_LinkType.subordinate; | |||
/// <summary> | |||
/// START_TIME_END_TIME共收到的车辆定位信息数量 | |||
/// </summary> | |||
@@ -31,5 +35,20 @@ namespace JT809.Protocol.MessageBody | |||
/// 注:采用 UTC 时间表示,如 2010-1-10 9:7:54 的 UTC 值为 1263085674,其在协议中表示为0x000000004B49286A. | |||
/// </summary> | |||
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); | |||
} | |||
} | |||
} |
@@ -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 | |||
/// <para>业务数据类型标识:DOWN_EXG_MSG</para> | |||
/// <para>描述:上级平台作为客户端向下级平台服务端发送车辆动态信息交换业务</para> | |||
/// </summary> | |||
[JT809Formatter(typeof(JT809BodiesFormatter<JT809_0x9200>))] | |||
public class JT809_0x9200: JT809ExchangeMessageBodies | |||
{ | |||
public override ushort MsgId => JT809BusinessType.从链路车辆动态信息交换业务.ToUInt16Value(); | |||
public override string Description => "从链路车辆动态信息交换业务"; | |||
public override JT809_LinkType LinkType => JT809_LinkType.subordinate; | |||
} | |||
} |