public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1003 value, IJT809Config config) { writer.WriteUInt32(value.UserId); writer.WriteStringPadLeft(value.Password, 8); }
public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) { JT809_JT1078_0x1B00_0x1B02 value = new JT809_JT1078_0x1B00_0x1B02(); value.Result = (JT809_JT1078_0x1B00_0x1B02_Result)reader.ReadByte(); writer.WriteString($"[{((byte)value.Result).ReadNumber() }]应答结果", value.Result.ToString()); value.SessionId = reader.ReadUInt16(); writer.WriteNumber($"[{value.SessionId.ReadNumber()}]对应平台文件上传消息的流水号", value.SessionId); var virtualHex = reader.ReadVirtualArray(32); value.ServerIp = reader.ReadString(32); writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]FTP服务器ip地址", value.ServerIp); value.TcpPort = reader.ReadUInt16(); writer.WriteNumber($"[{value.TcpPort.ReadNumber()}]FTP服务器端口", value.TcpPort); virtualHex = reader.ReadVirtualArray(49); value.UserName = reader.ReadString(49); writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]FTP用户名", value.UserName); virtualHex = reader.ReadVirtualArray(22); value.Password = reader.ReadString(22); writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]FTP密码", value.Password); virtualHex = reader.ReadVirtualArray(200); value.FilePath = reader.ReadString(200); writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]文件存储路径", value.FilePath); }
public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9003 value, IJT809Config config) { writer.WriteUInt32(value.VerifyCode); }
public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1300_0x1303 value, IJT809Config config) { if (value.EndMessageNumber - value.BeginMessageNumber >= byte.MaxValue) { throw new JT809Exception(JT809ErrorCode.IllegalArgument, "序列号间隔不能大于255"); } value.SerialCount = (byte)(value.EndMessageNumber - value.BeginMessageNumber + 1); writer.WriteUInt16(RetranDataType); writer.WriteByte(value.SerialCount); writer.WriteUInt32(value.BeginMessageNumber); writer.WriteUInt32(value.EndMessageNumber); writer.WriteUTCDateTime(value.Time); }
public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) { JT809_0x9300 value = new JT809_0x9300(); value.SubBusinessType = reader.ReadUInt16(); writer.WriteString($"[{value.SubBusinessType.ReadNumber()}]子业务类型标识", ((JT809SubBusinessType)value.SubBusinessType).ToString()); value.DataLength = reader.ReadUInt32(); writer.WriteNumber($"[{value.DataLength.ReadNumber()}]后续数据长度", value.DataLength); try { if (config.SubBusinessTypeFactory.TryGetValue(value.SubBusinessType, out object instance)) { if (instance is JT809SubBodies subBodies) { if (!subBodies.SkipSerialization) { writer.WriteStartObject("子业务类型"); instance.Analyze(ref reader, writer, config); writer.WriteEndObject(); } } } } catch { throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}"); } }
public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x1900_0x1901 value, IJT809Config config) { writer.WriteUInt32(value.ItemNum); if (value.ItemList.Count > 0) { var formatter = config.GetMessagePackFormatter <JT809_JT1078_0x1900_Record>(); foreach (var item in value.ItemList) { formatter.Serialize(ref writer, item, config); } } }
public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) { JT809_0x1500_0x1502 value = new JT809_0x1500_0x1502(); value.PhotoRspFlag = (JT809_0x1502_PhotoRspFlag)reader.ReadByte(); writer.WriteString($"[{value.PhotoRspFlag.ToByteValue()}]拍照应答标识", value.PhotoRspFlag.ToString()); if (config.Version == JT809Version.JTT2011) { config.GetMessagePackFormatter <JT809VehiclePositionProperties>().Analyze(ref reader, writer, config); } else if (config.Version == JT809Version.JTT2019) { config.GetMessagePackFormatter <JT809VehiclePositionProperties_2019>().Analyze(ref reader, writer, config); } value.LensID = reader.ReadByte(); writer.WriteNumber($"[{value.LensID}]镜头ID", value.LensID); value.PhotoLen = reader.ReadUInt32(); writer.WriteNumber($"[{value.PhotoLen}]图片长度", value.PhotoLen); value.SizeType = (JT809_0x9502_SizeType)reader.ReadByte(); writer.WriteString($"[{value.SizeType.ToByteValue()}]图片大小", value.SizeType.ToString()); value.Type = (JT809_0x9502_ImageType)reader.ReadByte(); writer.WriteString($"[{value.Type.ToByteValue()}]图像格式", value.Type.ToString()); if (value.PhotoLen > 0) { var virtualHex = reader.ReadVirtualArray((int)value.PhotoLen); value.Photo = reader.ReadArray((int)value.PhotoLen).ToArray(); writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]图片内容", value.Photo); } }
public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x9800_0x9801 value, IJT809Config config) { writer.WriteByte(value.ChannelId); writer.WriteByte(value.AVitemType); writer.WriteStringPadRight(value.AuthorizeCode, 64); writer.WriteArray(value.GnssData); }
public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) { JT809_JT1078_0x9800_0x9801 value = new JT809_JT1078_0x9800_0x9801(); value.ChannelId = reader.ReadByte(); writer.WriteString($"[{value.ChannelId.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.ChannelId)); value.AVitemType = reader.ReadByte(); writer.WriteString($"[{value.AVitemType.ReadNumber()}]音视频资源类型", AVResourceTypeDisplay(value.AVitemType)); var virtualHex = reader.ReadVirtualArray(64); value.AuthorizeCode = reader.ReadString(64); writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]时效口令", value.AuthorizeCode); virtualHex = reader.ReadVirtualArray(36); value.GnssData = reader.ReadArray(36).ToArray(); writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]车辆进入跨域地区后5min之内的任何位置", virtualHex.ToArray().ToHexString()); string LogicalChannelNoDisplay(byte LogicalChannelNo) { switch (LogicalChannelNo) { case 1: return("驾驶员"); case 2: return("车辆正前方"); case 3: return("车前门"); case 4: return("车厢前部"); case 5: return("车厢后部"); case 7: return("行李舱"); case 8: return("车辆左侧"); case 9: return("车辆右侧"); case 10: return("车辆正后方"); case 11: return("车厢中部"); case 12: return("车中门"); case 13: return("驾驶席车门"); case 33: return("驾驶员"); case 36: return("车厢前部"); case 37: return("车厢后部"); default: return("预留"); } } string AVResourceTypeDisplay(byte AVResourceType) { switch (AVResourceType) { case 0: return("音视频"); case 1: return("音频"); case 2: return("视频"); default: break; } return("未知"); } }
public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1500_0x1503 value, IJT809Config config) { if (config.Version == JT809Version.JTT2019) { writer.WriteUInt16(value.SourceDataType); writer.WriteUInt32(value.SourceMsgSn); } else { writer.WriteUInt32(value.MsgID); } writer.WriteByte((byte)value.Result); }
public JT809_JT1078_0x9800_0x9801 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { JT809_JT1078_0x9800_0x9801 value = new JT809_JT1078_0x9800_0x9801(); value.ChannelId = reader.ReadByte(); value.AVitemType = reader.ReadByte(); value.AuthorizeCode = reader.ReadString(64); value.GnssData = reader.ReadArray(36).ToArray(); return(value); }
public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) { JT809_0x9200 value = new JT809_0x9200(); //1078qq群808432702:大兄弟提供的 //由于车辆注册信息应答消息0x9201子业务不存在车牌号和颜色需要跳过 if (config.Version == JT809Version.JTT2019) { var subBusinessType = reader.ReadVirtualUInt16(); if (subBusinessType != JT809SubBusinessType.车辆注册信息应答消息.ToUInt16Value()) { var virtualHex = reader.ReadVirtualArray(21); value.VehicleNo = reader.ReadString(21); writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]车牌号", value.VehicleNo); value.VehicleColor = (JT809VehicleColorType)reader.ReadByte(); writer.WriteString($"[{value.VehicleColor.ToByteValue()}]车牌颜色", value.VehicleColor.ToString()); } } else { var virtualHex = reader.ReadVirtualArray(21); value.VehicleNo = reader.ReadString(21); writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]车牌号", value.VehicleNo); value.VehicleColor = (JT809VehicleColorType)reader.ReadByte(); writer.WriteString($"[{value.VehicleColor.ToByteValue()}]车牌颜色", value.VehicleColor.ToString()); } value.SubBusinessType = reader.ReadUInt16(); writer.WriteString($"[{value.SubBusinessType.ReadNumber()}]子业务类型标识", ((JT809SubBusinessType)value.SubBusinessType).ToString()); value.DataLength = reader.ReadUInt32(); writer.WriteNumber($"[{value.DataLength.ReadNumber()}]后续数据长度", value.DataLength); try { if (config.SubBusinessTypeFactory.TryGetValue(value.SubBusinessType, out object instance)) { if (instance is JT809SubBodies subBodies) { if (!subBodies.SkipSerialization) { writer.WriteStartObject("子业务类型"); instance.Analyze(ref reader, writer, config); writer.WriteEndObject(); } } } } catch { throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}"); } }
public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9300_0x9302 value, IJT809Config config) { writer.WriteByte((byte)value.ObjectType); writer.WriteStringPadRight(value.ObjectID, 12); writer.WriteUInt32(value.InfoID); // 先计算内容长度(汉字为两个字节) writer.Skip(4, out int lengthPosition); writer.WriteString(value.InfoContent); writer.WriteInt32Return(writer.GetCurrentPosition() - lengthPosition - 4, lengthPosition); }
public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) { JT809_0x9300_0x9302 value = new JT809_0x9300_0x9302(); value.ObjectType = (JT809_0x9302_ObjectType)reader.ReadByte(); writer.WriteString($"[{value.ObjectType.ToByteValue()}]查岗对象的类型", value.ObjectType.ToString()); var virtualHex = reader.ReadVirtualArray(12); value.ObjectID = reader.ReadString(12); writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]查岗对象的ID", value.ObjectID); value.InfoID = reader.ReadUInt32(); writer.WriteNumber($"[{value.InfoID.ReadNumber() }]信息ID", value.InfoID); value.InfoLength = reader.ReadUInt32(); writer.WriteNumber($"[{value.InfoLength.ReadNumber() }]数据长度", value.InfoLength); virtualHex = reader.ReadVirtualArray((int)value.InfoLength); value.InfoContent = reader.ReadString((int)value.InfoLength); writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]应答内容", value.InfoContent); }
public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1200_0x1207 value, IJT809Config config) { writer.WriteUTCDateTime(value.StartTime); writer.WriteUTCDateTime(value.EndTime); }
public void Serialize(ref JT809MessagePackWriter writer, JT808_JT1078_0x1700 value, IJT809Config config) { try { writer.WriteStringPadRight(value.VehicleNo, 21); writer.WriteByte((byte)value.VehicleColor); writer.WriteUInt16(value.SubBusinessType); // 先写入内容,然后在根据内容反写内容长度 writer.Skip(4, out int subContentLengthPosition); if (value.SubBodies != null) { JT809MessagePackFormatterResolverExtensions.JT809DynamicSerialize( value.SubBodies, ref writer, value.SubBodies, config); } writer.WriteInt32Return(writer.GetCurrentPosition() - subContentLengthPosition - 4, subContentLengthPosition); } catch { throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType}"); } }
public JT809_JT1078_0x1900_0x1901 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { JT809_JT1078_0x1900_0x1901 jT808_JT1078_0x1900_0x1901 = new JT809_JT1078_0x1900_0x1901(); jT808_JT1078_0x1900_0x1901.ItemNum = reader.ReadUInt32(); if (jT808_JT1078_0x1900_0x1901.ItemNum > 0) { List <JT809_JT1078_0x1900_Record> jT808_JT1078_0x1900_0x1901_RecordList = new List <JT809_JT1078_0x1900_Record>(); var formatter = config.GetMessagePackFormatter <JT809_JT1078_0x1900_Record>(); for (int i = 0; i < jT808_JT1078_0x1900_0x1901.ItemNum; i++) { var jT808_JT1078_0x1900_0x1901_Record = formatter.Deserialize(ref reader, config); jT808_JT1078_0x1900_0x1901_RecordList.Add(jT808_JT1078_0x1900_0x1901_Record); } jT808_JT1078_0x1900_0x1901.ItemList = jT808_JT1078_0x1900_0x1901_RecordList; } return(jT808_JT1078_0x1900_0x1901); }
public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) { JT809_0x1008 value = new JT809_0x1008(); value.ReasonCode = (JT809_0x1008_ReasonCode)reader.ReadByte(); writer.WriteString($"[{value.ReasonCode.ToByteValue()}]链路关闭原因", value.ReasonCode.ToString()); }
public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1500_0x1502 value, IJT809Config config) { writer.WriteByte((byte)value.PhotoRspFlag); if (config.Version == JT809Version.JTT2011) { if (value.VehiclePosition != null) { config.GetMessagePackFormatter <JT809VehiclePositionProperties>().Serialize(ref writer, value.VehiclePosition, config); } } else if (config.Version == JT809Version.JTT2019) { if (value.VehiclePosition_2019 != null) { config.GetMessagePackFormatter <JT809VehiclePositionProperties_2019>().Serialize(ref writer, value.VehiclePosition_2019, config); } } writer.WriteByte(value.LensID); bool isPhoto = (value.Photo != null && value.Photo.Length > 0); writer.WriteUInt32(isPhoto ? (uint)value.Photo.Length : 0); writer.WriteByte(value.SizeType.ToByteValue()); writer.WriteByte(value.Type.ToByteValue()); if (isPhoto) { writer.WriteArray(value.Photo); } }
public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) { var value = new JT809_0x1200_0x120E(); var virtualHex = reader.ReadVirtualArray(reader.ReadCurrentRemainContentLength()); value.DRVLine = reader.ReadArray(reader.ReadCurrentRemainContentLength()).ToArray(); writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]路线信息", value.DRVLine); }
public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) { var value = new JT809_0x1300_0x1303(); value.SerialCount = reader.ReadByte(); writer.WriteNumber($"[{ value.SerialCount.ReadNumber()}]对应需要重传消息地子业务类型标识", value.SerialCount); writer.WriteNumber($"[{value.BeginMessageNumber.ReadNumber()}需要重传消息的起始报文序列号]", value.BeginMessageNumber); writer.WriteNumber($"[{value.EndMessageNumber.ReadNumber()}需要重传消息的结束报文序列号]", value.EndMessageNumber); var virtualHex = reader.ReadVirtualArray(8); value.Time = reader.ReadUTCDateTime(); writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]重传起始系统utc时间", value.Time); }
public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1200_0x120E value, IJT809Config config) { writer.WriteArray(value.DRVLine); }
public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9300_0x9303 value, IJT809Config config) { writer.WriteArray(value.SerialList); writer.WriteUTCDateTime(value.Time); }
public void Serialize(ref JT809MessagePackWriter writer, JT809_0x1007 value, IJT809Config config) { writer.WriteByte((byte)value.ErrorCode); }
public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x1B00_0x1B02 value, IJT809Config config) { writer.WriteByte((byte)value.Result); writer.WriteUInt16(value.SessionId); writer.WriteStringPadLeft(value.ServerIp, 32); writer.WriteUInt16(value.TcpPort); writer.WriteStringPadLeft(value.UserName, 49); writer.WriteStringPadLeft(value.Password, 22); writer.WriteStringPadLeft(value.FilePath, 200); }
public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9200_0x9208 value, IJT809Config config) { writer.WriteByte((byte)value.Result); }
public JT809_JT1078_0x1B00_0x1B02 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { JT809_JT1078_0x1B00_0x1B02 value = new JT809_JT1078_0x1B00_0x1B02(); value.Result = (JT809_JT1078_0x1B00_0x1B02_Result)reader.ReadByte(); value.SessionId = reader.ReadUInt16(); value.ServerIp = reader.ReadString(32); value.TcpPort = reader.ReadUInt16(); value.UserName = reader.ReadString(49); value.Password = reader.ReadString(22); value.FilePath = reader.ReadString(200); return(value); }
public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) { JT809_0x1200_0x1207 value = new JT809_0x1200_0x1207(); var virtualHex = reader.ReadVirtualArray(8); value.StartTime = reader.ReadUTCDateTime(); writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]开始时间", value.StartTime); virtualHex = reader.ReadVirtualArray(8); value.EndTime = reader.ReadUTCDateTime(); writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]结束时间", value.StartTime); }
public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) { JT809_JT1078_0x1700 value = new JT809_JT1078_0x1700(); var virtualHex = reader.ReadVirtualArray(21); value.VehicleNo = reader.ReadString(21); writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]车牌号", value.VehicleNo); value.VehicleColor = (JT809VehicleColorType)reader.ReadByte(); writer.WriteString($"[{((byte)value.VehicleColor).ReadNumber()}]车牌颜色", value.VehicleColor.ToString()); value.SubBusinessType = reader.ReadUInt16(); writer.WriteString($"[{value.SubBusinessType.ReadNumber()}]子业务类型标识", ((JT809SubBusinessType)value.SubBusinessType).ToString()); value.DataLength = reader.ReadUInt32(); writer.WriteNumber($"[{value.DataLength.ReadNumber()}]后续数据长度", value.DataLength); try { if (config.SubBusinessTypeFactory.TryGetValue(value.SubBusinessType, out object instance)) { if (instance is JT809SubBodies subBodies) { if (!subBodies.SkipSerialization) { writer.WriteStartObject("子业务类型"); instance.Analyze(ref reader, writer, config); writer.WriteEndObject(); } } } } catch { throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}"); } }
public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x1A00_0x1A01 value, IJT809Config config) { writer.WriteStringPadLeft(value.ServerIp, 32); writer.WriteUInt16(value.ServerPort); writer.WriteByte(value.Result); }