终端一体化运控平台
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

133 linhas
4.3 KiB

  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. }