Browse Source

1

样式分支
fyf 2 years ago
parent
commit
9ac7f058a6
5 changed files with 223 additions and 10 deletions
  1. +6
    -1
      BPASmartClient.KLMCoffee/BPASmartClient.KLMCoffee.csproj
  2. +44
    -0
      BPASmartClient.KLMCoffee/CommandEvent.cs
  3. +111
    -0
      BPASmartClient.KLMCoffee/CommandHandler.cs
  4. +43
    -9
      BPASmartClient.KLMCoffee/Protocal/RecipeModel.cs
  5. +19
    -0
      BPASmartClient.MessageCommunication/Class_MessageName.cs

+ 6
- 1
BPASmartClient.KLMCoffee/BPASmartClient.KLMCoffee.csproj View File

@@ -1,7 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">


<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
</PropertyGroup> </PropertyGroup>


<ItemGroup>
<ProjectReference Include="..\BPASmartClient.MessageCommunication\BPASmartClient.MessageCommunication.csproj" />
<ProjectReference Include="..\BPASmartClient.SerialPort\BPASmartClient.SerialPort.csproj" />
</ItemGroup>

</Project> </Project>

+ 44
- 0
BPASmartClient.KLMCoffee/CommandEvent.cs View File

@@ -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
{

}
}

+ 111
- 0
BPASmartClient.KLMCoffee/CommandHandler.cs View File

@@ -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;
}
}
}

+ 43
- 9
BPASmartClient.KLMCoffee/Protocal/RecipeModel.cs View File

@@ -113,15 +113,49 @@ namespace BPASmartClient.KLMCoffee.Protocal
#endregion #endregion


#region 8种配方测试示例 #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 #endregion


#region 8种默认配方 #region 8种默认配方


+ 19
- 0
BPASmartClient.MessageCommunication/Class_MessageName.cs View File

@@ -63,5 +63,24 @@ namespace BPASmartClient.MessageCommunication
/// </summary> /// </summary>
public static string SCChip_RotorSwitch = "SCChip_RotorSwitch"; public static string SCChip_RotorSwitch = "SCChip_RotorSwitch";
#endregion #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
} }
} }

Loading…
Cancel
Save