You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
2.2 KiB

  1. using System.Text.Json;
  2. using JT808.Protocol.Extensions;
  3. using JT808.Protocol.Formatters;
  4. using JT808.Protocol.Interfaces;
  5. using JT808.Protocol.MessagePack;
  6. namespace JT808.Protocol.MessageBody
  7. {
  8. /// <summary>
  9. /// 违规行驶时段范围
  10. /// </summary>
  11. public class JT808_0x8103_0x0032 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter<JT808_0x8103_0x0032>, IJT808_2019_Version, IJT808Analyze
  12. {
  13. public override uint ParamId { get; set; } = 0x0032;
  14. /// <summary>
  15. /// 数据 长度
  16. /// </summary>
  17. public override byte ParamLength { get; set; } = 4;
  18. /// <summary>
  19. /// 违规行驶时段范围(非法位移阈值),单位为米
  20. /// </summary>
  21. public byte[] ParamValue { get; set; }
  22. public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config)
  23. {
  24. JT808_0x8103_0x0032 value = new JT808_0x8103_0x0032();
  25. value.ParamId = reader.ReadUInt32();
  26. value.ParamLength = reader.ReadByte();
  27. value.ParamValue = reader.ReadArray(4).ToArray();
  28. writer.WriteNumber($"[{ value.ParamId.ReadNumber()}]参数ID", value.ParamId);
  29. writer.WriteNumber($"[{value.ParamLength.ReadNumber()}]参数长度", value.ParamLength);
  30. writer.WriteString($"[{ value.ParamValue.ToHexString()}]参数值[违规行驶时段范围]", $"开始时间{value.ParamValue[0]}时{value.ParamValue[1]}分,结束时间{value.ParamValue[2]}时{value.ParamValue[3]}分");
  31. }
  32. public JT808_0x8103_0x0032 Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
  33. {
  34. JT808_0x8103_0x0032 value = new JT808_0x8103_0x0032();
  35. value.ParamId = reader.ReadUInt32();
  36. value.ParamLength = reader.ReadByte();
  37. value.ParamValue = reader.ReadArray(4).ToArray();
  38. return value;
  39. }
  40. public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8103_0x0032 value, IJT808Config config)
  41. {
  42. writer.WriteUInt32(value.ParamId);
  43. writer.WriteByte(value.ParamLength);
  44. writer.WriteArray(value.ParamValue);
  45. }
  46. }
  47. }