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.
 
 

244 lines
7.4 KiB

  1. using BPA.Utility;
  2. using HBLConsole.Communication;
  3. using HBLConsole.Service;
  4. using HBLDevice.Coffee;
  5. using HBLDevice.ICChip;
  6. using HBLDevice.IceCream;
  7. using PropertyChanged;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading;
  13. using System.Threading.Tasks;
  14. using HBLConsole.Service;
  15. namespace HBLConsole.Debug
  16. {
  17. [AddINotifyPropertyChangedInterface]
  18. internal class ViewModel_MORKIC
  19. {
  20. public string RobotConnected { get; set; }
  21. public string IceCreamConnected { get; set; }
  22. public string CoffeeConnected { get; set; }
  23. public void SimCoffee()
  24. {
  25. Task.Run(new Action(() =>
  26. {
  27. ActionManage.GetInstance.Send("SimCoffee", (DrCoffeeDrinksCode)Enum.Parse(typeof(DrCoffeeDrinksCode), SelectedCoffee));
  28. }));
  29. }
  30. public void SimIceCream()
  31. {
  32. ActionManage.GetInstance.Send("SimIceCream");
  33. }
  34. #region 咖啡机
  35. /// <summary>
  36. /// 咖啡机状态
  37. /// </summary>
  38. public DrCoffeeStatus CoffeeStatus { get; set; }
  39. /// <summary>
  40. /// 应用状态
  41. /// </summary>
  42. public DrCoffeeAppStatus AppStatus { get; set; }
  43. public DrCoffeeWarning Warning { get; set; }
  44. /// <summary>
  45. /// 故障信息
  46. /// </summary>
  47. public DrCoffeeFault CaffeeFault { get; set; }
  48. public List<string> Coffees { get; set; } = new List<string>();
  49. public string SelectedCoffee { get; set; }
  50. public List<string> CoffeeCmds { get; set; } = new List<string>();
  51. public string SelectedCoffeeCmd { get; set; }
  52. #endregion
  53. #region 冰淇淋
  54. ///// <summary>
  55. ///// 预冷温度
  56. ///// </summary>
  57. //public short YLWD { get; set; }
  58. ///// <summary>
  59. ///// 回气温度
  60. ///// </summary>
  61. //public short HQWD { get; set; }
  62. ///// <summary>
  63. ///// 环境温度
  64. ///// </summary>
  65. //public short HJWD { get; set; }
  66. ///// <summary>
  67. ///// 电流
  68. ///// </summary>
  69. //public short DL { get; set; }
  70. ///// <summary>
  71. ///// 电压
  72. ///// </summary>
  73. //public short DY { get; set; }
  74. ///// <summary>
  75. ///// 当前模式
  76. ///// </summary>
  77. //public MORKI_MODE CurrentMode { get; set; }
  78. ///// <summary>
  79. ///// 故障
  80. ///// </summary>
  81. //public MORKI_FAULT IceCreamFault { get; set; }
  82. ///// <summary>
  83. ///// 成型比
  84. ///// </summary>
  85. //public byte CXB { get; set; }
  86. ///// <summary>
  87. ///// 打料完成状态
  88. ///// </summary>
  89. //public string DLCompleted { get; set; }
  90. public string HasArticle { get; set; }
  91. public byte ArticleDist { get; set; } = 0;
  92. public List<string> IceCreamModes { get; set; } = new List<string>();
  93. public string SelecteIceCreamdMode { get; set; }
  94. #endregion
  95. public ViewModel_MORKIC()
  96. {
  97. foreach (DrCoffeeDrinksCode code in Enum.GetValues(typeof(DrCoffeeDrinksCode)))
  98. {
  99. Coffees.Add(code.ToString());
  100. }
  101. SelectedCoffee = Coffees[0];
  102. foreach (DrCoffeeCommCmd code in Enum.GetValues(typeof(DrCoffeeCommCmd)))
  103. {
  104. CoffeeCmds.Add(code.ToString());
  105. }
  106. SelectedCoffeeCmd = CoffeeCmds[0];
  107. foreach (MORKI_MODE code in Enum.GetValues(typeof(MORKI_MODE)))
  108. {
  109. IceCreamModes.Add(code.ToString());
  110. }
  111. SelecteIceCreamdMode = IceCreamModes[0];
  112. ThreadManage.GetInstance.StartLong(new Action(() =>
  113. {
  114. RobotConnected = LebaiHelper.GetInstance.IsConnected ? "已连接" : "未连接";
  115. IceCreamConnected = ChipStatus.GetInstance().OnLine ? "已连接" : "未连接";
  116. CoffeeConnected = MorkCStatus.GetInstance().OnLine ? "已连接" : "未连接";
  117. CoffeeStatus = MorkCStatus.GetInstance().CoffeeStatus;
  118. AppStatus = MorkCStatus.GetInstance().AppStatus;
  119. Warning = MorkCStatus.GetInstance().Warning;
  120. CaffeeFault = MorkCStatus.GetInstance().Fault;
  121. //YLWD = MorkIStatus.GetInstance().YLWD;
  122. //HQWD = MorkIStatus.GetInstance().HQWD;
  123. //HJWD = MorkIStatus.GetInstance().HJWD;
  124. //DL = MorkIStatus.GetInstance().DL;
  125. //DY = MorkIStatus.GetInstance().DY;
  126. //CurrentMode = MorkIStatus.GetInstance().CurrentMode;
  127. //IceCreamFault = MorkIStatus.GetInstance().Fault;
  128. //CXB = MorkIStatus.GetInstance().CXB;
  129. //DLCompleted = MorkIStatus.GetInstance().DLCompleted ? "打料完成" : "打料中";
  130. HasArticle = ChipStatus.GetInstance().ArticleExits ? "存在" : "无";
  131. ArticleDist = ChipStatus.GetInstance().ArticleDist;
  132. Thread.Sleep(500);
  133. }), "MORK IC-状态刷新");
  134. }
  135. public void MakeIceCream()
  136. {
  137. DischargeEvent dischargeEvent = new DischargeEvent();
  138. dischargeEvent.Publish();
  139. }
  140. public void SetIceCreamModel()
  141. {
  142. ModeSetEvent modeSetEvent = new ModeSetEvent();
  143. modeSetEvent.Mode = (MORKI_MODE)Enum.Parse(typeof(MORKI_MODE), SelecteIceCreamdMode);
  144. modeSetEvent.Publish();
  145. }
  146. public void MakeCoffee()
  147. {
  148. new MakeCoffeeEvent() { DrinkCode = (DrCoffeeDrinksCode)Enum.Parse(typeof(DrCoffeeDrinksCode), SelectedCoffee) }.Publish();
  149. }
  150. public void StopMakeCoffee()
  151. {
  152. new CancelMakeCoffeeEvent().Publish();
  153. }
  154. public void SetCoffeeModel()
  155. {
  156. new CoffeeCommCmdEvent() { CommCmd = (DrCoffeeCommCmd)Enum.Parse(typeof(DrCoffeeCommCmd), SelectedCoffeeCmd) }.Publish();
  157. }
  158. public void OpenSE1()
  159. {
  160. new SESwitchCreamEvent() { SteeringEngine = IC_SE.SE_1, IsOpen = true }.Publish();
  161. }
  162. public void CloseSE1()
  163. {
  164. new SESwitchCreamEvent() { SteeringEngine = IC_SE.SE_1, IsOpen = false }.Publish();
  165. }
  166. public void OpenSE2()
  167. {
  168. new SESwitchCreamEvent() { SteeringEngine = IC_SE.SE_2, IsOpen = true }.Publish();
  169. }
  170. public void CloseSE2()
  171. {
  172. new SESwitchCreamEvent() { SteeringEngine = IC_SE.SE_2, IsOpen = false }.Publish();
  173. }
  174. public void OpenSE3()
  175. {
  176. new SESwitchCreamEvent() { SteeringEngine = IC_SE.SE_3, IsOpen = true }.Publish();
  177. }
  178. public void CloseSE3()
  179. {
  180. new SESwitchCreamEvent() { SteeringEngine = IC_SE.SE_3, IsOpen = false }.Publish();
  181. }
  182. public void TurnRoll()
  183. {
  184. new RotorSwitchEvent() { TurnOn = true }.Publish();
  185. }
  186. public void StopTurnRoll()
  187. {
  188. new RotorSwitchEvent() { TurnOn = false }.Publish();
  189. }
  190. public void MakeIceCreamBySE1()
  191. {
  192. new MakeIceCreamEvent() { SteeringEngine = IC_SE.SE_1 }.Publish();
  193. }
  194. public void DoHasArticle()
  195. {
  196. new ArticleExitsEvent().Publish();
  197. }
  198. public void DoArticleDist()
  199. {
  200. new ArticleDistEvent().Publish();
  201. }
  202. }
  203. }