终端一体化运控平台
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.

ChipStatus.cs 4.3 KiB

2 jaren geleden
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. using BPASmartClient.Helper;
  2. using BPASmartClient.Model.单片机.Enum;
  3. using BPASmartClient.SCChip;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace BPASmartClient.SCChip
  10. {
  11. public class ChipStatus : Singleton<ChipStatus>
  12. {
  13. private DateTime lastRefreshTime = DateTime.MinValue;
  14. /// <summary>
  15. /// 是否在线
  16. /// </summary>
  17. public bool OnLine { get { return DateTime.Now.Subtract(lastRefreshTime).TotalSeconds <= 3; } }
  18. /// <summary>
  19. /// 取冰淇淋杯完成
  20. /// </summary>
  21. public bool CompletedTake_CPU_CUP_ICECREAM { get; set; }
  22. /// <summary>
  23. /// 取咖啡杯完成
  24. /// </summary>
  25. public bool CompletedTake_CPU_CUP_COFFEE { get; set; }
  26. /// <summary>
  27. /// 1号舵机打开完成
  28. /// </summary>
  29. public bool CompletedOpen_SE_1 { get; set; }
  30. /// <summary>
  31. /// 2号舵机打开完成
  32. /// </summary>
  33. public bool CompletedOpen_SE_2 { get; set; }
  34. /// <summary>
  35. /// 3号舵机打开完成
  36. /// </summary>
  37. public bool CompletedOpen_SE_3 { get; set; }
  38. /// <summary>
  39. /// 1号舵机关闭完成
  40. /// </summary>
  41. public bool CompletedClose_SE_1 { get; set; }
  42. /// <summary>
  43. /// 2号舵机关闭完成
  44. /// </summary>
  45. public bool CompletedClose_SE_2 { get; set; }
  46. /// <summary>
  47. /// 3号舵机关闭完成
  48. /// </summary>
  49. public bool CompletedClose_SE_3 { get; set; }
  50. /// <summary>
  51. /// 是否存在物品
  52. /// </summary>
  53. public bool ArticleExits { get; set; }
  54. /// <summary>
  55. /// 物品距离
  56. /// </summary>
  57. public byte ArticleDist { get; set; }
  58. public bool CanDo
  59. {
  60. get
  61. {
  62. if (!OnLine)
  63. return false;
  64. return true;
  65. }
  66. }
  67. public void ProcessMsg(ICChipPackage data)
  68. {
  69. try
  70. {
  71. switch (data.Cmd)
  72. {
  73. case IC_CMD.HEART_BEAT:
  74. lastRefreshTime = DateTime.Now;
  75. break;
  76. case IC_CMD.TAKE_CUP:
  77. switch ((IC_CUP)data.Value)
  78. {
  79. case IC_CUP.CUP_COFFEE:
  80. CompletedTake_CPU_CUP_COFFEE = true;
  81. break;
  82. case IC_CUP.CUP_ICECREAM:
  83. CompletedTake_CPU_CUP_ICECREAM = true;
  84. break;
  85. }
  86. break;
  87. case IC_CMD.OPEN_SE:
  88. switch ((IC_SE)data.Value)
  89. {
  90. case IC_SE.SE_1:
  91. CompletedOpen_SE_1 = true;
  92. break;
  93. case IC_SE.SE_2:
  94. CompletedOpen_SE_2 = true;
  95. break;
  96. case IC_SE.SE_3:
  97. CompletedOpen_SE_3 = true;
  98. break;
  99. }
  100. break;
  101. case IC_CMD.CLOSE_SE:
  102. switch ((IC_SE)data.Value)
  103. {
  104. case IC_SE.SE_1:
  105. CompletedClose_SE_1 = true;
  106. break;
  107. case IC_SE.SE_2:
  108. CompletedClose_SE_2 = true;
  109. break;
  110. case IC_SE.SE_3:
  111. CompletedClose_SE_3 = true;
  112. break;
  113. }
  114. break;
  115. case IC_CMD.ARTICLE_EXITS:
  116. ArticleExits = data.Value > 0;
  117. break;
  118. case IC_CMD.ARTICLE_DIST:
  119. ArticleDist = data.Value;
  120. break;
  121. }
  122. }
  123. catch (Exception ex)
  124. {
  125. }
  126. }
  127. }
  128. }