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

112 lines
4.1 KiB

  1. using BPASmartClient.KLMCoffee.Protocal;
  2. using BPASmartClient.MessageCommunication;
  3. using BPASmartClient.MessageCommunication.MsgControl;
  4. using BPASmartClient.SerialPort;
  5. using System;
  6. using System.Threading;
  7. namespace BPASmartClient.KLMCoffee
  8. {
  9. /// <summary>
  10. /// 指令封装
  11. /// </summary>
  12. internal class CommandHandler
  13. {
  14. byte[] cmdAsk;
  15. private SerialPortClient commProxy;
  16. private K95Command drinksOrder = new K95Command();
  17. public Action<bool> PauseAsk { get; set; }
  18. /// <summary>
  19. /// 初始化
  20. /// </summary>
  21. internal void Init(SerialPortClient commProxy)
  22. {
  23. this.commProxy = commProxy;
  24. Class_InnerMessageBus.GetInstance().ListenMessage(this,Class_MessageName.KLMCoffee_MakeCoffee,"MakeCoffeeHandler");
  25. Class_InnerMessageBus.GetInstance().ListenMessage(this,Class_MessageName.KLMCoffee_CancelMakeCoffee,"CancelMakeCoffeeHandler");
  26. Class_InnerMessageBus.GetInstance().ListenMessage(this,Class_MessageName.KLMCoffee_CoffeeCommCmd,"CoffeeCommCmdHandler");
  27. }
  28. ///// <summary>
  29. ///// 制作咖啡
  30. ///// </summary>
  31. //public void MakeCoffeeHandler(object sender,InnerMessageEventArgs e)
  32. //{
  33. // try
  34. // {
  35. // if (e.obj_MessageObj is MakeCoffeeEvent)
  36. // {
  37. // PauseAsk?.Invoke(true);
  38. // Thread.Sleep(200);
  39. // drinksOrder.ReturnsCommandData(K95CommandEnum.配方咖啡制作.GetString(),new new RecipeModel().Packe
  40. // );
  41. // drinksOrder.CommCmd = DrCoffeeCommCmd.饮品制作指令;
  42. // drinksOrder.DrinksCode = (DrCoffeeDrinksCode)int.Parse(e.obj_MessageObj.ToString());
  43. // commProxy.SendData(DrCoffee.Packe(drinksOrder));
  44. // Thread.Sleep(200);
  45. // PauseAsk?.Invoke(false);
  46. // }
  47. // }
  48. // catch (Exception ex)
  49. // {
  50. // MessageLog.GetInstance.Show($"BPASmartClient.DRCoffee 中引发错误,CancelMakeCoffeeHandler 类,描述:[{ex.Message}]");
  51. // }
  52. //}
  53. ///// <summary>
  54. ///// 取消制作
  55. ///// </summary>
  56. //public void CancelMakeCoffeeHandler(object sender,InnerMessageEventArgs e)
  57. //{
  58. // try
  59. // {
  60. // PauseAsk?.Invoke(true);
  61. // Thread.Sleep(200);
  62. // drinksOrder.CommCmd = DrCoffeeCommCmd.取消应用指令;
  63. // drinksOrder.DrinksCode = 0;
  64. // commProxy.SendData(DrCoffee.Packe(drinksOrder));
  65. // Thread.Sleep(200);
  66. // PauseAsk?.Invoke(false);
  67. // }
  68. // catch (Exception ex)
  69. // {
  70. // MessageLog.GetInstance.Show($"BPASmartClient.DRCoffee 中引发错误,CancelMakeCoffeeHandler 类,描述:[{ex.Message}]");
  71. // }
  72. //}
  73. ///// <summary>
  74. ///// 模式设置
  75. ///// </summary>
  76. ///// <param name="sender"></param>
  77. ///// <param name="e"></param>
  78. //public void CoffeeCommCmdHandler(object sender,InnerMessageEventArgs e)
  79. //{
  80. // try
  81. // {
  82. // if (e.obj_MessageObj is string)
  83. // {
  84. // PauseAsk?.Invoke(true);
  85. // Thread.Sleep(200);
  86. // drinksOrder.CommCmd = (DrCoffeeCommCmd)int.Parse(e.obj_MessageObj.ToString());
  87. // commProxy.SendData(DrCoffee.Packe(drinksOrder));
  88. // Thread.Sleep(200);
  89. // PauseAsk?.Invoke(false);
  90. // }
  91. // }
  92. // catch (Exception ex)
  93. // {
  94. // MessageLog.GetInstance.Show($"BPASmartClient.DRCoffee 中引发错误,CoffeeCommCmdHandler 类,描述:[{ex.Message}]");
  95. // }
  96. //}
  97. /// <summary>
  98. /// 发送状态询问
  99. /// </summary>
  100. internal byte[] GetStatusAsk()
  101. {
  102. return cmdAsk;
  103. }
  104. }
  105. }