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.

57 lines
2.3 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. /// 从服务器备份地址IP。该值为空,终端应使用主服务器相同配置
  10. /// 2019版本
  11. /// </summary>
  12. public class JT808_0x8103_0x0026 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter<JT808_0x8103_0x0026>, IJT808_2019_Version, IJT808Analyze
  13. {
  14. public override uint ParamId { get; set; } = 0x0026;
  15. /// <summary>
  16. /// 数据 长度
  17. /// </summary>
  18. public override byte ParamLength { get; set; }
  19. /// <summary>
  20. ///
  21. /// </summary>
  22. public string ParamValue { get; set; }
  23. public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config)
  24. {
  25. JT808_0x8103_0x0026 value = new JT808_0x8103_0x0026();
  26. value.ParamId = reader.ReadUInt32();
  27. value.ParamLength = reader.ReadByte();
  28. var paramValue = reader.ReadVirtualArray(value.ParamLength);
  29. value.ParamValue = reader.ReadString(value.ParamLength);
  30. writer.WriteNumber($"[{ value.ParamId.ReadNumber()}]参数ID", value.ParamId);
  31. writer.WriteNumber($"[{value.ParamLength.ReadNumber()}]参数长度", value.ParamLength);
  32. writer.WriteString($"[{paramValue.ToArray().ToHexString()}]参数值[从服务器备份地址IP]", value.ParamValue);
  33. }
  34. public JT808_0x8103_0x0026 Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
  35. {
  36. JT808_0x8103_0x0026 value = new JT808_0x8103_0x0026();
  37. value.ParamId = reader.ReadUInt32();
  38. value.ParamLength = reader.ReadByte();
  39. value.ParamValue = reader.ReadString(value.ParamLength);
  40. return value;
  41. }
  42. public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8103_0x0026 value, IJT808Config config)
  43. {
  44. writer.WriteUInt32(value.ParamId);
  45. writer.Skip(1, out int skipPosition);
  46. writer.WriteString(value.ParamValue);
  47. int length = writer.GetCurrentPosition() - skipPosition - 1;
  48. writer.WriteByteReturn((byte)length, skipPosition);
  49. }
  50. }
  51. }