|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace BPASmartClient.KLMCoffee.Protocal
- {
- /// <summary>
- /// 咖啡配方Model,控制内容
- /// </summary>
- public class RecipeModel
- {
- /// <summary>
- /// 饮品类型
- /// </summary>
- public DrinkType 饮品类型 { get; set; }
- /// <summary>
- /// 咖啡量:15-240
- /// </summary>
- public int 咖啡量 { get; set; }
- /// <summary>
- /// 咖啡温度:低/中/高
- /// </summary>
- public TempEnum 咖啡温度 { get; set; }
- /// <summary>
- /// 咖啡浓度:清淡/适中/浓郁
- /// </summary>
- public CoffeeConcentration 咖啡浓度 { get; set; }
- /// <summary>
- /// 热水量:25-450
- /// </summary>
- public int 热水量 { get; set; }
- /// <summary>
- /// 热水温度:低/中/高
- /// </summary>
- public TempEnum 热水温度 { get; set; }
- /// <summary>
- /// 牛奶时间:5-120/0
- /// </summary>
- public int 牛奶时间 { get; set; }
- /// <summary>
- /// 奶沫时间:5-120/0
- /// </summary>
- public int 奶沫时间 { get; set; }
- /// <summary>
- /// 预煮
- /// </summary>
- public CancelOrOkEnum 预煮 { get; set; }
- /// <summary>
- /// 咖啡增强
- /// </summary>
- public CancelOrOkEnum 咖啡增强 { get; set; }
- /// <summary>
- /// 咖啡牛奶同时出
- /// </summary>
- public CancelOrOkEnum 咖啡牛奶同时出 { get; set; }
- /// <summary>
- /// 出品顺序:否:先奶后咖啡 是:先咖啡后奶
- /// </summary>
- public CancelOrOkEnum 出品顺序 { get; set; }
-
- public RecipeModel()
- {
- 饮品类型 = DrinkType.意式;
- 咖啡量 = 0;
- 咖啡温度 = TempEnum.低;
- 咖啡浓度 = CoffeeConcentration.清淡;
- 热水量 = 0;
- 热水温度 = TempEnum.低;
- 牛奶时间 = 0;
- 奶沫时间 = 0;
- 预煮 = CancelOrOkEnum.否;
- 咖啡增强 = CancelOrOkEnum.否;
- 咖啡牛奶同时出 = CancelOrOkEnum.否;
- 出品顺序 = CancelOrOkEnum.否;
- }
-
- #region 获取配方字符串命令
- /// <summary>
- /// Int 转 16进制字符串 (保留几位)
- /// </summary>
- public string IntToHexString(int data,int length = 2)
- {
- try
- {
- return data.ToString("X").PadLeft(length,'0');
- }
- catch (Exception ex)
- {
- return string.Empty;
- }
- }
- /// <summary>
- /// 获取咖啡配方数据
- /// </summary>
- public string GetCoffeeRecipe()
- {
- string retdata = string.Empty;
- try
- {
- retdata = $"{饮品类型.GetString()}{IntToHexString(咖啡量,4)}" +
- $"{咖啡温度.GetString()}{咖啡浓度.GetString()}{IntToHexString(热水量,4)}{热水温度.GetString()}" +
- $"{IntToHexString(牛奶时间,2)}{IntToHexString(奶沫时间,2)}{预煮.GetString()}{咖啡增强.GetString()}" +
- $"{咖啡牛奶同时出.GetString()}{出品顺序.GetString()}";
- }
- catch (Exception ex)
- {
-
- }
- return retdata;
- }
- #endregion
-
- #region 8种配方测试示例
- /// <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种默认配方
- /// <summary>
- /// 意式:仅咖啡
- /// </summary>
- /// <param name="_咖啡量">15-240</param>
- public string GetItalian(int _咖啡量)
- {
- 饮品类型 = DrinkType.意式;
- 咖啡量 = _咖啡量;
- 咖啡温度 = TempEnum.中;
- 咖啡浓度 = CoffeeConcentration.适中;
- 热水量 = 0;
- 热水温度 = TempEnum.低;
- 牛奶时间 = 0;
- 奶沫时间 = 0;
- 预煮 = CancelOrOkEnum.是;
- 咖啡增强 = CancelOrOkEnum.否;
- 咖啡牛奶同时出 = CancelOrOkEnum.否;
- 出品顺序 = CancelOrOkEnum.是;
- return GetCoffeeRecipe();
- }
- /// <summary>
- /// 美式:咖啡+热水
- /// </summary>
- /// <param name="_咖啡量">15-240</param>
- /// <param name="_热水量">25-450</param>
- public string GetAmerican(int _咖啡量,int _热水量)
- {
- 饮品类型 = DrinkType.美式;
- 咖啡量 = _咖啡量;
- 咖啡温度 = TempEnum.中;
- 咖啡浓度 = CoffeeConcentration.适中;
- 热水量 = _热水量;
- 热水温度 = TempEnum.高;
- 牛奶时间 = 0;
- 奶沫时间 = 0;
- 预煮 = CancelOrOkEnum.是;
- 咖啡增强 = CancelOrOkEnum.否;
- 咖啡牛奶同时出 = CancelOrOkEnum.否;
- 出品顺序 = CancelOrOkEnum.是;
- return GetCoffeeRecipe();
- }
- /// <summary>
- /// 热水:仅热水
- /// </summary>
- /// <param name="_热水量">25-450</param>
- public string GetHotWater(int _热水量)
- {
- 饮品类型 = DrinkType.热水;
- 咖啡量 = 0;
- 咖啡温度 = TempEnum.低;
- 咖啡浓度 = CoffeeConcentration.清淡;
- 热水量 = _热水量;
- 热水温度 = TempEnum.高;
- 牛奶时间 = 0;
- 奶沫时间 = 0;
- 预煮 = CancelOrOkEnum.否;
- 咖啡增强 = CancelOrOkEnum.否;
- 咖啡牛奶同时出 = CancelOrOkEnum.否;
- 出品顺序 = CancelOrOkEnum.否;
- return GetCoffeeRecipe();
- }
- /// <summary>
- /// 卡布:热奶沫+咖啡
- /// </summary>
- /// <param name="_咖啡量">15-240</param>
- /// <param name="_奶沫时间">5-120</param>
- public string GetCabo(int _咖啡量,int _奶沫时间)
- {
- 饮品类型 = DrinkType.卡布;
- 咖啡量 = _咖啡量;
- 咖啡温度 = TempEnum.中;
- 咖啡浓度 = CoffeeConcentration.适中;
- 热水量 = 0;
- 热水温度 = TempEnum.低;
- 牛奶时间 = 0;
- 奶沫时间 = _奶沫时间;
- 预煮 = CancelOrOkEnum.是;
- 咖啡增强 = CancelOrOkEnum.是;
- 咖啡牛奶同时出 = CancelOrOkEnum.否;
- 出品顺序 = CancelOrOkEnum.是;
- return GetCoffeeRecipe();
- }
- /// <summary>
- /// 玛奇朵:热牛奶+奶沫+咖啡 牛奶和奶沫不能同时为0
- /// </summary>
- /// <param name="_咖啡量">15-240</param>
- /// <param name="_牛奶时间">5-120</param>
- /// <param name="_奶沫时间">5-120</param>
- public string GetMacChiato(int _咖啡量,int _牛奶时间,int _奶沫时间)
- {
- 饮品类型 = DrinkType.玛奇朵;
- 咖啡量 = _咖啡量;
- 咖啡温度 = TempEnum.中;
- 咖啡浓度 = CoffeeConcentration.适中;
- 热水量 = 0;
- 热水温度 = TempEnum.低;
- 牛奶时间 = _牛奶时间;
- 奶沫时间 = _奶沫时间;
- 预煮 = CancelOrOkEnum.是;
- 咖啡增强 = CancelOrOkEnum.否;
- 咖啡牛奶同时出 = CancelOrOkEnum.是;
- 出品顺序 = CancelOrOkEnum.否;
- return GetCoffeeRecipe();
- }
- /// <summary>
- /// 拿铁:热牛奶+奶沫+咖啡
- /// </summary>
- /// <param name="_咖啡量">15-240</param>
- /// <param name="_牛奶时间">5-120</param>
- /// <param name="_奶沫时间">5-120</param>
- public string GetLatte(int _咖啡量,int _牛奶时间,int _奶沫时间)
- {
- 饮品类型 = DrinkType.拿铁;
- 咖啡量 = _咖啡量;
- 咖啡温度 = TempEnum.中;
- 咖啡浓度 = CoffeeConcentration.适中;
- 热水量 = 0;
- 热水温度 = TempEnum.低;
- 牛奶时间 = _牛奶时间;
- 奶沫时间 = _奶沫时间;
- 预煮 = CancelOrOkEnum.是;
- 咖啡增强 = CancelOrOkEnum.否;
- 咖啡牛奶同时出 = CancelOrOkEnum.否;
- 出品顺序 = CancelOrOkEnum.是;
- return GetCoffeeRecipe();
- }
- /// <summary>
- /// 热牛奶:仅热牛奶
- /// </summary>
- /// <param name="_牛奶时间">5-120</param>
- public string GetHotMilk(int _牛奶时间)
- {
- 饮品类型 = DrinkType.热牛奶;
- 咖啡量 = 0;
- 咖啡温度 = TempEnum.低;
- 咖啡浓度 = CoffeeConcentration.清淡;
- 热水量 = 0;
- 热水温度 = TempEnum.低;
- 牛奶时间 = _牛奶时间;
- 奶沫时间 = 0;
- 预煮 = CancelOrOkEnum.否;
- 咖啡增强 = CancelOrOkEnum.否;
- 咖啡牛奶同时出 = CancelOrOkEnum.否;
- 出品顺序 = CancelOrOkEnum.否;
- return GetCoffeeRecipe();
- }
- /// <summary>
- /// 热奶沫:仅热奶沫
- /// </summary>
- /// <param name="_奶沫时间">5-120</param>
- public string GetHotMilkFoam(int _奶沫时间)
- {
- 饮品类型 = DrinkType.热奶沫;
- 咖啡量 = 0;
- 咖啡温度 = TempEnum.低;
- 咖啡浓度 = CoffeeConcentration.清淡;
- 热水量 = 0;
- 热水温度 = TempEnum.低;
- 牛奶时间 = 0;
- 奶沫时间 = _奶沫时间;
- 预煮 = CancelOrOkEnum.否;
- 咖啡增强 = CancelOrOkEnum.否;
- 咖啡牛奶同时出 = CancelOrOkEnum.否;
- 出品顺序 = CancelOrOkEnum.否;
- return GetCoffeeRecipe();
- }
- #endregion
- }
- }
|