@@ -1,7 +1,12 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<TargetFramework>net6.0</TargetFramework> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.MessageCommunication\BPASmartClient.MessageCommunication.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.SerialPort\BPASmartClient.SerialPort.csproj" /> | |||
</ItemGroup> | |||
</Project> |
@@ -0,0 +1,44 @@ | |||
using BPASmartClient.KLMCoffee.Protocal; | |||
namespace BPASmartClient.KLMCoffee | |||
{ | |||
/// <summary> | |||
/// 制作咖啡 | |||
/// </summary> | |||
public class MakeCoffeeEvent | |||
{ | |||
public DrinkType DrinkCode { get; set; } | |||
} | |||
/// <summary> | |||
/// 取消制作 | |||
/// </summary> | |||
public class CancelMakeCoffeeEvent | |||
{ | |||
} | |||
/// <summary> | |||
/// 模式设置 | |||
/// </summary> | |||
public class CoffeeCommCmdEvent | |||
{ | |||
//public DrCoffeeCommCmd CommCmd { get; set; } | |||
} | |||
/// <summary> | |||
/// 开始制作 | |||
/// </summary> | |||
public class CoffeBeginCook | |||
{ | |||
} | |||
/// <summary> | |||
/// 结束制作 | |||
/// </summary> | |||
public class CoffeEndCook | |||
{ | |||
} | |||
} |
@@ -0,0 +1,111 @@ | |||
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; | |||
} | |||
} | |||
} |
@@ -113,15 +113,49 @@ namespace BPASmartClient.KLMCoffee.Protocal | |||
#endregion | |||
#region 8种配方测试示例 | |||
//RecipeModel recipeModel = new RecipeModel(); | |||
//string sd = recipeModel.GetItalian(60); | |||
//sd = recipeModel.GetAmerican(60,450); | |||
//sd = recipeModel.GetHotWater(194); | |||
//sd = recipeModel.GetCabo(60,17); | |||
//sd = recipeModel.GetMacChiato(60,8,17); | |||
//sd = recipeModel.GetLatte(60,8,17); | |||
//sd = recipeModel.GetHotMilk(8); | |||
//sd = recipeModel.GetHotMilkFoam(17); | |||
/// <summary> | |||
/// 获取8中配方 | |||
/// </summary> | |||
/// <param name="drink"></param> | |||
/// <returns></returns> | |||
public string Packe(DrinkType drink) | |||
{ | |||
try | |||
{ | |||
switch (drink) | |||
{ | |||
case DrinkType.意式: | |||
return GetItalian(60); | |||
break; | |||
case DrinkType.美式: | |||
return GetAmerican(60,450); | |||
break; | |||
case DrinkType.热水: | |||
return GetHotWater(194); | |||
break; | |||
case DrinkType.卡布: | |||
return GetCabo(60,17); | |||
break; | |||
case DrinkType.玛奇朵: | |||
return GetMacChiato(60,8,17); | |||
break; | |||
case DrinkType.拿铁: | |||
return GetLatte(60,8,17); | |||
break; | |||
case DrinkType.热牛奶: | |||
return GetHotMilk(8); | |||
break; | |||
case DrinkType.热奶沫: | |||
return GetHotMilkFoam(17); | |||
break; | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
return GetItalian(60); | |||
} | |||
return GetItalian(60); | |||
} | |||
#endregion | |||
#region 8种默认配方 | |||
@@ -63,5 +63,24 @@ namespace BPASmartClient.MessageCommunication | |||
/// </summary> | |||
public static string SCChip_RotorSwitch = "SCChip_RotorSwitch"; | |||
#endregion | |||
#region 伽乐美咖啡机消息名称 | |||
/// <summary> | |||
/// 伽乐美咖啡机制作 | |||
/// </summary> | |||
public static string KLMCoffee_MakeCoffee = "KLMCoffee_MakeCoffee"; | |||
/// <summary> | |||
/// 伽乐美咖啡机取消制作咖啡 | |||
/// </summary> | |||
public static string KLMCoffee_CancelMakeCoffee = "KLMCoffee_CancelMakeCoffee"; | |||
/// <summary> | |||
/// 伽乐美咖啡机模式设置 | |||
/// </summary> | |||
public static string KLMCoffee_CoffeeCommCmd = "KLMCoffee_CoffeeCommCmd"; | |||
/// <summary> | |||
/// 伽乐美咖啡机结束制作 | |||
/// </summary> | |||
public static string KLMCoffee_CoffeEndCook = "KLMCoffee_CoffeEndCook"; | |||
#endregion | |||
} | |||
} |