|
- using BPASmartClient.KLMCoffee.Protocal;
- using BPASmartClient.MessageCommunication;
- using BPASmartClient.MessageCommunication.MsgControl;
- using BPASmartClient.SerialPort;
- using System;
- using System.Threading;
-
- namespace BPASmartClient.KLMCoffee
- {
- /// <summary>
- /// 指令封装
- /// </summary>
- internal class CommandHandler
- {
- byte[] cmdAsk;
- private SerialPortClient commProxy;
- private K95Command drinksOrder = new K95Command();
- public Action<bool> PauseAsk { get; set; }
-
- /// <summary>
- /// 初始化
- /// </summary>
- internal void Init(SerialPortClient commProxy)
- {
- this.commProxy = commProxy;
- Class_InnerMessageBus.GetInstance().ListenMessage(this,Class_MessageName.KLMCoffee_MakeCoffee,"MakeCoffeeHandler");
- Class_InnerMessageBus.GetInstance().ListenMessage(this,Class_MessageName.KLMCoffee_CancelMakeCoffee,"CancelMakeCoffeeHandler");
- Class_InnerMessageBus.GetInstance().ListenMessage(this,Class_MessageName.KLMCoffee_CoffeeCommCmd,"CoffeeCommCmdHandler");
- }
-
- ///// <summary>
- ///// 制作咖啡
- ///// </summary>
- //public void MakeCoffeeHandler(object sender,InnerMessageEventArgs e)
- //{
- // try
- // {
- // if (e.obj_MessageObj is MakeCoffeeEvent)
- // {
- // PauseAsk?.Invoke(true);
- // Thread.Sleep(200);
- // drinksOrder.ReturnsCommandData(K95CommandEnum.配方咖啡制作.GetString(),new new RecipeModel().Packe
- // );
- // drinksOrder.CommCmd = DrCoffeeCommCmd.饮品制作指令;
- // drinksOrder.DrinksCode = (DrCoffeeDrinksCode)int.Parse(e.obj_MessageObj.ToString());
- // commProxy.SendData(DrCoffee.Packe(drinksOrder));
- // Thread.Sleep(200);
- // PauseAsk?.Invoke(false);
- // }
- // }
- // catch (Exception ex)
- // {
- // MessageLog.GetInstance.Show($"BPASmartClient.DRCoffee 中引发错误,CancelMakeCoffeeHandler 类,描述:[{ex.Message}]");
- // }
- //}
-
- ///// <summary>
- ///// 取消制作
- ///// </summary>
- //public void CancelMakeCoffeeHandler(object sender,InnerMessageEventArgs e)
- //{
- // try
- // {
- // PauseAsk?.Invoke(true);
- // Thread.Sleep(200);
- // drinksOrder.CommCmd = DrCoffeeCommCmd.取消应用指令;
- // drinksOrder.DrinksCode = 0;
- // commProxy.SendData(DrCoffee.Packe(drinksOrder));
- // Thread.Sleep(200);
- // PauseAsk?.Invoke(false);
- // }
- // catch (Exception ex)
- // {
- // MessageLog.GetInstance.Show($"BPASmartClient.DRCoffee 中引发错误,CancelMakeCoffeeHandler 类,描述:[{ex.Message}]");
- // }
- //}
-
- ///// <summary>
- ///// 模式设置
- ///// </summary>
- ///// <param name="sender"></param>
- ///// <param name="e"></param>
- //public void CoffeeCommCmdHandler(object sender,InnerMessageEventArgs e)
- //{
- // try
- // {
- // if (e.obj_MessageObj is string)
- // {
- // PauseAsk?.Invoke(true);
- // Thread.Sleep(200);
- // drinksOrder.CommCmd = (DrCoffeeCommCmd)int.Parse(e.obj_MessageObj.ToString());
- // commProxy.SendData(DrCoffee.Packe(drinksOrder));
- // Thread.Sleep(200);
- // PauseAsk?.Invoke(false);
- // }
- // }
- // catch (Exception ex)
- // {
- // MessageLog.GetInstance.Show($"BPASmartClient.DRCoffee 中引发错误,CoffeeCommCmdHandler 类,描述:[{ex.Message}]");
- // }
- //}
-
- /// <summary>
- /// 发送状态询问
- /// </summary>
- internal byte[] GetStatusAsk()
- {
- return cmdAsk;
- }
- }
- }
|