diff --git a/README.md b/README.md index b3e8f84..043295a 100644 --- a/README.md +++ b/README.md @@ -55,4 +55,20 @@ | 10 | 0x120A | √ | 上报车辆驾驶员身份识别信息应答 | | 11 | 0x120B | √ | 上报车辆电子运单应答 | | 12 | 0x120C | √ | 主动上报驾驶员身份信息 | -| 13 | 0x120D | √ | 主动上报车辆电子运单信息 | \ No newline at end of file +| 13 | 0x120D | √ | 主动上报车辆电子运单信息 | + +#### 从链路动态信息交换消息 + +|序号|消息ID|完成情况|消息体名称| +|:------:|:------:|:------:|:------:| +| 1 | 0x9200 | √ | 从链路动态信息交换消息 | +| 2 | 0x9202 | √ | 交换车辆定位信息消息 | +| 3 | 0x9203 | √ | 车辆定位信息交换补发消息 | +| 4 | 0x9204 | √ | 交换车辆静态信息消息 | +| 5 | 0x9205 | √ | 启动车辆定位信息交换请求消息 | +| 6 | 0x9206 | √ | 结束车辆定位信息交换请求消息 | +| 7 | 0x9207 | √ | 申请交换指定车辆定位信息应答消息 | +| 8 | 0x9208 | √ | 取消申请交换指定车辆定位信息应答消息 | +| 9 | 0x9209 | √ | 补发车辆定位信息应答消息 | +| 10 | 0x920A | √ | 上报驾驶员身份识别信息请求消息 | +| 11 | 0x920B | √ | 上报车辆电子运单请求消息 | \ No newline at end of file diff --git a/src/JT809.Protocol/JT809.Protocol.csproj b/src/JT809.Protocol/JT809.Protocol.csproj index 0b294fc..0db14cb 100644 --- a/src/JT809.Protocol/JT809.Protocol.csproj +++ b/src/JT809.Protocol/JT809.Protocol.csproj @@ -40,6 +40,11 @@ + + + + + diff --git a/src/JT809.Protocol/JT809Enums/JT809BusinessType.cs b/src/JT809.Protocol/JT809Enums/JT809BusinessType.cs index c91dc79..9fa329c 100644 --- a/src/JT809.Protocol/JT809Enums/JT809BusinessType.cs +++ b/src/JT809.Protocol/JT809Enums/JT809BusinessType.cs @@ -126,9 +126,10 @@ namespace JT809.Protocol.JT809Enums [JT809BodiesType(typeof(JT809_0x1200))] UP_EXG_MSG = 0x1200, /// - ///从链路动态信息交换消息 + ///从链路动态信息交换消息 /// [Description("从链路动态信息交换消息")] + [JT809BodiesType(typeof(JT809_0x9200))] DOWN_EXG_MSG = 0x9200, #endregion #region 平台间信息交互类 diff --git a/src/JT809.Protocol/JT809Enums/JT809SubBusinessType.cs b/src/JT809.Protocol/JT809Enums/JT809SubBusinessType.cs index 777da96..f07a12b 100644 --- a/src/JT809.Protocol/JT809Enums/JT809SubBusinessType.cs +++ b/src/JT809.Protocol/JT809Enums/JT809SubBusinessType.cs @@ -89,51 +89,61 @@ namespace JT809.Protocol.JT809Enums ///交换车辆定位信息 /// [Description("交换车辆定位信息")] + [JT809BodiesType(typeof(JT809_0x9200_0x9202))] DOWN_EXG_MSG_CAR_LOCATION = 0x9202, /// ///车辆定位信息交换补发 /// [Description("车辆定位信息交换补发")] + [JT809BodiesType(typeof(JT809_0x9200_0x9203))] DOWN_EXG_MSG_HISTORY_ARCOSSAREA = 0x9203, /// ///交换车辆静态信息 /// [Description("交换车辆静态信息")] + [JT809BodiesType(typeof(JT809_0x9200_0x9204))] DOWN_EXG_MSG_CAR_INFO = 0x9204, /// ///启动车辆定位信息交换请求 /// [Description("启动车辆定位信息交换请求")] + [JT809BodiesType(typeof(JT809_0x9200_0x9205))] DOWN_EXG_MSG_RETURN_STARTUP = 0x9205, /// ///结束车辆定位信息交换请求 /// [Description("结束车辆定位信息交换请求")] + [JT809BodiesType(typeof(JT809_0x9200_0x9206))] DOWN_EXG_MSG_RETURN_END = 0x9206, /// ///申请交换指定车辆定位信息应答 /// [Description("申请交换指定车辆定位信息应答")] + [JT809BodiesType(typeof(JT809_0x9200_0x9207))] DOWN_EXG_MSG_APPLY_FOR_MONITOR_STARTUP_ACK = 0x9207, /// ///取消交换指定车辆定位信息应答 /// [Description("取消交换指定车辆定位信息应答")] + [JT809BodiesType(typeof(JT809_0x9200_0x9208))] DOWN_EXG_MSG_APPLY_FOR_MONITOR_END_ACK = 0x9208, /// ///补发车辆定位信息应答 /// [Description("补发车辆定位信息应答")] + [JT809BodiesType(typeof(JT809_0x9200_0x9209))] DOWN_EXG_MSG_APPLY_HISGNSSDATA_ACK = 0x9209, /// ///上报车辆驾驶员身份识别信息请求 /// [Description("上报车辆驾驶员身份识别信息请求")] + [JT809BodiesType(typeof(JT809_0x9200_0x920A))] DOWN_EXG_MSG_REPORT_DRIVER_INFO = 0x920A, /// ///上报车辆电子运单请求 /// [Description("上报车辆电子运单请求")] + [JT809BodiesType(typeof(JT809_0x9200_0x920B))] DOWN_EXG_MSG_TAKE_EWAYBILL_REQ = 0x920B, #endregion diff --git a/src/JT809.Protocol/JT809Enums/JT809_0x9205_ReasonCode.cs b/src/JT809.Protocol/JT809Enums/JT809_0x9205_ReasonCode.cs new file mode 100644 index 0000000..be9138d --- /dev/null +++ b/src/JT809.Protocol/JT809Enums/JT809_0x9205_ReasonCode.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Enums +{ + /// + /// 错误代码 + /// + public enum JT809_0x9205_ReasonCode : byte + { + 车辆进入指定区域 = 0x00, + 人工指定交换 = 0x01, + 应急状态下车辆定位信息回传 = 0x02, + 其它原因 = 0x03 + } +} diff --git a/src/JT809.Protocol/JT809Enums/JT809_0x9206_ReasonCode.cs b/src/JT809.Protocol/JT809Enums/JT809_0x9206_ReasonCode.cs new file mode 100644 index 0000000..beb7ac5 --- /dev/null +++ b/src/JT809.Protocol/JT809Enums/JT809_0x9206_ReasonCode.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Enums +{ + /// + /// 错误代码 + /// + public enum JT809_0x9206_ReasonCode : byte + { + 车辆离开指定区域 = 0x00, + 人工停止交换 = 0x01, + 紧急监控完成 = 0x02, + 车辆离线 = 0x03, + 其它原因 = 0x04 + } +} diff --git a/src/JT809.Protocol/JT809Enums/JT809_0x9207_Result.cs b/src/JT809.Protocol/JT809Enums/JT809_0x9207_Result.cs new file mode 100644 index 0000000..349c6ea --- /dev/null +++ b/src/JT809.Protocol/JT809Enums/JT809_0x9207_Result.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Enums +{ + /// + /// 验证结果 + /// + public enum JT809_0x9207_Result : byte + { + 申请成功 = 0x00, + 上级平台没有该车数据 = 0x01, + 申请时间段错误 = 0x02, + 其它 = 0x03 + } +} diff --git a/src/JT809.Protocol/JT809Enums/JT809_0x9208_Result.cs b/src/JT809.Protocol/JT809Enums/JT809_0x9208_Result.cs new file mode 100644 index 0000000..843ff04 --- /dev/null +++ b/src/JT809.Protocol/JT809Enums/JT809_0x9208_Result.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Enums +{ + /// + /// 验证结果 + /// + public enum JT809_0x9208_Result : byte + { + 取消申请成功 = 0x00, + 之前没有对应申请信息 = 0x01, + 其它 = 0x02 + } +} diff --git a/src/JT809.Protocol/JT809Enums/JT809_0x9209_Result.cs b/src/JT809.Protocol/JT809Enums/JT809_0x9209_Result.cs new file mode 100644 index 0000000..4dcca46 --- /dev/null +++ b/src/JT809.Protocol/JT809Enums/JT809_0x9209_Result.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Enums +{ + /// + /// 验证结果 + /// + public enum JT809_0x9209_Result : byte + { + 成功_上级平台即刻补发 = 0x00, + 成功_上级平台择机补发 = 0x01, + 失败_上级平台无对应申请的定位数据 = 0x02, + 失败_申请内容不正确 = 0x03, + 其它原因 = 0x04, + } +} diff --git a/src/JT809.Protocol/JT809Formatters/JT809MessageBodyFormatters/JT809_0x9200Formatter.cs b/src/JT809.Protocol/JT809Formatters/JT809MessageBodyFormatters/JT809_0x9200Formatter.cs new file mode 100644 index 0000000..dbe687c --- /dev/null +++ b/src/JT809.Protocol/JT809Formatters/JT809MessageBodyFormatters/JT809_0x9200Formatter.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_0x9200Formatter : IJT809Formatter + { + public JT809_0x9200 Deserialize(ReadOnlySpan bytes, out int readSize) + { + int offset = 0; + JT809_0x9200 jT809_0X9200 = new JT809_0x9200(); + jT809_0X9200.VehicleNo = JT809BinaryExtensions.ReadStringLittle(bytes, ref offset, 21); + jT809_0X9200.VehicleColor = (JT809VehicleColorType)JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + jT809_0X9200.SubBusinessType = (JT809SubBusinessType)JT809BinaryExtensions.ReadUInt16Little(bytes, ref offset); + jT809_0X9200.DataLength = JT809BinaryExtensions.ReadUInt32Little(bytes, ref offset); + //JT809.Protocol.JT809Enums.JT809BusinessType 映射对应消息特性 + JT809BodiesTypeAttribute jT809SubBodiesTypeAttribute = jT809_0X9200.SubBusinessType.GetAttribute(); + if (jT809SubBodiesTypeAttribute == null) + { + throw new JT809Exception(JT809ErrorCode.GetAttributeError, $"JT809BodiesTypeAttribute Not Found>{jT809_0X9200.SubBusinessType.ToString()}"); + } + try + { + jT809_0X9200.JT809SubBodies = JT809FormatterResolverExtensions.JT809DynamicDeserialize(JT809FormatterExtensions.GetFormatter(jT809SubBodiesTypeAttribute.JT809BodiesType), bytes.Slice(offset, (int)jT809_0X9200.DataLength), out readSize); + } + catch + { + throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{jT809_0X9200.SubBusinessType.ToString()}"); + } + readSize = offset; + return jT809_0X9200; + } + + public int Serialize(IMemoryOwner memoryOwner, int offset, JT809_0x9200 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_0x9200_0x9202Formatter.cs b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9200_0x9202Formatter.cs new file mode 100644 index 0000000..4cd3b59 --- /dev/null +++ b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9200_0x9202Formatter.cs @@ -0,0 +1,58 @@ +using JT809.Protocol.JT809Extensions; +using JT809.Protocol.JT809SubMessageBody; +using JT809.Protocol.JT809Enums; +using System; +using System.Buffers; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Formatters.JT809SubMessageBodyFormatters +{ + public class JT809_0x9200_0x9202Formatter : IJT809Formatter + { + public JT809_0x9200_0x9202 Deserialize(ReadOnlySpan bytes, out int readSize) + { + 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.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); + jT809_0X1200_0x9202.VehiclePosition.Hour = JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + jT809_0X1200_0x9202.VehiclePosition.Minute = JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + jT809_0X1200_0x9202.VehiclePosition.Second = JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + jT809_0X1200_0x9202.VehiclePosition.Lon = JT809BinaryExtensions.ReadUInt32Little(bytes, ref offset); + jT809_0X1200_0x9202.VehiclePosition.Lat = JT809BinaryExtensions.ReadUInt32Little(bytes, ref offset); + jT809_0X1200_0x9202.VehiclePosition.Vec1 = JT809BinaryExtensions.ReadUInt16Little(bytes, ref offset); + jT809_0X1200_0x9202.VehiclePosition.Vec2 = JT809BinaryExtensions.ReadUInt16Little(bytes, ref offset); + jT809_0X1200_0x9202.VehiclePosition.Vec3 = JT809BinaryExtensions.ReadUInt32Little(bytes, ref offset); + jT809_0X1200_0x9202.VehiclePosition.Direction = JT809BinaryExtensions.ReadUInt16Little(bytes, ref offset); + jT809_0X1200_0x9202.VehiclePosition.Altitude = JT809BinaryExtensions.ReadUInt16Little(bytes, ref offset); + jT809_0X1200_0x9202.VehiclePosition.State = JT809BinaryExtensions.ReadUInt32Little(bytes, ref offset); + jT809_0X1200_0x9202.VehiclePosition.Alarm = JT809BinaryExtensions.ReadUInt32Little(bytes, ref offset); + readSize = offset; + return jT809_0X1200_0x9202; + } + + public int Serialize(IMemoryOwner memoryOwner, int offset, JT809_0x9200_0x9202 value) + { + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset,(byte) value.VehiclePosition.Encrypt); + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, value.VehiclePosition.Day); + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, value.VehiclePosition.Month); + offset += JT809BinaryExtensions.WriteUInt16Little(memoryOwner, offset, value.VehiclePosition.Year); + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, value.VehiclePosition.Hour); + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, value.VehiclePosition.Minute); + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, value.VehiclePosition.Second); + offset += JT809BinaryExtensions.WriteUInt32Little(memoryOwner, offset, value.VehiclePosition.Lon); + offset += JT809BinaryExtensions.WriteUInt32Little(memoryOwner, offset, value.VehiclePosition.Lat); + offset += JT809BinaryExtensions.WriteUInt16Little(memoryOwner, offset, value.VehiclePosition.Vec1); + offset += JT809BinaryExtensions.WriteUInt16Little(memoryOwner, offset, value.VehiclePosition.Vec2); + offset += JT809BinaryExtensions.WriteUInt32Little(memoryOwner, offset, value.VehiclePosition.Vec3); + offset += JT809BinaryExtensions.WriteUInt16Little(memoryOwner, offset, value.VehiclePosition.Direction); + offset += JT809BinaryExtensions.WriteUInt16Little(memoryOwner, offset, value.VehiclePosition.Altitude); + offset += JT809BinaryExtensions.WriteUInt32Little(memoryOwner, offset, value.VehiclePosition.State); + offset += JT809BinaryExtensions.WriteUInt32Little(memoryOwner, offset, value.VehiclePosition.Alarm); + return offset; + } + } +} diff --git a/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9200_0x9203Formatter.cs b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9200_0x9203Formatter.cs new file mode 100644 index 0000000..371bc46 --- /dev/null +++ b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9200_0x9203Formatter.cs @@ -0,0 +1,71 @@ +using JT809.Protocol.JT809Enums; +using JT809.Protocol.JT809Extensions; +using JT809.Protocol.JT809Properties; +using JT809.Protocol.JT809SubMessageBody; +using System; +using System.Buffers; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809Formatters.JT809SubMessageBodyFormatters +{ + public class JT809_0x9200_0x9203Formatter : IJT809Formatter + { + public JT809_0x9200_0x9203 Deserialize(ReadOnlySpan bytes, out int readSize) + { + int offset = 0; + JT809_0x9200_0x9203 jT809_0X1200_0x9203 = new JT809_0x9200_0x9203(); + jT809_0X1200_0x9203.GNSSCount= JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + if (jT809_0X1200_0x9203.GNSSCount > 0) + { + jT809_0X1200_0x9203.GNSS = new List(); + int bufReadSize; + int tempOffset = 0; + for (int i = 0; i < jT809_0X1200_0x9203.GNSSCount; i++) + { + try + { + if (i == 0) + { + tempOffset = offset + 36; + JT809_0x9200_0x9202 jT809_0x1200_0x1202 = JT809FormatterExtensions.GetFormatter() + .Deserialize(bytes.Slice(offset, 36), out bufReadSize); + jT809_0X1200_0x9203.GNSS.Add(jT809_0x1200_0x1202); + } + else + { + JT809_0x9200_0x9202 jT809_0x1200_0x9202 = JT809FormatterExtensions.GetFormatter() + .Deserialize(bytes.Slice(tempOffset, 36), out bufReadSize); + tempOffset += 36; + jT809_0X1200_0x9203.GNSS.Add(jT809_0x1200_0x9202); + } + } + catch (Exception) + { + tempOffset += 36; + } + } + } + readSize = jT809_0X1200_0x9203.GNSSCount * 36 + 1; + return jT809_0X1200_0x9203; + } + + public int Serialize(IMemoryOwner memoryOwner, int offset, JT809_0x9200_0x9203 value) + { + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, (byte)value.GNSS.Count); + foreach(var item in value.GNSS) + { + try + { + int positionOffset = JT809FormatterExtensions.GetFormatter().Serialize(memoryOwner, offset, item); + offset = positionOffset; + } + catch (Exception ex) + { + + } + } + return offset; + } + } +} diff --git a/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9200_0x9204Formatter.cs b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9200_0x9204Formatter.cs new file mode 100644 index 0000000..ddc3515 --- /dev/null +++ b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9200_0x9204Formatter.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_0x9200_0x9204Formatter : IJT809Formatter + { + public JT809_0x9200_0x9204 Deserialize(ReadOnlySpan bytes, out int readSize) + { + int offset = 0; + JT809_0x9200_0x9204 jT809_0X1200_0x9204 = new JT809_0x9200_0x9204(); + jT809_0X1200_0x9204.CarInfo = JT809BinaryExtensions.ReadStringLittle(bytes, ref offset); + readSize = offset; + return jT809_0X1200_0x9204; + } + + public int Serialize(IMemoryOwner memoryOwner, int offset, JT809_0x9200_0x9204 value) + { + offset += JT809BinaryExtensions.WriteStringLittle(memoryOwner, offset, value.CarInfo); + return offset; + } + } +} diff --git a/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9200_0x9205Formatter.cs b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9200_0x9205Formatter.cs new file mode 100644 index 0000000..0688d4c --- /dev/null +++ b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9200_0x9205Formatter.cs @@ -0,0 +1,28 @@ +using JT809.Protocol.JT809Enums; +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_0x9200_0x9205Formatter : IJT809Formatter + { + public JT809_0x9200_0x9205 Deserialize(ReadOnlySpan bytes, out int readSize) + { + int offset = 0; + JT809_0x9200_0x9205 jT809_0X1200_0x9205 = new JT809_0x9200_0x9205(); + jT809_0X1200_0x9205.ReasonCode = (JT809_0x9205_ReasonCode)JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + readSize = offset; + return jT809_0X1200_0x9205; + } + + public int Serialize(IMemoryOwner memoryOwner, int offset, JT809_0x9200_0x9205 value) + { + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset,(byte)value.ReasonCode); + return offset; + } + } +} diff --git a/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9200_0x9206Formatter.cs b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9200_0x9206Formatter.cs new file mode 100644 index 0000000..c719d0f --- /dev/null +++ b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9200_0x9206Formatter.cs @@ -0,0 +1,28 @@ +using JT809.Protocol.JT809Enums; +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_0x9200_0x9206Formatter : IJT809Formatter + { + public JT809_0x9200_0x9206 Deserialize(ReadOnlySpan bytes, out int readSize) + { + int offset = 0; + JT809_0x9200_0x9206 jT809_0X1200_0x9206 = new JT809_0x9200_0x9206(); + jT809_0X1200_0x9206.ReasonCode = (JT809_0x9206_ReasonCode)JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + readSize = offset; + return jT809_0X1200_0x9206; + } + + public int Serialize(IMemoryOwner memoryOwner, int offset, JT809_0x9200_0x9206 value) + { + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, (byte)value.ReasonCode); + return offset; + } + } +} diff --git a/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9200_0x9207Formatter.cs b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9200_0x9207Formatter.cs new file mode 100644 index 0000000..829255c --- /dev/null +++ b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9200_0x9207Formatter.cs @@ -0,0 +1,28 @@ +using JT809.Protocol.JT809Enums; +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_0x9200_0x9207Formatter : IJT809Formatter + { + public JT809_0x9200_0x9207 Deserialize(ReadOnlySpan bytes, out int readSize) + { + int offset = 0; + JT809_0x9200_0x9207 jT809_0X1200_0x9207 = new JT809_0x9200_0x9207(); + jT809_0X1200_0x9207.Result = (JT809_0x9207_Result)JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + readSize = offset; + return jT809_0X1200_0x9207; + } + + public int Serialize(IMemoryOwner memoryOwner, int offset, JT809_0x9200_0x9207 value) + { + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, (byte)value.Result); + return offset; + } + } +} diff --git a/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9200_0x9208Formatter.cs b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9200_0x9208Formatter.cs new file mode 100644 index 0000000..f5b4001 --- /dev/null +++ b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9200_0x9208Formatter.cs @@ -0,0 +1,28 @@ +using JT809.Protocol.JT809Enums; +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_0x9200_0x9208Formatter : IJT809Formatter + { + public JT809_0x9200_0x9208 Deserialize(ReadOnlySpan bytes, out int readSize) + { + int offset = 0; + JT809_0x9200_0x9208 jT809_0X1200_0x9208 = new JT809_0x9200_0x9208(); + jT809_0X1200_0x9208.Result = (JT809_0x9208_Result)JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + readSize = offset; + return jT809_0X1200_0x9208; + } + + public int Serialize(IMemoryOwner memoryOwner, int offset, JT809_0x9200_0x9208 value) + { + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, (byte)value.Result); + return offset; + } + } +} diff --git a/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9200_0x9209Formatter.cs b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9200_0x9209Formatter.cs new file mode 100644 index 0000000..c3cbcbc --- /dev/null +++ b/src/JT809.Protocol/JT809Formatters/JT809SubMessageBodyFormatters/JT809_0x9200_0x9209Formatter.cs @@ -0,0 +1,28 @@ +using JT809.Protocol.JT809Enums; +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_0x9200_0x9209Formatter : IJT809Formatter + { + public JT809_0x9200_0x9209 Deserialize(ReadOnlySpan bytes, out int readSize) + { + int offset = 0; + JT809_0x9200_0x9209 jT809_0X1200_0x9209 = new JT809_0x9200_0x9209(); + jT809_0X1200_0x9209.Result = (JT809_0x9209_Result)JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); + readSize = offset; + return jT809_0X1200_0x9209; + } + + public int Serialize(IMemoryOwner memoryOwner, int offset, JT809_0x9200_0x9209 value) + { + offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, (byte)value.Result); + return offset; + } + } +} diff --git a/src/JT809.Protocol/JT809MessageBody/JT809_0x1200.cs b/src/JT809.Protocol/JT809MessageBody/JT809_0x1200.cs index 9656e74..92cf7bc 100644 --- a/src/JT809.Protocol/JT809MessageBody/JT809_0x1200.cs +++ b/src/JT809.Protocol/JT809MessageBody/JT809_0x1200.cs @@ -34,10 +34,6 @@ namespace JT809.Protocol.JT809MessageBody /// public uint DataLength { get; set; } /// - /// 数据部分 - /// - public byte[] Data { get; set; } - /// /// 子业务数据体 /// public JT809SubBodies JT809SubBodies { get; set; } diff --git a/src/JT809.Protocol/JT809MessageBody/JT809_0x9200.cs b/src/JT809.Protocol/JT809MessageBody/JT809_0x9200.cs new file mode 100644 index 0000000..57562b0 --- /dev/null +++ b/src/JT809.Protocol/JT809MessageBody/JT809_0x9200.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_EXG_MSG + /// 描述:上级平台作为客户端向下级平台服务端发送车辆动态信息交换业务 + /// + [JT809Formatter(typeof(JT809_0x9200Formatter))] + public class JT809_0x9200: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/JT809SubMessageBody/JT809_0x9200_0x9202.cs b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9200_0x9202.cs new file mode 100644 index 0000000..9e07a46 --- /dev/null +++ b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9200_0x9202.cs @@ -0,0 +1,27 @@ +using JT809.Protocol.JT809Attributes; +using JT809.Protocol.JT809Formatters.JT809SubMessageBodyFormatters; +using JT809.Protocol.JT809Properties; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809SubMessageBody +{ + /// + /// 交换车辆定位信息消息 + /// 子业务类型标识:DOWN_EXG_MSG_CAR_LOCATION + /// 描述:上级平台通过该消息不间断地向车辆驶入区域所属的下级平台发送车辆定位信息,直到该车驶离该区域 + /// + [JT809Formatter(typeof(JT809_0x9200_0x9202Formatter))] + public class JT809_0x9200_0x9202:JT809SubBodies + { + public JT809_0x9200_0x9202() + { + VehiclePosition = new JT809VehiclePositionProperties(); + } + /// + /// 车辆定位信息 + /// + public JT809VehiclePositionProperties VehiclePosition { get; set; } + } +} diff --git a/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9200_0x9203.cs b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9200_0x9203.cs new file mode 100644 index 0000000..e56c884 --- /dev/null +++ b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9200_0x9203.cs @@ -0,0 +1,26 @@ +using JT809.Protocol.JT809Attributes; +using JT809.Protocol.JT809Formatters.JT809SubMessageBodyFormatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809SubMessageBody +{ + /// + /// 车辆定位信息交换补发消息 + /// 子业务类型标识:DOWN_EXG_MSG_HISTORY_ARCOSSAREA + /// 描述:本业务在 DOWN_EXG_MSG_APPLY_HISGNSSDATA_ACK 应答成功后,立即开始交换。如果申请失败,则不进行数据转发 + /// + [JT809Formatter(typeof(JT809_0x9200_0x9203Formatter))] + public class JT809_0x9200_0x9203:JT809SubBodies + { + /// + /// 卫星定位数据个数 1<=GNSS_CNT<=5。 + /// + public byte GNSSCount { get; set; } + /// + /// 卫星定位数据集合 + /// + public IList GNSS { get; set; } + } +} diff --git a/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9200_0x9204.cs b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9200_0x9204.cs new file mode 100644 index 0000000..7c6e8ce --- /dev/null +++ b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9200_0x9204.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 +{ + /// + /// 交换车辆静态信息消息 + /// 子业务类型标识:DOWN_EXG_MSG_CAR_INFO + /// 描述:在首次启动跨域车辆定位信息交换,或者以后交换过程中车辆静态信息有更新时,由上级平台向下级平台下发一次车辆静态信息。下.级平台接收后自行更新该车辆静态信息 + /// + [JT809Formatter(typeof(JT809_0x9200_0x9204Formatter))] + public class JT809_0x9200_0x9204 + { + /// + /// 车牌号 + /// + public string CarInfo { get; set; } + } +} diff --git a/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9200_0x9205.cs b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9200_0x9205.cs new file mode 100644 index 0000000..60e7521 --- /dev/null +++ b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9200_0x9205.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 +{ + /// + /// 启动车辆定位信息交换请求消息 + /// 子业务类型标识:DOWN_EXG_MSG_RETURN_STARTUP + /// 描述:在有车辆进入非归属地区地理区域、人工指定车辆定位信息交换和应急状态监控车辆时,上级平台向下级平台发出启动车辆定位信息交换清求消息。下级平台收到此命令后需要回复启动车辆定位信息交换应答消息给上级平台,即UP_EXG_MSG-RETURN-STARTUP_ ACK + /// + [JT809Formatter(typeof(JT809_0x9200_0x9205Formatter))] + public class JT809_0x9200_0x9205:JT809SubBodies + { + /// + /// 错误代码 + /// + public JT809_0x9205_ReasonCode ReasonCode { get; set; } + } +} diff --git a/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9200_0x9206.cs b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9200_0x9206.cs new file mode 100644 index 0000000..259af26 --- /dev/null +++ b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9200_0x9206.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 +{ + /// + /// 结束车辆定位信息交换请求 + /// 子业务类型标识:DOWN_EXG_MSG_RETURN_END + /// 描述:在进入非归属地区地理区域的车辆离开该地理区域、人上取消指定车辆定位信息交换和应急状态结束时,上级平台向下级平台发出结束车辆定位信息交换请求消息。下级平台收到该命令后应回复结束车辆定位信息交换应答消息,即 UP_EXG_MSG_RE_TURN_END_ACK + /// + [JT809Formatter(typeof(JT809_0x9200_0x9206Formatter))] + public class JT809_0x9200_0x9206:JT809SubBodies + { + /// + /// 错误代码 + /// + public JT809_0x9206_ReasonCode ReasonCode { get; set; } + } +} diff --git a/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9200_0x9207.cs b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9200_0x9207.cs new file mode 100644 index 0000000..59c6fb1 --- /dev/null +++ b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9200_0x9207.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 +{ + /// + /// 申请交换指定车辆定位信息应答 + /// 子业务类型标识:DOWN_EXG_MSG_APPLY_FOR_MONITOR_STARTUP_ACK + /// 描述:应答下级平台申请交换指定车辆定位信息,请求消息."即 UP_EXG_MSG_APPLY_FOR_MONITOR_STARTUP + /// + [JT809Formatter(typeof(JT809_0x9200_0x9207Formatter))] + public class JT809_0x9200_0x9207:JT809SubBodies + { + /// + /// 返回结果 + /// + public JT809_0x9207_Result Result { get; set; } + } +} diff --git a/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9200_0x9208.cs b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9200_0x9208.cs new file mode 100644 index 0000000..7a179cf --- /dev/null +++ b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9200_0x9208.cs @@ -0,0 +1,22 @@ +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_EXG_MSG_APPLY_FOR_MONITOR_END_ACK + /// + [JT809Formatter(typeof(JT809_0x9200_0x9208Formatter))] + public class JT809_0x9200_0x9208:JT809SubBodies + { + /// + /// 返回结果 + /// + public JT809_0x9208_Result Result { get; set; } + } +} diff --git a/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9200_0x9209.cs b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9200_0x9209.cs new file mode 100644 index 0000000..f2ec9d0 --- /dev/null +++ b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9200_0x9209.cs @@ -0,0 +1,22 @@ +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_EXG_MSG_APPLY_FOR_MONITOR_END_ACK + /// + [JT809Formatter(typeof(JT809_0x9200_0x9209Formatter))] + public class JT809_0x9200_0x9209: JT809SubBodies + { + /// + /// 返回结果 + /// + public JT809_0x9209_Result Result { get; set; } + } +} diff --git a/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9200_0x920A.cs b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9200_0x920A.cs new file mode 100644 index 0000000..85d2670 --- /dev/null +++ b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9200_0x920A.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809SubMessageBody +{ + /// + /// 上报车辆驾驶员身份识别信息请求 + /// 子业务类型标识:DOWN_EXG_MSG_REPORT_DRIVER_INFO + /// + public class JT809_0x9200_0x920A:JT809SubBodies + { + } +} diff --git a/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9200_0x920B.cs b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9200_0x920B.cs new file mode 100644 index 0000000..bc6d76e --- /dev/null +++ b/src/JT809.Protocol/JT809SubMessageBody/JT809_0x9200_0x920B.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.JT809SubMessageBody +{ + /// + /// 上报车辆电子运单请求消息 + /// 子业务类型标识:DOWN_EXG_MSG_TAKE_EWAYBILL_REQ + /// + public class JT809_0x9200_0x920B + { + } +}