InfoBox.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace ProjectManagementSystem.Device.CasunBox
  7. {
  8. public class InfoBox : InfoBase
  9. {
  10. public int Route { get; set; }
  11. public int Status { get; set; }
  12. public int LightStatus { get; set; }
  13. public bool Called { get { return Status == 0x41; } }
  14. public bool CancelCall { get { return Status == 0x42; } }
  15. public override InfoBase Deserialize(byte[] data)
  16. {
  17. if (data[0] == 0x10 && data.Length == 14)
  18. {
  19. EBoxDevice = EnumBoxDevice.CallBox;
  20. byte function = data[1];
  21. switch (function)
  22. {
  23. case 0x41:
  24. case 0x42:
  25. Route = (data[6] << 8) + data[7] - 0x3030;
  26. Status = function;
  27. break;
  28. default:
  29. break;
  30. }
  31. LightStatus = 0;
  32. }
  33. else if (data[0] == 0x20 && data.Length == 16)
  34. {
  35. EBoxDevice = EnumBoxDevice.WarningLight;
  36. Route = data[14];
  37. LightStatus = data[4];
  38. Status = 0;
  39. }
  40. LastUpdateTime = DateTime.Now;
  41. return this;
  42. }
  43. }
  44. }