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.
 
 

163 lines
5.2 KiB

  1. using BPA.Utility;
  2. using HBLConsole.Communication;
  3. using HBLConsole.Service;
  4. using HBLDevice.Coffee;
  5. using HBLDevice.IceCream;
  6. using PropertyChanged;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading;
  12. using System.Threading.Tasks;
  13. namespace HBLConsole.Debug
  14. {
  15. [AddINotifyPropertyChangedInterface]
  16. internal class ViewModel_MORKIC
  17. {
  18. public string RobotConnected { get; set; }
  19. public string IceCreamConnected { get; set; }
  20. public string CoffeeConnected { get; set; }
  21. #region 咖啡机
  22. /// <summary>
  23. /// 咖啡机状态
  24. /// </summary>
  25. public DrCoffeeStatus CoffeeStatus { get; set; }
  26. /// <summary>
  27. /// 应用状态
  28. /// </summary>
  29. public DrCoffeeAppStatus AppStatus { get; set; }
  30. public DrCoffeeWarning Warning { get; set; }
  31. /// <summary>
  32. /// 故障信息
  33. /// </summary>
  34. public DrCoffeeFault CaffeeFault { get; set; }
  35. public List<string> Coffees { get; set; } = new List<string>();
  36. public string SelectedCoffee { get; set; }
  37. public List<string> CoffeeCmds { get; set; } = new List<string>();
  38. public string SelectedCoffeeCmd { get; set; }
  39. #endregion
  40. #region 冰淇淋
  41. /// <summary>
  42. /// 预冷温度
  43. /// </summary>
  44. public short YLWD { get; set; }
  45. /// <summary>
  46. /// 回气温度
  47. /// </summary>
  48. public short HQWD { get; set; }
  49. /// <summary>
  50. /// 环境温度
  51. /// </summary>
  52. public short HJWD { get; set; }
  53. /// <summary>
  54. /// 电流
  55. /// </summary>
  56. public short DL { get; set; }
  57. /// <summary>
  58. /// 电压
  59. /// </summary>
  60. public short DY { get; set; }
  61. /// <summary>
  62. /// 当前模式
  63. /// </summary>
  64. public MORKI_MODE CurrentMode { get; set; }
  65. /// <summary>
  66. /// 故障
  67. /// </summary>
  68. public MORKI_FAULT IceCreamFault { get; set; }
  69. /// <summary>
  70. /// 成型比
  71. /// </summary>
  72. public byte CXB { get; set; }
  73. /// <summary>
  74. /// 打料完成状态
  75. /// </summary>
  76. public string DLCompleted { get; set; }
  77. public List<string> IceCreamModes { get; set; } = new List<string>();
  78. public string SelecteIceCreamdMode { get; set; }
  79. #endregion
  80. public ViewModel_MORKIC()
  81. {
  82. foreach (DrCoffeeDrinksCode code in Enum.GetValues(typeof(DrCoffeeDrinksCode)))
  83. {
  84. Coffees.Add(code.ToString());
  85. }
  86. SelectedCoffee = Coffees[0];
  87. foreach (DrCoffeeCommCmd code in Enum.GetValues(typeof(DrCoffeeCommCmd)))
  88. {
  89. CoffeeCmds.Add(code.ToString());
  90. }
  91. SelectedCoffeeCmd = CoffeeCmds[0];
  92. foreach (MORKI_MODE code in Enum.GetValues(typeof(MORKI_MODE)))
  93. {
  94. IceCreamModes.Add(code.ToString());
  95. }
  96. SelecteIceCreamdMode = IceCreamModes[0];
  97. ThreadManage.GetInstance.StartLong(new Action(() =>
  98. {
  99. RobotConnected = LebaiHelper.GetInstance.IsConnected ? "已连接" : "未连接";
  100. IceCreamConnected = MorkIStatus.GetInstance().OnLine ? "已连接" : "未连接";
  101. CoffeeConnected = MorkCStatus.GetInstance().OnLine ? "已连接" : "未连接";
  102. CoffeeStatus = MorkCStatus.GetInstance().CoffeeStatus;
  103. AppStatus = MorkCStatus.GetInstance().AppStatus;
  104. Warning = MorkCStatus.GetInstance().Warning;
  105. CaffeeFault = MorkCStatus.GetInstance().Fault;
  106. YLWD = MorkIStatus.GetInstance().YLWD;
  107. HQWD = MorkIStatus.GetInstance().HQWD;
  108. HJWD = MorkIStatus.GetInstance().HJWD;
  109. DL = MorkIStatus.GetInstance().DL;
  110. DY = MorkIStatus.GetInstance().DY;
  111. CurrentMode = MorkIStatus.GetInstance().CurrentMode;
  112. IceCreamFault = MorkIStatus.GetInstance().Fault;
  113. CXB = MorkIStatus.GetInstance().CXB;
  114. DLCompleted = MorkIStatus.GetInstance().DLCompleted ? "打料完成" : "打料中";
  115. Thread.Sleep(500);
  116. }), "MORK IC-状态刷新");
  117. }
  118. public void MakeIceCream()
  119. {
  120. DischargeEvent dischargeEvent = new DischargeEvent();
  121. dischargeEvent.Publish();
  122. }
  123. public void SetIceCreamModel()
  124. {
  125. ModeSetEvent modeSetEvent = new ModeSetEvent();
  126. modeSetEvent.Mode = (MORKI_MODE)Enum.Parse(typeof(MORKI_MODE), SelecteIceCreamdMode);
  127. modeSetEvent.Publish();
  128. }
  129. public void MakeCoffee()
  130. {
  131. new MakeCoffeeEvent() { DrinkCode = (DrCoffeeDrinksCode)Enum.Parse(typeof(DrCoffeeDrinksCode), SelectedCoffee) }.Publish();
  132. }
  133. public void StopMakeCoffee()
  134. {
  135. new CancelMakeCoffeeEvent().Publish();
  136. }
  137. public void SetCoffeeModel()
  138. {
  139. new CoffeeCommCmdEvent() { CommCmd = (DrCoffeeCommCmd)Enum.Parse(typeof(DrCoffeeCommCmd), SelectedCoffeeCmd) }.Publish();
  140. }
  141. }
  142. }