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.

39 lines
1.6 KiB

  1. using JT808.Protocol.Extensions.JT1078.MessageBody;
  2. using JT808.Protocol.Formatters;
  3. using JT808.Protocol.Interfaces;
  4. using JT808.Protocol.MessagePack;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Text;
  8. namespace JT808.Protocol.Extensions.JT1078.Formatters
  9. {
  10. public class JT808_0x9101_Formatter : IJT808MessagePackFormatter<JT808_0x9101>
  11. {
  12. public JT808_0x9101 Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
  13. {
  14. JT808_0x9101 jT808_0X9101 = new JT808_0x9101();
  15. jT808_0X9101.ServerIPAddressLength = reader.ReadByte();
  16. jT808_0X9101.ServerIPAddress = reader.ReadString(jT808_0X9101.ServerIPAddressLength);
  17. jT808_0X9101.ServerVideoChannelTcpPort = reader.ReadUInt16();
  18. jT808_0X9101.ServerVideoChannelUdpPort = reader.ReadUInt16();
  19. jT808_0X9101.LogicalChannelNo = reader.ReadByte();
  20. jT808_0X9101.DataType = reader.ReadByte();
  21. jT808_0X9101.StreamType = reader.ReadByte();
  22. return jT808_0X9101;
  23. }
  24. public void Serialize(ref JT808MessagePackWriter writer, JT808_0x9101 value, IJT808Config config)
  25. {
  26. writer.Skip(1, out int position);
  27. writer.WriteString(value.ServerIPAddress);
  28. writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - position - 1), position);
  29. writer.WriteUInt16(value.ServerVideoChannelTcpPort);
  30. writer.WriteUInt16(value.ServerVideoChannelUdpPort);
  31. writer.WriteByte(value.LogicalChannelNo);
  32. writer.WriteByte(value.DataType);
  33. writer.WriteByte(value.StreamType);
  34. }
  35. }
  36. }