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.
 
 

117 lines
3.7 KiB

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