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.

63 lines
1.4 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace JT809.Protocol
  5. {
  6. public class JT809Header_Version
  7. {
  8. public byte[] Buffer { get; } = new byte[3];
  9. private const int MajorIndex = 0;
  10. private const int MinorIndex = 1;
  11. private const int BuildIndex = 2;
  12. public const int FixedByteLength = 3;
  13. public byte Major
  14. {
  15. get { return Buffer[MajorIndex]; }
  16. private set { Buffer[MajorIndex] = value; }
  17. }
  18. public byte Minor
  19. {
  20. get { return Buffer[MinorIndex]; }
  21. private set { Buffer[MinorIndex] = value; }
  22. }
  23. public byte Build
  24. {
  25. get { return Buffer[BuildIndex]; }
  26. private set { Buffer[BuildIndex] = value; }
  27. }
  28. /// <summary>
  29. /// 默认1.0.0版本
  30. /// </summary>
  31. public JT809Header_Version()
  32. {
  33. Major = 1;
  34. Minor = 0;
  35. Build = 0;
  36. }
  37. public JT809Header_Version(byte major, byte minor, byte buid)
  38. {
  39. Major = major;
  40. Minor = minor;
  41. Build = buid;
  42. }
  43. public JT809Header_Version(byte[] bytes)
  44. {
  45. Major = bytes[0];
  46. Minor = bytes[1];
  47. Build = bytes[2];
  48. }
  49. public override string ToString()
  50. {
  51. return $"{Major}.{Minor}.{Build}";
  52. }
  53. }
  54. }