@@ -14,7 +14,7 @@ | |||||
<licenseUrl>https://github.com/SmallChi/JT808/blob/master/LICENSE</licenseUrl> | <licenseUrl>https://github.com/SmallChi/JT808/blob/master/LICENSE</licenseUrl> | ||||
<license>https://github.com/SmallChi/JT808/blob/master/LICENSE</license> | <license>https://github.com/SmallChi/JT808/blob/master/LICENSE</license> | ||||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild> | <GeneratePackageOnBuild>false</GeneratePackageOnBuild> | ||||
<Version>2.1.8</Version> | |||||
<Version>2.2.0</Version> | |||||
<PackageLicenseFile>LICENSE</PackageLicenseFile> | <PackageLicenseFile>LICENSE</PackageLicenseFile> | ||||
</PropertyGroup> | </PropertyGroup> | ||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> | ||||
@@ -1,6 +1,8 @@ | |||||
using JT808.Protocol.Enums; | using JT808.Protocol.Enums; | ||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.MessagePack; | |||||
using JT808.Protocol.Formatters; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -8,7 +10,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 终端通用应答 | /// 终端通用应答 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x0001_Formatter))] | [JT808Formatter(typeof(JT808_0x0001_Formatter))] | ||||
public class JT808_0x0001 : JT808Bodies | |||||
public class JT808_0x0001 : JT808Bodies,IJT808MessagePackFormatter<JT808_0x0001> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 应答流水号 | /// 应答流水号 | ||||
@@ -26,5 +28,21 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0:成功/确认;1:失败;2:消息有误;3:不支持 | /// 0:成功/确认;1:失败;2:消息有误;3:不支持 | ||||
/// </summary> | /// </summary> | ||||
public JT808TerminalResult JT808TerminalResult { get; set; } | public JT808TerminalResult JT808TerminalResult { get; set; } | ||||
public JT808_0x0001 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0001 jT808_0X0001 = new JT808_0x0001(); | |||||
jT808_0X0001.MsgNum = reader.ReadUInt16(); | |||||
jT808_0X0001.MsgId = reader.ReadUInt16(); | |||||
jT808_0X0001.JT808TerminalResult = (JT808TerminalResult)reader.ReadByte(); | |||||
return jT808_0X0001; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0001 value, IJT808Config config) | |||||
{ | |||||
writer.WriteUInt16(value.MsgNum); | |||||
writer.WriteUInt16(value.MsgId); | |||||
writer.WriteByte((byte)value.JT808TerminalResult); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -7,7 +9,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 终端注册 | /// 终端注册 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x0100_Formatter))] | [JT808Formatter(typeof(JT808_0x0100_Formatter))] | ||||
public class JT808_0x0100 : JT808Bodies | |||||
public class JT808_0x0100 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0100> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 省域 ID | /// 省域 ID | ||||
@@ -58,5 +60,29 @@ namespace JT808.Protocol.MessageBody | |||||
/// 否则,表示公安交通管理部门颁发的机动车号牌。 | /// 否则,表示公安交通管理部门颁发的机动车号牌。 | ||||
/// </summary> | /// </summary> | ||||
public string PlateNo { get; set; } | public string PlateNo { get; set; } | ||||
public JT808_0x0100 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0100 jT808_0X0100 = new JT808_0x0100(); | |||||
jT808_0X0100.AreaID = reader.ReadUInt16(); | |||||
jT808_0X0100.CityOrCountyId = reader.ReadUInt16(); | |||||
jT808_0X0100.MakerId = reader.ReadString(5); | |||||
jT808_0X0100.TerminalModel = reader.ReadString(20); | |||||
jT808_0X0100.TerminalId = reader.ReadString(7); | |||||
jT808_0X0100.PlateColor = reader.ReadByte(); | |||||
jT808_0X0100.PlateNo = reader.ReadRemainStringContent(); | |||||
return jT808_0X0100; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0100 value, IJT808Config config) | |||||
{ | |||||
writer.WriteUInt16(value.AreaID); | |||||
writer.WriteUInt16(value.CityOrCountyId); | |||||
writer.WriteString(value.MakerId.PadRight(5, '0')); | |||||
writer.WriteString(value.TerminalModel.PadRight(20, '0')); | |||||
writer.WriteString(value.TerminalId.PadRight(7, '0')); | |||||
writer.WriteByte(value.PlateColor); | |||||
writer.WriteString(value.PlateNo); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -7,11 +9,23 @@ namespace JT808.Protocol.MessageBody | |||||
/// 终端鉴权 | /// 终端鉴权 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x0102_Formatter))] | [JT808Formatter(typeof(JT808_0x0102_Formatter))] | ||||
public class JT808_0x0102 : JT808Bodies | |||||
public class JT808_0x0102 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0102> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 鉴权码 | /// 鉴权码 | ||||
/// </summary> | /// </summary> | ||||
public string Code { get; set; } | public string Code { get; set; } | ||||
public JT808_0x0102 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0102 jT808_0X0102 = new JT808_0x0102(); | |||||
jT808_0X0102.Code = reader.ReadRemainStringContent(); | |||||
return jT808_0X0102; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0102 value, IJT808Config config) | |||||
{ | |||||
writer.WriteString(value.Code); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,9 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Extensions; | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
@@ -8,7 +12,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 查询终端参数应答 | /// 查询终端参数应答 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x0104_Formatter))] | [JT808Formatter(typeof(JT808_0x0104_Formatter))] | ||||
public class JT808_0x0104 : JT808Bodies | |||||
public class JT808_0x0104 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0104> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 应答流水号 | /// 应答流水号 | ||||
@@ -23,5 +27,41 @@ namespace JT808.Protocol.MessageBody | |||||
/// 参数列表 | /// 参数列表 | ||||
/// </summary> | /// </summary> | ||||
public IList<JT808_0x8103_BodyBase> ParamList { get; set; } | public IList<JT808_0x8103_BodyBase> ParamList { get; set; } | ||||
public JT808_0x0104 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0104 jT808_0x0104 = new JT808_0x0104(); | |||||
jT808_0x0104.MsgNum = reader.ReadUInt16(); | |||||
jT808_0x0104.AnswerParamsCount = reader.ReadByte(); | |||||
for (int i = 0; i < jT808_0x0104.AnswerParamsCount; i++) | |||||
{ | |||||
var paramId = reader.ReadVirtualUInt32();//参数ID | |||||
if (config.JT808_0X8103_Factory.ParamMethods.TryGetValue(paramId, out Type type)) | |||||
{ | |||||
if (jT808_0x0104.ParamList != null) | |||||
{ | |||||
jT808_0x0104.ParamList.Add(JT808MessagePackFormatterResolverExtensions.JT808DynamicDeserialize( | |||||
config.GetMessagePackFormatterByType(type), ref reader, config)); | |||||
} | |||||
else | |||||
{ | |||||
jT808_0x0104.ParamList = new List<JT808_0x8103_BodyBase> { JT808MessagePackFormatterResolverExtensions.JT808DynamicDeserialize( | |||||
config.GetMessagePackFormatterByType(type), ref reader, config) }; | |||||
} | |||||
} | |||||
} | |||||
return jT808_0x0104; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0104 value, IJT808Config config) | |||||
{ | |||||
writer.WriteUInt16(value.MsgNum); | |||||
writer.WriteByte(value.AnswerParamsCount); | |||||
foreach (var item in value.ParamList) | |||||
{ | |||||
object obj = config.GetMessagePackFormatterByType(item.GetType()); | |||||
JT808MessagePackFormatterResolverExtensions.JT808DynamicSerialize(obj, ref writer, item, config); | |||||
} | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -7,7 +9,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 查询终端属性应答 | /// 查询终端属性应答 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x0107_Formatter))] | [JT808Formatter(typeof(JT808_0x0107_Formatter))] | ||||
public class JT808_0x0107 : JT808Bodies | |||||
public class JT808_0x0107 : JT808Bodies,IJT808MessagePackFormatter<JT808_0x0107> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 终端类型 | /// 终端类型 | ||||
@@ -76,5 +78,37 @@ namespace JT808.Protocol.MessageBody | |||||
/// bit7,0:不支持其他通信方式, 1:支持其他通信方式 | /// bit7,0:不支持其他通信方式, 1:支持其他通信方式 | ||||
/// </summary> | /// </summary> | ||||
public byte CommunicationModule { get; set; } | public byte CommunicationModule { get; set; } | ||||
public JT808_0x0107 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0107 jT808_0X0107 = new JT808_0x0107(); | |||||
jT808_0X0107.TerminalType = reader.ReadUInt16(); | |||||
jT808_0X0107.MakerId = reader.ReadString(5); | |||||
jT808_0X0107.TerminalModel = reader.ReadString(20); | |||||
jT808_0X0107.TerminalId = reader.ReadString(7); | |||||
jT808_0X0107.Terminal_SIM_ICCID = reader.ReadBCD(10, config.Trim); | |||||
jT808_0X0107.Terminal_Hardware_Version_Length = reader.ReadByte(); | |||||
jT808_0X0107.Terminal_Hardware_Version_Num = reader.ReadString(jT808_0X0107.Terminal_Hardware_Version_Length); | |||||
jT808_0X0107.Terminal_Firmware_Version_Length = reader.ReadByte(); | |||||
jT808_0X0107.Terminal_Firmware_Version_Num = reader.ReadString(jT808_0X0107.Terminal_Firmware_Version_Length); | |||||
jT808_0X0107.GNSSModule = reader.ReadByte(); | |||||
jT808_0X0107.CommunicationModule = reader.ReadByte(); | |||||
return jT808_0X0107; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0107 value, IJT808Config config) | |||||
{ | |||||
writer.WriteUInt16(value.TerminalType); | |||||
writer.WriteString(value.MakerId.PadRight(5, '0')); | |||||
writer.WriteString(value.TerminalModel.PadRight(20, '0')); | |||||
writer.WriteString(value.TerminalId.PadRight(7, '0')); | |||||
writer.WriteBCD(value.Terminal_SIM_ICCID, 10); | |||||
writer.WriteByte((byte)value.Terminal_Hardware_Version_Num.Length); | |||||
writer.WriteString(value.Terminal_Hardware_Version_Num); | |||||
writer.WriteByte((byte)value.Terminal_Firmware_Version_Num.Length); | |||||
writer.WriteString(value.Terminal_Firmware_Version_Num); | |||||
writer.WriteByte(value.GNSSModule); | |||||
writer.WriteByte(value.CommunicationModule); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,6 +1,8 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Enums; | using JT808.Protocol.Enums; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -8,7 +10,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 终端升级结果通知 | /// 终端升级结果通知 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x0108_Formatter))] | [JT808Formatter(typeof(JT808_0x0108_Formatter))] | ||||
public class JT808_0x0108 : JT808Bodies | |||||
public class JT808_0x0108 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0108> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 升级类型 | /// 升级类型 | ||||
@@ -21,5 +23,18 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0:成功,1:失败,2:取消 | /// 0:成功,1:失败,2:取消 | ||||
/// </summary> | /// </summary> | ||||
public JT808UpgradeResult UpgradeResult { get; set; } | public JT808UpgradeResult UpgradeResult { get; set; } | ||||
public JT808_0x0108 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0108 jT808_0X0108 = new JT808_0x0108(); | |||||
jT808_0X0108.UpgradeType = (JT808UpgradeType)reader.ReadByte(); | |||||
jT808_0X0108.UpgradeResult = (JT808UpgradeResult)reader.ReadByte(); | |||||
return jT808_0X0108; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0108 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte((byte)value.UpgradeType); | |||||
writer.WriteByte((byte)value.UpgradeResult); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,10 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Enums; | |||||
using JT808.Protocol.Exceptions; | |||||
using JT808.Protocol.Extensions; | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
@@ -9,7 +14,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 位置信息汇报 | /// 位置信息汇报 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x0200_Formatter))] | [JT808Formatter(typeof(JT808_0x0200_Formatter))] | ||||
public class JT808_0x0200 : JT808Bodies | |||||
public class JT808_0x0200 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0200> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 报警标志 | /// 报警标志 | ||||
@@ -69,5 +74,140 @@ namespace JT808.Protocol.MessageBody | |||||
/// 依赖平台录入的设备类型 | /// 依赖平台录入的设备类型 | ||||
/// </summary> | /// </summary> | ||||
public Dictionary<byte, JT808_0x0200_CustomBodyBase> JT808CustomLocationAttachData { get; set; } | public Dictionary<byte, JT808_0x0200_CustomBodyBase> JT808CustomLocationAttachData { get; set; } | ||||
public JT808_0x0200 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0200 jT808_0X0200 = new JT808_0x0200(); | |||||
jT808_0X0200.AlarmFlag = reader.ReadUInt32(); | |||||
jT808_0X0200.StatusFlag = reader.ReadUInt32(); | |||||
if (((jT808_0X0200.StatusFlag >> 28) & 1) == 1) | |||||
{ //南纬 268435456 0x10000000 | |||||
jT808_0X0200.Lat = (int)reader.ReadUInt32(); | |||||
} | |||||
else | |||||
{ | |||||
jT808_0X0200.Lat = reader.ReadInt32(); | |||||
} | |||||
if (((jT808_0X0200.StatusFlag >> 27) & 1) == 1) | |||||
{ //西经 134217728 0x8000000 | |||||
jT808_0X0200.Lng = (int)reader.ReadUInt32(); | |||||
} | |||||
else | |||||
{ | |||||
jT808_0X0200.Lng = reader.ReadInt32(); | |||||
} | |||||
jT808_0X0200.Altitude = reader.ReadUInt16(); | |||||
jT808_0X0200.Speed = reader.ReadUInt16(); | |||||
jT808_0X0200.Direction = reader.ReadUInt16(); | |||||
jT808_0X0200.GPSTime = reader.ReadDateTime6(); | |||||
// 位置附加信息 | |||||
jT808_0X0200.JT808LocationAttachData = new Dictionary<byte, JT808_0x0200_BodyBase>(); | |||||
jT808_0X0200.JT808CustomLocationAttachOriginalData = new Dictionary<byte, byte[]>(); | |||||
jT808_0X0200.JT808UnknownLocationAttachOriginalData = new Dictionary<byte, byte[]>(); | |||||
while (reader.ReadCurrentRemainContentLength() > 0) | |||||
{ | |||||
try | |||||
{ | |||||
ReadOnlySpan<byte> attachSpan = reader.GetVirtualReadOnlySpan(2); | |||||
byte attachId = attachSpan[0]; | |||||
byte attachLen = attachSpan[1]; | |||||
if (config.JT808_0X0200_Factory.JT808LocationAttachMethod.TryGetValue(attachId, out Type jT808LocationAttachType)) | |||||
{ | |||||
object attachImplObj = config.GetMessagePackFormatterByType(jT808LocationAttachType); | |||||
dynamic attachImpl = JT808MessagePackFormatterResolverExtensions.JT808DynamicDeserialize(attachImplObj, ref reader, config); | |||||
jT808_0X0200.JT808LocationAttachData.Add(attachImpl.AttachInfoId, attachImpl); | |||||
} | |||||
else if (config.JT808_0X0200_Custom_Factory.AttachIds.Contains(attachId)) | |||||
{ | |||||
reader.Skip(2); | |||||
jT808_0X0200.JT808CustomLocationAttachOriginalData.Add(attachId, reader.ReadArray(reader.ReaderCount - 2, attachLen + 2).ToArray()); | |||||
reader.Skip(attachLen); | |||||
} | |||||
else | |||||
{ | |||||
reader.Skip(2); | |||||
jT808_0X0200.JT808UnknownLocationAttachOriginalData.Add(attachId, reader.ReadArray(reader.ReaderCount - 2, attachLen + 2).ToArray()); | |||||
reader.Skip(attachLen); | |||||
} | |||||
} | |||||
catch | |||||
{ | |||||
try | |||||
{ | |||||
byte attachId = reader.ReadByte(); | |||||
byte attachLen = reader.ReadByte(); | |||||
jT808_0X0200.JT808UnknownLocationAttachOriginalData.Add(attachId, reader.ReadArray(reader.ReaderCount - 2, attachLen + 2).ToArray()); | |||||
reader.Skip(attachLen); | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
throw; | |||||
} | |||||
} | |||||
} | |||||
return jT808_0X0200; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200 value, IJT808Config config) | |||||
{ | |||||
writer.WriteUInt32(value.AlarmFlag); | |||||
writer.WriteUInt32(value.StatusFlag); | |||||
//0x10000000 南纬 134217728 | |||||
//0x8000000 西经 268435456 | |||||
//0x18000000 南纬-西经 134217728+268435456 | |||||
if (((value.StatusFlag >> 28) & 1) == 1) | |||||
{ | |||||
uint lat = (uint)value.Lat; | |||||
writer.WriteUInt32(lat); | |||||
} | |||||
else | |||||
{ | |||||
if (value.Lat < 0) | |||||
{ | |||||
throw new JT808Exception(JT808ErrorCode.LatOrLngError, $"Lat {nameof(JT808_0x0200.StatusFlag)} ({value.StatusFlag}>>28) !=1"); | |||||
} | |||||
writer.WriteInt32(value.Lat); | |||||
} | |||||
if (((value.StatusFlag >> 27) & 1) == 1) | |||||
{ | |||||
uint lng = (uint)value.Lng; | |||||
writer.WriteUInt32(lng); | |||||
} | |||||
else | |||||
{ | |||||
if (value.Lng < 0) | |||||
{ | |||||
throw new JT808Exception(JT808ErrorCode.LatOrLngError, $"Lng {nameof(JT808_0x0200.StatusFlag)} ({value.StatusFlag}>>29) !=1"); | |||||
} | |||||
writer.WriteInt32(value.Lng); | |||||
} | |||||
writer.WriteUInt16(value.Altitude); | |||||
writer.WriteUInt16(value.Speed); | |||||
writer.WriteUInt16(value.Direction); | |||||
writer.WriteDateTime6(value.GPSTime); | |||||
if (value.JT808LocationAttachData != null && value.JT808LocationAttachData.Count > 0) | |||||
{ | |||||
foreach (var item in value.JT808LocationAttachData) | |||||
{ | |||||
try | |||||
{ | |||||
object attachImplObj = config.GetMessagePackFormatterByType(item.Value.GetType()); | |||||
JT808MessagePackFormatterResolverExtensions.JT808DynamicSerialize(attachImplObj, ref writer, item.Value, config); | |||||
} | |||||
catch | |||||
{ | |||||
} | |||||
} | |||||
} | |||||
if (value.JT808CustomLocationAttachData != null && value.JT808CustomLocationAttachData.Count > 0) | |||||
{ | |||||
foreach (var item in value.JT808CustomLocationAttachData) | |||||
{ | |||||
object attachImplObj = config.GetMessagePackFormatterByType(item.Value.GetType()); | |||||
JT808MessagePackFormatterResolverExtensions.JT808DynamicSerialize(attachImplObj, ref writer, item.Value, config); | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,12 +1,14 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
using System.Runtime.Serialization; | using System.Runtime.Serialization; | ||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
[JT808Formatter(typeof(JT808_0x0200_0x01_Formatter))] | [JT808Formatter(typeof(JT808_0x0200_0x01_Formatter))] | ||||
public class JT808_0x0200_0x01 : JT808_0x0200_BodyBase | |||||
public class JT808_0x0200_0x01 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x01> | |||||
{ | { | ||||
public override byte AttachInfoId { get; set; } = 0x01; | public override byte AttachInfoId { get; set; } = 0x01; | ||||
public override byte AttachInfoLength { get; set; } = 4; | public override byte AttachInfoLength { get; set; } = 4; | ||||
@@ -19,5 +21,20 @@ namespace JT808.Protocol.MessageBody | |||||
/// </summary> | /// </summary> | ||||
[IgnoreDataMember] | [IgnoreDataMember] | ||||
public double ConvertMileage => Mileage / 10.0; | public double ConvertMileage => Mileage / 10.0; | ||||
public JT808_0x0200_0x01 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x01 jT808LocationAttachImpl0X01 = new JT808_0x0200_0x01(); | |||||
jT808LocationAttachImpl0X01.AttachInfoId = reader.ReadByte(); | |||||
jT808LocationAttachImpl0X01.AttachInfoLength = reader.ReadByte(); | |||||
jT808LocationAttachImpl0X01.Mileage = reader.ReadInt32(); | |||||
return jT808LocationAttachImpl0X01; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x01 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.AttachInfoId); | |||||
writer.WriteByte(value.AttachInfoLength); | |||||
writer.WriteInt32(value.Mileage); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,11 +1,13 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
using System.Runtime.Serialization; | using System.Runtime.Serialization; | ||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
[JT808Formatter(typeof(JT808_0x0200_0x02_Formatter))] | [JT808Formatter(typeof(JT808_0x0200_0x02_Formatter))] | ||||
public class JT808_0x0200_0x02 : JT808_0x0200_BodyBase | |||||
public class JT808_0x0200_0x02 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x02> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 油量 | /// 油量 | ||||
@@ -18,5 +20,21 @@ namespace JT808.Protocol.MessageBody | |||||
public double ConvertOil => Oil / 10.0; | public double ConvertOil => Oil / 10.0; | ||||
public override byte AttachInfoId { get; set; } = 0x02; | public override byte AttachInfoId { get; set; } = 0x02; | ||||
public override byte AttachInfoLength { get; set; } = 2; | public override byte AttachInfoLength { get; set; } = 2; | ||||
public JT808_0x0200_0x02 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x02 jT808LocationAttachImpl0X02 = new JT808_0x0200_0x02(); | |||||
jT808LocationAttachImpl0X02.AttachInfoId = reader.ReadByte(); | |||||
jT808LocationAttachImpl0X02.AttachInfoLength = reader.ReadByte(); | |||||
jT808LocationAttachImpl0X02.Oil = reader.ReadUInt16(); | |||||
return jT808LocationAttachImpl0X02; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x02 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.AttachInfoId); | |||||
writer.WriteByte(value.AttachInfoLength); | |||||
writer.WriteUInt16(value.Oil); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,12 +1,14 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
using System.Runtime.Serialization; | using System.Runtime.Serialization; | ||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
[JT808Formatter(typeof(JT808_0x0200_0x03_Formatter))] | [JT808Formatter(typeof(JT808_0x0200_0x03_Formatter))] | ||||
public class JT808_0x0200_0x03 : JT808_0x0200_BodyBase | |||||
public class JT808_0x0200_0x03 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x03> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 行驶记录功能获取的速度 | /// 行驶记录功能获取的速度 | ||||
@@ -19,5 +21,20 @@ namespace JT808.Protocol.MessageBody | |||||
public double ConvertSpeed => Speed / 10.0; | public double ConvertSpeed => Speed / 10.0; | ||||
public override byte AttachInfoId { get; set; } = 0x03; | public override byte AttachInfoId { get; set; } = 0x03; | ||||
public override byte AttachInfoLength { get; set; } = 2; | public override byte AttachInfoLength { get; set; } = 2; | ||||
public JT808_0x0200_0x03 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x03 jT808LocationAttachImpl0x03 = new JT808_0x0200_0x03(); | |||||
jT808LocationAttachImpl0x03.AttachInfoId = reader.ReadByte(); | |||||
jT808LocationAttachImpl0x03.AttachInfoLength = reader.ReadByte(); | |||||
jT808LocationAttachImpl0x03.Speed = reader.ReadUInt16(); | |||||
return jT808LocationAttachImpl0x03; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x03 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.AttachInfoId); | |||||
writer.WriteByte(value.AttachInfoLength); | |||||
writer.WriteUInt16(value.Speed); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,10 +1,12 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
[JT808Formatter(typeof(JT808_0x0200_0x04_Formatter))] | [JT808Formatter(typeof(JT808_0x0200_0x04_Formatter))] | ||||
public class JT808_0x0200_0x04 : JT808_0x0200_BodyBase | |||||
public class JT808_0x0200_0x04 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x04> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 需要人工确认报警事件的 ID,从 1 开始计数 | /// 需要人工确认报警事件的 ID,从 1 开始计数 | ||||
@@ -12,5 +14,21 @@ namespace JT808.Protocol.MessageBody | |||||
public ushort EventId { get; set; } | public ushort EventId { get; set; } | ||||
public override byte AttachInfoId { get; set; } = 0x04; | public override byte AttachInfoId { get; set; } = 0x04; | ||||
public override byte AttachInfoLength { get; set; } = 2; | public override byte AttachInfoLength { get; set; } = 2; | ||||
public JT808_0x0200_0x04 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x04 jT808LocationAttachImpl0x04 = new JT808_0x0200_0x04(); | |||||
jT808LocationAttachImpl0x04.AttachInfoId = reader.ReadByte(); | |||||
jT808LocationAttachImpl0x04.AttachInfoLength = reader.ReadByte(); | |||||
jT808LocationAttachImpl0x04.EventId = reader.ReadUInt16(); | |||||
return jT808LocationAttachImpl0x04; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x04 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.AttachInfoId); | |||||
writer.WriteByte(value.AttachInfoLength); | |||||
writer.WriteUInt16(value.EventId); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,11 +1,13 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Enums; | using JT808.Protocol.Enums; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
[JT808Formatter(typeof(JT808_0x0200_0x11_Formatter))] | [JT808Formatter(typeof(JT808_0x0200_0x11_Formatter))] | ||||
public class JT808_0x0200_0x11 : JT808_0x0200_BodyBase | |||||
public class JT808_0x0200_0x11 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x11> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 超速报警附加信息 | /// 超速报警附加信息 | ||||
@@ -38,5 +40,29 @@ namespace JT808.Protocol.MessageBody | |||||
} | } | ||||
set { } | set { } | ||||
} | } | ||||
public JT808_0x0200_0x11 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x11 jT808LocationAttachImpl0x11 = new JT808_0x0200_0x11(); | |||||
jT808LocationAttachImpl0x11.AttachInfoId = reader.ReadByte(); | |||||
jT808LocationAttachImpl0x11.AttachInfoLength = reader.ReadByte(); | |||||
jT808LocationAttachImpl0x11.JT808PositionType = (JT808PositionType)reader.ReadByte(); | |||||
if (jT808LocationAttachImpl0x11.JT808PositionType != JT808PositionType.无特定位置) | |||||
{ | |||||
jT808LocationAttachImpl0x11.AreaId = reader.ReadInt32(); | |||||
} | |||||
return jT808LocationAttachImpl0x11; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x11 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.AttachInfoId); | |||||
writer.WriteByte(value.AttachInfoLength); | |||||
writer.WriteByte((byte)value.JT808PositionType); | |||||
if (value.JT808PositionType != JT808PositionType.无特定位置) | |||||
{ | |||||
writer.WriteInt32(value.AreaId); | |||||
} | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,11 +1,13 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Enums; | using JT808.Protocol.Enums; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
[JT808Formatter(typeof(JT808_0x0200_0x12_Formatter))] | [JT808Formatter(typeof(JT808_0x0200_0x12_Formatter))] | ||||
public class JT808_0x0200_0x12 : JT808_0x0200_BodyBase | |||||
public class JT808_0x0200_0x12 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x12> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 位置类型 | /// 位置类型 | ||||
@@ -29,5 +31,25 @@ namespace JT808.Protocol.MessageBody | |||||
public JT808DirectionType Direction { get; set; } | public JT808DirectionType Direction { get; set; } | ||||
public override byte AttachInfoId { get; set; } = 0x12; | public override byte AttachInfoId { get; set; } = 0x12; | ||||
public override byte AttachInfoLength { get; set; } = 6; | public override byte AttachInfoLength { get; set; } = 6; | ||||
public JT808_0x0200_0x12 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x12 jT808LocationAttachImpl0x12 = new JT808_0x0200_0x12(); | |||||
jT808LocationAttachImpl0x12.AttachInfoId = reader.ReadByte(); | |||||
jT808LocationAttachImpl0x12.AttachInfoLength = reader.ReadByte(); | |||||
jT808LocationAttachImpl0x12.JT808PositionType = (JT808PositionType)reader.ReadByte(); | |||||
jT808LocationAttachImpl0x12.AreaId = reader.ReadInt32(); | |||||
jT808LocationAttachImpl0x12.Direction = (JT808DirectionType)reader.ReadByte(); | |||||
return jT808LocationAttachImpl0x12; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x12 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.AttachInfoId); | |||||
writer.WriteByte(value.AttachInfoLength); | |||||
writer.WriteByte((byte)value.JT808PositionType); | |||||
writer.WriteInt32(value.AreaId); | |||||
writer.WriteByte((byte)value.Direction); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,13 +1,14 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Enums; | using JT808.Protocol.Enums; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
[JT808Formatter(typeof(JT808_0x0200_0x13_Formatter))] | [JT808Formatter(typeof(JT808_0x0200_0x13_Formatter))] | ||||
public class JT808_0x0200_0x13 : JT808_0x0200_BodyBase | |||||
public class JT808_0x0200_0x13 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x13> | |||||
{ | { | ||||
public override byte AttachInfoId { get; set; } = 0x13; | public override byte AttachInfoId { get; set; } = 0x13; | ||||
public override byte AttachInfoLength { get; set; } = 7; | public override byte AttachInfoLength { get; set; } = 7; | ||||
@@ -27,5 +28,25 @@ namespace JT808.Protocol.MessageBody | |||||
/// 结果 0:不足;1:过长 | /// 结果 0:不足;1:过长 | ||||
/// </summary> | /// </summary> | ||||
public JT808DrivenRouteType DrivenRoute { get; set; } | public JT808DrivenRouteType DrivenRoute { get; set; } | ||||
public JT808_0x0200_0x13 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x13 jT808LocationAttachImpl0x13 = new JT808_0x0200_0x13(); | |||||
jT808LocationAttachImpl0x13.AttachInfoId = reader.ReadByte(); | |||||
jT808LocationAttachImpl0x13.AttachInfoLength = reader.ReadByte(); | |||||
jT808LocationAttachImpl0x13.DrivenRouteId = reader.ReadInt32(); | |||||
jT808LocationAttachImpl0x13.Time = reader.ReadUInt16(); | |||||
jT808LocationAttachImpl0x13.DrivenRoute = (JT808DrivenRouteType)reader.ReadByte(); | |||||
return jT808LocationAttachImpl0x13; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x13 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.AttachInfoId); | |||||
writer.WriteByte(value.AttachInfoLength); | |||||
writer.WriteInt32(value.DrivenRouteId); | |||||
writer.WriteUInt16(value.Time); | |||||
writer.WriteByte((byte)value.DrivenRoute); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,11 +1,12 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
[JT808Formatter(typeof(JT808_0x0200_0x25_Formatter))] | [JT808Formatter(typeof(JT808_0x0200_0x25_Formatter))] | ||||
public class JT808_0x0200_0x25 : JT808_0x0200_BodyBase | |||||
public class JT808_0x0200_0x25 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x25> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 扩展车辆信号状态位 | /// 扩展车辆信号状态位 | ||||
@@ -13,5 +14,20 @@ namespace JT808.Protocol.MessageBody | |||||
public int CarSignalStatus { get; set; } | public int CarSignalStatus { get; set; } | ||||
public override byte AttachInfoId { get; set; } = 0x25; | public override byte AttachInfoId { get; set; } = 0x25; | ||||
public override byte AttachInfoLength { get; set; } = 4; | public override byte AttachInfoLength { get; set; } = 4; | ||||
public JT808_0x0200_0x25 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x25 jT808LocationAttachImpl0x13 = new JT808_0x0200_0x25(); | |||||
jT808LocationAttachImpl0x13.AttachInfoId = reader.ReadByte(); | |||||
jT808LocationAttachImpl0x13.AttachInfoLength = reader.ReadByte(); | |||||
jT808LocationAttachImpl0x13.CarSignalStatus = reader.ReadInt32(); | |||||
return jT808LocationAttachImpl0x13; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x25 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.AttachInfoId); | |||||
writer.WriteByte(value.AttachInfoLength); | |||||
writer.WriteInt32(value.CarSignalStatus); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,11 +1,12 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
[JT808Formatter(typeof(JT808_0x0200_0x2A_Formatter))] | [JT808Formatter(typeof(JT808_0x0200_0x2A_Formatter))] | ||||
public class JT808_0x0200_0x2A : JT808_0x0200_BodyBase | |||||
public class JT808_0x0200_0x2A : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x2A> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// IO状态位 | /// IO状态位 | ||||
@@ -13,5 +14,21 @@ namespace JT808.Protocol.MessageBody | |||||
public ushort IOStatus { get; set; } | public ushort IOStatus { get; set; } | ||||
public override byte AttachInfoId { get; set; } = 0x2A; | public override byte AttachInfoId { get; set; } = 0x2A; | ||||
public override byte AttachInfoLength { get; set; } = 2; | public override byte AttachInfoLength { get; set; } = 2; | ||||
public JT808_0x0200_0x2A Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x2A jT808LocationAttachImpl0X2A = new JT808_0x0200_0x2A(); | |||||
jT808LocationAttachImpl0X2A.AttachInfoId = reader.ReadByte(); | |||||
jT808LocationAttachImpl0X2A.AttachInfoLength = reader.ReadByte(); | |||||
jT808LocationAttachImpl0X2A.IOStatus = reader.ReadUInt16(); | |||||
return jT808LocationAttachImpl0X2A; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x2A value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.AttachInfoId); | |||||
writer.WriteByte(value.AttachInfoLength); | |||||
writer.WriteUInt16(value.IOStatus); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,11 +1,12 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
[JT808Formatter(typeof(JT808_0x0200_0x2B_Formatter))] | [JT808Formatter(typeof(JT808_0x0200_0x2B_Formatter))] | ||||
public class JT808_0x0200_0x2B : JT808_0x0200_BodyBase | |||||
public class JT808_0x0200_0x2B : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x2B> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 模拟量 bit0-15,AD0;bit16-31,AD1 | /// 模拟量 bit0-15,AD0;bit16-31,AD1 | ||||
@@ -13,5 +14,20 @@ namespace JT808.Protocol.MessageBody | |||||
public int Analog { get; set; } | public int Analog { get; set; } | ||||
public override byte AttachInfoId { get; set; } = 0x2B; | public override byte AttachInfoId { get; set; } = 0x2B; | ||||
public override byte AttachInfoLength { get; set; } = 4; | public override byte AttachInfoLength { get; set; } = 4; | ||||
public JT808_0x0200_0x2B Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x2B jT808LocationAttachImpl0x2B = new JT808_0x0200_0x2B(); | |||||
jT808LocationAttachImpl0x2B.AttachInfoId = reader.ReadByte(); | |||||
jT808LocationAttachImpl0x2B.AttachInfoLength = reader.ReadByte(); | |||||
jT808LocationAttachImpl0x2B.Analog = reader.ReadInt32(); | |||||
return jT808LocationAttachImpl0x2B; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x2B value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.AttachInfoId); | |||||
writer.WriteByte(value.AttachInfoLength); | |||||
writer.WriteInt32(value.Analog); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,11 +1,12 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
[JT808Formatter(typeof(JT808_0x0200_0x30_Formatter))] | [JT808Formatter(typeof(JT808_0x0200_0x30_Formatter))] | ||||
public class JT808_0x0200_0x30 : JT808_0x0200_BodyBase | |||||
public class JT808_0x0200_0x30 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x30> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 无线通信网络信号强度 | /// 无线通信网络信号强度 | ||||
@@ -13,5 +14,20 @@ namespace JT808.Protocol.MessageBody | |||||
public byte WiFiSignalStrength { get; set; } | public byte WiFiSignalStrength { get; set; } | ||||
public override byte AttachInfoId { get; set; } = 0x30; | public override byte AttachInfoId { get; set; } = 0x30; | ||||
public override byte AttachInfoLength { get; set; } = 1; | public override byte AttachInfoLength { get; set; } = 1; | ||||
public JT808_0x0200_0x30 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x30 jT808LocationAttachImpl0x30 = new JT808_0x0200_0x30(); | |||||
jT808LocationAttachImpl0x30.AttachInfoId = reader.ReadByte(); | |||||
jT808LocationAttachImpl0x30.AttachInfoLength = reader.ReadByte(); | |||||
jT808LocationAttachImpl0x30.WiFiSignalStrength = reader.ReadByte(); | |||||
return jT808LocationAttachImpl0x30; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x30 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.AttachInfoId); | |||||
writer.WriteByte(value.AttachInfoLength); | |||||
writer.WriteByte(value.WiFiSignalStrength); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,10 +1,12 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
[JT808Formatter(typeof(JT808_0x0200_0x31_Formatter))] | [JT808Formatter(typeof(JT808_0x0200_0x31_Formatter))] | ||||
public class JT808_0x0200_0x31 : JT808_0x0200_BodyBase | |||||
public class JT808_0x0200_0x31 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x31> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// GNSS 定位卫星数 | /// GNSS 定位卫星数 | ||||
@@ -12,5 +14,19 @@ namespace JT808.Protocol.MessageBody | |||||
public byte GNSSCount { get; set; } | public byte GNSSCount { get; set; } | ||||
public override byte AttachInfoId { get; set; } = 0x31; | public override byte AttachInfoId { get; set; } = 0x31; | ||||
public override byte AttachInfoLength { get; set; } = 1; | public override byte AttachInfoLength { get; set; } = 1; | ||||
public JT808_0x0200_0x31 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x31 jT808LocationAttachImpl0x31 = new JT808_0x0200_0x31(); | |||||
jT808LocationAttachImpl0x31.AttachInfoId = reader.ReadByte(); | |||||
jT808LocationAttachImpl0x31.AttachInfoLength = reader.ReadByte(); | |||||
jT808LocationAttachImpl0x31.GNSSCount = reader.ReadByte(); | |||||
return jT808LocationAttachImpl0x31; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x31 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.AttachInfoId); | |||||
writer.WriteByte(value.AttachInfoLength); | |||||
writer.WriteByte(value.GNSSCount); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -7,7 +9,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 位置信息查询应答 | /// 位置信息查询应答 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x0201_Formatter))] | [JT808Formatter(typeof(JT808_0x0201_Formatter))] | ||||
public class JT808_0x0201 : JT808Bodies | |||||
public class JT808_0x0201 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0201> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 应答流水号 | /// 应答流水号 | ||||
@@ -19,5 +21,18 @@ namespace JT808.Protocol.MessageBody | |||||
/// 位置信息汇报见 8.12 | /// 位置信息汇报见 8.12 | ||||
/// </summary> | /// </summary> | ||||
public JT808_0x0200 Position { get; set; } | public JT808_0x0200 Position { get; set; } | ||||
public JT808_0x0201 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0201 jT808_0X0201 = new JT808_0x0201(); | |||||
jT808_0X0201.MsgNum = reader.ReadUInt16(); | |||||
jT808_0X0201.Position = config.GetMessagePackFormatter<JT808_0x0200>().Deserialize(ref reader, config); | |||||
return jT808_0X0201; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0201 value, IJT808Config config) | |||||
{ | |||||
writer.WriteUInt16(value.MsgNum); | |||||
config.GetMessagePackFormatter<JT808_0x0200>().Serialize(ref writer, value.Position, config); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -8,11 +10,21 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x0301 | /// 0x0301 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x0301_Formatter))] | [JT808Formatter(typeof(JT808_0x0301_Formatter))] | ||||
public class JT808_0x0301 : JT808Bodies | |||||
public class JT808_0x0301 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0301> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 事件 ID | /// 事件 ID | ||||
/// </summary> | /// </summary> | ||||
public byte EventId { get; set; } | public byte EventId { get; set; } | ||||
public JT808_0x0301 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0301 jT808_0X0301 = new JT808_0x0301(); | |||||
jT808_0X0301.EventId = reader.ReadByte(); | |||||
return jT808_0X0301; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0301 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.EventId); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -8,7 +10,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x0302 | /// 0x0302 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x0302_Formatter))] | [JT808Formatter(typeof(JT808_0x0302_Formatter))] | ||||
public class JT808_0x0302 : JT808Bodies | |||||
public class JT808_0x0302 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0302> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 应答流水号 | /// 应答流水号 | ||||
@@ -20,5 +22,17 @@ namespace JT808.Protocol.MessageBody | |||||
/// 提问下发中附带的答案 ID | /// 提问下发中附带的答案 ID | ||||
/// </summary> | /// </summary> | ||||
public byte AnswerId { get; set; } | public byte AnswerId { get; set; } | ||||
public JT808_0x0302 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0302 jT808_0X0302 = new JT808_0x0302(); | |||||
jT808_0X0302.ReplySNo = reader.ReadUInt16(); | |||||
jT808_0X0302.AnswerId = reader.ReadByte(); | |||||
return jT808_0X0302; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0302 value, IJT808Config config) | |||||
{ | |||||
writer.WriteUInt16(value.ReplySNo); | |||||
writer.WriteByte(value.AnswerId); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -8,7 +10,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x0303 | /// 0x0303 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x0303_Formatter))] | [JT808Formatter(typeof(JT808_0x0303_Formatter))] | ||||
public class JT808_0x0303 : JT808Bodies | |||||
public class JT808_0x0303 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0303> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 信息类型 | /// 信息类型 | ||||
@@ -18,5 +20,18 @@ namespace JT808.Protocol.MessageBody | |||||
/// 点播/取消标志 | /// 点播/取消标志 | ||||
/// </summary> | /// </summary> | ||||
public byte Flag { get; set; } | public byte Flag { get; set; } | ||||
public JT808_0x0303 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0303 jT808_0X0303 = new JT808_0x0303(); | |||||
jT808_0X0303.InformationType = reader.ReadByte(); | |||||
jT808_0X0303.Flag = reader.ReadByte(); | |||||
return jT808_0X0303; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0303 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.InformationType); | |||||
writer.WriteByte(value.Flag); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -7,7 +9,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 车辆控制应答 | /// 车辆控制应答 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x0500_Formatter))] | [JT808Formatter(typeof(JT808_0x0500_Formatter))] | ||||
public class JT808_0x0500 : JT808Bodies | |||||
public class JT808_0x0500 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0500> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 应答流水号 | /// 应答流水号 | ||||
@@ -18,5 +20,18 @@ namespace JT808.Protocol.MessageBody | |||||
/// 位置信息汇报消息体 | /// 位置信息汇报消息体 | ||||
/// </summary> | /// </summary> | ||||
public JT808_0x0200 JT808_0x0200 { get; set; } | public JT808_0x0200 JT808_0x0200 { get; set; } | ||||
public JT808_0x0500 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0500 jT808_0X0500 = new JT808_0x0500(); | |||||
jT808_0X0500.MsgNum = reader.ReadUInt16(); | |||||
jT808_0X0500.JT808_0x0200 = config.GetMessagePackFormatter<JT808_0x0200>().Deserialize(ref reader, config); | |||||
return jT808_0X0500; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0500 value, IJT808Config config) | |||||
{ | |||||
writer.WriteUInt16(value.MsgNum); | |||||
config.GetMessagePackFormatter<JT808_0x0200>().Serialize(ref writer, value.JT808_0x0200, config); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,8 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Extensions; | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
using System; | using System; | ||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
@@ -9,7 +12,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x0701 | /// 0x0701 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x0701_Formatter))] | [JT808Formatter(typeof(JT808_0x0701_Formatter))] | ||||
public class JT808_0x0701 : JT808Bodies | |||||
public class JT808_0x0701 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0701> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 电子运单长度 | /// 电子运单长度 | ||||
@@ -23,5 +26,21 @@ namespace JT808.Protocol.MessageBody | |||||
/// 注意:需要具体的实现 | /// 注意:需要具体的实现 | ||||
/// </summary> | /// </summary> | ||||
public JT808_0x0701_CustomBodyBase ElectronicContentObj { get; set; } | public JT808_0x0701_CustomBodyBase ElectronicContentObj { get; set; } | ||||
public JT808_0x0701 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0701 jT808_0X0701 = new JT808_0x0701(); | |||||
jT808_0X0701.ElectronicWaybillLength = reader.ReadUInt32(); | |||||
jT808_0X0701.ElectronicContent = reader.ReadArray((int)jT808_0X0701.ElectronicWaybillLength).ToArray(); | |||||
return jT808_0X0701; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0701 value, IJT808Config config) | |||||
{ | |||||
writer.Skip(4, out int skipPosition); | |||||
object obj = config.GetMessagePackFormatterByType(value.ElectronicContentObj.GetType()); | |||||
JT808MessagePackFormatterResolverExtensions.JT808DynamicSerialize(obj, ref writer, value.ElectronicContentObj, config); | |||||
int contentLength = writer.GetCurrentPosition() - skipPosition - 4; | |||||
writer.WriteInt32Return(contentLength, skipPosition); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,6 +1,8 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Enums; | using JT808.Protocol.Enums; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
using System; | using System; | ||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
@@ -9,7 +11,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 驾驶员身份信息采集上报 | /// 驾驶员身份信息采集上报 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x0702_Formatter))] | [JT808Formatter(typeof(JT808_0x0702_Formatter))] | ||||
public class JT808_0x0702 : JT808Bodies | |||||
public class JT808_0x0702 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0702> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 状态 | /// 状态 | ||||
@@ -58,5 +60,44 @@ namespace JT808.Protocol.MessageBody | |||||
/// 证件有效期 BCD[4] | /// 证件有效期 BCD[4] | ||||
/// </summary> | /// </summary> | ||||
public DateTime CertificateExpiresDate { get; set; } | public DateTime CertificateExpiresDate { get; set; } | ||||
public JT808_0x0702 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0702 jT808_0X0702 = new JT808_0x0702(); | |||||
jT808_0X0702.IC_Card_Status = (JT808ICCardStatus)reader.ReadByte(); | |||||
jT808_0X0702.IC_Card_PlugDateTime = reader.ReadDateTime6(); | |||||
if (jT808_0X0702.IC_Card_Status == JT808ICCardStatus.从业资格证IC卡插入_驾驶员上班) | |||||
{ | |||||
jT808_0X0702.IC_Card_ReadResult = (JT808ICCardReadResult)reader.ReadByte(); | |||||
if (jT808_0X0702.IC_Card_ReadResult == JT808ICCardReadResult.IC卡读卡成功) | |||||
{ | |||||
jT808_0X0702.DriverUserNameLength = reader.ReadByte(); | |||||
jT808_0X0702.DriverUserName = reader.ReadString(jT808_0X0702.DriverUserNameLength); | |||||
jT808_0X0702.QualificationCode = reader.ReadString(20); | |||||
jT808_0X0702.LicenseIssuingLength = reader.ReadByte(); | |||||
jT808_0X0702.LicenseIssuing = reader.ReadString(jT808_0X0702.LicenseIssuingLength); | |||||
jT808_0X0702.CertificateExpiresDate = reader.ReadDateTime4(); | |||||
} | |||||
} | |||||
return jT808_0X0702; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0702 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte((byte)value.IC_Card_Status); | |||||
writer.WriteDateTime6(value.IC_Card_PlugDateTime); | |||||
if (value.IC_Card_Status == JT808ICCardStatus.从业资格证IC卡插入_驾驶员上班) | |||||
{ | |||||
writer.WriteByte((byte)value.IC_Card_ReadResult); | |||||
if (value.IC_Card_ReadResult == JT808ICCardReadResult.IC卡读卡成功) | |||||
{ | |||||
writer.WriteByte((byte)value.DriverUserName.Length); | |||||
writer.WriteString(value.DriverUserName); | |||||
writer.WriteString(value.QualificationCode.PadRight(20, '0')); | |||||
writer.WriteByte((byte)value.LicenseIssuing.Length); | |||||
writer.WriteString(value.LicenseIssuing); | |||||
writer.WriteDateTime4(value.CertificateExpiresDate); | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,8 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
@@ -8,7 +11,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 定位数据批量上传 | /// 定位数据批量上传 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x0704_Formatter))] | [JT808Formatter(typeof(JT808_0x0704_Formatter))] | ||||
public class JT808_0x0704 : JT808Bodies | |||||
public class JT808_0x0704 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0704> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 数据项个数 | /// 数据项个数 | ||||
@@ -33,5 +36,49 @@ namespace JT808.Protocol.MessageBody | |||||
正常位置批量汇报 = 0x00, | 正常位置批量汇报 = 0x00, | ||||
盲区补报 = 0x01 | 盲区补报 = 0x01 | ||||
} | } | ||||
public JT808_0x0704 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0704 jT808_0X0704 = new JT808_0x0704(); | |||||
jT808_0X0704.Count = reader.ReadUInt16(); | |||||
jT808_0X0704.LocationType = (JT808_0x0704.BatchLocationType)reader.ReadByte(); | |||||
List<JT808_0x0200> jT808_0X0200s = new List<JT808_0x0200>(); | |||||
for (int i = 0; i < jT808_0X0704.Count; i++) | |||||
{ | |||||
int buflen = reader.ReadUInt16(); | |||||
try | |||||
{ | |||||
JT808MessagePackReader tmpReader = new JT808MessagePackReader(reader.ReadArray(buflen)); | |||||
JT808_0x0200 jT808_0X0200 = config.GetMessagePackFormatter<JT808_0x0200>().Deserialize(ref tmpReader, config); | |||||
jT808_0X0200s.Add(jT808_0X0200); | |||||
} | |||||
catch (Exception) | |||||
{ | |||||
} | |||||
} | |||||
jT808_0X0704.Positions = jT808_0X0200s; | |||||
return jT808_0X0704; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0704 value, IJT808Config config) | |||||
{ | |||||
writer.WriteUInt16(value.Count); | |||||
writer.WriteByte((byte)value.LocationType); | |||||
foreach (var item in value?.Positions) | |||||
{ | |||||
try | |||||
{ | |||||
writer.Skip(2, out int position); | |||||
config.GetMessagePackFormatter<JT808_0x0200>().Serialize(ref writer, item, config); | |||||
ushort length = (ushort)(writer.GetCurrentPosition() - position - 2); | |||||
writer.WriteUInt16Return(length, position); | |||||
} | |||||
catch (Exception) | |||||
{ | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,8 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Exceptions; | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
using JT808.Protocol.Metadata; | using JT808.Protocol.Metadata; | ||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
@@ -11,7 +14,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x0705 | /// 0x0705 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x0705_Formatter))] | [JT808Formatter(typeof(JT808_0x0705_Formatter))] | ||||
public class JT808_0x0705 : JT808Bodies | |||||
public class JT808_0x0705 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0705> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 数据项个数 | /// 数据项个数 | ||||
@@ -27,5 +30,51 @@ namespace JT808.Protocol.MessageBody | |||||
/// CAN 总线数据项 | /// CAN 总线数据项 | ||||
/// </summary> | /// </summary> | ||||
public List<JT808CanProperty> CanItems { get; set; } | public List<JT808CanProperty> CanItems { get; set; } | ||||
public JT808_0x0705 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0705 jT808_0X0705 = new JT808_0x0705(); | |||||
jT808_0X0705.CanItemCount = reader.ReadUInt16(); | |||||
jT808_0X0705.FirstCanReceiveTime = reader.ReadDateTime5(); | |||||
jT808_0X0705.CanItems = new List<JT808CanProperty>(); | |||||
for (var i = 0; i < jT808_0X0705.CanItemCount; i++) | |||||
{ | |||||
JT808CanProperty jT808CanProperty = new JT808CanProperty(); | |||||
jT808CanProperty.CanId = reader.ReadArray(4).ToArray(); | |||||
if (jT808CanProperty.CanId.Length != 4) | |||||
{ | |||||
throw new JT808Exception(Enums.JT808ErrorCode.NotEnoughLength, $"{nameof(jT808CanProperty.CanId)}->4"); | |||||
} | |||||
jT808CanProperty.CanData = reader.ReadArray(8).ToArray(); | |||||
if (jT808CanProperty.CanData.Length != 8) | |||||
{ | |||||
throw new JT808Exception(Enums.JT808ErrorCode.NotEnoughLength, $"{nameof(jT808CanProperty.CanData)}->8"); | |||||
} | |||||
jT808_0X0705.CanItems.Add(jT808CanProperty); | |||||
} | |||||
return jT808_0X0705; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0705 value, IJT808Config config) | |||||
{ | |||||
if (value.CanItems != null && value.CanItems.Count > 0) | |||||
{ | |||||
writer.WriteUInt16((ushort)value.CanItems.Count); | |||||
writer.WriteDateTime5(value.FirstCanReceiveTime); | |||||
foreach (var item in value.CanItems) | |||||
{ | |||||
if (item.CanId.Length != 4) | |||||
{ | |||||
throw new JT808Exception(Enums.JT808ErrorCode.NotEnoughLength, $"{nameof(item.CanId)}->4"); | |||||
} | |||||
writer.WriteArray(item.CanId); | |||||
if (item.CanData.Length != 8) | |||||
{ | |||||
throw new JT808Exception(Enums.JT808ErrorCode.NotEnoughLength, $"{nameof(item.CanData)}->8"); | |||||
} | |||||
writer.WriteArray(item.CanData); | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -8,7 +10,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x0800 | /// 0x0800 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x0800_Formatter))] | [JT808Formatter(typeof(JT808_0x0800_Formatter))] | ||||
public class JT808_0x0800 : JT808Bodies | |||||
public class JT808_0x0800 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0800> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 多媒体数据 ID | /// 多媒体数据 ID | ||||
@@ -43,5 +45,24 @@ namespace JT808.Protocol.MessageBody | |||||
/// 通道 ID | /// 通道 ID | ||||
/// </summary> | /// </summary> | ||||
public byte ChannelId { get; set; } | public byte ChannelId { get; set; } | ||||
public JT808_0x0800 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0800 jT808_0X0800 = new JT808_0x0800(); | |||||
jT808_0X0800.MultimediaId = reader.ReadUInt32(); | |||||
jT808_0X0800.MultimediaType = reader.ReadByte(); | |||||
jT808_0X0800.MultimediaCodingFormat = reader.ReadByte(); | |||||
jT808_0X0800.EventItemCoding = reader.ReadByte(); | |||||
jT808_0X0800.ChannelId = reader.ReadByte(); | |||||
return jT808_0X0800; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0800 value, IJT808Config config) | |||||
{ | |||||
writer.WriteUInt32(value.MultimediaId); | |||||
writer.WriteByte(value.MultimediaType); | |||||
writer.WriteByte(value.MultimediaCodingFormat); | |||||
writer.WriteByte(value.EventItemCoding); | |||||
writer.WriteByte(value.ChannelId); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -8,7 +10,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x0801 | /// 0x0801 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x0801_Formatter))] | [JT808Formatter(typeof(JT808_0x0801_Formatter))] | ||||
public class JT808_0x0801 : JT808Bodies | |||||
public class JT808_0x0801 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0801> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 多媒体 ID | /// 多媒体 ID | ||||
@@ -43,5 +45,30 @@ namespace JT808.Protocol.MessageBody | |||||
/// 多媒体数据包 | /// 多媒体数据包 | ||||
/// </summary> | /// </summary> | ||||
public byte[] MultimediaDataPackage { get; set; } | public byte[] MultimediaDataPackage { get; set; } | ||||
public JT808_0x0801 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0801 jT808_0X0801 = new JT808_0x0801(); | |||||
jT808_0X0801.MultimediaId = reader.ReadUInt32(); | |||||
jT808_0X0801.MultimediaType = reader.ReadByte(); | |||||
jT808_0X0801.MultimediaCodingFormat = reader.ReadByte(); | |||||
jT808_0X0801.EventItemCoding = reader.ReadByte(); | |||||
jT808_0X0801.ChannelId = reader.ReadByte(); | |||||
JT808MessagePackReader positionReader = new JT808MessagePackReader(reader.ReadArray(28)); | |||||
jT808_0X0801.Position = config.GetMessagePackFormatter<JT808_0x0200>().Deserialize(ref positionReader, config); | |||||
jT808_0X0801.MultimediaDataPackage = reader.ReadContent().ToArray(); | |||||
return jT808_0X0801; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0801 value, IJT808Config config) | |||||
{ | |||||
writer.WriteUInt32(value.MultimediaId); | |||||
writer.WriteByte(value.MultimediaType); | |||||
writer.WriteByte(value.MultimediaCodingFormat); | |||||
writer.WriteByte(value.EventItemCoding); | |||||
writer.WriteByte(value.ChannelId); | |||||
config.GetMessagePackFormatter<JT808_0x0200>().Serialize(ref writer, value.Position, config); | |||||
writer.WriteArray(value.MultimediaDataPackage); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
using JT808.Protocol.Metadata; | using JT808.Protocol.Metadata; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
@@ -10,7 +12,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x0802 | /// 0x0802 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x0802_Formatter))] | [JT808Formatter(typeof(JT808_0x0802_Formatter))] | ||||
public class JT808_0x0802 : JT808Bodies | |||||
public class JT808_0x0802 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0802> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 应答流水号 | /// 应答流水号 | ||||
@@ -26,5 +28,39 @@ namespace JT808.Protocol.MessageBody | |||||
/// 检索项集合 | /// 检索项集合 | ||||
/// </summary> | /// </summary> | ||||
public List<JT808MultimediaSearchProperty> MultimediaSearchItems { get; set; } | public List<JT808MultimediaSearchProperty> MultimediaSearchItems { get; set; } | ||||
public JT808_0x0802 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0802 JT808_0x0802 = new JT808_0x0802(); | |||||
JT808_0x0802.MsgNum = reader.ReadUInt16(); | |||||
JT808_0x0802.MultimediaItemCount = reader.ReadUInt16(); | |||||
JT808_0x0802.MultimediaSearchItems = new List<JT808MultimediaSearchProperty>(); | |||||
for (var i = 0; i < JT808_0x0802.MultimediaItemCount; i++) | |||||
{ | |||||
JT808MultimediaSearchProperty jT808MultimediaSearchProperty = new JT808MultimediaSearchProperty(); | |||||
jT808MultimediaSearchProperty.MultimediaId = reader.ReadUInt32(); | |||||
jT808MultimediaSearchProperty.MultimediaType = reader.ReadByte(); | |||||
jT808MultimediaSearchProperty.ChannelId = reader.ReadByte(); | |||||
jT808MultimediaSearchProperty.EventItemCoding = reader.ReadByte(); | |||||
JT808MessagePackReader positionReader = new JT808MessagePackReader(reader.ReadArray(28)); | |||||
jT808MultimediaSearchProperty.Position = config.GetMessagePackFormatter<JT808_0x0200>().Deserialize(ref positionReader, config); | |||||
JT808_0x0802.MultimediaSearchItems.Add(jT808MultimediaSearchProperty); | |||||
} | |||||
return JT808_0x0802; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0802 value, IJT808Config config) | |||||
{ | |||||
writer.WriteUInt16(value.MsgNum); | |||||
writer.WriteUInt16((ushort)value.MultimediaSearchItems.Count); | |||||
foreach (var item in value.MultimediaSearchItems) | |||||
{ | |||||
writer.WriteUInt32(item.MultimediaId); | |||||
writer.WriteByte(item.MultimediaType); | |||||
writer.WriteByte(item.ChannelId); | |||||
writer.WriteByte(item.EventItemCoding); | |||||
config.GetMessagePackFormatter<JT808_0x0200>().Serialize(ref writer, item.Position, config); | |||||
} | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
@@ -9,7 +11,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x0805 | /// 0x0805 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x0805_Formatter))] | [JT808Formatter(typeof(JT808_0x0805_Formatter))] | ||||
public class JT808_0x0805 : JT808Bodies | |||||
public class JT808_0x0805 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0805> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 应答流水号 | /// 应答流水号 | ||||
@@ -30,5 +32,31 @@ namespace JT808.Protocol.MessageBody | |||||
/// 多媒体ID列表 | /// 多媒体ID列表 | ||||
/// </summary> | /// </summary> | ||||
public List<uint> MultimediaIds { get; set; } | public List<uint> MultimediaIds { get; set; } | ||||
public JT808_0x0805 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0805 jT808_0X0805 = new JT808_0x0805(); | |||||
jT808_0X0805.MsgNum = reader.ReadUInt16(); | |||||
jT808_0X0805.Result = reader.ReadByte(); | |||||
jT808_0X0805.MultimediaIdCount = reader.ReadUInt16(); | |||||
jT808_0X0805.MultimediaIds = new List<uint>(); | |||||
for (var i = 0; i < jT808_0X0805.MultimediaIdCount; i++) | |||||
{ | |||||
uint id = reader.ReadUInt32(); | |||||
jT808_0X0805.MultimediaIds.Add(id); | |||||
} | |||||
return jT808_0X0805; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0805 value, IJT808Config config) | |||||
{ | |||||
writer.WriteUInt16(value.MsgNum); | |||||
writer.WriteByte(value.Result); | |||||
writer.WriteUInt16((ushort)value.MultimediaIds.Count); | |||||
foreach (var item in value.MultimediaIds) | |||||
{ | |||||
writer.WriteUInt32(item); | |||||
} | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,8 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Extensions; | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -7,7 +10,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 数据上行透传 | /// 数据上行透传 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x0900_Formatter))] | [JT808Formatter(typeof(JT808_0x0900_Formatter))] | ||||
public class JT808_0x0900 : JT808Bodies | |||||
public class JT808_0x0900 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0900> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 透传消息类型 | /// 透传消息类型 | ||||
@@ -23,5 +26,20 @@ namespace JT808.Protocol.MessageBody | |||||
/// 透传消息内容 | /// 透传消息内容 | ||||
/// </summary> | /// </summary> | ||||
public JT808_0x0900_BodyBase JT808_0x0900_BodyBase { get; set; } | public JT808_0x0900_BodyBase JT808_0x0900_BodyBase { get; set; } | ||||
public JT808_0x0900 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0900 jT808_0X0900 = new JT808_0x0900(); | |||||
jT808_0X0900.PassthroughType = reader.ReadByte(); | |||||
jT808_0X0900.PassthroughData = reader.ReadContent().ToArray(); ; | |||||
return jT808_0X0900; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0900 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.PassthroughType); | |||||
object obj = config.GetMessagePackFormatterByType(value.JT808_0x0900_BodyBase.GetType()); | |||||
JT808MessagePackFormatterResolverExtensions.JT808DynamicSerialize(obj, ref writer, value.JT808_0x0900_BodyBase, config); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -8,7 +10,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x0901 | /// 0x0901 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x0901_Formatter))] | [JT808Formatter(typeof(JT808_0x0901_Formatter))] | ||||
public class JT808_0x0901 : JT808Bodies | |||||
public class JT808_0x0901 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0901> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 未压缩消息长度 | /// 未压缩消息长度 | ||||
@@ -20,5 +22,21 @@ namespace JT808.Protocol.MessageBody | |||||
/// 可实现 <see cref="JT808.Protocol.IJT808ICompress"/>自定义压缩算法 | /// 可实现 <see cref="JT808.Protocol.IJT808ICompress"/>自定义压缩算法 | ||||
/// </summary> | /// </summary> | ||||
public byte[] UnCompressMessage { get; set; } | public byte[] UnCompressMessage { get; set; } | ||||
public JT808_0x0901 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0901 jT808_0X0901 = new JT808_0x0901(); | |||||
var compressMessageLength = reader.ReadUInt32(); | |||||
var data = reader.ReadArray((int)compressMessageLength); | |||||
jT808_0X0901.UnCompressMessage = config.Compress.Decompress(data.ToArray()); | |||||
jT808_0X0901.UnCompressMessageLength = (uint)jT808_0X0901.UnCompressMessage.Length; | |||||
return jT808_0X0901; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0901 value, IJT808Config config) | |||||
{ | |||||
var data = config.Compress.Compress(value.UnCompressMessage); | |||||
writer.WriteUInt32((uint)data.Length); | |||||
writer.WriteArray(data); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,8 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Exceptions; | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -8,7 +11,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x0A00 | /// 0x0A00 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x0A00_Formatter))] | [JT808Formatter(typeof(JT808_0x0A00_Formatter))] | ||||
public class JT808_0x0A00 : JT808Bodies | |||||
public class JT808_0x0A00 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0A00> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// e | /// e | ||||
@@ -20,5 +23,28 @@ namespace JT808.Protocol.MessageBody | |||||
/// RSA 公钥{e,n}中的 n | /// RSA 公钥{e,n}中的 n | ||||
/// </summary> | /// </summary> | ||||
public byte[] N { get; set; } | public byte[] N { get; set; } | ||||
public JT808_0x0A00 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0A00 jT808_0X0A00 = new JT808_0x0A00 | |||||
{ | |||||
E = reader.ReadUInt32(), | |||||
N = reader.ReadArray(128).ToArray() | |||||
}; | |||||
if (jT808_0X0A00.N.Length != 128) | |||||
{ | |||||
throw new JT808Exception(Enums.JT808ErrorCode.NotEnoughLength, $"{nameof(jT808_0X0A00.N)}->128"); | |||||
} | |||||
return jT808_0X0A00; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0A00 value, IJT808Config config) | |||||
{ | |||||
writer.WriteUInt32(value.E); | |||||
if (value.N.Length != 128) | |||||
{ | |||||
throw new JT808Exception(Enums.JT808ErrorCode.NotEnoughLength, $"{nameof(value.N)}->128"); | |||||
} | |||||
writer.WriteArray(value.N); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,6 +1,8 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Enums; | using JT808.Protocol.Enums; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -8,7 +10,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 平台通用应答 | /// 平台通用应答 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8001_Formatter))] | [JT808Formatter(typeof(JT808_0x8001_Formatter))] | ||||
public class JT808_0x8001 : JT808Bodies | |||||
public class JT808_0x8001 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8001> | |||||
{ | { | ||||
public ushort MsgNum { get; set; } | public ushort MsgNum { get; set; } | ||||
/// <summary> | /// <summary> | ||||
@@ -16,5 +18,20 @@ namespace JT808.Protocol.MessageBody | |||||
/// </summary> | /// </summary> | ||||
public ushort MsgId { get; set; } | public ushort MsgId { get; set; } | ||||
public JT808PlatformResult JT808PlatformResult { get; set; } | public JT808PlatformResult JT808PlatformResult { get; set; } | ||||
public JT808_0x8001 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8001 jT808_0X8001 = new JT808_0x8001(); | |||||
jT808_0X8001.MsgNum = reader.ReadUInt16(); | |||||
jT808_0X8001.MsgId = reader.ReadUInt16(); | |||||
jT808_0X8001.JT808PlatformResult = (JT808PlatformResult)reader.ReadByte(); | |||||
return jT808_0X8001; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8001 value, IJT808Config config) | |||||
{ | |||||
writer.WriteUInt16(value.MsgNum); | |||||
writer.WriteUInt16(value.MsgId); | |||||
writer.WriteByte((byte)value.JT808PlatformResult); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -8,7 +10,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x8003 | /// 0x8003 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8003_Formatter))] | [JT808Formatter(typeof(JT808_0x8003_Formatter))] | ||||
public class JT808_0x8003 : JT808Bodies | |||||
public class JT808_0x8003 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8003> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 原始消息流水号 | /// 原始消息流水号 | ||||
@@ -26,5 +28,20 @@ namespace JT808.Protocol.MessageBody | |||||
/// 重传包序号顺序排列,如“包 ID1 包 ID2......包 IDn”。 | /// 重传包序号顺序排列,如“包 ID1 包 ID2......包 IDn”。 | ||||
/// </summary> | /// </summary> | ||||
public byte[] AgainPackageData { get; set; } | public byte[] AgainPackageData { get; set; } | ||||
public JT808_0x8003 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8003 jT808_0X8003 = new JT808_0x8003(); | |||||
jT808_0X8003.OriginalMsgNum = reader.ReadUInt16(); | |||||
jT808_0X8003.AgainPackageCount = reader.ReadByte(); | |||||
jT808_0X8003.AgainPackageData = reader.ReadArray(jT808_0X8003.AgainPackageCount * 2).ToArray(); | |||||
return jT808_0X8003; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8003 value, IJT808Config config) | |||||
{ | |||||
writer.WriteUInt16(value.OriginalMsgNum); | |||||
writer.WriteByte((byte)(value.AgainPackageData.Length / 2)); | |||||
writer.WriteArray(value.AgainPackageData); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,6 +1,8 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Enums; | using JT808.Protocol.Enums; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -8,7 +10,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 终端注册应答 | /// 终端注册应答 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8100_Formatter))] | [JT808Formatter(typeof(JT808_0x8100_Formatter))] | ||||
public class JT808_0x8100 : JT808Bodies | |||||
public class JT808_0x8100 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8100> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 应答流水号 | /// 应答流水号 | ||||
@@ -26,5 +28,29 @@ namespace JT808.Protocol.MessageBody | |||||
/// 只有在成功后才有该字段 | /// 只有在成功后才有该字段 | ||||
/// </summary> | /// </summary> | ||||
public string Code { get; set; } | public string Code { get; set; } | ||||
public JT808_0x8100 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8100 jT808_0X8100 = new JT808_0x8100(); | |||||
jT808_0X8100.MsgNum = reader.ReadUInt16(); | |||||
jT808_0X8100.JT808TerminalRegisterResult = (JT808TerminalRegisterResult)reader.ReadByte(); | |||||
// 只有在成功后才有该字段 | |||||
if (jT808_0X8100.JT808TerminalRegisterResult == JT808TerminalRegisterResult.成功) | |||||
{ | |||||
jT808_0X8100.Code = reader.ReadRemainStringContent(); | |||||
} | |||||
return jT808_0X8100; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8100 value, IJT808Config config) | |||||
{ | |||||
writer.WriteUInt16(value.MsgNum); | |||||
writer.WriteByte((byte)value.JT808TerminalRegisterResult); | |||||
// 只有在成功后才有该字段 | |||||
if (value.JT808TerminalRegisterResult == JT808TerminalRegisterResult.成功) | |||||
{ | |||||
writer.WriteString(value.Code); | |||||
} | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
using System; | using System; | ||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
@@ -8,7 +10,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 终端控制 | /// 终端控制 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8105_Formatter))] | [JT808Formatter(typeof(JT808_0x8105_Formatter))] | ||||
public class JT808_0x8105 : JT808Bodies | |||||
public class JT808_0x8105 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8105> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 命令字 | /// 命令字 | ||||
@@ -18,6 +20,29 @@ namespace JT808.Protocol.MessageBody | |||||
/// 命令参数 | /// 命令参数 | ||||
/// </summary> | /// </summary> | ||||
public CommandParams CommandValue { get; set; } | public CommandParams CommandValue { get; set; } | ||||
public JT808_0x8105 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8105 jT808_0x8105 = new JT808_0x8105 | |||||
{ | |||||
CommandWord = reader.ReadByte() | |||||
}; | |||||
if (jT808_0x8105.CommandWord == 1 || jT808_0x8105.CommandWord == 2) | |||||
{ | |||||
jT808_0x8105.CommandValue = new CommandParams(); | |||||
jT808_0x8105.CommandValue.SetCommandParams(reader.ReadRemainStringContent()); | |||||
} | |||||
return jT808_0x8105; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8105 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.CommandWord); | |||||
if (value.CommandWord == 1 || value.CommandWord == 2) | |||||
{ | |||||
writer.WriteString(value.CommandValue.ToString()); | |||||
} | |||||
} | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 命令参数 | /// 命令参数 | ||||
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
using System; | using System; | ||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
@@ -9,7 +11,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x8106 | /// 0x8106 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8106_Formatter))] | [JT808Formatter(typeof(JT808_0x8106_Formatter))] | ||||
public class JT808_0x8106 : JT808Bodies | |||||
public class JT808_0x8106 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8106> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 参数总数 | /// 参数总数 | ||||
@@ -20,6 +22,28 @@ namespace JT808.Protocol.MessageBody | |||||
/// 参数 ID 列表 | /// 参数 ID 列表 | ||||
/// 参数顺序排列,如“参数 ID1 参数 ID2......参数IDn”。 | /// 参数顺序排列,如“参数 ID1 参数 ID2......参数IDn”。 | ||||
/// </summary> | /// </summary> | ||||
public UInt32[] Parameters { get; set; } | |||||
public uint[] Parameters { get; set; } | |||||
public JT808_0x8106 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8106 jT808_0X8106 = new JT808_0x8106(); | |||||
jT808_0X8106.ParameterCount = reader.ReadByte(); | |||||
jT808_0X8106.Parameters = new uint[jT808_0X8106.ParameterCount]; | |||||
for (int i = 0; i < jT808_0X8106.ParameterCount; i++) | |||||
{ | |||||
jT808_0X8106.Parameters.SetValue(reader.ReadUInt32(), i); | |||||
} | |||||
return jT808_0X8106; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8106 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.ParameterCount); | |||||
for (int i = 0; i < value.ParameterCount; i++) | |||||
{ | |||||
writer.WriteUInt32(value.Parameters[i]); | |||||
} | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,6 +1,8 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Enums; | using JT808.Protocol.Enums; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -8,7 +10,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 下发终端升级包 | /// 下发终端升级包 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8108_Formatter))] | [JT808Formatter(typeof(JT808_0x8108_Formatter))] | ||||
public class JT808_0x8108 : JT808Bodies | |||||
public class JT808_0x8108 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8108> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 升级类型 | /// 升级类型 | ||||
@@ -35,5 +37,27 @@ namespace JT808.Protocol.MessageBody | |||||
/// 升级数据包 | /// 升级数据包 | ||||
/// </summary> | /// </summary> | ||||
public byte[] UpgradePackage { get; set; } | public byte[] UpgradePackage { get; set; } | ||||
public JT808_0x8108 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8108 jT808_0X8108 = new JT808_0x8108(); | |||||
jT808_0X8108.UpgradeType = (JT808UpgradeType)reader.ReadByte(); | |||||
jT808_0X8108.MakerId = reader.ReadString(5); | |||||
jT808_0X8108.VersionNumLength = reader.ReadByte(); | |||||
jT808_0X8108.VersionNum = reader.ReadString(jT808_0X8108.VersionNumLength); | |||||
jT808_0X8108.UpgradePackageLength = reader.ReadInt32(); | |||||
jT808_0X8108.UpgradePackage = reader.ReadArray(jT808_0X8108.UpgradePackageLength).ToArray(); | |||||
return jT808_0X8108; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8108 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte((byte)value.UpgradeType); | |||||
writer.WriteString(value.MakerId.PadRight(5, '0')); | |||||
writer.WriteByte((byte)value.VersionNum.Length); | |||||
writer.WriteString(value.VersionNum); | |||||
writer.WriteInt32(value.UpgradePackage.Length); | |||||
writer.WriteArray(value.UpgradePackage); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -7,7 +9,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 临时位置跟踪控制 | /// 临时位置跟踪控制 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8202_Formatter))] | [JT808Formatter(typeof(JT808_0x8202_Formatter))] | ||||
public class JT808_0x8202 : JT808Bodies | |||||
public class JT808_0x8202 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8202> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 时间间隔 | /// 时间间隔 | ||||
@@ -20,5 +22,18 @@ namespace JT808.Protocol.MessageBody | |||||
/// 单位为秒(s),终端在接收到位置跟踪控制消息后,在有效期截止时间之前,依据消息中的时间间隔发送位置汇报 | /// 单位为秒(s),终端在接收到位置跟踪控制消息后,在有效期截止时间之前,依据消息中的时间间隔发送位置汇报 | ||||
/// </summary> | /// </summary> | ||||
public int LocationTrackingValidity { get; set; } | public int LocationTrackingValidity { get; set; } | ||||
public JT808_0x8202 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8202 jT808_0X8202 = new JT808_0x8202(); | |||||
jT808_0X8202.Interval = reader.ReadUInt16(); | |||||
jT808_0X8202.LocationTrackingValidity = reader.ReadInt32(); | |||||
return jT808_0X8202; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8202 value, IJT808Config config) | |||||
{ | |||||
writer.WriteUInt16(value.Interval); | |||||
writer.WriteInt32(value.LocationTrackingValidity); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -8,7 +10,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x8203 | /// 0x8203 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8203_Formatter))] | [JT808Formatter(typeof(JT808_0x8203_Formatter))] | ||||
public class JT808_0x8203 : JT808Bodies | |||||
public class JT808_0x8203 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8203> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 报警消息流水号 | /// 报警消息流水号 | ||||
@@ -19,5 +21,19 @@ namespace JT808.Protocol.MessageBody | |||||
/// 人工确认报警类型 | /// 人工确认报警类型 | ||||
/// </summary> | /// </summary> | ||||
public uint ManualConfirmAlarmType { get; set; } | public uint ManualConfirmAlarmType { get; set; } | ||||
public JT808_0x8203 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8203 jT808_0X8203 = new JT808_0x8203(); | |||||
jT808_0X8203.AlarmMsgNum = reader.ReadUInt16(); | |||||
jT808_0X8203.ManualConfirmAlarmType = reader.ReadUInt32(); | |||||
return jT808_0X8203; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8203 value, IJT808Config config) | |||||
{ | |||||
writer.WriteUInt16(value.AlarmMsgNum); | |||||
writer.WriteUInt32(value.ManualConfirmAlarmType); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -7,7 +9,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 文本信息下发 | /// 文本信息下发 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8300_Formatter))] | [JT808Formatter(typeof(JT808_0x8300_Formatter))] | ||||
public class JT808_0x8300 : JT808Bodies | |||||
public class JT808_0x8300 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8300> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 文本信息标志位含义见 表 38 | /// 文本信息标志位含义见 表 38 | ||||
@@ -19,5 +21,19 @@ namespace JT808.Protocol.MessageBody | |||||
/// 最长为 1024 字节,经GBK编码 | /// 最长为 1024 字节,经GBK编码 | ||||
/// </summary> | /// </summary> | ||||
public string TextInfo { get; set; } | public string TextInfo { get; set; } | ||||
public JT808_0x8300 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8300 jT808_0X8300 = new JT808_0x8300(); | |||||
jT808_0X8300.TextFlag = reader.ReadByte(); | |||||
jT808_0X8300.TextInfo = reader.ReadRemainStringContent(); | |||||
return jT808_0X8300; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8300 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.TextFlag); | |||||
writer.WriteString(value.TextInfo); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
using JT808.Protocol.Metadata; | using JT808.Protocol.Metadata; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
@@ -10,7 +12,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x8301 | /// 0x8301 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8301_Formatter))] | [JT808Formatter(typeof(JT808_0x8301_Formatter))] | ||||
public class JT808_0x8301 : JT808Bodies | |||||
public class JT808_0x8301 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8301> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 设置类型 | /// 设置类型 | ||||
@@ -25,5 +27,40 @@ namespace JT808.Protocol.MessageBody | |||||
/// 事件项 | /// 事件项 | ||||
/// </summary> | /// </summary> | ||||
public List<JT808EventProperty> EventItems { get; set; } | public List<JT808EventProperty> EventItems { get; set; } | ||||
public JT808_0x8301 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8301 jT808_0X8301 = new JT808_0x8301(); | |||||
jT808_0X8301.SettingType = reader.ReadByte(); | |||||
jT808_0X8301.SettingCount = reader.ReadByte(); | |||||
jT808_0X8301.EventItems = new List<JT808EventProperty>(); | |||||
for (var i = 0; i < jT808_0X8301.SettingCount; i++) | |||||
{ | |||||
JT808EventProperty jT808EventProperty = new JT808EventProperty(); | |||||
jT808EventProperty.EventId = reader.ReadByte(); | |||||
jT808EventProperty.EventContentLength = reader.ReadByte(); | |||||
jT808EventProperty.EventContent = reader.ReadString(jT808EventProperty.EventContentLength); | |||||
jT808_0X8301.EventItems.Add(jT808EventProperty); | |||||
} | |||||
return jT808_0X8301; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8301 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.SettingType); | |||||
if (value.EventItems != null && value.EventItems.Count > 0) | |||||
{ | |||||
writer.WriteByte((byte)value.EventItems.Count); | |||||
foreach (var item in value.EventItems) | |||||
{ | |||||
writer.WriteByte(item.EventId); | |||||
// 先计算内容长度(汉字为两个字节) | |||||
writer.Skip(1, out int eventPosition); | |||||
writer.WriteString(item.EventContent); | |||||
byte eventLength = (byte)(writer.GetCurrentPosition() - eventPosition - 1); | |||||
writer.WriteByteReturn(eventLength, eventPosition); | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,8 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
@@ -9,7 +12,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x8302 | /// 0x8302 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8302_Formatter))] | [JT808Formatter(typeof(JT808_0x8302_Formatter))] | ||||
public class JT808_0x8302 : JT808Bodies | |||||
public class JT808_0x8302 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8302> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 标志 | /// 标志 | ||||
@@ -47,5 +50,51 @@ namespace JT808.Protocol.MessageBody | |||||
/// </summary> | /// </summary> | ||||
public string Content { get; set; } | public string Content { get; set; } | ||||
} | } | ||||
public JT808_0x8302 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8302 jT808_0X8302 = new JT808_0x8302(); | |||||
jT808_0X8302.Flag = reader.ReadByte(); | |||||
jT808_0X8302.IssueContentLength = reader.ReadByte(); | |||||
jT808_0X8302.Issue = reader.ReadString(jT808_0X8302.IssueContentLength); | |||||
jT808_0X8302.Answers = new List<JT808_0x8302.Answer>(); | |||||
while (reader.ReadCurrentRemainContentLength() > 0) | |||||
{ | |||||
try | |||||
{ | |||||
JT808_0x8302.Answer answer = new JT808_0x8302.Answer(); | |||||
answer.Id = reader.ReadByte(); | |||||
answer.ContentLength = reader.ReadUInt16(); | |||||
answer.Content = reader.ReadString(answer.ContentLength); | |||||
jT808_0X8302.Answers.Add(answer); | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
break; | |||||
} | |||||
} | |||||
return jT808_0X8302; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8302 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.Flag); | |||||
// 先计算内容长度(汉字为两个字节) | |||||
writer.Skip(1, out int issuePosition); | |||||
writer.WriteString(value.Issue); | |||||
ushort issueLength = (ushort)(writer.GetCurrentPosition() - issuePosition - 1); | |||||
writer.WriteByteReturn((byte)issueLength, issuePosition); | |||||
if (value.Answers != null && value.Answers.Count > 0) | |||||
{ | |||||
foreach (var item in value.Answers) | |||||
{ | |||||
writer.WriteByte(item.Id); | |||||
writer.Skip(2, out int answerPosition); | |||||
writer.WriteString(item.Content); | |||||
ushort answerLength = (ushort)(writer.GetCurrentPosition() - answerPosition - 2); | |||||
writer.WriteUInt16Return(answerLength, answerPosition); | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
using JT808.Protocol.Metadata; | using JT808.Protocol.Metadata; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
@@ -10,7 +12,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x8303 | /// 0x8303 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8303_Formatter))] | [JT808Formatter(typeof(JT808_0x8303_Formatter))] | ||||
public class JT808_0x8303 : JT808Bodies | |||||
public class JT808_0x8303 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8303> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 设置类型 | /// 设置类型 | ||||
@@ -26,5 +28,36 @@ namespace JT808.Protocol.MessageBody | |||||
/// 信息项列表 | /// 信息项列表 | ||||
/// </summary> | /// </summary> | ||||
public List<JT808InformationItemProperty> InformationItems { get; set; } | public List<JT808InformationItemProperty> InformationItems { get; set; } | ||||
public JT808_0x8303 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8303 jT808_0X8303 = new JT808_0x8303(); | |||||
jT808_0X8303.SettingType = reader.ReadByte(); | |||||
jT808_0X8303.InformationItemCount = reader.ReadByte(); | |||||
jT808_0X8303.InformationItems = new List<JT808InformationItemProperty>(); | |||||
for (var i = 0; i < jT808_0X8303.InformationItemCount; i++) | |||||
{ | |||||
JT808InformationItemProperty jT808InformationItemProperty = new JT808InformationItemProperty(); | |||||
jT808InformationItemProperty.InformationType = reader.ReadByte(); | |||||
jT808InformationItemProperty.InformationLength = reader.ReadUInt16(); | |||||
jT808InformationItemProperty.InformationName = reader.ReadString(jT808InformationItemProperty.InformationLength); | |||||
jT808_0X8303.InformationItems.Add(jT808InformationItemProperty); | |||||
} | |||||
return jT808_0X8303; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8303 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.SettingType); | |||||
writer.WriteByte((byte)value.InformationItems.Count); | |||||
foreach (var item in value.InformationItems) | |||||
{ | |||||
writer.WriteByte(item.InformationType); | |||||
// 先计算内容长度(汉字为两个字节) | |||||
writer.Skip(2, out int position); | |||||
writer.WriteString(item.InformationName); | |||||
ushort length = (ushort)(writer.GetCurrentPosition() - position - 2); | |||||
writer.WriteUInt16Return(length, position); | |||||
} | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -8,7 +10,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x8304 | /// 0x8304 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8304_Formatter))] | [JT808Formatter(typeof(JT808_0x8304_Formatter))] | ||||
public class JT808_0x8304 : JT808Bodies | |||||
public class JT808_0x8304 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8304> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 信息类型 | /// 信息类型 | ||||
@@ -23,6 +25,24 @@ namespace JT808.Protocol.MessageBody | |||||
/// 经 GBK 编码 | /// 经 GBK 编码 | ||||
/// </summary> | /// </summary> | ||||
public string InformationContent { get; set; } | public string InformationContent { get; set; } | ||||
public JT808_0x8304 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8304 jT808_0X8304 = new JT808_0x8304(); | |||||
jT808_0X8304.InformationType = reader.ReadByte(); | |||||
jT808_0X8304.InformationLength = reader.ReadUInt16(); | |||||
jT808_0X8304.InformationContent = reader.ReadString(jT808_0X8304.InformationLength); | |||||
return jT808_0X8304; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8304 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.InformationType); | |||||
// 先计算内容长度(汉字为两个字节) | |||||
writer.Skip(2, out int position); | |||||
writer.WriteString(value.InformationContent); | |||||
ushort length = (ushort)(writer.GetCurrentPosition() - position - 2); | |||||
writer.WriteUInt16Return(length, position); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,6 +1,8 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Enums; | using JT808.Protocol.Enums; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -8,7 +10,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 电话回拨 | /// 电话回拨 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8400_Formatter))] | [JT808Formatter(typeof(JT808_0x8400_Formatter))] | ||||
public class JT808_0x8400 : JT808Bodies | |||||
public class JT808_0x8400 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8400> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 0:普通通话;1:监听 | /// 0:普通通话;1:监听 | ||||
@@ -19,5 +21,20 @@ namespace JT808.Protocol.MessageBody | |||||
/// 最长为 20 字节 | /// 最长为 20 字节 | ||||
/// </summary> | /// </summary> | ||||
public string PhoneNumber { get; set; } | public string PhoneNumber { get; set; } | ||||
public JT808_0x8400 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8400 jT808_0X8400 = new JT808_0x8400(); | |||||
jT808_0X8400.CallBack = (JT808CallBackType)reader.ReadByte(); | |||||
// 最长为 20 字节 | |||||
jT808_0X8400.PhoneNumber = reader.ReadRemainStringContent(); | |||||
return jT808_0X8400; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8400 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte((byte)value.CallBack); | |||||
writer.WriteString(value.PhoneNumber); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,6 +1,8 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Enums; | using JT808.Protocol.Enums; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
using JT808.Protocol.Metadata; | using JT808.Protocol.Metadata; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
@@ -10,7 +12,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 设置电话本 | /// 设置电话本 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8401_Formatter))] | [JT808Formatter(typeof(JT808_0x8401_Formatter))] | ||||
public class JT808_0x8401 : JT808Bodies | |||||
public class JT808_0x8401 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8401> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 设置类型 | /// 设置类型 | ||||
@@ -24,5 +26,38 @@ namespace JT808.Protocol.MessageBody | |||||
/// 联系人项 | /// 联系人项 | ||||
/// </summary> | /// </summary> | ||||
public IList<JT808ContactProperty> JT808ContactProperties { get; set; } | public IList<JT808ContactProperty> JT808ContactProperties { get; set; } | ||||
public JT808_0x8401 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8401 jT808_0X8401 = new JT808_0x8401(); | |||||
jT808_0X8401.SettingTelephoneBook = (JT808SettingTelephoneBook)reader.ReadByte(); | |||||
jT808_0X8401.ContactCount = reader.ReadByte(); | |||||
List<JT808ContactProperty> jT808_0X8401s = new List<JT808ContactProperty>(); | |||||
for (var i = 0; i < jT808_0X8401.ContactCount; i++) | |||||
{ | |||||
JT808ContactProperty jT808ContactProperty = new JT808ContactProperty(); | |||||
jT808ContactProperty.TelephoneBookContactType = (JT808TelephoneBookContactType)reader.ReadByte(); | |||||
jT808ContactProperty.PhoneNumberLength = reader.ReadByte(); | |||||
jT808ContactProperty.PhoneNumber = reader.ReadString(jT808ContactProperty.PhoneNumberLength); | |||||
jT808ContactProperty.ContactLength = reader.ReadByte(); | |||||
jT808ContactProperty.Contact = reader.ReadString(jT808ContactProperty.ContactLength); | |||||
jT808_0X8401s.Add(jT808ContactProperty); | |||||
} | |||||
jT808_0X8401.JT808ContactProperties = jT808_0X8401s; | |||||
return jT808_0X8401; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8401 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte((byte)value.SettingTelephoneBook); | |||||
writer.WriteByte((byte)value.JT808ContactProperties.Count); | |||||
foreach (var item in value.JT808ContactProperties) | |||||
{ | |||||
writer.WriteByte((byte)item.TelephoneBookContactType); | |||||
writer.WriteByte((byte)item.PhoneNumber.Length); | |||||
writer.WriteString(item.PhoneNumber); | |||||
writer.WriteByte((byte)item.Contact.Length); | |||||
writer.WriteString(item.Contact); | |||||
} | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -7,7 +9,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 车辆控制 | /// 车辆控制 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8500_Formatter))] | [JT808Formatter(typeof(JT808_0x8500_Formatter))] | ||||
public class JT808_0x8500 : JT808Bodies | |||||
public class JT808_0x8500 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8500> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 控制标志 | /// 控制标志 | ||||
@@ -16,5 +18,16 @@ namespace JT808.Protocol.MessageBody | |||||
/// 1-7 保留 | /// 1-7 保留 | ||||
/// </summary> | /// </summary> | ||||
public byte ControlFlag { get; set; } | public byte ControlFlag { get; set; } | ||||
public JT808_0x8500 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8500 jT808_0X8500 = new JT808_0x8500(); | |||||
jT808_0X8500.ControlFlag = reader.ReadByte(); | |||||
return jT808_0X8500; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8500 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.ControlFlag); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,6 +1,9 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
using JT808.Protocol.Metadata; | using JT808.Protocol.Metadata; | ||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
@@ -11,7 +14,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 注:本条消息协议支持周期时间范围,如要限制每天的8:30-18:00,起始/结束时间设为:00-00-00-08-30-00/00-00-00-18-00-00,其他以此类推 | /// 注:本条消息协议支持周期时间范围,如要限制每天的8:30-18:00,起始/结束时间设为:00-00-00-08-30-00/00-00-00-18-00-00,其他以此类推 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8600_Formatter))] | [JT808Formatter(typeof(JT808_0x8600_Formatter))] | ||||
public class JT808_0x8600 : JT808Bodies | |||||
public class JT808_0x8600 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8600> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 设置属性 | /// 设置属性 | ||||
@@ -26,5 +29,79 @@ namespace JT808.Protocol.MessageBody | |||||
/// 区域项 | /// 区域项 | ||||
/// </summary> | /// </summary> | ||||
public List<JT808CircleAreaProperty> AreaItems { get; set; } | public List<JT808CircleAreaProperty> AreaItems { get; set; } | ||||
public JT808_0x8600 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8600 jT808_0X8600 = new JT808_0x8600(); | |||||
jT808_0X8600.SettingAreaProperty = reader.ReadByte(); | |||||
jT808_0X8600.AreaCount = reader.ReadByte(); | |||||
jT808_0X8600.AreaItems = new List<JT808CircleAreaProperty>(); | |||||
for (var i = 0; i < jT808_0X8600.AreaCount; i++) | |||||
{ | |||||
JT808CircleAreaProperty jT808CircleAreaProperty = new JT808CircleAreaProperty(); | |||||
jT808CircleAreaProperty.AreaId = reader.ReadUInt32(); | |||||
jT808CircleAreaProperty.AreaProperty = reader.ReadUInt16(); | |||||
jT808CircleAreaProperty.CenterPointLat = reader.ReadUInt32(); | |||||
jT808CircleAreaProperty.CenterPointLng = reader.ReadUInt32(); | |||||
jT808CircleAreaProperty.Radius = reader.ReadUInt32(); | |||||
ReadOnlySpan<char> areaProperty16Bit = Convert.ToString(jT808CircleAreaProperty.AreaProperty, 2).PadLeft(16, '0').AsSpan(); | |||||
bool bit0Flag = areaProperty16Bit.Slice(areaProperty16Bit.Length - 1).ToString().Equals("0"); | |||||
if (!bit0Flag) | |||||
{ | |||||
jT808CircleAreaProperty.StartTime = reader.ReadDateTime6(); | |||||
jT808CircleAreaProperty.EndTime = reader.ReadDateTime6(); | |||||
} | |||||
bool bit1Flag = areaProperty16Bit.Slice(areaProperty16Bit.Length - 2, 1).ToString().Equals("0"); | |||||
if (!bit1Flag) | |||||
{ | |||||
jT808CircleAreaProperty.HighestSpeed = reader.ReadUInt16(); | |||||
jT808CircleAreaProperty.OverspeedDuration = reader.ReadByte(); | |||||
} | |||||
jT808_0X8600.AreaItems.Add(jT808CircleAreaProperty); | |||||
} | |||||
return jT808_0X8600; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8600 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.SettingAreaProperty); | |||||
if (value.AreaItems != null) | |||||
{ | |||||
writer.WriteByte((byte)value.AreaItems.Count); | |||||
foreach (var item in value.AreaItems) | |||||
{ | |||||
writer.WriteUInt32(item.AreaId); | |||||
writer.WriteUInt16(item.AreaProperty); | |||||
writer.WriteUInt32(item.CenterPointLat); | |||||
writer.WriteUInt32(item.CenterPointLng); | |||||
writer.WriteUInt32(item.Radius); | |||||
ReadOnlySpan<char> areaProperty16Bit = Convert.ToString(item.AreaProperty, 2).PadLeft(16, '0').AsSpan(); | |||||
bool bit0Flag = areaProperty16Bit.Slice(areaProperty16Bit.Length - 1).ToString().Equals("0"); | |||||
if (!bit0Flag) | |||||
{ | |||||
if (item.StartTime.HasValue) | |||||
{ | |||||
writer.WriteDateTime6(item.StartTime.Value); | |||||
} | |||||
if (item.EndTime.HasValue) | |||||
{ | |||||
writer.WriteDateTime6(item.EndTime.Value); | |||||
} | |||||
} | |||||
bool bit1Flag = areaProperty16Bit.Slice(areaProperty16Bit.Length - 2, 1).ToString().Equals("0"); | |||||
if (!bit1Flag) | |||||
{ | |||||
if (item.HighestSpeed.HasValue) | |||||
{ | |||||
writer.WriteUInt16(item.HighestSpeed.Value); | |||||
} | |||||
if (item.OverspeedDuration.HasValue) | |||||
{ | |||||
writer.WriteByte(item.OverspeedDuration.Value); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
@@ -9,7 +11,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x8601 | /// 0x8601 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8601_Formatter))] | [JT808Formatter(typeof(JT808_0x8601_Formatter))] | ||||
public class JT808_0x8601 : JT808Bodies | |||||
public class JT808_0x8601 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8601> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 区域数 | /// 区域数 | ||||
@@ -20,5 +22,29 @@ namespace JT808.Protocol.MessageBody | |||||
/// 区域ID集合 | /// 区域ID集合 | ||||
/// </summary> | /// </summary> | ||||
public List<uint> AreaIds { get; set; } | public List<uint> AreaIds { get; set; } | ||||
public JT808_0x8601 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8601 jT808_0X8601 = new JT808_0x8601(); | |||||
jT808_0X8601.AreaCount = reader.ReadByte(); | |||||
jT808_0X8601.AreaIds = new List<uint>(); | |||||
for (var i = 0; i < jT808_0X8601.AreaCount; i++) | |||||
{ | |||||
jT808_0X8601.AreaIds.Add(reader.ReadUInt32()); | |||||
} | |||||
return jT808_0X8601; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8601 value, IJT808Config config) | |||||
{ | |||||
if (value.AreaIds != null) | |||||
{ | |||||
writer.WriteByte((byte)value.AreaIds.Count); | |||||
foreach (var item in value.AreaIds) | |||||
{ | |||||
writer.WriteUInt32(item); | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,6 +1,9 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
using JT808.Protocol.Metadata; | using JT808.Protocol.Metadata; | ||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
@@ -10,7 +13,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x8602 | /// 0x8602 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8602_Formatter))] | [JT808Formatter(typeof(JT808_0x8602_Formatter))] | ||||
public class JT808_0x8602 : JT808Bodies | |||||
public class JT808_0x8602 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8602> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 设置属性 | /// 设置属性 | ||||
@@ -26,5 +29,80 @@ namespace JT808.Protocol.MessageBody | |||||
/// </summary> | /// </summary> | ||||
public List<JT808RectangleAreaProperty> AreaItems { get; set; } | public List<JT808RectangleAreaProperty> AreaItems { get; set; } | ||||
public JT808_0x8602 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8602 jT808_0X8602 = new JT808_0x8602(); | |||||
jT808_0X8602.SettingAreaProperty = reader.ReadByte(); | |||||
jT808_0X8602.AreaCount = reader.ReadByte(); | |||||
jT808_0X8602.AreaItems = new List<JT808RectangleAreaProperty>(); | |||||
for (var i = 0; i < jT808_0X8602.AreaCount; i++) | |||||
{ | |||||
JT808RectangleAreaProperty jT808CircleAreaProperty = new JT808RectangleAreaProperty(); | |||||
jT808CircleAreaProperty.AreaId = reader.ReadUInt32(); | |||||
jT808CircleAreaProperty.AreaProperty = reader.ReadUInt16(); | |||||
jT808CircleAreaProperty.UpLeftPointLat = reader.ReadUInt32(); | |||||
jT808CircleAreaProperty.UpLeftPointLng = reader.ReadUInt32(); | |||||
jT808CircleAreaProperty.LowRightPointLat = reader.ReadUInt32(); | |||||
jT808CircleAreaProperty.LowRightPointLng = reader.ReadUInt32(); | |||||
ReadOnlySpan<char> areaProperty16Bit = Convert.ToString(jT808CircleAreaProperty.AreaProperty, 2).PadLeft(16, '0').AsSpan(); | |||||
bool bit0Flag = areaProperty16Bit.Slice(areaProperty16Bit.Length - 1).ToString().Equals("0"); | |||||
if (!bit0Flag) | |||||
{ | |||||
jT808CircleAreaProperty.StartTime = reader.ReadDateTime6(); | |||||
jT808CircleAreaProperty.EndTime = reader.ReadDateTime6(); | |||||
} | |||||
bool bit1Flag = areaProperty16Bit.Slice(areaProperty16Bit.Length - 2, 1).ToString().Equals("0"); | |||||
if (!bit1Flag) | |||||
{ | |||||
jT808CircleAreaProperty.HighestSpeed = reader.ReadUInt16(); | |||||
jT808CircleAreaProperty.OverspeedDuration = reader.ReadByte(); | |||||
} | |||||
jT808_0X8602.AreaItems.Add(jT808CircleAreaProperty); | |||||
} | |||||
return jT808_0X8602; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8602 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.SettingAreaProperty); | |||||
if (value.AreaItems != null) | |||||
{ | |||||
writer.WriteByte((byte)value.AreaItems.Count); | |||||
foreach (var item in value.AreaItems) | |||||
{ | |||||
writer.WriteUInt32(item.AreaId); | |||||
writer.WriteUInt16(item.AreaProperty); | |||||
writer.WriteUInt32(item.UpLeftPointLat); | |||||
writer.WriteUInt32(item.UpLeftPointLng); | |||||
writer.WriteUInt32(item.LowRightPointLat); | |||||
writer.WriteUInt32(item.LowRightPointLng); | |||||
ReadOnlySpan<char> areaProperty16Bit = Convert.ToString(item.AreaProperty, 2).PadLeft(16, '0').AsSpan(); | |||||
bool bit0Flag = areaProperty16Bit.Slice(areaProperty16Bit.Length - 1).ToString().Equals("0"); | |||||
if (!bit0Flag) | |||||
{ | |||||
if (item.StartTime.HasValue) | |||||
{ | |||||
writer.WriteDateTime6(item.StartTime.Value); | |||||
} | |||||
if (item.EndTime.HasValue) | |||||
{ | |||||
writer.WriteDateTime6(item.EndTime.Value); | |||||
} | |||||
} | |||||
bool bit1Flag = areaProperty16Bit.Slice(areaProperty16Bit.Length - 2, 1).ToString().Equals("0"); | |||||
if (!bit1Flag) | |||||
{ | |||||
if (item.HighestSpeed.HasValue) | |||||
{ | |||||
writer.WriteUInt16(item.HighestSpeed.Value); | |||||
} | |||||
if (item.OverspeedDuration.HasValue) | |||||
{ | |||||
writer.WriteByte(item.OverspeedDuration.Value); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
@@ -9,7 +11,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x8603 | /// 0x8603 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8603_Formatter))] | [JT808Formatter(typeof(JT808_0x8603_Formatter))] | ||||
public class JT808_0x8603 : JT808Bodies | |||||
public class JT808_0x8603 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8603> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 区域数 | /// 区域数 | ||||
@@ -20,5 +22,29 @@ namespace JT808.Protocol.MessageBody | |||||
/// 区域ID集合 | /// 区域ID集合 | ||||
/// </summary> | /// </summary> | ||||
public List<uint> AreaIds { get; set; } | public List<uint> AreaIds { get; set; } | ||||
public JT808_0x8603 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8603 jT808_0X8603 = new JT808_0x8603(); | |||||
jT808_0X8603.AreaCount = reader.ReadByte(); | |||||
jT808_0X8603.AreaIds = new List<uint>(); | |||||
for (var i = 0; i < jT808_0X8603.AreaCount; i++) | |||||
{ | |||||
jT808_0X8603.AreaIds.Add(reader.ReadUInt32()); | |||||
} | |||||
return jT808_0X8603; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8603 value, IJT808Config config) | |||||
{ | |||||
if (value.AreaIds != null) | |||||
{ | |||||
writer.WriteByte((byte)value.AreaIds.Count); | |||||
foreach (var item in value.AreaIds) | |||||
{ | |||||
writer.WriteUInt32(item); | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
using JT808.Protocol.Metadata; | using JT808.Protocol.Metadata; | ||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
@@ -11,7 +13,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x8604 | /// 0x8604 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8604_Formatter))] | [JT808Formatter(typeof(JT808_0x8604_Formatter))] | ||||
public class JT808_0x8604 : JT808Bodies | |||||
public class JT808_0x8604 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8604> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 区域 ID | /// 区域 ID | ||||
@@ -50,5 +52,75 @@ namespace JT808.Protocol.MessageBody | |||||
/// 顶点项 | /// 顶点项 | ||||
/// </summary> | /// </summary> | ||||
public List<JT808PeakProperty> PeakItems { get; set; } | public List<JT808PeakProperty> PeakItems { get; set; } | ||||
public JT808_0x8604 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8604 jT808_0X8604 = new JT808_0x8604(); | |||||
jT808_0X8604.AreaId = reader.ReadUInt32(); | |||||
jT808_0X8604.AreaProperty = reader.ReadUInt16(); | |||||
ReadOnlySpan<char> areaProperty16Bit = Convert.ToString(jT808_0X8604.AreaProperty, 2).PadLeft(16, '0').AsSpan(); | |||||
bool bit0Flag = areaProperty16Bit.Slice(areaProperty16Bit.Length - 1).ToString().Equals("0"); | |||||
if (!bit0Flag) | |||||
{ | |||||
jT808_0X8604.StartTime = reader.ReadDateTime6(); | |||||
jT808_0X8604.EndTime = reader.ReadDateTime6(); | |||||
} | |||||
bool bit1Flag = areaProperty16Bit.Slice(areaProperty16Bit.Length - 2, 1).ToString().Equals("0"); | |||||
if (!bit1Flag) | |||||
{ | |||||
jT808_0X8604.HighestSpeed = reader.ReadUInt16(); | |||||
jT808_0X8604.OverspeedDuration = reader.ReadByte(); | |||||
} | |||||
jT808_0X8604.PeakCount = reader.ReadUInt16(); | |||||
jT808_0X8604.PeakItems = new List<JT808PeakProperty>(); | |||||
for (var i = 0; i < jT808_0X8604.PeakCount; i++) | |||||
{ | |||||
var item = new JT808PeakProperty(); | |||||
item.Lat = reader.ReadUInt32(); | |||||
item.Lng = reader.ReadUInt32(); | |||||
jT808_0X8604.PeakItems.Add(item); | |||||
} | |||||
return jT808_0X8604; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8604 value, IJT808Config config) | |||||
{ | |||||
writer.WriteUInt32(value.AreaId); | |||||
writer.WriteUInt16(value.AreaProperty); | |||||
ReadOnlySpan<char> areaProperty16Bit = Convert.ToString(value.AreaProperty, 2).PadLeft(16, '0').AsSpan(); | |||||
bool bit0Flag = areaProperty16Bit.Slice(areaProperty16Bit.Length - 1).ToString().Equals("0"); | |||||
if (!bit0Flag) | |||||
{ | |||||
if (value.StartTime.HasValue) | |||||
{ | |||||
writer.WriteDateTime6(value.StartTime.Value); | |||||
} | |||||
if (value.EndTime.HasValue) | |||||
{ | |||||
writer.WriteDateTime6(value.EndTime.Value); | |||||
} | |||||
} | |||||
bool bit1Flag = areaProperty16Bit.Slice(areaProperty16Bit.Length - 2, 1).ToString().Equals("0"); | |||||
if (!bit1Flag) | |||||
{ | |||||
if (value.HighestSpeed.HasValue) | |||||
{ | |||||
writer.WriteUInt16(value.HighestSpeed.Value); | |||||
} | |||||
if (value.OverspeedDuration.HasValue) | |||||
{ | |||||
writer.WriteByte(value.OverspeedDuration.Value); | |||||
} | |||||
} | |||||
if (value.PeakItems != null && value.PeakItems.Count > 0) | |||||
{ | |||||
writer.WriteUInt16((ushort)value.PeakItems.Count); | |||||
foreach (var item in value.PeakItems) | |||||
{ | |||||
writer.WriteUInt32(item.Lat); | |||||
writer.WriteUInt32(item.Lng); | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
@@ -9,7 +11,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x8605 | /// 0x8605 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8605_Formatter))] | [JT808Formatter(typeof(JT808_0x8605_Formatter))] | ||||
public class JT808_0x8605 : JT808Bodies | |||||
public class JT808_0x8605 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8605> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 区域数 | /// 区域数 | ||||
@@ -20,5 +22,28 @@ namespace JT808.Protocol.MessageBody | |||||
/// 区域ID集合 | /// 区域ID集合 | ||||
/// </summary> | /// </summary> | ||||
public List<uint> AreaIds { get; set; } | public List<uint> AreaIds { get; set; } | ||||
public JT808_0x8605 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8605 jT808_0X8605 = new JT808_0x8605(); | |||||
jT808_0X8605.AreaCount = reader.ReadByte(); | |||||
jT808_0X8605.AreaIds = new List<uint>(); | |||||
for (var i = 0; i < jT808_0X8605.AreaCount; i++) | |||||
{ | |||||
jT808_0X8605.AreaIds.Add(reader.ReadUInt32()); | |||||
} | |||||
return jT808_0X8605; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8605 value, IJT808Config config) | |||||
{ | |||||
if (value.AreaIds != null) | |||||
{ | |||||
writer.WriteByte((byte)value.AreaIds.Count); | |||||
foreach (var item in value.AreaIds) | |||||
{ | |||||
writer.WriteUInt32(item); | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
using JT808.Protocol.Metadata; | using JT808.Protocol.Metadata; | ||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
@@ -11,7 +13,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x8606 | /// 0x8606 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8606_Formatter))] | [JT808Formatter(typeof(JT808_0x8606_Formatter))] | ||||
public class JT808_0x8606 : JT808Bodies | |||||
public class JT808_0x8606 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8606> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 路线 ID | /// 路线 ID | ||||
@@ -40,5 +42,94 @@ namespace JT808.Protocol.MessageBody | |||||
/// 拐点项 | /// 拐点项 | ||||
/// </summary> | /// </summary> | ||||
public List<JT808InflectionPointProperty> InflectionPointItems { get; set; } | public List<JT808InflectionPointProperty> InflectionPointItems { get; set; } | ||||
public JT808_0x8606 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8606 jT808_0X8606 = new JT808_0x8606(); | |||||
jT808_0X8606.RouteId = reader.ReadUInt32(); | |||||
jT808_0X8606.RouteProperty = reader.ReadUInt16(); | |||||
ReadOnlySpan<char> routeProperty16Bit = Convert.ToString(jT808_0X8606.RouteProperty, 2).PadLeft(16, '0').AsSpan(); | |||||
bool bit0Flag = routeProperty16Bit.Slice(routeProperty16Bit.Length - 1).ToString().Equals("0"); | |||||
if (!bit0Flag) | |||||
{ | |||||
jT808_0X8606.StartTime = reader.ReadDateTime6(); | |||||
jT808_0X8606.EndTime = reader.ReadDateTime6(); | |||||
} | |||||
jT808_0X8606.InflectionPointCount = reader.ReadUInt16(); | |||||
jT808_0X8606.InflectionPointItems = new List<JT808InflectionPointProperty>(); | |||||
for (var i = 0; i < jT808_0X8606.InflectionPointCount; i++) | |||||
{ | |||||
JT808InflectionPointProperty jT808InflectionPointProperty = new JT808InflectionPointProperty(); | |||||
jT808InflectionPointProperty.InflectionPointId = reader.ReadUInt32(); | |||||
jT808InflectionPointProperty.SectionId = reader.ReadUInt32(); | |||||
jT808InflectionPointProperty.InflectionPointLat = reader.ReadUInt32(); | |||||
jT808InflectionPointProperty.InflectionPointLng = reader.ReadUInt32(); | |||||
jT808InflectionPointProperty.SectionWidth = reader.ReadByte(); | |||||
jT808InflectionPointProperty.SectionProperty = reader.ReadByte(); | |||||
ReadOnlySpan<char> sectionProperty16Bit = Convert.ToString(jT808InflectionPointProperty.SectionProperty, 2).PadLeft(16, '0').AsSpan(); | |||||
bool sectionBit0Flag = sectionProperty16Bit.Slice(sectionProperty16Bit.Length - 1).ToString().Equals("0"); | |||||
if (!sectionBit0Flag) | |||||
{ | |||||
jT808InflectionPointProperty.SectionLongDrivingThreshold = reader.ReadUInt16(); | |||||
jT808InflectionPointProperty.SectionDrivingUnderThreshold = reader.ReadUInt16(); | |||||
} | |||||
bool sectionBit1Flag = sectionProperty16Bit.Slice(sectionProperty16Bit.Length - 2, 1).ToString().Equals("0"); | |||||
if (!sectionBit1Flag) | |||||
{ | |||||
jT808InflectionPointProperty.SectionHighestSpeed = reader.ReadUInt16(); | |||||
jT808InflectionPointProperty.SectionOverspeedDuration = reader.ReadByte(); | |||||
} | |||||
jT808_0X8606.InflectionPointItems.Add(jT808InflectionPointProperty); | |||||
} | |||||
return jT808_0X8606; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8606 value, IJT808Config config) | |||||
{ | |||||
writer.WriteUInt32(value.RouteId); | |||||
writer.WriteUInt16(value.RouteProperty); | |||||
ReadOnlySpan<char> routeProperty16Bit = Convert.ToString(value.RouteProperty, 2).PadLeft(16, '0').AsSpan(); | |||||
bool bit0Flag = routeProperty16Bit.Slice(routeProperty16Bit.Length - 1).ToString().Equals("0"); | |||||
if (!bit0Flag) | |||||
{ | |||||
if (value.StartTime.HasValue) | |||||
writer.WriteDateTime6(value.StartTime.Value); | |||||
if (value.EndTime.HasValue) | |||||
writer.WriteDateTime6(value.EndTime.Value); | |||||
} | |||||
//bool bit1Flag = routeProperty16Bit.Slice(routeProperty16Bit.Length - 2, 1).ToString().Equals("0"); | |||||
if (value.InflectionPointItems != null && value.InflectionPointItems.Count > 0) | |||||
{ | |||||
writer.WriteUInt16((ushort)value.InflectionPointItems.Count); | |||||
foreach (var item in value.InflectionPointItems) | |||||
{ | |||||
writer.WriteUInt32(item.InflectionPointId); | |||||
writer.WriteUInt32(item.SectionId); | |||||
writer.WriteUInt32(item.InflectionPointLat); | |||||
writer.WriteUInt32(item.InflectionPointLng); | |||||
writer.WriteByte(item.SectionWidth); | |||||
writer.WriteByte(item.SectionProperty); | |||||
ReadOnlySpan<char> sectionProperty16Bit = Convert.ToString(item.SectionProperty, 2).PadLeft(16, '0').AsSpan(); | |||||
bool sectionBit0Flag = sectionProperty16Bit.Slice(sectionProperty16Bit.Length - 1).ToString().Equals("0"); | |||||
if (!sectionBit0Flag) | |||||
{ | |||||
if (item.SectionLongDrivingThreshold.HasValue) | |||||
writer.WriteUInt16(item.SectionLongDrivingThreshold.Value); | |||||
if (item.SectionDrivingUnderThreshold.HasValue) | |||||
writer.WriteUInt16(item.SectionDrivingUnderThreshold.Value); | |||||
} | |||||
bool sectionBit1Flag = sectionProperty16Bit.Slice(sectionProperty16Bit.Length - 2, 1).ToString().Equals("0"); | |||||
if (!sectionBit1Flag) | |||||
{ | |||||
if (item.SectionHighestSpeed.HasValue) | |||||
writer.WriteUInt16(item.SectionHighestSpeed.Value); | |||||
if (item.SectionOverspeedDuration.HasValue) | |||||
writer.WriteByte(item.SectionOverspeedDuration.Value); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
@@ -9,7 +11,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x8607 | /// 0x8607 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8607_Formatter))] | [JT808Formatter(typeof(JT808_0x8607_Formatter))] | ||||
public class JT808_0x8607 : JT808Bodies | |||||
public class JT808_0x8607 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8607> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 区域数 | /// 区域数 | ||||
@@ -20,5 +22,29 @@ namespace JT808.Protocol.MessageBody | |||||
/// 区域ID集合 | /// 区域ID集合 | ||||
/// </summary> | /// </summary> | ||||
public List<uint> AreaIds { get; set; } | public List<uint> AreaIds { get; set; } | ||||
public JT808_0x8607 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8607 jT808_0X8607 = new JT808_0x8607(); | |||||
jT808_0X8607.AreaCount = reader.ReadByte(); | |||||
jT808_0X8607.AreaIds = new List<uint>(); | |||||
for (var i = 0; i < jT808_0X8607.AreaCount; i++) | |||||
{ | |||||
jT808_0X8607.AreaIds.Add(reader.ReadUInt32()); | |||||
} | |||||
return jT808_0X8607; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8607 value, IJT808Config config) | |||||
{ | |||||
if (value.AreaIds != null) | |||||
{ | |||||
writer.WriteByte((byte)value.AreaIds.Count); | |||||
foreach (var item in value.AreaIds) | |||||
{ | |||||
writer.WriteUInt32(item); | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -8,7 +10,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x8800 | /// 0x8800 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8800_Formatter))] | [JT808Formatter(typeof(JT808_0x8800_Formatter))] | ||||
public class JT808_0x8800 : JT808Bodies | |||||
public class JT808_0x8800 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8800> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 多媒体ID | /// 多媒体ID | ||||
@@ -23,5 +25,20 @@ namespace JT808.Protocol.MessageBody | |||||
/// 重传包序号顺序排列,如“包 ID1 包 ID2......包 IDn”。 | /// 重传包序号顺序排列,如“包 ID1 包 ID2......包 IDn”。 | ||||
/// </summary> | /// </summary> | ||||
public byte[] RetransmitPackageIds { get; set; } | public byte[] RetransmitPackageIds { get; set; } | ||||
public JT808_0x8800 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8800 jT808_0X8800 = new JT808_0x8800(); | |||||
jT808_0X8800.MultimediaId = reader.ReadUInt32(); | |||||
jT808_0X8800.RetransmitPackageCount = reader.ReadByte(); | |||||
jT808_0X8800.RetransmitPackageIds = reader.ReadArray(jT808_0X8800.RetransmitPackageCount * 2).ToArray(); | |||||
return jT808_0X8800; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8800 value, IJT808Config config) | |||||
{ | |||||
writer.WriteUInt32(value.MultimediaId); | |||||
writer.WriteByte((byte)(value.RetransmitPackageIds.Length / 2)); | |||||
writer.WriteArray(value.RetransmitPackageIds); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -8,7 +10,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x8801 | /// 0x8801 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8801_Formatter))] | [JT808Formatter(typeof(JT808_0x8801_Formatter))] | ||||
public class JT808_0x8801 : JT808Bodies | |||||
public class JT808_0x8801 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8801> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 通道 ID | /// 通道 ID | ||||
@@ -66,5 +68,34 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0-255 | /// 0-255 | ||||
/// </summary> | /// </summary> | ||||
public byte Chroma { get; set; } | public byte Chroma { get; set; } | ||||
public JT808_0x8801 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8801 jT808_0X8801 = new JT808_0x8801(); | |||||
jT808_0X8801.ChannelId = reader.ReadByte(); | |||||
jT808_0X8801.ShootingCommand = reader.ReadUInt16(); | |||||
jT808_0X8801.VideoTime = reader.ReadUInt16(); | |||||
jT808_0X8801.SaveFlag = reader.ReadByte(); | |||||
jT808_0X8801.Resolution = reader.ReadByte(); | |||||
jT808_0X8801.VideoQuality = reader.ReadByte(); | |||||
jT808_0X8801.Lighting = reader.ReadByte(); | |||||
jT808_0X8801.Contrast = reader.ReadByte(); | |||||
jT808_0X8801.Saturability = reader.ReadByte(); | |||||
jT808_0X8801.Chroma = reader.ReadByte(); | |||||
return jT808_0X8801; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8801 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.ChannelId); | |||||
writer.WriteUInt16(value.ShootingCommand); | |||||
writer.WriteUInt16(value.VideoTime); | |||||
writer.WriteByte(value.SaveFlag); | |||||
writer.WriteByte(value.Resolution); | |||||
writer.WriteByte(value.VideoQuality); | |||||
writer.WriteByte(value.Lighting); | |||||
writer.WriteByte(value.Contrast); | |||||
writer.WriteByte(value.Saturability); | |||||
writer.WriteByte(value.Chroma); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
using System; | using System; | ||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
@@ -9,7 +11,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x8802 | /// 0x8802 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8802_Formatter))] | [JT808Formatter(typeof(JT808_0x8802_Formatter))] | ||||
public class JT808_0x8802 : JT808Bodies | |||||
public class JT808_0x8802 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8802> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 多媒体类型 | /// 多媒体类型 | ||||
@@ -36,5 +38,24 @@ namespace JT808.Protocol.MessageBody | |||||
/// YY-MM-DD-hh-mm-ss | /// YY-MM-DD-hh-mm-ss | ||||
/// </summary> | /// </summary> | ||||
public DateTime EndTime { get; set; } | public DateTime EndTime { get; set; } | ||||
public JT808_0x8802 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8802 jT808_0X8802 = new JT808_0x8802(); | |||||
jT808_0X8802.MultimediaType = reader.ReadByte(); | |||||
jT808_0X8802.ChannelId = reader.ReadByte(); | |||||
jT808_0X8802.EventItemCoding = reader.ReadByte(); | |||||
jT808_0X8802.StartTime = reader.ReadDateTime6(); | |||||
jT808_0X8802.EndTime = reader.ReadDateTime6(); | |||||
return jT808_0X8802; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8802 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.MultimediaType); | |||||
writer.WriteByte(value.ChannelId); | |||||
writer.WriteByte(value.EventItemCoding); | |||||
writer.WriteDateTime6(value.StartTime); | |||||
writer.WriteDateTime6(value.EndTime); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
using System; | using System; | ||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
@@ -9,7 +11,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x8803 | /// 0x8803 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8803_Formatter))] | [JT808Formatter(typeof(JT808_0x8803_Formatter))] | ||||
public class JT808_0x8803 : JT808Bodies | |||||
public class JT808_0x8803 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8803> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 多媒体类型 | /// 多媒体类型 | ||||
@@ -42,5 +44,26 @@ namespace JT808.Protocol.MessageBody | |||||
/// <see cref="JT808.Protocol.Enums.JT808MultimediaDeleted"/> | /// <see cref="JT808.Protocol.Enums.JT808MultimediaDeleted"/> | ||||
/// </summary> | /// </summary> | ||||
public byte MultimediaDeleted { get; set; } | public byte MultimediaDeleted { get; set; } | ||||
public JT808_0x8803 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8803 jT808_0X8803 = new JT808_0x8803(); | |||||
jT808_0X8803.MultimediaType = reader.ReadByte(); | |||||
jT808_0X8803.ChannelId = reader.ReadByte(); | |||||
jT808_0X8803.EventItemCoding = reader.ReadByte(); | |||||
jT808_0X8803.StartTime = reader.ReadDateTime6(); | |||||
jT808_0X8803.EndTime = reader.ReadDateTime6(); | |||||
jT808_0X8803.MultimediaDeleted = reader.ReadByte(); | |||||
return jT808_0X8803; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8803 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.MultimediaType); | |||||
writer.WriteByte(value.ChannelId); | |||||
writer.WriteByte(value.EventItemCoding); | |||||
writer.WriteDateTime6(value.StartTime); | |||||
writer.WriteDateTime6(value.EndTime); | |||||
writer.WriteByte(value.MultimediaDeleted); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,6 +1,8 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Enums; | using JT808.Protocol.Enums; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -8,7 +10,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 录音开始命令 | /// 录音开始命令 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8804_Formatter))] | [JT808Formatter(typeof(JT808_0x8804_Formatter))] | ||||
public class JT808_0x8804 : JT808Bodies | |||||
public class JT808_0x8804 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8804> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 录音命令 | /// 录音命令 | ||||
@@ -29,5 +31,22 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0:8K;1:11K;2:23K;3:32K;其他保留 | /// 0:8K;1:11K;2:23K;3:32K;其他保留 | ||||
/// </summary> | /// </summary> | ||||
public byte AudioSampleRate { get; set; } | public byte AudioSampleRate { get; set; } | ||||
public JT808_0x8804 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8804 jT808_0X8804 = new JT808_0x8804(); | |||||
jT808_0X8804.RecordCmd = (JT808RecordCmd)reader.ReadByte(); | |||||
jT808_0X8804.RecordTime = reader.ReadUInt16(); | |||||
jT808_0X8804.RecordSave = (JT808RecordSave)reader.ReadByte(); | |||||
jT808_0X8804.AudioSampleRate = reader.ReadByte(); | |||||
return jT808_0X8804; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8804 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte((byte)value.RecordCmd); | |||||
writer.WriteUInt16(value.RecordTime); | |||||
writer.WriteByte((byte)value.RecordSave); | |||||
writer.WriteByte(value.AudioSampleRate); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,7 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -7,7 +9,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 单条存储多媒体数据检索上传命令 | /// 单条存储多媒体数据检索上传命令 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8805_Formatter))] | [JT808Formatter(typeof(JT808_0x8805_Formatter))] | ||||
public class JT808_0x8805 : JT808Bodies | |||||
public class JT808_0x8805 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8805> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 多媒体ID | /// 多媒体ID | ||||
@@ -18,5 +20,18 @@ namespace JT808.Protocol.MessageBody | |||||
/// <see cref="JT808.Protocol.Enums.JT808MultimediaDeleted"/> | /// <see cref="JT808.Protocol.Enums.JT808MultimediaDeleted"/> | ||||
/// </summary> | /// </summary> | ||||
public byte MultimediaDeleted { get; set; } | public byte MultimediaDeleted { get; set; } | ||||
public JT808_0x8805 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8805 jT808_0X8805 = new JT808_0x8805(); | |||||
jT808_0X8805.MultimediaId = reader.ReadUInt32(); | |||||
jT808_0X8805.MultimediaDeleted = reader.ReadByte(); | |||||
return jT808_0X8805; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8805 value, IJT808Config config) | |||||
{ | |||||
writer.WriteUInt32(value.MultimediaId); | |||||
writer.WriteByte(value.MultimediaDeleted); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,8 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Extensions; | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -7,7 +10,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 数据下行透传 | /// 数据下行透传 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8900_Formatter))] | [JT808Formatter(typeof(JT808_0x8900_Formatter))] | ||||
public class JT808_0x8900 : JT808Bodies | |||||
public class JT808_0x8900 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8900> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 透传消息类型 | /// 透传消息类型 | ||||
@@ -24,5 +27,20 @@ namespace JT808.Protocol.MessageBody | |||||
/// 透传消息内容 | /// 透传消息内容 | ||||
/// </summary> | /// </summary> | ||||
public JT808_0x8900_BodyBase JT808_0X8900_BodyBase { get; set; } | public JT808_0x8900_BodyBase JT808_0X8900_BodyBase { get; set; } | ||||
public JT808_0x8900 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8900 jT808_0X8900 = new JT808_0x8900(); | |||||
jT808_0X8900.PassthroughType = reader.ReadByte(); | |||||
jT808_0X8900.PassthroughData = reader.ReadContent().ToArray(); | |||||
return jT808_0X8900; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8900 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.PassthroughType); | |||||
object obj = config.GetMessagePackFormatterByType(value.JT808_0X8900_BodyBase.GetType()); | |||||
JT808MessagePackFormatterResolverExtensions.JT808DynamicSerialize(obj, ref writer, value.JT808_0X8900_BodyBase, config); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,5 +1,8 @@ | |||||
using JT808.Protocol.Attributes; | using JT808.Protocol.Attributes; | ||||
using JT808.Protocol.Exceptions; | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Formatters.MessageBodyFormatters; | using JT808.Protocol.Formatters.MessageBodyFormatters; | ||||
using JT808.Protocol.MessagePack; | |||||
namespace JT808.Protocol.MessageBody | namespace JT808.Protocol.MessageBody | ||||
{ | { | ||||
@@ -8,7 +11,7 @@ namespace JT808.Protocol.MessageBody | |||||
/// 0x8A00 | /// 0x8A00 | ||||
/// </summary> | /// </summary> | ||||
[JT808Formatter(typeof(JT808_0x8A00_Formatter))] | [JT808Formatter(typeof(JT808_0x8A00_Formatter))] | ||||
public class JT808_0x8A00 : JT808Bodies | |||||
public class JT808_0x8A00 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8A00> | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// e | /// e | ||||
@@ -20,5 +23,23 @@ namespace JT808.Protocol.MessageBody | |||||
/// RSA 公钥{e,n}中的 n | /// RSA 公钥{e,n}中的 n | ||||
/// </summary> | /// </summary> | ||||
public byte[] N { get; set; } | public byte[] N { get; set; } | ||||
public JT808_0x8A00 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x8A00 jT808_0X8A00 = new JT808_0x8A00(); | |||||
jT808_0X8A00.E = reader.ReadUInt32(); | |||||
jT808_0X8A00.N = reader.ReadArray(128).ToArray(); | |||||
return jT808_0X8A00; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8A00 value, IJT808Config config) | |||||
{ | |||||
writer.WriteUInt32(value.E); | |||||
if (value.N.Length != 128) | |||||
{ | |||||
throw new JT808Exception(Enums.JT808ErrorCode.NotEnoughLength, $"{nameof(value.N)}->128"); | |||||
} | |||||
writer.WriteArray(value.N); | |||||
} | |||||
} | } | ||||
} | } |