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.
 
 

148 lines
4.5 KiB

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