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 rivejä
2.3 KiB

  1. using System.Text.Json;
  2. using JT808.Protocol.Attributes;
  3. using JT808.Protocol.Extensions;
  4. using JT808.Protocol.Formatters;
  5. using JT808.Protocol.Interfaces;
  6. using JT808.Protocol.MessagePack;
  7. namespace JT808.Protocol.MessageBody
  8. {
  9. /// <summary>
  10. /// CAN 总线通道 2 采集时间间隔(ms),0 表示不采集
  11. /// </summary>
  12. public class JT808_0x8103_0x0102 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter<JT808_0x8103_0x0102>, IJT808Analyze
  13. {
  14. public override uint ParamId { get; set; } = 0x0102;
  15. /// <summary>
  16. /// 数据 长度
  17. /// </summary>
  18. public override byte ParamLength { get; set; }
  19. /// <summary>
  20. /// CAN 总线通道 2 采集时间间隔(ms),0 表示不采集
  21. /// </summary>
  22. public uint ParamValue { get; set; }
  23. public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config)
  24. {
  25. JT808_0x8103_0x0102 jT808_0x8103_0x0102 = new JT808_0x8103_0x0102();
  26. jT808_0x8103_0x0102.ParamId = reader.ReadUInt32();
  27. jT808_0x8103_0x0102.ParamLength = reader.ReadByte();
  28. jT808_0x8103_0x0102.ParamValue = reader.ReadUInt32();
  29. writer.WriteNumber($"[{ jT808_0x8103_0x0102.ParamId.ReadNumber()}]参数ID", jT808_0x8103_0x0102.ParamId);
  30. writer.WriteNumber($"[{jT808_0x8103_0x0102.ParamLength.ReadNumber()}]参数长度", jT808_0x8103_0x0102.ParamLength);
  31. writer.WriteNumber($"[{ jT808_0x8103_0x0102.ParamValue.ReadNumber()}]参数值[CAN 总线通道2, 采集时间间隔(ms),0 表示不采集]", jT808_0x8103_0x0102.ParamValue);
  32. }
  33. public JT808_0x8103_0x0102 Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
  34. {
  35. JT808_0x8103_0x0102 jT808_0x8103_0x0102 = new JT808_0x8103_0x0102();
  36. jT808_0x8103_0x0102.ParamId = reader.ReadUInt32();
  37. jT808_0x8103_0x0102.ParamLength = reader.ReadByte();
  38. jT808_0x8103_0x0102.ParamValue = reader.ReadUInt32();
  39. return jT808_0x8103_0x0102;
  40. }
  41. public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8103_0x0102 value, IJT808Config config)
  42. {
  43. writer.WriteUInt32(value.ParamId);
  44. writer.WriteByte(value.ParamLength);
  45. writer.WriteUInt32(value.ParamValue);
  46. }
  47. }
  48. }