Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

66 rader
2.7 KiB

  1. using JT808.Protocol.Formatters;
  2. using JT808.Protocol.MessageBody;
  3. using JT808.Protocol.MessagePack;
  4. using JT808.Protocol.Interfaces;
  5. using System.Text.Json;
  6. using JT808.Protocol.Extensions.JT1078.Enums;
  7. using System.Linq;
  8. namespace JT808.Protocol.Extensions.JT1078.MessageBody
  9. {
  10. /// <summary>
  11. /// 视频相关报警
  12. /// 0x0200_0x14
  13. /// </summary>
  14. public class JT808_0x0200_0x14 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x14>,IJT808Analyze
  15. {
  16. public override byte AttachInfoId { get; set; } = 0x14;
  17. /// <summary>
  18. /// 数据 长度
  19. /// </summary>
  20. public override byte AttachInfoLength { get; set; } = 4;
  21. /// <summary>
  22. /// 视频相关报警
  23. /// <see cref="JT808.Protocol.Extensions.JT1078.Enums.VideoRelateAlarmType"/>
  24. /// </summary>
  25. public uint VideoRelateAlarm { get; set; }
  26. public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config)
  27. {
  28. JT808_0x0200_0x14 value = new JT808_0x0200_0x14();
  29. value.AttachInfoId = reader.ReadByte();
  30. writer.WriteNumber($"[{value.AttachInfoId.ReadNumber()}]附加信息Id", value.AttachInfoId);
  31. value.AttachInfoLength = reader.ReadByte();
  32. writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength);
  33. value.VideoRelateAlarm = reader.ReadUInt32();
  34. writer.WriteNumber($"[{value.VideoRelateAlarm.ReadNumber()}]视频相关报警", value.VideoRelateAlarm);
  35. var videoRelateAlarmFlags = JT808EnumExtensions.GetEnumTypes<VideoRelateAlarmType>((int)value.VideoRelateAlarm, 32);
  36. if (videoRelateAlarmFlags.Any())
  37. {
  38. writer.WriteStartArray("视频报警集合");
  39. foreach (var item in videoRelateAlarmFlags)
  40. {
  41. writer.WriteStringValue(item.ToString());
  42. }
  43. writer.WriteEndArray();
  44. }
  45. }
  46. public JT808_0x0200_0x14 Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
  47. {
  48. JT808_0x0200_0x14 value = new JT808_0x0200_0x14();
  49. value.AttachInfoId = reader.ReadByte();
  50. value.AttachInfoLength = reader.ReadByte();
  51. value.VideoRelateAlarm = reader.ReadUInt32();
  52. return value;
  53. }
  54. public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x14 value, IJT808Config config)
  55. {
  56. writer.WriteByte(value.AttachInfoId);
  57. writer.WriteByte(value.AttachInfoLength);
  58. writer.WriteUInt32(value.VideoRelateAlarm);
  59. }
  60. }
  61. }