您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

65 行
2.0 KiB

  1. using JT808.Protocol.Formatters;
  2. using JT808.Protocol.Interfaces;
  3. using JT808.Protocol.MessagePack;
  4. using System.Collections.Generic;
  5. namespace JT808.Protocol.MessageBody
  6. {
  7. /// <summary>
  8. /// 查询区域或线路数据
  9. /// 0x8608
  10. /// 2019版本
  11. /// </summary>
  12. public class JT808_0x8608 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8608>, IJT808_2019_Version
  13. {
  14. public override ushort MsgId { get; } = 0x8608;
  15. /// <summary>
  16. /// 查询类型
  17. /// </summary>
  18. public byte QueryType { get; set; }
  19. /// <summary>
  20. /// 查询的区域或线路的ID数量
  21. /// 0表示查询所有区域或线路数据,大于0表示后面跟随要查询的区域或线路的ID数量
  22. /// </summary>
  23. public uint Count { get; set; }
  24. /// <summary>
  25. /// 查询的区域或线路的ID
  26. /// </summary>
  27. public List<uint> Ids { get; set; }
  28. public JT808_0x8608 Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
  29. {
  30. JT808_0x8608 value = new JT808_0x8608();
  31. value.QueryType = reader.ReadByte();
  32. value.Count = reader.ReadUInt32();
  33. if (value.Count > 0)
  34. {
  35. value.Ids = new List<uint>();
  36. for(int i = 0; i < value.Count; i++)
  37. {
  38. value.Ids.Add(reader.ReadUInt32());
  39. }
  40. }
  41. return value;
  42. }
  43. public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8608 value, IJT808Config config)
  44. {
  45. writer.WriteByte(value.QueryType);
  46. if(value.Ids!=null && value.Ids.Count > 0)
  47. {
  48. writer.WriteUInt32((uint)value.Ids.Count);
  49. foreach(var item in value.Ids)
  50. {
  51. writer.WriteUInt32(item);
  52. }
  53. }
  54. else
  55. {
  56. writer.WriteUInt32(0);
  57. }
  58. }
  59. }
  60. }