diff --git a/README.md b/README.md index 5823ef9..75a347b 100644 --- a/README.md +++ b/README.md @@ -89,4 +89,56 @@ |:------:|:------:|:------:|:------:| | 1 | 0x9300 | √ | 从链路平台间信息交互消息 | | 2 | 0x9301 | √ | 平台查岗请求 | -| 3 | 0x9302 | √ | 下发平台间报文请求 | \ No newline at end of file +| 3 | 0x9302 | √ | 下发平台间报文请求 | + +### 车辆报警信息交互类 + +#### 主链路报警信息交互消息 + +|序号|消息ID|完成情况|消息体名称| +|:------:|:------:|:------:|:------:| +| 1 | 0x1400 | √ | 主链路平台间信息交互消息 | +| 2 | 0x1401 | √ | 报警督办应答消息 | +| 3 | 0x1402 | √ | 上报报警信息消息 | +| 4 | 0x1403 | √ | 主动上报报警处理结果信息 | + +#### 从链路报警信息交互消息 + +|序号|消息ID|完成情况|消息体名称| +|:------:|:------:|:------:|:------:| +| 1 | 0x9400 | √ | 主链路平台间信息交互消息 | +| 2 | 0x9401 | √ | 报警督办请求 | +| 3 | 0x9402 | √ | 报警预警 | +| 4 | 0x9403 | √ | 实时交换报警信息 | + +### 车辆监管类 + +#### 主链路车辆监管消息 + +|序号|消息ID|完成情况|消息体名称| +|:------:|:------:|:------:|:------:| +| 1 | 0x1500 | √ | 主链路车辆监管消息 | +| 2 | 0x1501 | √ | 车辆单向监听应答 | +| 3 | 0x1502 | √ | 车辆拍照应答 | + +#### 从链路车辆监管消息 + +|序号|消息ID|完成情况|消息体名称| +|:------:|:------:|:------:|:------:| +| 1 | 0x9500 | √ | 从链路车辆监管消息 | + +### 车辆静态信息交换类 + +#### 主链路静态信息交换消息 + +|序号|消息ID|完成情况|消息体名称| +|:------:|:------:|:------:|:------:| +| 1 | 0x1600 | √ | 主链路静态信息交换消息 | +| 2 | 0x1601 | √ | 补报车辆静态信息应答 | + +#### 从链路静态信息交换消息 + +|序号|消息ID|完成情况|消息体名称| +|:------:|:------:|:------:|:------:| +| 1 | 0x9600 | √ | 从链路静态信息交换消息 | +| 2 | 0x9601 | √ | 补报车辆静态信息应答 | \ No newline at end of file diff --git a/src/JT809.Protocol.sln b/src/JT809.Protocol.sln index 2fad148..d8efee5 100644 --- a/src/JT809.Protocol.sln +++ b/src/JT809.Protocol.sln @@ -5,7 +5,7 @@ VisualStudioVersion = 15.0.27428.2005 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT809.Protocol", "JT809.Protocol\JT809.Protocol.csproj", "{4D33A5C9-F583-4230-9791-AB0394EFAD57}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JT809.Protocol.Test", "JT809.Protocol.Test\JT809.Protocol.Test.csproj", "{59D2D876-8D81-4CCE-839A-B153912C0C27}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT809.Protocol.Test", "JT809.Protocol.Test\JT809.Protocol.Test.csproj", "{59D2D876-8D81-4CCE-839A-B153912C0C27}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/src/JT809.Protocol/JT809.Protocol.csproj b/src/JT809.Protocol/JT809.Protocol.csproj index f041121..6467b7f 100644 --- a/src/JT809.Protocol/JT809.Protocol.csproj +++ b/src/JT809.Protocol/JT809.Protocol.csproj @@ -38,6 +38,14 @@ + + + + + + + + @@ -52,7 +60,7 @@ - + diff --git a/src/JT809.Protocol/JT809Enums/JT809BusinessType.cs b/src/JT809.Protocol/JT809Enums/JT809BusinessType.cs index d6466b8..acc4e7e 100644 --- a/src/JT809.Protocol/JT809Enums/JT809BusinessType.cs +++ b/src/JT809.Protocol/JT809Enums/JT809BusinessType.cs @@ -151,24 +151,27 @@ namespace JT809.Protocol.JT809Enums ///主链路报警信息交互消息 /// [Description("主链路报警信息交互消息")] + [JT809BodiesType(typeof(JT809_0x1400))] UP_WARN_MSG = 0x1400, /// ///从链路报警信息交互消息 /// [Description("从链路报警信息交互消息")] + [JT809BodiesType(typeof(JT809_0x9400))] DOWN_WARN_MSG = 0x9400, #endregion - #region 车辆监管类 /// ///主链路车辆监管消息 /// [Description("主链路车辆监管消息")] + [JT809BodiesType(typeof(JT809_0x1500))] UP_CTRL_MSG = 0x1500, /// ///从链路车辆监管消息 /// [Description("从链路车辆监管消息")] + [JT809BodiesType(typeof(JT809_0x9500))] DOWN_CTRL_MSG = 0x9500, #endregion #region 车辆静态信息交换类 @@ -176,11 +179,13 @@ namespace JT809.Protocol.JT809Enums ///主链路静态信息交换消息 /// [Description("主链路静态信息交换消息")] + [JT809BodiesType(typeof(JT809_0x1600))] UP_BASE_MSG = 0x1600, /// ///从链路静态信息交换消息 /// [Description("从链路静态信息交换消息")] + [JT809BodiesType(typeof(JT809_0x9600))] DOWN_BASE_MSG = 0x9600, #endregion } diff --git a/src/JT809.Protocol/JT809Enums/JT809SubBusinessType.cs b/src/JT809.Protocol/JT809Enums/JT809SubBusinessType.cs index d127715..ee1c5ef 100644 --- a/src/JT809.Protocol/JT809Enums/JT809SubBusinessType.cs +++ b/src/JT809.Protocol/JT809Enums/JT809SubBusinessType.cs @@ -182,16 +182,19 @@ namespace JT809.Protocol.JT809Enums ///报警督办应答 /// [Description("报警督办应答")] + [JT809BodiesType(typeof(JT809_0x1400_0x1401))] UP_WARN_MSG_URGE_TODO_ACK = 0x1401, /// ///上报报警信息 /// [Description("上报报警信息")] + [JT809BodiesType(typeof(JT809_0x1400_0x1402))] UP_WARN_MSG_ADPT_INFO = 0x1402, /// ///主动上报报警处理结果信息 /// [Description("主动上报报警处理结果信息")] + [JT809BodiesType(typeof(JT809_0x1400_0x1403))] UP_WARN_MSG_ADPT_TODO_INFO = 0x1403, #endregion @@ -200,16 +203,19 @@ namespace JT809.Protocol.JT809Enums ///报警督办请求 /// [Description("报警督办请求")] + [JT809BodiesType(typeof(JT809_0x9400_0x9401))] DOWN_WARN_MSG_URGE_TODO_REQ = 0x9401, /// ///报警预警 /// [Description("报警预警")] + [JT809BodiesType(typeof(JT809_0x9400_0x9402))] DOWN_WARN_MSG_INFORM_TIPS = 0x9402, /// ///实时交换报警信息 /// [Description("实时交换报警信息")] + [JT809BodiesType(typeof(JT809_0x9400_0x9403))] DOWN_WARN_MSG_EXG_INFORM = 0x9403, #endregion @@ -218,26 +224,31 @@ namespace JT809.Protocol.JT809Enums ///车辆单向监听应答 /// [Description("车辆单向监听应答")] + [JT809BodiesType(typeof(JT809_0x1500_0x1501))] UP_CTRL_MSG_MONITOR_VEHICLE_ACK = 0x1501, /// ///车辆拍照应答 /// [Description("车辆拍照应答")] + [JT809BodiesType(typeof(JT809_0x1500_0x1502))] UP_CTRL_MSG_TAKE_PHOTO_ACK = 0x1502, /// ///下发车辆报文应答 /// [Description("下发车辆报文应答")] + //[JT809BodiesType(typeof(JT809_0x1500_0x1503))] UP_CTRL_MSG_TEXT_INFO_ACK = 0x1503, /// ///上报车辆行驶记录应答 /// [Description("上报车辆行驶记录应答")] + //[JT809BodiesType(typeof(JT809_0x1500_0x1504))] UP_CTRL_MSG_TAKE_TRAVEL_ACK = 0x1504, /// ///车辆应急接入监管平台应答消息 /// [Description("车辆应急接入监管平台应答消息")] + //[JT809BodiesType(typeof(JT809_0x1500_0x1505))] UP_CTRL_MSG_EMERGENCY_MONITORING_ACK = 0x1505, #endregion @@ -274,6 +285,7 @@ namespace JT809.Protocol.JT809Enums ///补报车辆静态信息应答 /// [Description("补报车辆静态信息应答")] + [JT809BodiesType(typeof(JT809_0x1600_0x1601))] UP_BASE_MSG_VEHICLE_ADDED_ACK = 0x1601, #endregion @@ -282,6 +294,7 @@ namespace JT809.Protocol.JT809Enums ///补报车辆静态信息请求 /// [Description("补报车辆静态信息请求")] + [JT809BodiesType(typeof(JT809_0x9600_0x9601))] DOWN_BASE_MSG_VEHICLE_ADDED = 0x9601, #endregion } diff --git a/src/JT809.Protocol/JT809Enums/JT809_0x1401_Result.cs b/src/JT809.Protocol/JT809Enums/JT809_0x1401_Result.cs new file mode 100644 index 0000000..6367243 --- /dev/null +++ b/src/JT809.Protocol/JT809Enums/JT809_0x1401_Result.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Enums +{ + /// + /// 报警处理结果 + /// + public enum JT809_0x1401_Result : byte + { + 处理中 = 0x00, + 已处理完毕 = 0x01, + 不做处理 = 0x02, + 将来处理 = 0x03 + } +} diff --git a/src/JT809.Protocol/JT809Enums/JT809_0x1402_WarnSrc.cs b/src/JT809.Protocol/JT809Enums/JT809_0x1402_WarnSrc.cs new file mode 100644 index 0000000..d0a32eb --- /dev/null +++ b/src/JT809.Protocol/JT809Enums/JT809_0x1402_WarnSrc.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Enums +{ + /// + /// 报警信息来源 + /// + public enum JT809_0x1402_WarnSrc : byte + { + 车载终端 = 0x00, + 企业监控平台 = 0x01, + 政府监管平台 = 0x02, + 其他 =0x09 + } +} diff --git a/src/JT809.Protocol/JT809Enums/JT809_0x1403_Result.cs b/src/JT809.Protocol/JT809Enums/JT809_0x1403_Result.cs new file mode 100644 index 0000000..2d11de4 --- /dev/null +++ b/src/JT809.Protocol/JT809Enums/JT809_0x1403_Result.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Enums +{ + /// + /// 报警处理结果 + /// + public enum JT809_0x1403_Result : byte + { + 处理中 = 0x00, + 已处理完毕 = 0x01, + 不做处理 = 0x02, + 将来处理 = 0x03 + } +} diff --git a/src/JT809.Protocol/JT809Enums/JT809_0x1501_Result.cs b/src/JT809.Protocol/JT809Enums/JT809_0x1501_Result.cs new file mode 100644 index 0000000..b1c640f --- /dev/null +++ b/src/JT809.Protocol/JT809Enums/JT809_0x1501_Result.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Enums +{ + /// + /// 应答结果 + /// + public enum JT809_0x1501_Result : byte + { + 监听成功 = 0x00, + 监听失败 = 0x01 + } +} diff --git a/src/JT809.Protocol/JT809Enums/JT809_0x1502_PhotoRspFlag.cs b/src/JT809.Protocol/JT809Enums/JT809_0x1502_PhotoRspFlag.cs new file mode 100644 index 0000000..f53c3d6 --- /dev/null +++ b/src/JT809.Protocol/JT809Enums/JT809_0x1502_PhotoRspFlag.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Enums +{ + /// + /// 拍照应答标识 + /// + public enum JT809_0x1502_PhotoRspFlag : byte + { + 不支持拍照 = 0x00, + 完成拍照 = 0x01, + 完成拍照_照片数据稍后传送 = 0x02, + 未拍照_不在线 = 0x03, + 未拍照_无法使用指定镜头 = 0x04, + 未拍照_其他原因 = 0x05, + 车牌号码错误 = 0x09, + } +} diff --git a/src/JT809.Protocol/JT809Enums/JT809_0x9401_WarnSrc.cs b/src/JT809.Protocol/JT809Enums/JT809_0x9401_WarnSrc.cs new file mode 100644 index 0000000..2b52f9b --- /dev/null +++ b/src/JT809.Protocol/JT809Enums/JT809_0x9401_WarnSrc.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Enums +{ + /// + /// 报警信息来源 + /// + public enum JT809_0x9401_WarnSrc : byte + { + 车载终端 = 0x00, + 企业监控平台 = 0x01, + 政府监管平台 = 0x02, + 其他 =0x09 + } +} diff --git a/src/JT809.Protocol/JT809Enums/JT809_0x9402_WarnSrc.cs b/src/JT809.Protocol/JT809Enums/JT809_0x9402_WarnSrc.cs new file mode 100644 index 0000000..6423253 --- /dev/null +++ b/src/JT809.Protocol/JT809Enums/JT809_0x9402_WarnSrc.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Enums +{ + /// + /// 报警信息来源 + /// + public enum JT809_0x9402_WarnSrc : byte + { + 车载终端 = 0x00, + 企业监控平台 = 0x01, + 政府监管平台 = 0x02, + 其他 =0x09 + } +} diff --git a/src/JT809.Protocol/JT809Enums/JT809_0x9403_WarnSrc.cs b/src/JT809.Protocol/JT809Enums/JT809_0x9403_WarnSrc.cs new file mode 100644 index 0000000..48d7f9f --- /dev/null +++ b/src/JT809.Protocol/JT809Enums/JT809_0x9403_WarnSrc.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Enums +{ + /// + /// 报警信息来源 + /// + public enum JT809_0x9403_WarnSrc : byte + { + 车载终端 = 0x00, + 企业监控平台 = 0x01, + 政府监管平台 = 0x02, + 其他 =0x09 + } +} diff --git a/src/JT809.Protocol/JT809Enums/JT809_VehiclePositionExcrypt.cs b/src/JT809.Protocol/JT809Enums/JT809_VehiclePositionEncrypt.cs similarity index 85% rename from src/JT809.Protocol/JT809Enums/JT809_VehiclePositionExcrypt.cs rename to src/JT809.Protocol/JT809Enums/JT809_VehiclePositionEncrypt.cs index 8f2408e..0764afa 100644 --- a/src/JT809.Protocol/JT809Enums/JT809_VehiclePositionExcrypt.cs +++ b/src/JT809.Protocol/JT809Enums/JT809_VehiclePositionEncrypt.cs @@ -7,7 +7,7 @@ namespace JT809.Protocol.JT809Enums /// /// 定位信息是否使用国家测绘局批准的地图保密插件进行加密。 /// - public enum JT809_VehiclePositionExcrypt:byte + public enum JT809_VehiclePositionEncrypt:byte { 未加密 = 0x00, 已加密 = 0x01 diff --git a/src/JT809.Protocol/JT809Formatters/JT809MessageBodyFormatters/JT809_0x1006Formatter.cs b/src/JT809.Protocol/JT809Formatters/JT809MessageBodyFormatters/JT809_0x1006Formatter.cs new file mode 100644 index 0000000..5308752 --- /dev/null +++ b/src/JT809.Protocol/JT809Formatters/JT809MessageBodyFormatters/JT809_0x1006Formatter.cs @@ -0,0 +1,64 @@ +using JT809.Protocol.JT809Attributes; +using JT809.Protocol.JT809Enums; +using JT809.Protocol.JT809Exceptions; +using JT809.Protocol.JT809Extensions; +using JT809.Protocol.JT809MessageBody; +using System; +using System.Buffers; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Formatters.JT809MessageBodyFormatters +{ + public class JT809_0x1006Formatter : IJT809Formatter + { + public JT809_0x1006 Deserialize(ReadOnlySpan bytes, out int readSize) + { + int offset = 0; + JT809_0x1006 jT809_0X1006 = new JT809_0x1006(); + jT809_0X1006.VehicleNo = JT809BinaryExtensions.ReadStringLittle(bytes, ref offset, 21); + jT809_0X1006.VehicleColor = (JT809VehicleColorType)JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + jT809_0X1006.SubBusinessType = (JT809SubBusinessType)JT809BinaryExtensions.ReadUInt16Little(bytes, ref offset); + jT809_0X1006.DataLength = JT809BinaryExtensions.ReadUInt32Little(bytes, ref offset); + //JT809.Protocol.JT809Enums.JT809BusinessType 映射对应消息特性 + JT809BodiesTypeAttribute jT809SubBodiesTypeAttribute = jT809_0X1006.SubBusinessType.GetAttribute(); + if (jT809SubBodiesTypeAttribute == null) + { + throw new JT809Exception(JT809ErrorCode.GetAttributeError, $"JT809BodiesTypeAttribute Not Found>{jT809_0X1006.SubBusinessType.ToString()}"); + } + try + { + jT809_0X1006.JT809SubBodies = JT809FormatterResolverExtensions.JT809DynamicDeserialize(JT809FormatterExtensions.GetFormatter(jT809SubBodiesTypeAttribute.JT809BodiesType), bytes.Slice(offset, (int)jT809_0X1006.DataLength), out readSize); + } + catch + { + throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{jT809_0X1006.SubBusinessType.ToString()}"); + } + readSize = offset; + return jT809_0X1006; + } + + public int Serialize(IMemoryOwner memoryOwner, int offset, JT809_0x1006 value) + { + offset += JT809BinaryExtensions.WriteStringLittle(memoryOwner, offset, value.VehicleNo, 21); + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, (byte)value.VehicleColor); + offset += JT809BinaryExtensions.WriteUInt16Little(memoryOwner, offset, (ushort)value.SubBusinessType); + offset += JT809BinaryExtensions.WriteUInt32Little(memoryOwner, offset, value.DataLength); + //JT809.Protocol.JT809Enums.JT809BusinessType 映射对应消息特性 + JT809BodiesTypeAttribute jT809SubBodiesTypeAttribute = value.SubBusinessType.GetAttribute(); + if (jT809SubBodiesTypeAttribute == null) + { + throw new JT809Exception(JT809ErrorCode.GetAttributeError, $"JT809BodiesTypeAttribute Not Found>{value.SubBusinessType.ToString()}"); + } + try + { + offset = JT809FormatterResolverExtensions.JT809DynamicSerialize(JT809FormatterExtensions.GetFormatter(jT809SubBodiesTypeAttribute.JT809BodiesType), memoryOwner, offset, value.JT809SubBodies); + } + catch + { + throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}"); + } + return offset; + } + } +} diff --git a/src/JT809.Protocol/JT809Formatters/JT809MessageBodyFormatters/JT809_0x1400Formatter.cs b/src/JT809.Protocol/JT809Formatters/JT809MessageBodyFormatters/JT809_0x1400Formatter.cs new file mode 100644 index 0000000..8333a8f --- /dev/null +++ b/src/JT809.Protocol/JT809Formatters/JT809MessageBodyFormatters/JT809_0x1400Formatter.cs @@ -0,0 +1,64 @@ +using JT809.Protocol.JT809Attributes; +using JT809.Protocol.JT809Enums; +using JT809.Protocol.JT809Exceptions; +using JT809.Protocol.JT809Extensions; +using JT809.Protocol.JT809MessageBody; +using System; +using System.Buffers; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Formatters.JT809MessageBodyFormatters +{ + public class JT809_0x1400Formatter : IJT809Formatter + { + public JT809_0x1400 Deserialize(ReadOnlySpan bytes, out int readSize) + { + int offset = 0; + JT809_0x1400 jT809_0X1400 = new JT809_0x1400(); + jT809_0X1400.VehicleNo = JT809BinaryExtensions.ReadStringLittle(bytes, ref offset, 21); + jT809_0X1400.VehicleColor = (JT809VehicleColorType)JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + jT809_0X1400.SubBusinessType = (JT809SubBusinessType)JT809BinaryExtensions.ReadUInt16Little(bytes, ref offset); + jT809_0X1400.DataLength = JT809BinaryExtensions.ReadUInt32Little(bytes, ref offset); + //JT809.Protocol.JT809Enums.JT809BusinessType 映射对应消息特性 + JT809BodiesTypeAttribute jT809SubBodiesTypeAttribute = jT809_0X1400.SubBusinessType.GetAttribute(); + if (jT809SubBodiesTypeAttribute == null) + { + throw new JT809Exception(JT809ErrorCode.GetAttributeError, $"JT809BodiesTypeAttribute Not Found>{jT809_0X1400.SubBusinessType.ToString()}"); + } + try + { + jT809_0X1400.JT809SubBodies = JT809FormatterResolverExtensions.JT809DynamicDeserialize(JT809FormatterExtensions.GetFormatter(jT809SubBodiesTypeAttribute.JT809BodiesType), bytes.Slice(offset, (int)jT809_0X1400.DataLength), out readSize); + } + catch + { + throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{jT809_0X1400.SubBusinessType.ToString()}"); + } + readSize = offset; + return jT809_0X1400; + } + + public int Serialize(IMemoryOwner memoryOwner, int offset, JT809_0x1400 value) + { + offset += JT809BinaryExtensions.WriteStringLittle(memoryOwner, offset, value.VehicleNo, 21); + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, (byte)value.VehicleColor); + offset += JT809BinaryExtensions.WriteUInt16Little(memoryOwner, offset, (ushort)value.SubBusinessType); + offset += JT809BinaryExtensions.WriteUInt32Little(memoryOwner, offset, value.DataLength); + //JT809.Protocol.JT809Enums.JT809BusinessType 映射对应消息特性 + JT809BodiesTypeAttribute jT809SubBodiesTypeAttribute = value.SubBusinessType.GetAttribute(); + if (jT809SubBodiesTypeAttribute == null) + { + throw new JT809Exception(JT809ErrorCode.GetAttributeError, $"JT809BodiesTypeAttribute Not Found>{value.SubBusinessType.ToString()}"); + } + try + { + offset = JT809FormatterResolverExtensions.JT809DynamicSerialize(JT809FormatterExtensions.GetFormatter(jT809SubBodiesTypeAttribute.JT809BodiesType), memoryOwner, offset, value.JT809SubBodies); + } + catch + { + throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}"); + } + return offset; + } + } +} diff --git a/src/JT809.Protocol/JT809Formatters/JT809MessageBodyFormatters/JT809_0x1500Formatter.cs b/src/JT809.Protocol/JT809Formatters/JT809MessageBodyFormatters/JT809_0x1500Formatter.cs new file mode 100644 index 0000000..fc84cb3 --- /dev/null +++ b/src/JT809.Protocol/JT809Formatters/JT809MessageBodyFormatters/JT809_0x1500Formatter.cs @@ -0,0 +1,64 @@ +using JT809.Protocol.JT809Attributes; +using JT809.Protocol.JT809Enums; +using JT809.Protocol.JT809Exceptions; +using JT809.Protocol.JT809Extensions; +using JT809.Protocol.JT809MessageBody; +using System; +using System.Buffers; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Formatters.JT809MessageBodyFormatters +{ + public class JT809_0x1500Formatter : IJT809Formatter + { + public JT809_0x1500 Deserialize(ReadOnlySpan bytes, out int readSize) + { + int offset = 0; + JT809_0x1500 jT809_0X1500 = new JT809_0x1500(); + jT809_0X1500.VehicleNo = JT809BinaryExtensions.ReadStringLittle(bytes, ref offset, 21); + jT809_0X1500.VehicleColor = (JT809VehicleColorType)JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + jT809_0X1500.SubBusinessType = (JT809SubBusinessType)JT809BinaryExtensions.ReadUInt16Little(bytes, ref offset); + jT809_0X1500.DataLength = JT809BinaryExtensions.ReadUInt32Little(bytes, ref offset); + //JT809.Protocol.JT809Enums.JT809BusinessType 映射对应消息特性 + JT809BodiesTypeAttribute jT809SubBodiesTypeAttribute = jT809_0X1500.SubBusinessType.GetAttribute(); + if (jT809SubBodiesTypeAttribute == null) + { + throw new JT809Exception(JT809ErrorCode.GetAttributeError, $"JT809BodiesTypeAttribute Not Found>{jT809_0X1500.SubBusinessType.ToString()}"); + } + try + { + jT809_0X1500.JT809SubBodies = JT809FormatterResolverExtensions.JT809DynamicDeserialize(JT809FormatterExtensions.GetFormatter(jT809SubBodiesTypeAttribute.JT809BodiesType), bytes.Slice(offset, (int)jT809_0X1500.DataLength), out readSize); + } + catch + { + throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{jT809_0X1500.SubBusinessType.ToString()}"); + } + readSize = offset; + return jT809_0X1500; + } + + public int Serialize(IMemoryOwner memoryOwner, int offset, JT809_0x1500 value) + { + offset += JT809BinaryExtensions.WriteStringLittle(memoryOwner, offset, value.VehicleNo, 21); + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, (byte)value.VehicleColor); + offset += JT809BinaryExtensions.WriteUInt16Little(memoryOwner, offset, (ushort)value.SubBusinessType); + offset += JT809BinaryExtensions.WriteUInt32Little(memoryOwner, offset, value.DataLength); + //JT809.Protocol.JT809Enums.JT809BusinessType 映射对应消息特性 + JT809BodiesTypeAttribute jT809SubBodiesTypeAttribute = value.SubBusinessType.GetAttribute(); + if (jT809SubBodiesTypeAttribute == null) + { + throw new JT809Exception(JT809ErrorCode.GetAttributeError, $"JT809BodiesTypeAttribute Not Found>{value.SubBusinessType.ToString()}"); + } + try + { + offset = JT809FormatterResolverExtensions.JT809DynamicSerialize(JT809FormatterExtensions.GetFormatter(jT809SubBodiesTypeAttribute.JT809BodiesType), memoryOwner, offset, value.JT809SubBodies); + } + catch + { + throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}"); + } + return offset; + } + } +} diff --git a/src/JT809.Protocol/JT809Formatters/JT809MessageBodyFormatters/JT809_0x1600Formatter.cs b/src/JT809.Protocol/JT809Formatters/JT809MessageBodyFormatters/JT809_0x1600Formatter.cs new file mode 100644 index 0000000..678e4b1 --- /dev/null +++ b/src/JT809.Protocol/JT809Formatters/JT809MessageBodyFormatters/JT809_0x1600Formatter.cs @@ -0,0 +1,64 @@ +using JT809.Protocol.JT809Attributes; +using JT809.Protocol.JT809Enums; +using JT809.Protocol.JT809Exceptions; +using JT809.Protocol.JT809Extensions; +using JT809.Protocol.JT809MessageBody; +using System; +using System.Buffers; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Formatters.JT809MessageBodyFormatters +{ + public class JT809_0x1600Formatter : IJT809Formatter + { + public JT809_0x1600 Deserialize(ReadOnlySpan bytes, out int readSize) + { + int offset = 0; + JT809_0x1600 jT809_0X1600 = new JT809_0x1600(); + jT809_0X1600.VehicleNo = JT809BinaryExtensions.ReadStringLittle(bytes, ref offset, 21); + jT809_0X1600.VehicleColor = (JT809VehicleColorType)JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + jT809_0X1600.SubBusinessType = (JT809SubBusinessType)JT809BinaryExtensions.ReadUInt16Little(bytes, ref offset); + jT809_0X1600.DataLength = JT809BinaryExtensions.ReadUInt32Little(bytes, ref offset); + //JT809.Protocol.JT809Enums.JT809BusinessType 映射对应消息特性 + JT809BodiesTypeAttribute jT809SubBodiesTypeAttribute = jT809_0X1600.SubBusinessType.GetAttribute(); + if (jT809SubBodiesTypeAttribute == null) + { + throw new JT809Exception(JT809ErrorCode.GetAttributeError, $"JT809BodiesTypeAttribute Not Found>{jT809_0X1600.SubBusinessType.ToString()}"); + } + try + { + jT809_0X1600.JT809SubBodies = JT809FormatterResolverExtensions.JT809DynamicDeserialize(JT809FormatterExtensions.GetFormatter(jT809SubBodiesTypeAttribute.JT809BodiesType), bytes.Slice(offset, (int)jT809_0X1600.DataLength), out readSize); + } + catch + { + throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{jT809_0X1600.SubBusinessType.ToString()}"); + } + readSize = offset; + return jT809_0X1600; + } + + public int Serialize(IMemoryOwner memoryOwner, int offset, JT809_0x1600 value) + { + offset += JT809BinaryExtensions.WriteStringLittle(memoryOwner, offset, value.VehicleNo, 21); + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, (byte)value.VehicleColor); + offset += JT809BinaryExtensions.WriteUInt16Little(memoryOwner, offset, (ushort)value.SubBusinessType); + offset += JT809BinaryExtensions.WriteUInt32Little(memoryOwner, offset, value.DataLength); + //JT809.Protocol.JT809Enums.JT809BusinessType 映射对应消息特性 + JT809BodiesTypeAttribute jT809SubBodiesTypeAttribute = value.SubBusinessType.GetAttribute(); + if (jT809SubBodiesTypeAttribute == null) + { + throw new JT809Exception(JT809ErrorCode.GetAttributeError, $"JT809BodiesTypeAttribute Not Found>{value.SubBusinessType.ToString()}"); + } + try + { + offset = JT809FormatterResolverExtensions.JT809DynamicSerialize(JT809FormatterExtensions.GetFormatter(jT809SubBodiesTypeAttribute.JT809BodiesType), memoryOwner, offset, value.JT809SubBodies); + } + catch + { + throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}"); + } + return offset; + } + } +} diff --git a/src/JT809.Protocol/JT809Formatters/JT809MessageBodyFormatters/JT809_0x9400Formatter.cs b/src/JT809.Protocol/JT809Formatters/JT809MessageBodyFormatters/JT809_0x9400Formatter.cs new file mode 100644 index 0000000..081fab2 --- /dev/null +++ b/src/JT809.Protocol/JT809Formatters/JT809MessageBodyFormatters/JT809_0x9400Formatter.cs @@ -0,0 +1,64 @@ +using JT809.Protocol.JT809Attributes; +using JT809.Protocol.JT809Enums; +using JT809.Protocol.JT809Exceptions; +using JT809.Protocol.JT809Extensions; +using JT809.Protocol.JT809MessageBody; +using System; +using System.Buffers; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Formatters.JT809MessageBodyFormatters +{ + public class JT809_0x9400Formatter : IJT809Formatter + { + public JT809_0x9400 Deserialize(ReadOnlySpan bytes, out int readSize) + { + int offset = 0; + JT809_0x9400 jT809_0X9400 = new JT809_0x9400(); + jT809_0X9400.VehicleNo = JT809BinaryExtensions.ReadStringLittle(bytes, ref offset, 21); + jT809_0X9400.VehicleColor = (JT809VehicleColorType)JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + jT809_0X9400.SubBusinessType = (JT809SubBusinessType)JT809BinaryExtensions.ReadUInt16Little(bytes, ref offset); + jT809_0X9400.DataLength = JT809BinaryExtensions.ReadUInt32Little(bytes, ref offset); + //JT809.Protocol.JT809Enums.JT809BusinessType 映射对应消息特性 + JT809BodiesTypeAttribute jT809SubBodiesTypeAttribute = jT809_0X9400.SubBusinessType.GetAttribute(); + if (jT809SubBodiesTypeAttribute == null) + { + throw new JT809Exception(JT809ErrorCode.GetAttributeError, $"JT809BodiesTypeAttribute Not Found>{jT809_0X9400.SubBusinessType.ToString()}"); + } + try + { + jT809_0X9400.JT809SubBodies = JT809FormatterResolverExtensions.JT809DynamicDeserialize(JT809FormatterExtensions.GetFormatter(jT809SubBodiesTypeAttribute.JT809BodiesType), bytes.Slice(offset, (int)jT809_0X9400.DataLength), out readSize); + } + catch + { + throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{jT809_0X9400.SubBusinessType.ToString()}"); + } + readSize = offset; + return jT809_0X9400; + } + + public int Serialize(IMemoryOwner memoryOwner, int offset, JT809_0x9400 value) + { + offset += JT809BinaryExtensions.WriteStringLittle(memoryOwner, offset, value.VehicleNo, 21); + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, (byte)value.VehicleColor); + offset += JT809BinaryExtensions.WriteUInt16Little(memoryOwner, offset, (ushort)value.SubBusinessType); + offset += JT809BinaryExtensions.WriteUInt32Little(memoryOwner, offset, value.DataLength); + //JT809.Protocol.JT809Enums.JT809BusinessType 映射对应消息特性 + JT809BodiesTypeAttribute jT809SubBodiesTypeAttribute = value.SubBusinessType.GetAttribute(); + if (jT809SubBodiesTypeAttribute == null) + { + throw new JT809Exception(JT809ErrorCode.GetAttributeError, $"JT809BodiesTypeAttribute Not Found>{value.SubBusinessType.ToString()}"); + } + try + { + offset = JT809FormatterResolverExtensions.JT809DynamicSerialize(JT809FormatterExtensions.GetFormatter(jT809SubBodiesTypeAttribute.JT809BodiesType), memoryOwner, offset, value.JT809SubBodies); + } + catch + { + throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}"); + } + return offset; + } + } +} diff --git a/src/JT809.Protocol/JT809Formatters/JT809MessageBodyFormatters/JT809_0x9500Formatter.cs b/src/JT809.Protocol/JT809Formatters/JT809MessageBodyFormatters/JT809_0x9500Formatter.cs new file mode 100644 index 0000000..9303a30 --- /dev/null +++ b/src/JT809.Protocol/JT809Formatters/JT809MessageBodyFormatters/JT809_0x9500Formatter.cs @@ -0,0 +1,64 @@ +using JT809.Protocol.JT809Attributes; +using JT809.Protocol.JT809Enums; +using JT809.Protocol.JT809Exceptions; +using JT809.Protocol.JT809Extensions; +using JT809.Protocol.JT809MessageBody; +using System; +using System.Buffers; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Formatters.JT809MessageBodyFormatters +{ + public class JT809_0x9500Formatter : IJT809Formatter + { + public JT809_0x9500 Deserialize(ReadOnlySpan bytes, out int readSize) + { + int offset = 0; + JT809_0x9500 jT809_0X9500 = new JT809_0x9500(); + jT809_0X9500.VehicleNo = JT809BinaryExtensions.ReadStringLittle(bytes, ref offset, 21); + jT809_0X9500.VehicleColor = (JT809VehicleColorType)JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + jT809_0X9500.SubBusinessType = (JT809SubBusinessType)JT809BinaryExtensions.ReadUInt16Little(bytes, ref offset); + jT809_0X9500.DataLength = JT809BinaryExtensions.ReadUInt32Little(bytes, ref offset); + //JT809.Protocol.JT809Enums.JT809BusinessType 映射对应消息特性 + JT809BodiesTypeAttribute jT809SubBodiesTypeAttribute = jT809_0X9500.SubBusinessType.GetAttribute(); + if (jT809SubBodiesTypeAttribute == null) + { + throw new JT809Exception(JT809ErrorCode.GetAttributeError, $"JT809BodiesTypeAttribute Not Found>{jT809_0X9500.SubBusinessType.ToString()}"); + } + try + { + jT809_0X9500.JT809SubBodies = JT809FormatterResolverExtensions.JT809DynamicDeserialize(JT809FormatterExtensions.GetFormatter(jT809SubBodiesTypeAttribute.JT809BodiesType), bytes.Slice(offset, (int)jT809_0X9500.DataLength), out readSize); + } + catch + { + throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{jT809_0X9500.SubBusinessType.ToString()}"); + } + readSize = offset; + return jT809_0X9500; + } + + public int Serialize(IMemoryOwner memoryOwner, int offset, JT809_0x9500 value) + { + offset += JT809BinaryExtensions.WriteStringLittle(memoryOwner, offset, value.VehicleNo, 21); + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, (byte)value.VehicleColor); + offset += JT809BinaryExtensions.WriteUInt16Little(memoryOwner, offset, (ushort)value.SubBusinessType); + offset += JT809BinaryExtensions.WriteUInt32Little(memoryOwner, offset, value.DataLength); + //JT809.Protocol.JT809Enums.JT809BusinessType 映射对应消息特性 + JT809BodiesTypeAttribute jT809SubBodiesTypeAttribute = value.SubBusinessType.GetAttribute(); + if (jT809SubBodiesTypeAttribute == null) + { + throw new JT809Exception(JT809ErrorCode.GetAttributeError, $"JT809BodiesTypeAttribute Not Found>{value.SubBusinessType.ToString()}"); + } + try + { + offset = JT809FormatterResolverExtensions.JT809DynamicSerialize(JT809FormatterExtensions.GetFormatter(jT809SubBodiesTypeAttribute.JT809BodiesType), memoryOwner, offset, value.JT809SubBodies); + } + catch + { + throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}"); + } + return offset; + } + } +} diff --git a/src/JT809.Protocol/JT809Formatters/JT809MessageBodyFormatters/JT809_0x9600Formatter.cs b/src/JT809.Protocol/JT809Formatters/JT809MessageBodyFormatters/JT809_0x9600Formatter.cs new file mode 100644 index 0000000..0010368 --- /dev/null +++ b/src/JT809.Protocol/JT809Formatters/JT809MessageBodyFormatters/JT809_0x9600Formatter.cs @@ -0,0 +1,64 @@ +using JT809.Protocol.JT809Attributes; +using JT809.Protocol.JT809Enums; +using JT809.Protocol.JT809Exceptions; +using JT809.Protocol.JT809Extensions; +using JT809.Protocol.JT809MessageBody; +using System; +using System.Buffers; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Formatters.JT809MessageBodyFormatters +{ + public class JT809_0x9600Formatter : IJT809Formatter + { + public JT809_0x9600 Deserialize(ReadOnlySpan bytes, out int readSize) + { + int offset = 0; + JT809_0x9600 jT809_0X9600 = new JT809_0x9600(); + jT809_0X9600.VehicleNo = JT809BinaryExtensions.ReadStringLittle(bytes, ref offset, 21); + jT809_0X9600.VehicleColor = (JT809VehicleColorType)JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + jT809_0X9600.SubBusinessType = (JT809SubBusinessType)JT809BinaryExtensions.ReadUInt16Little(bytes, ref offset); + jT809_0X9600.DataLength = JT809BinaryExtensions.ReadUInt32Little(bytes, ref offset); + //JT809.Protocol.JT809Enums.JT809BusinessType 映射对应消息特性 + JT809BodiesTypeAttribute jT809SubBodiesTypeAttribute = jT809_0X9600.SubBusinessType.GetAttribute(); + if (jT809SubBodiesTypeAttribute == null) + { + throw new JT809Exception(JT809ErrorCode.GetAttributeError, $"JT809BodiesTypeAttribute Not Found>{jT809_0X9600.SubBusinessType.ToString()}"); + } + try + { + jT809_0X9600.JT809SubBodies = JT809FormatterResolverExtensions.JT809DynamicDeserialize(JT809FormatterExtensions.GetFormatter(jT809SubBodiesTypeAttribute.JT809BodiesType), bytes.Slice(offset, (int)jT809_0X9600.DataLength), out readSize); + } + catch + { + throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{jT809_0X9600.SubBusinessType.ToString()}"); + } + readSize = offset; + return jT809_0X9600; + } + + public int Serialize(IMemoryOwner memoryOwner, int offset, JT809_0x9600 value) + { + offset += JT809BinaryExtensions.WriteStringLittle(memoryOwner, offset, value.VehicleNo, 21); + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, (byte)value.VehicleColor); + offset += JT809BinaryExtensions.WriteUInt16Little(memoryOwner, offset, (ushort)value.SubBusinessType); + offset += JT809BinaryExtensions.WriteUInt32Little(memoryOwner, offset, value.DataLength); + //JT809.Protocol.JT809Enums.JT809BusinessType 映射对应消息特性 + JT809BodiesTypeAttribute jT809SubBodiesTypeAttribute = value.SubBusinessType.GetAttribute(); + if (jT809SubBodiesTypeAttribute == null) + { + throw new JT809Exception(JT809ErrorCode.GetAttributeError, $"JT809BodiesTypeAttribute Not Found>{value.SubBusinessType.ToString()}"); + } + try + { + offset = JT809FormatterResolverExtensions.JT809DynamicSerialize(JT809FormatterExtensions.GetFormatter(jT809SubBodiesTypeAttribute.JT809BodiesType), memoryOwner, offset, value.JT809SubBodies); + } + catch + { + throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}"); + } + return offset; + } + } +} diff --git a/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x1200_0x1202Formatter.cs b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x1200_0x1202Formatter.cs index b9db23b..5b2e7db 100644 --- a/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x1200_0x1202Formatter.cs +++ b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x1200_0x1202Formatter.cs @@ -14,7 +14,7 @@ namespace JT809.Protocol.JT809Formatters.JT809SubMessageBodyFormatters { int offset = 0; JT809_0x1200_0x1202 jT809_0X1200_0X1202 = new JT809_0x1200_0x1202(); - jT809_0X1200_0X1202.VehiclePosition.Encrypt = (JT809_VehiclePositionExcrypt)JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + jT809_0X1200_0X1202.VehiclePosition.Encrypt = (JT809_VehiclePositionEncrypt)JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); jT809_0X1200_0X1202.VehiclePosition.Day= JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); jT809_0X1200_0X1202.VehiclePosition.Month = JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); jT809_0X1200_0X1202.VehiclePosition.Year = JT809BinaryExtensions.ReadUInt16Little(bytes, ref offset); diff --git a/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x1400_0x1401Formatter.cs b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x1400_0x1401Formatter.cs new file mode 100644 index 0000000..9349d11 --- /dev/null +++ b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x1400_0x1401Formatter.cs @@ -0,0 +1,29 @@ +using JT809.Protocol.JT809Extensions; +using JT809.Protocol.JT809SubMessageBody; +using System; +using System.Buffers; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Formatters.JT809SubMessageBodyFormatters +{ + public class JT809_0x1400_0x1401Formatter : IJT809Formatter + { + public JT809_0x1400_0x1401 Deserialize(ReadOnlySpan bytes, out int readSize) + { + int offset = 0; + JT809_0x1400_0x1401 jT809_0X1400_0X1401 = new JT809_0x1400_0x1401(); + jT809_0X1400_0X1401.SupervisionID = JT809BinaryExtensions.ReadUInt32Little(bytes, ref offset); + jT809_0X1400_0X1401.Result = (JT809Enums.JT809_0x1401_Result)JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + readSize = offset; + return jT809_0X1400_0X1401; + } + + public int Serialize(IMemoryOwner memoryOwner, int offset, JT809_0x1400_0x1401 value) + { + offset += JT809BinaryExtensions.WriteUInt32Little(memoryOwner, offset, value.SupervisionID); + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset,(byte)value.Result); + return offset; + } + } +} diff --git a/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x1400_0x1402Formatter.cs b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x1400_0x1402Formatter.cs new file mode 100644 index 0000000..9e3c335 --- /dev/null +++ b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x1400_0x1402Formatter.cs @@ -0,0 +1,40 @@ +using JT809.Protocol.JT809Extensions; +using JT809.Protocol.JT809SubMessageBody; +using System; +using System.Buffers; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Formatters.JT809SubMessageBodyFormatters +{ + public class JT809_0x1400_0x1402Formatter : IJT809Formatter + { + public JT809_0x1400_0x1402 Deserialize(ReadOnlySpan bytes, out int readSize) + { + int offset = 0; + JT809_0x1400_0x1402 jT809_0X1400_0X1402 = new JT809_0x1400_0x1402(); + jT809_0X1400_0X1402.WarnSrc = (JT809Enums.JT809_0x1402_WarnSrc)JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + jT809_0X1400_0X1402.WarnType= JT809BinaryExtensions.ReadUInt16Little(bytes, ref offset); + jT809_0X1400_0X1402.WarnTime = JT809BinaryExtensions.ReadUTCDateTimeLittle(bytes, ref offset); + jT809_0X1400_0X1402.InfoID= JT809BinaryExtensions.ReadUInt32Little(bytes, ref offset); + jT809_0X1400_0X1402.InfoLength = JT809BinaryExtensions.ReadUInt32Little(bytes, ref offset); + jT809_0X1400_0X1402.InfoContent= JT809BinaryExtensions.ReadStringLittle(bytes, ref offset, (int)jT809_0X1400_0X1402.InfoLength); + readSize = offset; + return jT809_0X1400_0X1402; + } + + public int Serialize(IMemoryOwner memoryOwner, int offset, JT809_0x1400_0x1402 value) + { + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, (byte)value.WarnSrc); + offset += JT809BinaryExtensions.WriteUInt16Little(memoryOwner, offset,value.WarnType); + offset += JT809BinaryExtensions.WriteUTCDateTimeLittle(memoryOwner, offset, value.WarnTime); + offset += JT809BinaryExtensions.WriteUInt32Little(memoryOwner, offset, value.InfoID); + // 先计算内容长度(汉字为两个字节) + offset += 4; + int byteLength = JT809BinaryExtensions.WriteStringLittle(memoryOwner, offset, value.InfoContent); + JT809BinaryExtensions.WriteInt32Little(memoryOwner, offset - 4, byteLength); + offset += byteLength; + return offset; + } + } +} diff --git a/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x1400_0x1403Formatter.cs b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x1400_0x1403Formatter.cs new file mode 100644 index 0000000..9cf7ec2 --- /dev/null +++ b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x1400_0x1403Formatter.cs @@ -0,0 +1,29 @@ +using JT809.Protocol.JT809Extensions; +using JT809.Protocol.JT809SubMessageBody; +using System; +using System.Buffers; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Formatters.JT809SubMessageBodyFormatters +{ + public class JT809_0x1400_0x1403Formatter : IJT809Formatter + { + public JT809_0x1400_0x1403 Deserialize(ReadOnlySpan bytes, out int readSize) + { + int offset = 0; + JT809_0x1400_0x1403 jT809_0X1400_0X1403 = new JT809_0x1400_0x1403(); + jT809_0X1400_0X1403.InfoID = JT809BinaryExtensions.ReadUInt32Little(bytes, ref offset); + jT809_0X1400_0X1403.Result = (JT809Enums.JT809_0x1403_Result)JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + readSize = offset; + return jT809_0X1400_0X1403; + } + + public int Serialize(IMemoryOwner memoryOwner, int offset, JT809_0x1400_0x1403 value) + { + offset += JT809BinaryExtensions.WriteUInt32Little(memoryOwner, offset, value.InfoID); + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, (byte)value.Result); + return offset; + } + } +} diff --git a/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x1500_0x1501Formatter.cs b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x1500_0x1501Formatter.cs new file mode 100644 index 0000000..83602d2 --- /dev/null +++ b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x1500_0x1501Formatter.cs @@ -0,0 +1,27 @@ +using JT809.Protocol.JT809Extensions; +using JT809.Protocol.JT809SubMessageBody; +using System; +using System.Buffers; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Formatters.JT809SubMessageBodyFormatters +{ + public class JT809_0x1500_0x1501Formatter : IJT809Formatter + { + public JT809_0x1500_0x1501 Deserialize(ReadOnlySpan bytes, out int readSize) + { + int offset = 0; + JT809_0x1500_0x1501 jT809_0X1500_0X1501 = new JT809_0x1500_0x1501(); + jT809_0X1500_0X1501.Result= (JT809Enums.JT809_0x1501_Result)JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + readSize = offset; + return jT809_0X1500_0X1501; + } + + public int Serialize(IMemoryOwner memoryOwner, int offset, JT809_0x1500_0x1501 value) + { + offset+= JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, (byte)value.Result); + return offset; + } + } +} diff --git a/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x1500_0x1502Formatter.cs b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x1500_0x1502Formatter.cs new file mode 100644 index 0000000..74f18ef --- /dev/null +++ b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x1500_0x1502Formatter.cs @@ -0,0 +1,21 @@ +using JT809.Protocol.JT809SubMessageBody; +using System; +using System.Buffers; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Formatters.JT809SubMessageBodyFormatters +{ + public class JT809_0x1500_0x1502Formatter : IJT809Formatter + { + public JT809_0x1500_0x1502 Deserialize(ReadOnlySpan bytes, out int readSize) + { + throw new NotImplementedException(); + } + + public int Serialize(IMemoryOwner memoryOwner, int offset, JT809_0x1500_0x1502 value) + { + throw new NotImplementedException(); + } + } +} diff --git a/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9200_0x9202Formatter.cs b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9200_0x9202Formatter.cs index 4cd3b59..ddbfdfd 100644 --- a/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9200_0x9202Formatter.cs +++ b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9200_0x9202Formatter.cs @@ -14,7 +14,7 @@ namespace JT809.Protocol.JT809Formatters.JT809SubMessageBodyFormatters { int offset = 0; JT809_0x9200_0x9202 jT809_0X1200_0x9202 = new JT809_0x9200_0x9202(); - jT809_0X1200_0x9202.VehiclePosition.Encrypt = (JT809_VehiclePositionExcrypt)JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + jT809_0X1200_0x9202.VehiclePosition.Encrypt = (JT809_VehiclePositionEncrypt)JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); jT809_0X1200_0x9202.VehiclePosition.Day= JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); jT809_0X1200_0x9202.VehiclePosition.Month = JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); jT809_0X1200_0x9202.VehiclePosition.Year = JT809BinaryExtensions.ReadUInt16Little(bytes, ref offset); diff --git a/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9400_0x9401Formatter.cs b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9400_0x9401Formatter.cs new file mode 100644 index 0000000..dc58805 --- /dev/null +++ b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9400_0x9401Formatter.cs @@ -0,0 +1,43 @@ +using JT809.Protocol.JT809Extensions; +using JT809.Protocol.JT809SubMessageBody; +using System; +using System.Buffers; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Formatters.JT809SubMessageBodyFormatters +{ + public class JT809_0x9400_0x9401Formatter : IJT809Formatter + { + public JT809_0x9400_0x9401 Deserialize(ReadOnlySpan bytes, out int readSize) + { + int offset = 0; + JT809_0x9400_0x9401 jT809_0X9400_0X9401 = new JT809_0x9400_0x9401(); + jT809_0X9400_0X9401.WarnSrc = (JT809Enums.JT809_0x9401_WarnSrc)JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + jT809_0X9400_0X9401.WarnType = JT809BinaryExtensions.ReadUInt16Little(bytes, ref offset); + jT809_0X9400_0X9401.WarnTime = JT809BinaryExtensions.ReadUTCDateTimeLittle(bytes, ref offset); + jT809_0X9400_0X9401.SupervisionID = JT809BinaryExtensions.ReadUInt32Little(bytes, ref offset); + jT809_0X9400_0X9401.SupervisionEndtime = JT809BinaryExtensions.ReadUTCDateTimeLittle(bytes, ref offset); + jT809_0X9400_0X9401.SupervisionLevel = JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + jT809_0X9400_0X9401.Supervisor = JT809BinaryExtensions.ReadStringLittle(bytes, ref offset,16); + jT809_0X9400_0X9401.SupervisorTel = JT809BinaryExtensions.ReadStringLittle(bytes, ref offset,20); + jT809_0X9400_0X9401.SupervisorEmail = JT809BinaryExtensions.ReadStringLittle(bytes, ref offset,32); + readSize = offset; + return jT809_0X9400_0X9401; + } + + public int Serialize(IMemoryOwner memoryOwner, int offset, JT809_0x9400_0x9401 value) + { + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, (byte)value.WarnSrc); + offset += JT809BinaryExtensions.WriteUInt16Little(memoryOwner, offset, value.WarnType); + offset += JT809BinaryExtensions.WriteUTCDateTimeLittle(memoryOwner, offset, value.WarnTime); + offset += JT809BinaryExtensions.WriteUInt32Little(memoryOwner, offset, value.SupervisionID); + offset += JT809BinaryExtensions.WriteUTCDateTimeLittle(memoryOwner, offset, value.SupervisionEndtime); + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, value.SupervisionLevel); + offset += JT809BinaryExtensions.WriteStringLittle(memoryOwner, offset, value.Supervisor,16); + offset += JT809BinaryExtensions.WriteStringLittle(memoryOwner, offset, value.SupervisorTel,20); + offset += JT809BinaryExtensions.WriteStringLittle(memoryOwner, offset, value.SupervisorEmail,32); + return offset; + } + } +} diff --git a/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9400_0x9402Formatter.cs b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9400_0x9402Formatter.cs new file mode 100644 index 0000000..033922c --- /dev/null +++ b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9400_0x9402Formatter.cs @@ -0,0 +1,38 @@ +using JT809.Protocol.JT809Extensions; +using JT809.Protocol.JT809SubMessageBody; +using System; +using System.Buffers; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Formatters.JT809SubMessageBodyFormatters +{ + public class JT809_0x9400_0x9402Formatter : IJT809Formatter + { + public JT809_0x9400_0x9402 Deserialize(ReadOnlySpan bytes, out int readSize) + { + int offset = 0; + JT809_0x9400_0x9402 jT809_0X9400_0X9402 = new JT809_0x9400_0x9402(); + jT809_0X9400_0X9402.WarnSrc = (JT809Enums.JT809_0x9402_WarnSrc)JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + jT809_0X9400_0X9402.WarnType = JT809BinaryExtensions.ReadUInt16Little(bytes, ref offset); + jT809_0X9400_0X9402.WarnTime = JT809BinaryExtensions.ReadUTCDateTimeLittle(bytes, ref offset); + jT809_0X9400_0X9402.WarnLength = JT809BinaryExtensions.ReadUInt32Little(bytes, ref offset); + jT809_0X9400_0X9402.WarnContent = JT809BinaryExtensions.ReadStringLittle(bytes, ref offset,(int)jT809_0X9400_0X9402.WarnLength); + readSize = offset; + return jT809_0X9400_0X9402; + } + + public int Serialize(IMemoryOwner memoryOwner, int offset, JT809_0x9400_0x9402 value) + { + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, (byte)value.WarnSrc); + offset += JT809BinaryExtensions.WriteUInt16Little(memoryOwner, offset, value.WarnType); + offset += JT809BinaryExtensions.WriteUTCDateTimeLittle(memoryOwner, offset, value.WarnTime); + // 先计算内容长度(汉字为两个字节) + offset += 4; + int byteLength = JT809BinaryExtensions.WriteStringLittle(memoryOwner, offset, value.WarnContent); + JT809BinaryExtensions.WriteInt32Little(memoryOwner, offset - 4, byteLength); + offset += byteLength; + return offset; + } + } +} diff --git a/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9400_0x9403Formatter.cs b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9400_0x9403Formatter.cs new file mode 100644 index 0000000..508eb1a --- /dev/null +++ b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9400_0x9403Formatter.cs @@ -0,0 +1,38 @@ +using JT809.Protocol.JT809Extensions; +using JT809.Protocol.JT809SubMessageBody; +using System; +using System.Buffers; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Formatters.JT809SubMessageBodyFormatters +{ + public class JT809_0x9400_0x9403Formatter : IJT809Formatter + { + public JT809_0x9400_0x9403 Deserialize(ReadOnlySpan bytes, out int readSize) + { + int offset = 0; + JT809_0x9400_0x9403 jT809_0X9400_0X9403 = new JT809_0x9400_0x9403(); + jT809_0X9400_0X9403.WarnSrc = (JT809Enums.JT809_0x9403_WarnSrc)JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + jT809_0X9400_0X9403.WarnType = JT809BinaryExtensions.ReadUInt16Little(bytes, ref offset); + jT809_0X9400_0X9403.WarnTime = JT809BinaryExtensions.ReadUTCDateTimeLittle(bytes, ref offset); + jT809_0X9400_0X9403.WarnLength = JT809BinaryExtensions.ReadUInt32Little(bytes, ref offset); + jT809_0X9400_0X9403.WarnContent = JT809BinaryExtensions.ReadStringLittle(bytes, ref offset, (int)jT809_0X9400_0X9403.WarnLength); + readSize = offset; + return jT809_0X9400_0X9403; + } + + public int Serialize(IMemoryOwner memoryOwner, int offset, JT809_0x9400_0x9403 value) + { + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, (byte)value.WarnSrc); + offset += JT809BinaryExtensions.WriteUInt16Little(memoryOwner, offset, value.WarnType); + offset += JT809BinaryExtensions.WriteUTCDateTimeLittle(memoryOwner, offset, value.WarnTime); + // 先计算内容长度(汉字为两个字节) + offset += 4; + int byteLength = JT809BinaryExtensions.WriteStringLittle(memoryOwner, offset, value.WarnContent); + JT809BinaryExtensions.WriteInt32Little(memoryOwner, offset - 4, byteLength); + offset += byteLength; + return offset; + } + } +} diff --git a/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9600_0x1601Formatter.cs b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9600_0x1601Formatter.cs new file mode 100644 index 0000000..c6a305b --- /dev/null +++ b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9600_0x1601Formatter.cs @@ -0,0 +1,27 @@ +using JT809.Protocol.JT809Extensions; +using JT809.Protocol.JT809SubMessageBody; +using System; +using System.Buffers; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Formatters.JT809SubMessageBodyFormatters +{ + public class JT809_0x9600_0x1601Formatter : IJT809Formatter + { + public JT809_0x1600_0x1601 Deserialize(ReadOnlySpan bytes, out int readSize) + { + int offset = 0; + JT809_0x1600_0x1601 jT809_0X9600_0X1601 = new JT809_0x1600_0x1601(); + jT809_0X9600_0X1601.CarInfo = JT809BinaryExtensions.ReadStringLittle(bytes, ref offset); + readSize = offset; + return jT809_0X9600_0X1601; + } + + public int Serialize(IMemoryOwner memoryOwner, int offset, JT809_0x1600_0x1601 value) + { + offset += JT809BinaryExtensions.WriteStringLittle(memoryOwner, offset, value.CarInfo); + return offset; + } + } +} diff --git a/src/JT809.Protocol/JT809MessageBody/JT809_0x1006.cs b/src/JT809.Protocol/JT809MessageBody/JT809_0x1006.cs index 830905c..0fab2b9 100644 --- a/src/JT809.Protocol/JT809MessageBody/JT809_0x1006.cs +++ b/src/JT809.Protocol/JT809MessageBody/JT809_0x1006.cs @@ -1,4 +1,5 @@ -using System; +using JT809.Protocol.JT809Enums; +using System; using System.Collections.Generic; using System.Text; @@ -14,6 +15,25 @@ namespace JT809.Protocol.JT809MessageBody /// public class JT809_0x1006:JT809Bodies { - + /// + /// 车牌号 + /// + public string VehicleNo { get; set; } + /// + /// 车辆颜色 + /// + public JT809VehicleColorType VehicleColor { get; set; } + /// + /// 子业务类型标识 + /// + public JT809SubBusinessType SubBusinessType { get; set; } + /// + /// 后续数据长度 + /// + public uint DataLength { get; set; } + /// + /// 子业务数据体 + /// + public JT809SubBodies JT809SubBodies { get; set; } } } diff --git a/src/JT809.Protocol/JT809MessageBody/JT809_0x1400.cs b/src/JT809.Protocol/JT809MessageBody/JT809_0x1400.cs new file mode 100644 index 0000000..8979616 --- /dev/null +++ b/src/JT809.Protocol/JT809MessageBody/JT809_0x1400.cs @@ -0,0 +1,42 @@ +using JT809.Protocol.JT809Attributes; +using JT809.Protocol.JT809Enums; +using JT809.Protocol.JT809Formatters.JT809MessageBodyFormatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809MessageBody +{ + /// + /// 主链路报警信息交互消息 + /// 主链路车辆报警信息业务 + /// 链路类型:主链路 + /// 消息方向:下级平台往上级平台 + /// 业务数据类型标识:UP_WARN_MSG + /// 描述:下级平台向上级平台发送车辆报警信息业务 + /// + [JT809Formatter(typeof(JT809_0x1400Formatter))] + public class JT809_0x1400:JT809Bodies + { + /// + /// 车牌号 + /// + public string VehicleNo { get; set; } + /// + /// 车辆颜色 + /// + public JT809VehicleColorType VehicleColor { get; set; } + /// + /// 子业务类型标识 + /// + public JT809SubBusinessType SubBusinessType { get; set; } + /// + /// 后续数据长度 + /// + public uint DataLength { get; set; } + /// + /// 子业务数据体 + /// + public JT809SubBodies JT809SubBodies { get; set; } + } +} diff --git a/src/JT809.Protocol/JT809MessageBody/JT809_0x1500.cs b/src/JT809.Protocol/JT809MessageBody/JT809_0x1500.cs new file mode 100644 index 0000000..863e5d7 --- /dev/null +++ b/src/JT809.Protocol/JT809MessageBody/JT809_0x1500.cs @@ -0,0 +1,41 @@ +using JT809.Protocol.JT809Attributes; +using JT809.Protocol.JT809Enums; +using JT809.Protocol.JT809Formatters.JT809MessageBodyFormatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809MessageBody +{ + /// + /// 主链路车辆监管消息 + /// 链路类型:主链路 + /// 消息方向:下级平台往上级平台 + /// 业务数据类型标识:UP_CTRL_MSG + /// 描述:下级平台向上级平台发送车辆监管业务 + /// + [JT809Formatter(typeof(JT809_0x1500Formatter))] + public class JT809_0x1500:JT809Bodies + { + /// + /// 车牌号 + /// + public string VehicleNo { get; set; } + /// + /// 车辆颜色 + /// + public JT809VehicleColorType VehicleColor { get; set; } + /// + /// 子业务类型标识 + /// + public JT809SubBusinessType SubBusinessType { get; set; } + /// + /// 后续数据长度 + /// + public uint DataLength { get; set; } + /// + /// 子业务数据体 + /// + public JT809SubBodies JT809SubBodies { get; set; } + } +} diff --git a/src/JT809.Protocol/JT809MessageBody/JT809_0x1600.cs b/src/JT809.Protocol/JT809MessageBody/JT809_0x1600.cs new file mode 100644 index 0000000..0f92142 --- /dev/null +++ b/src/JT809.Protocol/JT809MessageBody/JT809_0x1600.cs @@ -0,0 +1,41 @@ +using JT809.Protocol.JT809Attributes; +using JT809.Protocol.JT809Enums; +using JT809.Protocol.JT809Formatters.JT809MessageBodyFormatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809MessageBody +{ + /// + /// 主链路静态信息交换消息 + /// 链路类型:主链路 + /// 业务数据类型标识:UP_ BASE_ MSG + /// 消息方向:下级平台往上级平台 + /// 描述:下级平台向上级平台发送车辆睁态信息交换业务 + /// + [JT809Formatter(typeof(JT809_0x1600Formatter))] + public class JT809_0x1600:JT809Bodies + { + /// + /// 车牌号 + /// + public string VehicleNo { get; set; } + /// + /// 车辆颜色 + /// + public JT809VehicleColorType VehicleColor { get; set; } + /// + /// 子业务类型标识 + /// + public JT809SubBusinessType SubBusinessType { get; set; } + /// + /// 后续数据长度 + /// + public uint DataLength { get; set; } + /// + /// 子业务数据体 + /// + public JT809SubBodies JT809SubBodies { get; set; } + } +} diff --git a/src/JT809.Protocol/JT809MessageBody/JT809_0x9400.cs b/src/JT809.Protocol/JT809MessageBody/JT809_0x9400.cs new file mode 100644 index 0000000..bb4944c --- /dev/null +++ b/src/JT809.Protocol/JT809MessageBody/JT809_0x9400.cs @@ -0,0 +1,41 @@ +using JT809.Protocol.JT809Attributes; +using JT809.Protocol.JT809Enums; +using JT809.Protocol.JT809Formatters.JT809MessageBodyFormatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809MessageBody +{ + /// + /// 从链路报警信息交互消息 + /// 链路类型:从链路 + /// 消息方向:上级平台往下级平台 + /// 业务数据类型标识:DOWN_WARN_MSG + /// 描述:上级平台向下级平台发送报瞥信息业务 + /// + [JT809Formatter(typeof(JT809_0x9400Formatter))] + public class JT809_0x9400:JT809Bodies + { + /// + /// 车牌号 + /// + public string VehicleNo { get; set; } + /// + /// 车辆颜色 + /// + public JT809VehicleColorType VehicleColor { get; set; } + /// + /// 子业务类型标识 + /// + public JT809SubBusinessType SubBusinessType { get; set; } + /// + /// 后续数据长度 + /// + public uint DataLength { get; set; } + /// + /// 子业务数据体 + /// + public JT809SubBodies JT809SubBodies { get; set; } + } +} diff --git a/src/JT809.Protocol/JT809MessageBody/JT809_0x9500.cs b/src/JT809.Protocol/JT809MessageBody/JT809_0x9500.cs new file mode 100644 index 0000000..fd20f19 --- /dev/null +++ b/src/JT809.Protocol/JT809MessageBody/JT809_0x9500.cs @@ -0,0 +1,41 @@ +using JT809.Protocol.JT809Attributes; +using JT809.Protocol.JT809Enums; +using JT809.Protocol.JT809Formatters.JT809MessageBodyFormatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809MessageBody +{ + /// + /// 从链路车辆监管消息 + /// 链路类型:从链路 + /// 消息方向:上级平台往下级平台 + /// 业务数据类型标识:DOWN_CTRL_MSG + /// 描述:上级平台向下级平台发送车辆监监管业务 + /// + [JT809Formatter(typeof(JT809_0x9500Formatter))] + public class JT809_0x9500:JT809Bodies + { + /// + /// 车牌号 + /// + public string VehicleNo { get; set; } + /// + /// 车辆颜色 + /// + public JT809VehicleColorType VehicleColor { get; set; } + /// + /// 子业务类型标识 + /// + public JT809SubBusinessType SubBusinessType { get; set; } + /// + /// 后续数据长度 + /// + public uint DataLength { get; set; } + /// + /// 子业务数据体 + /// + public JT809SubBodies JT809SubBodies { get; set; } + } +} diff --git a/src/JT809.Protocol/JT809MessageBody/JT809_0x9600.cs b/src/JT809.Protocol/JT809MessageBody/JT809_0x9600.cs new file mode 100644 index 0000000..72aff60 --- /dev/null +++ b/src/JT809.Protocol/JT809MessageBody/JT809_0x9600.cs @@ -0,0 +1,41 @@ +using JT809.Protocol.JT809Attributes; +using JT809.Protocol.JT809Enums; +using JT809.Protocol.JT809Formatters.JT809MessageBodyFormatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809MessageBody +{ + /// + /// 从链路静态信息交换消息 + /// 链路类型:从链路 + /// 消息方向:上级平台往下级台 + /// 业务数据类型标识:DOWN_BASE_MSG + /// 描述:上级平台向下级平台发送车辆静态信息交换业务 + /// + [JT809Formatter(typeof(JT809_0x9600Formatter))] + public class JT809_0x9600:JT809Bodies + { + /// + /// 车牌号 + /// + public string VehicleNo { get; set; } + /// + /// 车辆颜色 + /// + public JT809VehicleColorType VehicleColor { get; set; } + /// + /// 子业务类型标识 + /// + public JT809SubBusinessType SubBusinessType { get; set; } + /// + /// 后续数据长度 + /// + public uint DataLength { get; set; } + /// + /// 子业务数据体 + /// + public JT809SubBodies JT809SubBodies { get; set; } + } +} diff --git a/src/JT809.Protocol/JT809Properties/JT809VehiclePositionProperties.cs b/src/JT809.Protocol/JT809Properties/JT809VehiclePositionProperties.cs index aad81ef..bfbee54 100644 --- a/src/JT809.Protocol/JT809Properties/JT809VehiclePositionProperties.cs +++ b/src/JT809.Protocol/JT809Properties/JT809VehiclePositionProperties.cs @@ -13,7 +13,7 @@ namespace JT809.Protocol.JT809Properties /// /// 该字段标识传输的定位信息是否使用国家测绘局批准的地图保密插件进行加密。 /// - public JT809_VehiclePositionExcrypt Encrypt { get; set; } + public JT809_VehiclePositionEncrypt Encrypt { get; set; } /// /// 日 /// diff --git a/src/JT809.Protocol/JT809SubMessageBody/JT809_0x1400_0x1401.cs b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x1400_0x1401.cs new file mode 100644 index 0000000..355520c --- /dev/null +++ b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x1400_0x1401.cs @@ -0,0 +1,27 @@ +using JT809.Protocol.JT809Attributes; +using JT809.Protocol.JT809Enums; +using JT809.Protocol.JT809Formatters.JT809SubMessageBodyFormatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809SubMessageBody +{ + /// + /// 报警督办应答消息 + /// 子业务类型标识:UP_WARN_MSG_URGE_TODO_ACK + /// 描述:下级平台应答上级平台下发的报警督办请求消息,向上.级平台上报车辆的报瞥处理结果 + /// + [JT809Formatter(typeof(JT809_0x1400_0x1401Formatter))] + public class JT809_0x1400_0x1401:JT809SubBodies + { + /// + /// 报警督办 ID + /// + public uint SupervisionID { get; set; } + /// + /// 报警处理结果 + /// + public JT809_0x1401_Result Result { get; set; } + } +} diff --git a/src/JT809.Protocol/JT809SubMessageBody/JT809_0x1400_0x1402.cs b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x1400_0x1402.cs new file mode 100644 index 0000000..68a6eaf --- /dev/null +++ b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x1400_0x1402.cs @@ -0,0 +1,44 @@ +using JT809.Protocol.JT809Attributes; +using JT809.Protocol.JT809Enums; +using JT809.Protocol.JT809Formatters.JT809SubMessageBodyFormatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809SubMessageBody +{ + /// + /// 上报报警信息消息 + /// 子业务类型标识:UP_WARN_MSG_ADPT_INFO + /// 描述:下级平台向上级平台上报某车辆的报警信息 + /// 本条消息上级平台无需应答 + /// + [JT809Formatter(typeof(JT809_0x1400_0x1402Formatter))] + public class JT809_0x1400_0x1402:JT809SubBodies + { + /// + /// 报警信息来源 + /// + public JT809_0x1402_WarnSrc WarnSrc { get; set; } + /// + /// 报警类型 + /// + public ushort WarnType { get; set; } + /// + /// 报警时间 + /// + public DateTime WarnTime { get; set; } + /// + /// 信息ID + /// + public uint InfoID { get; set; } + /// + /// 数据长度 + /// + public uint InfoLength { get; set; } + /// + /// 数据长度 + /// + public string InfoContent { get; set; } + } +} diff --git a/src/JT809.Protocol/JT809SubMessageBody/JT809_0x1400_0x1403.cs b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x1400_0x1403.cs new file mode 100644 index 0000000..24e3e6f --- /dev/null +++ b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x1400_0x1403.cs @@ -0,0 +1,28 @@ +using JT809.Protocol.JT809Attributes; +using JT809.Protocol.JT809Enums; +using JT809.Protocol.JT809Formatters.JT809SubMessageBodyFormatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809SubMessageBody +{ + /// + /// 主动上报报警处理结果信息 + /// 子业务类型标识:UP_WARN_MSG_ADPT_TODO_INFO + /// 描述:下级平台向上级平台上报报警处理结果 + /// 本条消息上级平台无需应答 + /// + [JT809Formatter(typeof(JT809_0x1400_0x1403Formatter))] + public class JT809_0x1400_0x1403:JT809SubBodies + { + /// + /// 报警信息ID + /// + public uint InfoID { get; set; } + /// + /// 处理结果 + /// + public JT809_0x1403_Result Result { get; set; } + } +} diff --git a/src/JT809.Protocol/JT809SubMessageBody/JT809_0x1500_0x1501.cs b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x1500_0x1501.cs new file mode 100644 index 0000000..bd81a4b --- /dev/null +++ b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x1500_0x1501.cs @@ -0,0 +1,23 @@ +using JT809.Protocol.JT809Attributes; +using JT809.Protocol.JT809Enums; +using JT809.Protocol.JT809Formatters.JT809SubMessageBodyFormatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809SubMessageBody +{ + /// + /// 车辆单向监听应答 + /// 子业务类型标识:UP_CTRL_MSG_MONITOR_VEHTCLE_ACK + /// 描述:下级平台向上级平台上传车辆单向监听请求消息的应答 + /// + [JT809Formatter(typeof(JT809_0x1500_0x1501Formatter))] + public class JT809_0x1500_0x1501:JT809SubBodies + { + /// + /// 应答结果 + /// + public JT809_0x1501_Result Result { get; set; } + } +} diff --git a/src/JT809.Protocol/JT809SubMessageBody/JT809_0x1500_0x1502.cs b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x1500_0x1502.cs new file mode 100644 index 0000000..3be9b62 --- /dev/null +++ b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x1500_0x1502.cs @@ -0,0 +1,49 @@ +using JT809.Protocol.JT809Attributes; +using JT809.Protocol.JT809Enums; +using JT809.Protocol.JT809Formatters.JT809SubMessageBodyFormatters; +using JT809.Protocol.JT809Properties; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809SubMessageBody +{ + /// + /// 车辆拍照应答 + /// 子业务类型标识:UP_ CTRL_ MSG _TAKE_ PHOTO_ ACK + /// 描述:下级平台应答上级平台发送的车辆拍照请求消息,上传图片信息到上级平台 + /// + [JT809Formatter(typeof(JT809_0x1500_0x1502Formatter))] + public class JT809_0x1500_0x1502:JT809SubBodies + { + /// + /// 拍照应答标识 + /// + public JT809_0x1502_PhotoRspFlag PhotoRspFlag { get; set; } + + /// + /// 车辆定位信息 + /// + public JT809VehiclePositionProperties VehiclePosition { get; set; } + /// + /// 镜头ID + /// + public byte LensID { get; set; } + /// + /// 图片长度 + /// + public uint PhotoLen { get; set; } + /// + /// 图片大小 + /// + public byte SizeType { get; set; } + /// + /// 图像格式 + /// + public byte Type { get; set; } + /// + /// 图片内容 + /// + public byte[] Photo { get; set; } + } +} diff --git a/src/JT809.Protocol/JT809SubMessageBody/JT809_0x1600_0x1601.cs b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x1600_0x1601.cs new file mode 100644 index 0000000..f7dc5c2 --- /dev/null +++ b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x1600_0x1601.cs @@ -0,0 +1,22 @@ +using JT809.Protocol.JT809Attributes; +using JT809.Protocol.JT809Formatters.JT809SubMessageBodyFormatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809SubMessageBody +{ + /// + /// 补报车辆静态信息应答 + /// 子业务类型标识:UP_BASE_MSG_VEHICLE_ADDED_ACK + /// 描述:上级平台应答下级平台发送的补报车辆静态信息清求消息 + /// + [JT809Formatter(typeof(JT809_0x9600_0x1601Formatter))] + public class JT809_0x1600_0x1601:JT809SubBodies + { + /// + /// 车辆信息 + /// + public string CarInfo { get; set; } + } +} diff --git a/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9400_0x9401.cs b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9400_0x9401.cs new file mode 100644 index 0000000..e8b218f --- /dev/null +++ b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9400_0x9401.cs @@ -0,0 +1,55 @@ +using JT809.Protocol.JT809Attributes; +using JT809.Protocol.JT809Enums; +using JT809.Protocol.JT809Formatters.JT809SubMessageBodyFormatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809SubMessageBody +{ + /// + /// 报警督办请求消息 + /// 子业务类型标识:DOWN_WARN_MSG_URGE_TODO_REQ + /// 描述:上级平台向车辆归属下级平台下发本消息,催促其及时处理相关车辆的报警信息 + /// + [JT809Formatter(typeof(JT809_0x9400_0x9401Formatter))] + public class JT809_0x9400_0x9401:JT809SubBodies + { + /// + /// 报警信息来源 + /// + public JT809_0x9401_WarnSrc WarnSrc { get; set; } + /// + /// 报警类型 + /// + public ushort WarnType { get; set; } + /// + /// 报警时间 + /// + public DateTime WarnTime { get; set; } + /// + /// 报警督办ID + /// + public uint SupervisionID { get; set; } + /// + /// 督办截止时间 + /// + public DateTime SupervisionEndtime { get; set; } + /// + /// 督办级别 + /// + public byte SupervisionLevel { get; set; } + /// + /// 督办人 + /// + public string Supervisor { get; set; } + /// + /// 督办联系电话 + /// + public string SupervisorTel { get; set; } + /// + /// 督办联系电子邮件 + /// + public string SupervisorEmail { get; set; } + } +} diff --git a/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9400_0x9402.cs b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9400_0x9402.cs new file mode 100644 index 0000000..ffa8648 --- /dev/null +++ b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9400_0x9402.cs @@ -0,0 +1,40 @@ +using JT809.Protocol.JT809Attributes; +using JT809.Protocol.JT809Enums; +using JT809.Protocol.JT809Formatters.JT809SubMessageBodyFormatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809SubMessageBody +{ + /// + /// 报警预警 + /// 子业务类型标识:DOWN_WARN_MSG_INFORM_TIPS + /// 描述:用于上级平台向车辆归属或车辆跨域下级平台下发相关车辆的报警顶警或运行提示信息 + /// 本条消息下级平台无需应答 + /// + [JT809Formatter(typeof(JT809_0x9400_0x9402Formatter))] + public class JT809_0x9400_0x9402:JT809SubBodies + { + /// + /// 报警信息来源 + /// + public JT809_0x9402_WarnSrc WarnSrc { get; set; } + /// + /// 报警类型 + /// + public ushort WarnType { get; set; } + /// + /// 报警时间 + /// + public DateTime WarnTime { get; set; } + /// + /// 数据长度 + /// + public uint WarnLength { get; set; } + /// + /// 报警描述 + /// + public string WarnContent { get; set; } + } +} diff --git a/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9400_0x9403.cs b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9400_0x9403.cs new file mode 100644 index 0000000..474b972 --- /dev/null +++ b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9400_0x9403.cs @@ -0,0 +1,40 @@ +using JT809.Protocol.JT809Attributes; +using JT809.Protocol.JT809Enums; +using JT809.Protocol.JT809Formatters.JT809SubMessageBodyFormatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809SubMessageBody +{ + /// + /// 实时交换报警信息 + /// 子业务类型标识:DOWN_WARN_MSG_EXG_INFORM + /// 描述:用于上级平台向车辆跨域目的地下级平台下发相关车辆的当前报警情况 + /// 本条消息下级平台无需应答 + /// + [JT809Formatter(typeof(JT809_0x9400_0x9403Formatter))] + public class JT809_0x9400_0x9403:JT809SubBodies + { + /// + /// 报警信息来源 + /// + public JT809_0x9403_WarnSrc WarnSrc { get; set; } + /// + /// 报警类型 + /// + public ushort WarnType { get; set; } + /// + /// 报警时间 + /// + public DateTime WarnTime { get; set; } + /// + /// 数据长度 + /// + public uint WarnLength { get; set; } + /// + /// 报警描述 + /// + public string WarnContent { get; set; } + } +} diff --git a/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9600_0x9601.cs b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9600_0x9601.cs new file mode 100644 index 0000000..2ca7d38 --- /dev/null +++ b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9600_0x9601.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809SubMessageBody +{ + /// + /// 补报车辆静态信息请求消息 + /// 子业务类型标识:DOWN_BASE_MSG_VEHICLE_ADDED + /// 描述:上级平台在接收到车辆定位信息后,发现该车辆静态信息在上级平台不存在,上级平台向下级平台下发补报该车辆静态信息的请求消息 + /// + public class JT809_0x9600_0x9601:JT809SubBodies + { + } +}