diff --git a/src/JT809.Protocol.Test/JT809SubMessageBody/JT809_0x9500_0x9504Test.cs b/src/JT809.Protocol.Test/JT809SubMessageBody/JT809_0x9500_0x9504Test.cs index 4d99a5d..43e277f 100644 --- a/src/JT809.Protocol.Test/JT809SubMessageBody/JT809_0x9500_0x9504Test.cs +++ b/src/JT809.Protocol.Test/JT809SubMessageBody/JT809_0x9500_0x9504Test.cs @@ -22,7 +22,7 @@ namespace JT809.Protocol.Test.JT809SubMessageBody Command= JT809CommandType.采集记录仪事故疑点记录, StartTime=DateTime.Parse("2018-09-27 20:00:20"), EndTime=DateTime.Parse("2018-09-27 23:00:20"), - Max=5556 + //Max=5556 }; var hex = JT809Serializer.Serialize(jT809_0X9500_0X9504).ToHexString(); //"10 18 09 27 20 00 20 18 09 27 23 00 20 15 B4" @@ -39,7 +39,7 @@ namespace JT809.Protocol.Test.JT809SubMessageBody Assert.Equal(JT809CommandType.采集记录仪事故疑点记录, jT809_0X9500_0X9504.Command); Assert.Equal(DateTime.Parse("2018-09-27 20:00:20"), jT809_0X9500_0X9504.StartTime); Assert.Equal(DateTime.Parse("2018-09-27 23:00:20"), jT809_0X9500_0X9504.EndTime); - Assert.Equal(5556, jT809_0X9500_0X9504.Max); + //Assert.Equal(5556, jT809_0X9500_0X9504.Max); } } } diff --git a/src/JT809.Protocol/Enums/JT809BusinessType.cs b/src/JT809.Protocol/Enums/JT809BusinessType.cs index a2adbe9..deaf481 100644 --- a/src/JT809.Protocol/Enums/JT809BusinessType.cs +++ b/src/JT809.Protocol/Enums/JT809BusinessType.cs @@ -228,7 +228,7 @@ namespace JT809.Protocol.Enums [JT809BusinessTypeDescription("DOWN_PLATFORM_MSG", "从链路平台间信息交互业务")] 从链路平台间信息交互业务 = 0x9300, #endregion - #region 车辆报警信息交互类 + #region 车辆报警信息交互类(2013) 报警信息交互业务类(2019) /// ///主链路报警信息交互消息 ///UP_WARN_MSG diff --git a/src/JT809.Protocol/Enums/JT809SubBusinessType.cs b/src/JT809.Protocol/Enums/JT809SubBusinessType.cs index 204f38d..f541e0d 100644 --- a/src/JT809.Protocol/Enums/JT809SubBusinessType.cs +++ b/src/JT809.Protocol/Enums/JT809SubBusinessType.cs @@ -107,6 +107,16 @@ namespace JT809.Protocol.Enums [JT809BodiesType(typeof(JT809_0x1200_0x120D))] [JT809SubBusinessTypeDescription("UP_EXG_MSG_REPORT_EWAYBILL_INFO", "主动上报车辆电子运单信息", JT809BusinessType.主链路车辆动态信息交换业务)] 主动上报车辆电子运单信息 = 0x120D, + /// + ///主动上报车辆行驶路线信息 + ///UP_EXG_MSG_DRVLINE_INFO + /// + [Description("主动上报车辆行驶路线信息")] + [JT809BodiesType(typeof(JT809_0x1200_0x120E))] + [JT809SubBusinessTypeDescription("UP_EXG_MSG_DRVLINE_INFO", "主动上报车辆行驶路线信息", JT809BusinessType.主链路车辆动态信息交换业务)] + 主动上报车辆行驶路线信息 = 0x120E, + + #endregion #region 从链路动态信息交换消息 DOWN_EXG_MSG @@ -189,6 +199,22 @@ namespace JT809.Protocol.Enums [JT809BodiesType(typeof(JT809_0x9200_0x920B))] [JT809SubBusinessTypeDescription("DOWN_EXG_MSG_TAKE_EWAYBILL_REQ", "上报车辆电子运单请求消息", JT809BusinessType.从链路车辆动态信息交换业务)] 上报车辆电子运单请求消息 = 0x920B, + /// + ///上报车辆车辆行驶路线请求 + ///DOWN_BASE_MSG_DRVLINE_REQ + /// + [Description("上报车辆车辆行驶路线请求")] + [JT809BodiesType(typeof(JT809_0x9200_0x920C))] + [JT809SubBusinessTypeDescription("DOWN_BASE_MSG_DRVLINE_REQ", "上报车辆车辆行驶路线请求", JT809BusinessType.从链路车辆动态信息交换业务)] + 上报车辆车辆行驶路线请求 = 0x920C, + /// + ///车辆行驶线路请求应答 + ///DOWN_BASE_MSG_DRVLINE_ACK + /// + [Description("车辆行驶线路请求应答")] + [JT809BodiesType(typeof(JT809_0x9200_0x920D))] + [JT809SubBusinessTypeDescription("DOWN_BASE_MSG_DRVLINE_ACK", "车辆行驶线路请求应答", JT809BusinessType.从链路车辆动态信息交换业务)] + 车辆行驶线路请求应答 = 0x920B, #endregion #region 主链路平台信息交互消息 UP_PLATFORM_MSG @@ -208,6 +234,15 @@ namespace JT809.Protocol.Enums [JT809BodiesType(typeof(JT809_0x1300_0x1302))] [JT809SubBusinessTypeDescription("UP_PLATFORM_MSG_INFO_ACK", "下发平台间报文应答消息", JT809BusinessType.主链路平台间信息交互消息)] 下发平台间报文应答消息 = 0x1302, + /// + ///上传平台间消息补传请求消息 + ///UP_PLATFORM_MSG_RETRAN_REQ + /// + [Description("上传平台间消息补传请求消息")] + [JT809BodiesType(typeof(JT809_0x1300_0x1303))] + [JT809SubBusinessTypeDescription("UP_PLATFORM_MSG_RETRAN_REQ", "上传平台间消息补传请求消息", JT809BusinessType.主链路平台间信息交互消息)] + 上传平台间消息补传请求消息 = 0x1303, + #endregion #region 从链路平台信息交互消息 DOWN_PLATFORM_MSG @@ -227,6 +262,15 @@ namespace JT809.Protocol.Enums [JT809BodiesType(typeof(JT809_0x9300_0x9302))] [JT809SubBusinessTypeDescription("DOWN_PLATFORM_MSG_INFO_REQ", "下发平台间报文请求", JT809BusinessType.从链路平台间信息交互业务)] 下发平台间报文请求 = 0x9302, + /// + ///下发平台间消息补传请求消息 + ///DOWN_PLATFORM_MSG_RETRAN_REQ + /// + [Description("下发平台间消息补传请求消息")] + [JT809BodiesType(typeof(JT809_0x9300_0x9303))] + [JT809SubBusinessTypeDescription("DOWN_PLATFORM_MSG_RETRAN_REQ", "下发平台间消息补传请求消息", JT809BusinessType.从链路平台间信息交互业务)] + 下发平台间消息补传请求消息 = 0x9303, + #endregion #region 主链路报警信息交互消息 UP_WARN_MSG @@ -247,13 +291,38 @@ namespace JT809.Protocol.Enums [JT809SubBusinessTypeDescription("UP_WARN_MSG_ADPT_INFO", "上报报警信息消息", JT809BusinessType.主链路报警信息交互消息)] 上报报警信息消息 = 0x1402, /// - ///主动上报报警处理结果信息 + ///上报报警督办应答消息 + ///UP_WARN_MSG_URGE_TODO_ACK_INFO + /// + [Description("上报报警督办应答消息")] + [JT809BodiesType(typeof(JT809_0x1400_0x1411))] + [JT809SubBusinessTypeDescription("UP_WARN_MSG_URGE_TODO_ACK_INFO", "上报报警督办应答消息", JT809BusinessType.主链路报警信息交互消息)] + 上报报警督办应答消息 = 0x1411, + /// + ///主动上报报警处理结果消息 ///UP_WARN_MSG_ADPT_TODO_INFO /// - [Description("主动上报报警处理结果信息")] + [Description("主动上报报警处理结果消息")] + [JT809BodiesType(typeof(JT809_0x1400_0x1412))] + [JT809SubBusinessTypeDescription("UP_WARN_MSG_URGE_TODO_ACK_INFO", "主动上报报警处理结果消息", JT809BusinessType.主链路报警信息交互消息)] + 主动上报报警处理结果消息 = 0x1412, + /// + ///上报报警督办请求消息 + ///UP_WARN_MSG_URGE_TODO_REQ_INFO + /// + [Description("上报报警督办请求消息")] + [JT809BodiesType(typeof(JT809_0x1400_0x1413))] + [JT809SubBusinessTypeDescription("UP_WARN_MSG_URGE_TODO_REQ_INFO", "上报报警督办请求消息", JT809BusinessType.主链路报警信息交互消息)] + 上报报警督办请求消息 = 0x1413, + + /// + ///主动上报报警处理结果信息2013_上报报警预警信息2019 + ///UP_WARN_MSG_ADPT_TODO_INFO_2013_UP_WARN_MSG_INFORM_TIPS_2019 + /// + [Description("主动上报报警处理结果信息2013_上报报警预警信息2019")] [JT809BodiesType(typeof(JT809_0x1400_0x1403))] - [JT809SubBusinessTypeDescription("UP_WARN_MSG_ADPT_TODO_INFO", "主动上报报警处理结果信息", JT809BusinessType.主链路报警信息交互消息)] - 主动上报报警处理结果信息 = 0x1403, + [JT809SubBusinessTypeDescription("UP_WARN_MSG_ADPT_TODO_INFO_2013_UP_WARN_MSG_INFORM_TIPS_2019", "主动上报报警处理结果信息2013_上报报警预警信息2019", JT809BusinessType.主链路报警信息交互消息)] + 主动上报报警处理结果信息2013_上报报警预警信息2019 = 0x1403, #endregion #region 从链路报警信息交互消息 DOWN_WARN_MSG @@ -266,13 +335,13 @@ namespace JT809.Protocol.Enums [JT809SubBusinessTypeDescription("DOWN_WARN_MSG_URGE_TODO_REQ", "报警督办请求消息", JT809BusinessType.从链路报警信息交互消息)] 报警督办请求消息 = 0x9401, /// - ///报警预警 + ///报警预警2013_下发报警预警消息2019 ///DOWN_WARN_MSG_INFORM_TIPS /// - [Description("报警预警")] + [Description("报警预警2013_下发报警预警消息2019")] [JT809BodiesType(typeof(JT809_0x9400_0x9402))] - [JT809SubBusinessTypeDescription("DOWN_WARN_MSG_INFORM_TIPS", "报警预警", JT809BusinessType.从链路报警信息交互消息)] - 报警预警 = 0x9402, + [JT809SubBusinessTypeDescription("DOWN_WARN_MSG_INFORM_TIPS", "报警预警2013_下发报警预警消息2019", JT809BusinessType.从链路报警信息交互消息)] + 报警预警2013_下发报警预警消息2019 = 0x9402, /// ///实时交换报警信息 ///DOWN_WARN_MSG_EXG_INFORM diff --git a/src/JT809.Protocol/Enums/JT809_0x1411_Result.cs b/src/JT809.Protocol/Enums/JT809_0x1411_Result.cs new file mode 100644 index 0000000..c2ac247 --- /dev/null +++ b/src/JT809.Protocol/Enums/JT809_0x1411_Result.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Enums +{ + /// + /// 报警处理结果 + /// + public enum JT809_0x1411_Result : byte + { + 处理中 = 0x00, + 已处理完毕 = 0x01, + 不做处理 = 0x02, + 将来处理 = 0x03 + } +} diff --git a/src/JT809.Protocol/Enums/JT809_0x1412_Result.cs b/src/JT809.Protocol/Enums/JT809_0x1412_Result.cs new file mode 100644 index 0000000..66684dd --- /dev/null +++ b/src/JT809.Protocol/Enums/JT809_0x1412_Result.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Enums +{ + /// + /// 报警处理结果 + /// + public enum JT809_0x1412_Result : byte + { + 处理中 = 0x00, + 已处理完毕 = 0x01, + 不做处理 = 0x02, + 将来处理 = 0x03 + } +} diff --git a/src/JT809.Protocol/Enums/JT809_0x1413_SupervisionLevel.cs b/src/JT809.Protocol/Enums/JT809_0x1413_SupervisionLevel.cs new file mode 100644 index 0000000..d76454f --- /dev/null +++ b/src/JT809.Protocol/Enums/JT809_0x1413_SupervisionLevel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Enums +{ + /// + /// 报警处理结果 + /// + public enum JT809_0x1413_SupervisionLevel : byte + { + 紧急 = 0x00, + 一般 = 0x01, + } +} diff --git a/src/JT809.Protocol/JT809.Protocol.csproj b/src/JT809.Protocol/JT809.Protocol.csproj index e9dfc6f..b9c1f55 100644 --- a/src/JT809.Protocol/JT809.Protocol.csproj +++ b/src/JT809.Protocol/JT809.Protocol.csproj @@ -67,6 +67,9 @@ + + + diff --git a/src/JT809.Protocol/MessageBody/JT809_0x1400.cs b/src/JT809.Protocol/MessageBody/JT809_0x1400.cs index 68ff0d7..b6aec0a 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x1400.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x1400.cs @@ -2,6 +2,7 @@ using JT809.Protocol.Exceptions; using JT809.Protocol.Extensions; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; namespace JT809.Protocol.MessageBody @@ -14,7 +15,7 @@ namespace JT809.Protocol.MessageBody /// 业务数据类型标识:UP_WARN_MSG /// 描述:下级平台向上级平台发送车辆报警信息业务 /// - public class JT809_0x1400: JT809ExchangeMessageBodies, IJT809MessagePackFormatter + public class JT809_0x1400: JT809ExchangeMessageBodies, IJT809MessagePackFormatter, IJT809_2019_Version { public override ushort MsgId => JT809BusinessType.主链路报警信息交互消息.ToUInt16Value(); public override string Description => "主链路报警信息交互消息"; @@ -23,9 +24,12 @@ namespace JT809.Protocol.MessageBody public JT809_0x1400 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { JT809_0x1400 value = new JT809_0x1400(); - value.VehicleNo = reader.ReadString(21); - value.VehicleColor = (JT809VehicleColorType)reader.ReadByte(); - value.SubBusinessType = reader.ReadUInt16(); + if (config.Version == JT809Version.JTT2013) + { + value.VehicleNo = reader.ReadString(21); + value.VehicleColor = (JT809VehicleColorType)reader.ReadByte(); + value.SubBusinessType = reader.ReadUInt16(); + } value.DataLength = reader.ReadUInt32(); try { @@ -51,8 +55,11 @@ namespace JT809.Protocol.MessageBody public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1400 value, IJT809Config config) { - writer.WriteStringPadRight(value.VehicleNo, 21); - writer.WriteByte((byte)value.VehicleColor); + if (config.Version == JT809Version.JTT2013) + { + writer.WriteStringPadRight(value.VehicleNo, 21); + writer.WriteByte((byte)value.VehicleColor); + } writer.WriteUInt16(value.SubBusinessType); try { diff --git a/src/JT809.Protocol/MessageBody/JT809_0x9400.cs b/src/JT809.Protocol/MessageBody/JT809_0x9400.cs index b711025..c0e9b08 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x9400.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x9400.cs @@ -3,6 +3,7 @@ using JT809.Protocol.Enums; using JT809.Protocol.Exceptions; using JT809.Protocol.Extensions; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; namespace JT809.Protocol.MessageBody @@ -14,7 +15,7 @@ namespace JT809.Protocol.MessageBody /// 业务数据类型标识:DOWN_WARN_MSG /// 描述:上级平台向下级平台发送报瞥信息业务 /// - public class JT809_0x9400: JT809ExchangeMessageBodies, IJT809MessagePackFormatter + public class JT809_0x9400: JT809ExchangeMessageBodies, IJT809MessagePackFormatter, IJT809_2019_Version { public override ushort MsgId => JT809BusinessType.从链路报警信息交互消息.ToUInt16Value(); public override string Description => "从链路报警信息交互消息"; @@ -22,8 +23,11 @@ namespace JT809.Protocol.MessageBody public JT809_0x9400 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { JT809_0x9400 value = new JT809_0x9400(); - value.VehicleNo = reader.ReadString(21); - value.VehicleColor = (JT809VehicleColorType)reader.ReadByte(); + if (config.Version == JT809Version.JTT2013) + { + value.VehicleNo = reader.ReadString(21); + value.VehicleColor = (JT809VehicleColorType)reader.ReadByte(); + } value.SubBusinessType = reader.ReadUInt16(); value.DataLength = reader.ReadUInt32(); try @@ -50,8 +54,11 @@ namespace JT809.Protocol.MessageBody public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9400 value, IJT809Config config) { - writer.WriteStringPadRight(value.VehicleNo, 21); - writer.WriteByte((byte)value.VehicleColor); + if (config.Version == JT809Version.JTT2013) + { + writer.WriteStringPadRight(value.VehicleNo, 21); + writer.WriteByte((byte)value.VehicleColor); + } writer.WriteUInt16(value.SubBusinessType); try { diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x120E.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x120E.cs new file mode 100644 index 0000000..713d3cc --- /dev/null +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x1200_0x120E.cs @@ -0,0 +1,34 @@ +using JT809.Protocol.Enums; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; +using JT809.Protocol.Extensions; +using JT809.Protocol.Interfaces; + +namespace JT809.Protocol.SubMessageBody +{ + /// + /// 主动上报车辆行驶路线信息 + /// 子业务类型标识:UP_EXG_MSG_DRVLINE_INFO + /// + public class JT809_0x1200_0x120E:JT809SubBodies, IJT809MessagePackFormatter, IJT809_2019_Version + { + public override ushort SubMsgId => JT809SubBusinessType.主动上报车辆行驶路线信息.ToUInt16Value(); + + public override string Description => "主动上报车辆行驶路线信息"; + /// + /// 路线信息 按照808-2019中8606规定的报文格式 + /// + public byte[] DRVLine { get; set; } + public JT809_0x1200_0x120E Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + var value = new JT809_0x1200_0x120E(); + value.DRVLine = reader.ReadArray(reader.ReadCurrentRemainContentLength()).ToArray(); + return value; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1200_0x120E value, IJT809Config config) + { + writer.WriteArray(value.DRVLine); + } + } +} diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x1300_0x1301.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x1300_0x1301.cs index 0e18692..512c8de 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x1300_0x1301.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x1300_0x1301.cs @@ -2,6 +2,7 @@ using JT809.Protocol.Formatters; using JT809.Protocol.MessagePack; using JT809.Protocol.Extensions; +using JT809.Protocol.Interfaces; namespace JT809.Protocol.SubMessageBody { @@ -10,7 +11,7 @@ namespace JT809.Protocol.SubMessageBody /// 子业务类型标识:UP_PLATFORM_MSG_POST_QUERY_ACK /// 描述:下级平台应答上级平台发送的不定期平台查岗消息 /// - public class JT809_0x1300_0x1301:JT809SubBodies, IJT809MessagePackFormatter + public class JT809_0x1300_0x1301:JT809SubBodies, IJT809MessagePackFormatter, IJT809_2019_Version { public override ushort SubMsgId => JT809SubBusinessType.平台查岗应答消息.ToUInt16Value(); @@ -20,10 +21,31 @@ namespace JT809.Protocol.SubMessageBody /// public JT809_0x1301_ObjectType ObjectType { get; set; } /// + /// 查岗应答人姓名 + /// + public string Responder { get; set; } + /// + /// 查岗应答人联系电话 + /// + public string ResponderTel { get; set; } + /// /// 查岗对象的ID /// public string ObjectID { get; set; } /// + /// 查岗对象的ID + /// 20位 + /// + public string ObjectID_2019 { get; set; } + /// + /// 对应平台查岗请求消息源子业务类型标识 + /// + public ushort SourceDataType { get; set; } + /// + /// 对应平台查岗请求消息源报文序列号 + /// + public uint SourceMsgSn { get; set; } + /// /// 信息ID /// public uint InfoID { get; set; } @@ -37,20 +59,40 @@ namespace JT809.Protocol.SubMessageBody public string InfoContent { get; set; } public JT809_0x1300_0x1301 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { - JT809_0x1300_0x1301 jT809_0X1200_0X1301 = new JT809_0x1300_0x1301(); - jT809_0X1200_0X1301.ObjectType = (JT809_0x1301_ObjectType)reader.ReadByte(); - jT809_0X1200_0X1301.ObjectID = reader.ReadString(12); - jT809_0X1200_0X1301.InfoID = reader.ReadUInt32(); - jT809_0X1200_0X1301.InfoLength = reader.ReadUInt32(); - jT809_0X1200_0X1301.InfoContent = reader.ReadString((int)jT809_0X1200_0X1301.InfoLength); - return jT809_0X1200_0X1301; + var value = new JT809_0x1300_0x1301(); + value.ObjectType = (JT809_0x1301_ObjectType)reader.ReadByte(); + if (config.Version == JT809Version.JTT2013) + { + value.ObjectID = reader.ReadString(12); + value.InfoID = reader.ReadUInt32(); + } + else { + value.Responder = reader.ReadString(16); + value.ResponderTel = reader.ReadString(20); + value.ObjectID_2019 = reader.ReadString(20); + value.SourceDataType = reader.ReadUInt16(); + value.SourceMsgSn = reader.ReadUInt32(); + } + value.InfoLength = reader.ReadUInt32(); + value.InfoContent = reader.ReadString((int)value.InfoLength); + return value; } public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1300_0x1301 value, IJT809Config config) { writer.WriteByte((byte)value.ObjectType); - writer.WriteStringPadRight(value.ObjectID, 12); - writer.WriteUInt32(value.InfoID); + if (config.Version == JT809Version.JTT2013) + { + writer.WriteStringPadRight(value.ObjectID, 12); + writer.WriteUInt32(value.InfoID); + } + else { + writer.WriteStringPadRight(value.Responder, 16); + writer.WriteStringPadRight(value.ResponderTel, 20); + writer.WriteStringPadRight(value.ObjectID_2019, 20); + writer.WriteUInt16(value.SourceDataType); + writer.WriteUInt32(value.SourceMsgSn); + } // 先计算内容长度(汉字为两个字节) writer.Skip(4, out int lengthPosition); writer.WriteString(value.InfoContent); diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x1300_0x1303.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x1300_0x1303.cs new file mode 100644 index 0000000..2d37e56 --- /dev/null +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x1300_0x1303.cs @@ -0,0 +1,44 @@ +using JT809.Protocol.Enums; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; +using JT809.Protocol.Extensions; +using System; +using JT809.Protocol.Interfaces; + +namespace JT809.Protocol.SubMessageBody +{ + /// + /// 上传平台间消息补传请求消息 + /// 子业务类型标识:UP_PLATFORM_MSG_RETRAN_REQ + /// 描述:下级平台在接收消息时,如发现消息报文序列号不连续,则立即发送消息补传请求。上级平台收到消息补传请求后,根据请求的消息报文序列号或起始时间(当仅填写一项时。另一项全为0),重传相应的消息 + /// + public class JT809_0x1300_0x1303:JT809SubBodies, IJT809MessagePackFormatter, IJT809_2019_Version + { + public override ushort SubMsgId => JT809SubBusinessType.上传平台间消息补传请求消息.ToUInt16Value(); + + public override string Description => "上传平台间消息补传请求消息"; + /// + /// 需要重传消息的起始报文序列号和结束的报文序列号。如只请求重传一个消息,则起始消息报文序列号和结束消息报文序列号相同 + /// 8位 + /// + public byte[] SerialList { get; set; } + /// + /// 重传起始系统utc时间 + /// 8位 + /// + public DateTime Time { get; set; } + public JT809_0x1300_0x1303 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + var value= new JT809_0x1300_0x1303(); + value.SerialList = reader.ReadArray(8).ToArray(); + value.Time = reader.ReadUTCDateTime(); + return value; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1300_0x1303 value, IJT809Config config) + { + writer.WriteArray(value.SerialList); + writer.WriteUTCDateTime(value.Time); + } + } +} diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x1400_0x1402.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x1400_0x1402.cs index fe4b51e..58195fe 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x1400_0x1402.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x1400_0x1402.cs @@ -3,6 +3,7 @@ using JT809.Protocol.Formatters; using JT809.Protocol.MessagePack; using JT809.Protocol.Extensions; using System; +using JT809.Protocol.Interfaces; namespace JT809.Protocol.SubMessageBody { @@ -12,7 +13,7 @@ namespace JT809.Protocol.SubMessageBody /// 描述:下级平台向上级平台上报某车辆的报警信息 /// 本条消息上级平台无需应答 /// - public class JT809_0x1400_0x1402:JT809SubBodies, IJT809MessagePackFormatter + public class JT809_0x1400_0x1402:JT809SubBodies, IJT809MessagePackFormatter, IJT809_2019_Version { public override ushort SubMsgId => JT809SubBusinessType.上报报警信息消息.ToUInt16Value(); @@ -22,6 +23,10 @@ namespace JT809.Protocol.SubMessageBody /// public JT809WarnSrc WarnSrc { get; set; } /// + /// 发起报警平台唯一编码,由平台所在地行政区域代码和平台编号组成 + /// + public byte[] SourcePlatformId { get; set; } + /// /// 报警类型 /// public JT809WarnType WarnType { get; set; } @@ -30,6 +35,30 @@ namespace JT809.Protocol.SubMessageBody /// public DateTime WarnTime { get; set; } /// + /// 事件开始时间 utc + /// + public DateTime StartTime { get; set; } + /// + /// 事件结束时间 utc + /// + public DateTime EndTime { get; set; } + /// + /// 车牌号码 非车辆相关报警全填0 + /// + public string VehicleNo { get; set; } + /// + /// 车牌颜色 非车辆相关报警全填0 + /// + public JT809VehicleColorType VehicleColor { get; set; } + /// + /// 被报警平台唯一编码,由平台所在地行政区划代码和平台编号组成。非平台相关报警全填0 + /// + public byte[] DestinationPlatformId { get; set; } + /// + /// 线路ID 808-2019中0x8606规定的报文中的线路ID + /// + public uint DRVLineId { get; set; } + /// /// 信息ID /// public uint InfoID { get; set; } @@ -43,22 +72,58 @@ namespace JT809.Protocol.SubMessageBody public string InfoContent { get; set; } public JT809_0x1400_0x1402 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { - JT809_0x1400_0x1402 jT809_0X1400_0X1402 = new JT809_0x1400_0x1402(); - jT809_0X1400_0X1402.WarnSrc = (JT809WarnSrc)reader.ReadByte(); - jT809_0X1400_0X1402.WarnType = (JT809WarnType)reader.ReadUInt16(); - jT809_0X1400_0X1402.WarnTime = reader.ReadUTCDateTime(); - jT809_0X1400_0X1402.InfoID = reader.ReadUInt32(); - jT809_0X1400_0X1402.InfoLength = reader.ReadUInt32(); - jT809_0X1400_0X1402.InfoContent = reader.ReadString((int)jT809_0X1400_0X1402.InfoLength); - return jT809_0X1400_0X1402; + var value = new JT809_0x1400_0x1402(); + if (config.Version == JT809Version.JTT2013) + { + value.WarnSrc = (JT809WarnSrc)reader.ReadByte(); + } + else { + value.SourcePlatformId = reader.ReadArray(11).ToArray(); + } + value.WarnType = (JT809WarnType)reader.ReadUInt16(); + value.WarnTime = reader.ReadUTCDateTime(); + if (config.Version != JT809Version.JTT2013) + { + value.InfoID = reader.ReadUInt32(); + } + else + { + value.StartTime = reader.ReadUTCDateTime(); + value.EndTime = reader.ReadUTCDateTime(); +#warning 此处车牌号文档长度有误,使用旧版长度21 + value.VehicleNo = reader.ReadString(21); + value.VehicleColor = (JT809VehicleColorType)reader.ReadByte(); + value.DestinationPlatformId = reader.ReadArray(11).ToArray(); + value.DRVLineId = reader.ReadUInt32(); + } + value.InfoLength = reader.ReadUInt32(); + value.InfoContent = reader.ReadString((int)value.InfoLength); + return value; } public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1400_0x1402 value, IJT809Config config) { - writer.WriteByte((byte)value.WarnSrc); + if (config.Version == JT809Version.JTT2013) + { + writer.WriteByte((byte)value.WarnSrc); + } + else { + writer.WriteArray(value.SourcePlatformId); + } writer.WriteUInt16((ushort)value.WarnType); writer.WriteUTCDateTime(value.WarnTime); - writer.WriteUInt32(value.InfoID); + if (config.Version == JT809Version.JTT2013) + { + writer.WriteUInt32(value.InfoID); + } + else { + writer.WriteUTCDateTime(value.StartTime); + writer.WriteUTCDateTime(value.EndTime); + writer.WriteStringPadRight(value.VehicleNo,21); + writer.WriteByte((byte)value.VehicleColor); + writer.WriteArray(value.DestinationPlatformId); + writer.WriteUInt32(value.DRVLineId); + } // 先计算内容长度(汉字为两个字节) writer.Skip(4, out int lengthPosition); writer.WriteString(value.InfoContent); diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x1400_0x1403.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x1400_0x1403.cs index 104b42b..3eb7c35 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x1400_0x1403.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x1400_0x1403.cs @@ -2,20 +2,69 @@ using JT809.Protocol.Formatters; using JT809.Protocol.MessagePack; using JT809.Protocol.Extensions; +using JT809.Protocol.Interfaces; +using System; namespace JT809.Protocol.SubMessageBody { /// - /// 主动上报报警处理结果信息 - /// 子业务类型标识:UP_WARN_MSG_ADPT_TODO_INFO - /// 描述:下级平台向上级平台上报报警处理结果 + /// 主动上报报警处理结果信息(2013) + /// 上报报警预警信息(2019) + /// 子业务类型标识:UP_WARN_MSG_ADPT_TODO_INFO_2013 + /// 子业务类型标识:UP_WARN_MSG_INFORM_TIPS_2019 + /// 描述:下级平台向上级平台上报报警处理结果2013 + /// 描述:用于下级平台向上级平台上报相关报警预警或运行提示信息2019 /// 本条消息上级平台无需应答 /// - public class JT809_0x1400_0x1403:JT809SubBodies, IJT809MessagePackFormatter + public class JT809_0x1400_0x1403:JT809SubBodies, IJT809MessagePackFormatter, IJT809_2019_Version { - public override ushort SubMsgId => JT809SubBusinessType.主动上报报警处理结果信息.ToUInt16Value(); + public override ushort SubMsgId => JT809SubBusinessType.主动上报报警处理结果信息2013_上报报警预警信息2019.ToUInt16Value(); - public override string Description => "主动上报报警处理结果信息"; + public override string Description => "主动上报报警处理结果信息2013_上报报警预警信息2019"; + /// + /// 发起报警平台唯一编码,由平台所在地行政区域代码和平台编号组成 + /// + public byte[] SourcePlatformId { get; set; } + /// + /// 报警类型 + /// + public JT809WarnType WarnType { get; set; } + /// + /// 报警时间 + /// + public DateTime WarnTime { get; set; } + /// + /// 事件开始时间 utc + /// + public DateTime StartTime { get; set; } + /// + /// 事件结束时间 utc + /// + public DateTime EndTime { get; set; } + /// + /// 车牌号码 非车辆相关报警全填0 + /// + public string VehicleNo { get; set; } + /// + /// 车牌颜色 非车辆相关报警全填0 + /// + public JT809VehicleColorType VehicleColor { get; set; } + /// + /// 被报警平台唯一编码,由平台所在地行政区划代码和平台编号组成。非平台相关报警全填0 + /// + public byte[] DestinationPlatformId { get; set; } + /// + /// 线路ID 808-2019中0x8606规定的报文中的线路ID + /// + public uint DRVLineId { get; set; } + /// + /// 数据长度 + /// + public uint InfoLength { get; set; } + /// + /// 数据长度 + /// + public string InfoContent { get; set; } /// /// 报警信息ID /// @@ -26,16 +75,52 @@ namespace JT809.Protocol.SubMessageBody public JT809_0x1403_Result Result { get; set; } public JT809_0x1400_0x1403 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { - JT809_0x1400_0x1403 jT809_0X1400_0X1403 = new JT809_0x1400_0x1403(); - jT809_0X1400_0X1403.InfoID = reader.ReadUInt32(); - jT809_0X1400_0X1403.Result = (JT809_0x1403_Result)reader.ReadByte(); - return jT809_0X1400_0X1403; + var value = new JT809_0x1400_0x1403(); + if (config.Version == JT809Version.JTT2013) + { + value.InfoID = reader.ReadUInt32(); + value.Result = (JT809_0x1403_Result)reader.ReadByte(); + } + else { + value.SourcePlatformId = reader.ReadArray(11).ToArray(); + value.WarnType = (JT809WarnType)reader.ReadUInt16(); + value.WarnTime = reader.ReadUTCDateTime(); + value.StartTime = reader.ReadUTCDateTime(); + value.EndTime = reader.ReadUTCDateTime(); +#warning 此处车牌号文档长度有误,使用旧版长度21 + value.VehicleNo = reader.ReadString(21); + value.VehicleColor = (JT809VehicleColorType)reader.ReadByte(); + value.DestinationPlatformId = reader.ReadArray(11).ToArray(); + value.DRVLineId = reader.ReadUInt32(); + value.InfoLength = reader.ReadUInt32(); + value.InfoContent = reader.ReadString((int)value.InfoLength); + } + return value; } public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1400_0x1403 value, IJT809Config config) { - writer.WriteUInt32(value.InfoID); - writer.WriteByte((byte)value.Result); + if (config.Version == JT809Version.JTT2013) + { + writer.WriteUInt32(value.InfoID); + writer.WriteByte((byte)value.Result); + } + else { + writer.WriteArray(value.SourcePlatformId); + writer.WriteUInt16((ushort)value.WarnType); + writer.WriteUTCDateTime(value.WarnTime); + writer.WriteUTCDateTime(value.StartTime); + writer.WriteUTCDateTime(value.EndTime); + writer.WriteStringPadRight(value.VehicleNo, 21); + writer.WriteByte((byte)value.VehicleColor); + writer.WriteArray(value.DestinationPlatformId); + writer.WriteUInt32(value.DRVLineId); + // 先计算内容长度(汉字为两个字节) + writer.Skip(4, out int lengthPosition); + writer.WriteString(value.InfoContent); + writer.WriteInt32Return(writer.GetCurrentPosition() - lengthPosition - 4, lengthPosition); + + } } } } diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x1400_0x1411.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x1400_0x1411.cs new file mode 100644 index 0000000..41c12e1 --- /dev/null +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x1400_0x1411.cs @@ -0,0 +1,49 @@ +using JT809.Protocol.Enums; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; +using JT809.Protocol.Extensions; +using System; +using JT809.Protocol.Interfaces; + +namespace JT809.Protocol.SubMessageBody +{ + /// + /// 上报报警督办应答消息 + /// 子业务类型标识:UP_WARN_MSG_ADPT_INFO + /// 描述:下级平台向上级平台上报某车辆的报警信息 + /// 本条消息上级平台无需应答 + /// + public class JT809_0x1400_0x1411 : JT809SubBodies, IJT809MessagePackFormatter, IJT809_2019_Version + { + public override ushort SubMsgId => JT809SubBusinessType.上报报警督办应答消息.ToUInt16Value(); + + public override string Description => "上报报警督办应答消息"; + /// + /// 对应报警督办请求消息源子业务类型标识 + /// + public ushort SourceDateType { get; set; } + /// + /// 对应报警督办请求消息源报文序列号 + /// + public uint SourceMsgSn { get; set; } + /// + /// 报警处理结果 + /// + public JT809_0x1411_Result Result { get; set; } + public JT809_0x1400_0x1411 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + var value = new JT809_0x1400_0x1411(); + value.SourceDateType = reader.ReadUInt16(); + value.SourceMsgSn = reader.ReadUInt32(); + value.Result = (JT809_0x1411_Result)reader.ReadByte(); + return value; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1400_0x1411 value, IJT809Config config) + { + writer.WriteUInt16(value.SourceDateType); + writer.WriteUInt32(value.SourceMsgSn); + writer.WriteByte((byte)value.Result); + } + } +} diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x1400_0x1412.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x1400_0x1412.cs new file mode 100644 index 0000000..dca02bf --- /dev/null +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x1400_0x1412.cs @@ -0,0 +1,49 @@ +using JT809.Protocol.Enums; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; +using JT809.Protocol.Extensions; +using System; +using JT809.Protocol.Interfaces; + +namespace JT809.Protocol.SubMessageBody +{ + /// + /// 主动上报报警处理结果消息 + /// 子业务类型标识:UP_WARN_MSG_ADPT_TODO_INFO + /// 描述:下级平台主动向上级平台上报报警处理结果 + /// 本条消息上级平台无需应答 + /// + public class JT809_0x1400_0x1412 : JT809SubBodies, IJT809MessagePackFormatter, IJT809_2019_Version + { + public override ushort SubMsgId => JT809SubBusinessType.主动上报报警处理结果消息.ToUInt16Value(); + + public override string Description => "主动上报报警处理结果消息"; + /// + /// 对应报警督办请求消息源子业务类型标识 + /// + public ushort SourceDateType { get; set; } + /// + /// 对应报警督办请求消息源报文序列号 + /// + public uint SourceMsgSn { get; set; } + /// + /// 报警处理结果 + /// + public JT809_0x1412_Result Result { get; set; } + public JT809_0x1400_0x1412 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + var value = new JT809_0x1400_0x1412(); + value.SourceDateType = reader.ReadUInt16(); + value.SourceMsgSn = reader.ReadUInt32(); + value.Result = (JT809_0x1412_Result)reader.ReadByte(); + return value; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1400_0x1412 value, IJT809Config config) + { + writer.WriteUInt16(value.SourceDateType); + writer.WriteUInt32(value.SourceMsgSn); + writer.WriteByte((byte)value.Result); + } + } +} diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x1400_0x1413.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x1400_0x1413.cs new file mode 100644 index 0000000..4c59778 --- /dev/null +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x1400_0x1413.cs @@ -0,0 +1,85 @@ +using JT809.Protocol.Enums; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; +using JT809.Protocol.Extensions; +using System; +using JT809.Protocol.Interfaces; + +namespace JT809.Protocol.SubMessageBody +{ + /// + /// 上报报警督办请求消息 + /// 子业务类型标识:UP_WARN_MSG_URGE_TODO_REQ_INFO + /// 描述:下级平台告知上级平台已对报警情况进行催办 + /// 本条消息上级平台无需应答 + /// + public class JT809_0x1400_0x1413 : JT809SubBodies, IJT809MessagePackFormatter, IJT809_2019_Version + { + public override ushort SubMsgId => JT809SubBusinessType.主动上报报警处理结果消息.ToUInt16Value(); + + public override string Description => "上报报警督办请求消息"; + /// + /// 发起报警平台唯一编码,由平台所在地行政区划大码和平台编号组成 + /// + public byte[] SourcePlatformId { get; set; } + /// + /// 报警时间 utc + /// + public DateTime WarnTime { get; set; } + /// + /// 对应报警督办请求消息源子业务类型标识 + /// + public ushort SourceDateType { get; set; } + /// + /// 对应报警督办请求消息源报文序列号 + /// + public uint SourceMsgSn { get; set; } + /// + /// 督办截止时间 utc + /// + public DateTime SupervisionEndTime { get; set; } + /// + /// 督办级别 + /// + public JT809_0x1413_SupervisionLevel SupervisionLevel { get; set; } + /// + /// 督办人 + /// + public string Supervisor { get; set; } + /// + /// 督办人联系电话 + /// + public string SupervisorTel { get; set; } + /// + /// 督办人联系电子邮件 + /// + public string SupervisorEmail { get; set; } + public JT809_0x1400_0x1413 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + var value = new JT809_0x1400_0x1413(); + value.SourcePlatformId = reader.ReadArray(11).ToArray(); + value.WarnTime = reader.ReadUTCDateTime(); + value.SourceDateType = reader.ReadUInt16(); + value.SourceMsgSn = reader.ReadUInt32(); + value.SupervisionEndTime = reader.ReadUTCDateTime(); + value.SupervisionLevel=(JT809_0x1413_SupervisionLevel)reader.ReadByte(); + value.Supervisor = reader.ReadString(16); + value.SupervisorTel = reader.ReadString(20); + value.SupervisorEmail = reader.ReadString(32); + return value; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1400_0x1413 value, IJT809Config config) + { + writer.WriteArray(value.SourcePlatformId); + writer.WriteUTCDateTime(value.WarnTime); + writer.WriteUInt16(value.SourceDateType); + writer.WriteUInt32(value.SourceMsgSn); + writer.WriteUTCDateTime(value.SupervisionEndTime); + writer.WriteByte((byte)value.SupervisionLevel); + writer.WriteStringPadRight(value.Supervisor, 16); + writer.WriteStringPadRight(value.SupervisorTel, 20); + writer.WriteStringPadRight(value.SupervisorEmail, 32); + } + } +} diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x920C.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x920C.cs new file mode 100644 index 0000000..e595da5 --- /dev/null +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x920C.cs @@ -0,0 +1,22 @@ +using JT809.Protocol.Enums; +using JT809.Protocol.Extensions; +using JT809.Protocol.Interfaces; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.SubMessageBody +{ + /// + /// 上报车辆车辆行驶路线请求 + /// 子业务类型标识:DOWN_BASE_MSG_DRVLINE_REQ + /// + public class JT809_0x9200_0x920C:JT809SubBodies, IJT809_2019_Version + { + public override ushort SubMsgId => JT809SubBusinessType.上报车辆车辆行驶路线请求.ToUInt16Value(); + + public override string Description => "上报车辆车辆行驶路线请求"; + + public override bool SkipSerialization => true; + } +} diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x920D.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x920D.cs new file mode 100644 index 0000000..da44691 --- /dev/null +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x9200_0x920D.cs @@ -0,0 +1,57 @@ +using JT809.Protocol.Enums; +using JT809.Protocol.Extensions; +using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; +using JT809.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.SubMessageBody +{ + /// + /// 车辆行驶线路请求应答 + /// 子业务类型标识:DOWN_BASE_MSG_DRVLINE_ACK + /// + public class JT809_0x9200_0x920D : JT809SubBodies, IJT809MessagePackFormatter, IJT809_2019_Version + { + public override ushort SubMsgId => JT809SubBusinessType.车辆行驶线路请求应答.ToUInt16Value(); + + public override string Description => "车辆行驶线路请求应答"; + /// + /// 线路ID,按照808-2019中0x8606规定的报文中的线路ID + /// + public uint DRVLineID { get; set; } + /// + /// 处理结果 0x00 完成记录,0x01 审核通过,完成记录 0x02信息错误,未完成记录0x03 审核未通过,未完成记录 + /// + public byte Result { get; set; } + /// + /// 未通过原因内容长度 + /// + public ushort ReasonLength { get; set; } + /// + /// 经过GBK编码后的未通过原因 + /// + public string Reason { get; set; } + + public JT809_0x9200_0x920D Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + var value = new JT809_0x9200_0x920D(); + value.DRVLineID = reader.ReadUInt32(); + value.Result = reader.ReadByte(); + value.ReasonLength = reader.ReadUInt16(); + value.Reason = reader.ReadString(value.ReasonLength); + return value; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9200_0x920D value, IJT809Config config) + { + writer.WriteUInt32(value.DRVLineID); + writer.WriteByte(value.Result); + writer.Skip(2, out int position); + writer.WriteString(value.Reason); + writer.WriteUInt16Return((ushort)(writer.GetCurrentPosition() - position-2), position); + } + } +} diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x9300_0x9303.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x9300_0x9303.cs new file mode 100644 index 0000000..619aefe --- /dev/null +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x9300_0x9303.cs @@ -0,0 +1,44 @@ +using JT809.Protocol.Enums; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; +using JT809.Protocol.Extensions; +using System; +using JT809.Protocol.Interfaces; + +namespace JT809.Protocol.SubMessageBody +{ + /// + /// 下发平台间消息补传请求消息 + /// 子业务类型标识:DOWN_PLATFORM_MSG_RETRAN_REQ + /// 描述:上级平台接收方在接受消息时,如发现消息报文序列号不连接,则立即发送消息补传请求。下级平台收到消息补传请求后,根据请求的消息报文序列号。重传相应的消息 + /// + public class JT809_0x9300_0x9303:JT809SubBodies, IJT809MessagePackFormatter, IJT809_2019_Version + { + public override ushort SubMsgId => JT809SubBusinessType.下发平台间消息补传请求消息.ToUInt16Value(); + + public override string Description => "下发平台间消息补传请求消息"; + /// + /// 需要重传消息的起始报文序列号和结束的报文序列号。如只请求重传一个消息,则起始消息报文序列号和结束消息报文序列号相同 + /// 8位 + /// + public byte[] SerialList { get; set; } + /// + /// 重传起始系统utc时间 + /// 8位 + /// + public DateTime Time { get; set; } + public JT809_0x9300_0x9303 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + var value = new JT809_0x9300_0x9303(); + value.SerialList = reader.ReadArray(8).ToArray(); + value.Time = reader.ReadUTCDateTime(); + return value; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9300_0x9303 value, IJT809Config config) + { + writer.WriteArray(value.SerialList); + writer.WriteUTCDateTime(value.Time); + } + } +} diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x9400_0x9402.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x9400_0x9402.cs index d800b13..d65514c 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x9400_0x9402.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x9400_0x9402.cs @@ -3,33 +3,63 @@ using JT809.Protocol.Formatters; using JT809.Protocol.MessagePack; using JT809.Protocol.Extensions; using System; +using JT809.Protocol.Interfaces; namespace JT809.Protocol.SubMessageBody { /// - /// 报警预警 + /// 报警预警2013 + /// 下发报警预警消息2019 /// 子业务类型标识:DOWN_WARN_MSG_INFORM_TIPS /// 描述:用于上级平台向车辆归属或车辆跨域下级平台下发相关车辆的报警顶警或运行提示信息 /// 本条消息下级平台无需应答 /// - public class JT809_0x9400_0x9402:JT809SubBodies, IJT809MessagePackFormatter + public class JT809_0x9400_0x9402:JT809SubBodies, IJT809MessagePackFormatter,IJT809_2019_Version { - public override ushort SubMsgId => JT809SubBusinessType.报警预警.ToUInt16Value(); + public override ushort SubMsgId => JT809SubBusinessType.报警预警2013_下发报警预警消息2019.ToUInt16Value(); - public override string Description => "报警预警"; + public override string Description => "报警预警2013_下发报警预警消息2019"; /// /// 报警信息来源 /// public JT809WarnSrc WarnSrc { get; set; } /// + /// 发起报警平台唯一编码,由平台所在地行政区域代码和平台编号组成 + /// + public byte[] SourcePlatformId { get; set; } + /// /// 报警类型 /// public JT809WarnType WarnType { get; set; } /// - /// 报警时间 UTCDateTime + /// 报警时间 /// public DateTime WarnTime { get; set; } /// + /// 事件开始时间 utc + /// + public DateTime StartTime { get; set; } + /// + /// 事件结束时间 utc + /// + public DateTime EndTime { get; set; } + /// + /// 车牌号码 非车辆相关报警全填0 + /// + public string VehicleNo { get; set; } + /// + /// 车牌颜色 非车辆相关报警全填0 + /// + public JT809VehicleColorType VehicleColor { get; set; } + /// + /// 被报警平台唯一编码,由平台所在地行政区划代码和平台编号组成。非平台相关报警全填0 + /// + public byte[] DestinationPlatformId { get; set; } + /// + /// 线路ID 808-2019中0x8606规定的报文中的线路ID + /// + public uint DRVLineId { get; set; } + /// /// 数据长度 /// public uint WarnLength { get; set; } @@ -40,20 +70,49 @@ namespace JT809.Protocol.SubMessageBody public JT809_0x9400_0x9402 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { - JT809_0x9400_0x9402 jT809_0X9400_0X9402 = new JT809_0x9400_0x9402(); - jT809_0X9400_0X9402.WarnSrc = (JT809WarnSrc)reader.ReadByte(); - jT809_0X9400_0X9402.WarnType = (JT809WarnType)reader.ReadUInt16(); - jT809_0X9400_0X9402.WarnTime = reader.ReadUTCDateTime(); - jT809_0X9400_0X9402.WarnLength = reader.ReadUInt32(); - jT809_0X9400_0X9402.WarnContent = reader.ReadString((int)jT809_0X9400_0X9402.WarnLength); - return jT809_0X9400_0X9402; + var value = new JT809_0x9400_0x9402(); + if (config.Version == JT809Version.JTT2013) + { + value.WarnSrc = (JT809WarnSrc)reader.ReadByte(); + } + else { + value.SourcePlatformId = reader.ReadArray(11).ToArray(); + } + value.WarnType = (JT809WarnType)reader.ReadUInt16(); + value.WarnTime = reader.ReadUTCDateTime(); + if (config.Version == JT809Version.JTT2019) { + value.StartTime = reader.ReadUTCDateTime(); + value.EndTime = reader.ReadUTCDateTime(); +#warning 此处车牌号文档长度有误,使用旧版长度21 + value.VehicleNo = reader.ReadString(21); + value.VehicleColor = (JT809VehicleColorType)reader.ReadByte(); + value.DestinationPlatformId = reader.ReadArray(11).ToArray(); + value.DRVLineId = reader.ReadUInt32(); + } + value.WarnLength = reader.ReadUInt32(); + value.WarnContent = reader.ReadString((int)value.WarnLength); + return value; } public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9400_0x9402 value, IJT809Config config) { - writer.WriteByte((byte)value.WarnSrc); + if (config.Version == JT809Version.JTT2013) + { + writer.WriteByte((byte)value.WarnSrc); + } + else { + writer.WriteArray(value.SourcePlatformId); + } writer.WriteUInt16((ushort)value.WarnType); writer.WriteUTCDateTime(value.WarnTime); + if (config.Version == JT809Version.JTT2019) { + writer.WriteUTCDateTime(value.StartTime); + writer.WriteUTCDateTime(value.EndTime); + writer.WriteStringPadRight(value.VehicleNo, 21); + writer.WriteByte((byte)value.VehicleColor); + writer.WriteArray(value.DestinationPlatformId); + writer.WriteUInt32(value.DRVLineId); + } // 先计算内容长度(汉字为两个字节) writer.Skip(4, out int lengthPosition); writer.WriteString(value.WarnContent); diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x9400_0x9403.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x9400_0x9403.cs index 2a37256..a936711 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x9400_0x9403.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x9400_0x9403.cs @@ -3,6 +3,7 @@ using JT809.Protocol.Formatters; using JT809.Protocol.MessagePack; using JT809.Protocol.Extensions; using System; +using JT809.Protocol.Interfaces; namespace JT809.Protocol.SubMessageBody { @@ -12,7 +13,7 @@ namespace JT809.Protocol.SubMessageBody /// 描述:用于上级平台向车辆跨域目的地下级平台下发相关车辆的当前报警情况 /// 本条消息下级平台无需应答 /// - public class JT809_0x9400_0x9403:JT809SubBodies, IJT809MessagePackFormatter + public class JT809_0x9400_0x9403:JT809SubBodies, IJT809MessagePackFormatter,IJT809_2019_Version { public override ushort SubMsgId => JT809SubBusinessType.实时交换报警信息.ToUInt16Value(); @@ -22,6 +23,10 @@ namespace JT809.Protocol.SubMessageBody /// public JT809WarnSrc WarnSrc { get; set; } /// + /// 发起报警平台唯一编码,由平台所在地行政区域代码和平台编号组成 + /// + public byte[] SourcePlatformId { get; set; } + /// /// 报警类型 /// public JT809WarnType WarnType { get; set; } @@ -30,6 +35,30 @@ namespace JT809.Protocol.SubMessageBody /// public DateTime WarnTime { get; set; } /// + /// 事件开始时间 utc + /// + public DateTime StartTime { get; set; } + /// + /// 事件结束时间 utc + /// + public DateTime EndTime { get; set; } + /// + /// 车牌号码 非车辆相关报警全填0 + /// + public string VehicleNo { get; set; } + /// + /// 车牌颜色 非车辆相关报警全填0 + /// + public JT809VehicleColorType VehicleColor { get; set; } + /// + /// 被报警平台唯一编码,由平台所在地行政区划代码和平台编号组成。非平台相关报警全填0 + /// + public byte[] DestinationPlatformId { get; set; } + /// + /// 线路ID 808-2019中0x8606规定的报文中的线路ID + /// + public uint DRVLineId { get; set; } + /// /// 数据长度 /// public uint WarnLength { get; set; } @@ -39,20 +68,53 @@ namespace JT809.Protocol.SubMessageBody public string WarnContent { get; set; } public JT809_0x9400_0x9403 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { - JT809_0x9400_0x9403 jT809_0X9400_0X9403 = new JT809_0x9400_0x9403(); - jT809_0X9400_0X9403.WarnSrc = (JT809WarnSrc)reader.ReadByte(); - jT809_0X9400_0X9403.WarnType = (JT809WarnType)reader.ReadUInt16(); - jT809_0X9400_0X9403.WarnTime = reader.ReadUTCDateTime(); - jT809_0X9400_0X9403.WarnLength = reader.ReadUInt32(); - jT809_0X9400_0X9403.WarnContent = reader.ReadString((int)jT809_0X9400_0X9403.WarnLength); - return jT809_0X9400_0X9403; + var value = new JT809_0x9400_0x9403(); + if (config.Version == JT809Version.JTT2013) + { + value.WarnSrc = (JT809WarnSrc)reader.ReadByte(); + } + else + { + value.SourcePlatformId = reader.ReadArray(11).ToArray(); + } + value.WarnType = (JT809WarnType)reader.ReadUInt16(); + value.WarnTime = reader.ReadUTCDateTime(); + if (config.Version == JT809Version.JTT2019) + { + value.StartTime = reader.ReadUTCDateTime(); + value.EndTime = reader.ReadUTCDateTime(); +#warning 此处车牌号文档长度有误,使用旧版长度21 + value.VehicleNo = reader.ReadString(21); + value.VehicleColor = (JT809VehicleColorType)reader.ReadByte(); + value.DestinationPlatformId = reader.ReadArray(11).ToArray(); + value.DRVLineId = reader.ReadUInt32(); + } + value.WarnLength = reader.ReadUInt32(); + value.WarnContent = reader.ReadString((int)value.WarnLength); + return value; } public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9400_0x9403 value, IJT809Config config) { - writer.WriteByte((byte)value.WarnSrc); + if (config.Version == JT809Version.JTT2013) + { + writer.WriteByte((byte)value.WarnSrc); + } + else + { + writer.WriteArray(value.SourcePlatformId); + } writer.WriteUInt16((ushort)value.WarnType); writer.WriteUTCDateTime(value.WarnTime); + if (config.Version == JT809Version.JTT2019) + { + writer.WriteUTCDateTime(value.StartTime); + writer.WriteUTCDateTime(value.EndTime); + writer.WriteStringPadRight(value.VehicleNo, 21); + writer.WriteByte((byte)value.VehicleColor); + writer.WriteArray(value.DestinationPlatformId); + writer.WriteUInt32(value.DRVLineId); + } // 先计算内容长度(汉字为两个字节) writer.Skip(4, out int lengthPosition); writer.WriteString(value.WarnContent); diff --git a/src/JT809.Protocol/SubMessageBody/JT809_0x9500_0x9504.cs b/src/JT809.Protocol/SubMessageBody/JT809_0x9500_0x9504.cs index 4a447fd..c12a805 100644 --- a/src/JT809.Protocol/SubMessageBody/JT809_0x9500_0x9504.cs +++ b/src/JT809.Protocol/SubMessageBody/JT809_0x9500_0x9504.cs @@ -3,6 +3,7 @@ using JT809.Protocol.Formatters; using JT809.Protocol.MessagePack; using JT809.Protocol.Extensions; using System; +using JT809.Protocol.Interfaces; namespace JT809.Protocol.SubMessageBody { @@ -11,16 +12,12 @@ namespace JT809.Protocol.SubMessageBody /// 子业务类型标识:DOVJN_CTRL_MSG_TAKE_TRAVEL_REQ /// 描述:上级平台向下级平台下发上报车辆行驶记录请求消息 /// - public class JT809_0x9500_0x9504:JT809SubBodies, IJT809MessagePackFormatter + public class JT809_0x9500_0x9504:JT809SubBodies, IJT809MessagePackFormatter, IJT809_2019_Version { public override ushort SubMsgId => JT809SubBusinessType.上报车辆行驶记录请求消息.ToUInt16Value(); public override string Description => "上报车辆行驶记录请求消息"; /// - /// 命令字ID - /// - public JT809CommandType Command { get; set; } - /// /// 开始时间 /// public DateTime StartTime { get; set; } @@ -29,68 +26,24 @@ namespace JT809.Protocol.SubMessageBody /// public DateTime EndTime { get; set; } /// - /// 最大数据数 + /// 命令字ID /// - public ushort Max { get; set; } + public JT809CommandType Command { get; set; } public JT809_0x9500_0x9504 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { - JT809_0x9500_0x9504 jT809_0X9500_0X9504 = new JT809_0x9500_0x9504(); - jT809_0X9500_0X9504.Command = (JT809CommandType)reader.ReadByte(); - switch (jT809_0X9500_0X9504.Command) - { - case JT809CommandType.记录仪标准版本: - case JT809CommandType.当前驾驶人信息: - case JT809CommandType.记录仪时间: - case JT809CommandType.记录仪累计行驶里程: - case JT809CommandType.记录仪脉冲系数: - case JT809CommandType.车辆信息: - case JT809CommandType.记录仪状态信号配置信息: - case JT809CommandType.记录仪唯一性编号: - break; - case JT809CommandType.采集记录仪行驶记录: - case JT809CommandType.采集记录仪位置信息记录: - case JT809CommandType.采集记录仪事故疑点记录: - case JT809CommandType.采集记录仪超时驾驶记录: - case JT809CommandType.采集记录仪驾驶人身份记录: - case JT809CommandType.采集记录仪外部供电记录: - case JT809CommandType.采集记录仪参数修改记录: - case JT809CommandType.采集记录仪速度状态日志: - jT809_0X9500_0X9504.StartTime = reader.ReadDateTime6(); - jT809_0X9500_0X9504.EndTime = reader.ReadDateTime6(); - jT809_0X9500_0X9504.Max = reader.ReadUInt16(); - break; - } - return jT809_0X9500_0X9504; + var value = new JT809_0x9500_0x9504(); + value.StartTime = reader.ReadUTCDateTime(); + value.EndTime = reader.ReadUTCDateTime(); + value.Command = (JT809CommandType)reader.ReadByte(); + return value; } public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9500_0x9504 value, IJT809Config config) { + writer.WriteUTCDateTime(value.StartTime); + writer.WriteUTCDateTime(value.EndTime); writer.WriteByte((byte)value.Command); - switch (value.Command) - { - case JT809CommandType.记录仪标准版本: - case JT809CommandType.当前驾驶人信息: - case JT809CommandType.记录仪时间: - case JT809CommandType.记录仪累计行驶里程: - case JT809CommandType.记录仪脉冲系数: - case JT809CommandType.车辆信息: - case JT809CommandType.记录仪状态信号配置信息: - case JT809CommandType.记录仪唯一性编号: - break; - case JT809CommandType.采集记录仪行驶记录: - case JT809CommandType.采集记录仪位置信息记录: - case JT809CommandType.采集记录仪事故疑点记录: - case JT809CommandType.采集记录仪超时驾驶记录: - case JT809CommandType.采集记录仪驾驶人身份记录: - case JT809CommandType.采集记录仪外部供电记录: - case JT809CommandType.采集记录仪参数修改记录: - case JT809CommandType.采集记录仪速度状态日志: - writer.WriteDateTime6(value.StartTime); - writer.WriteDateTime6(value.EndTime); - writer.WriteUInt16(value.Max); - break; - } } } }