终端一体化运控平台
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

213 lines
7.4 KiB

  1. using BPASmartClient.Business;
  2. using BPASmartClient.Device;
  3. using BPASmartClient.DRCoffee;
  4. using BPASmartClient.EventBus;
  5. using BPASmartClient.GSIceCream;
  6. using BPASmartClient.Helper;
  7. using BPASmartClient.Lebai;
  8. using BPASmartClient.LebaiRobot;
  9. using BPASmartClient.Model;
  10. using BPASmartClient.Model.冰淇淋.Enum;
  11. using BPASmartClient.Model.咖啡机.Enum;
  12. using BPASmartClient.SCChip;
  13. using Microsoft.Toolkit.Mvvm.ComponentModel;
  14. using Microsoft.Toolkit.Mvvm.Input;
  15. using System;
  16. using System.Collections.Concurrent;
  17. using System.Collections.Generic;
  18. using System.Linq;
  19. using System.Text;
  20. using System.Threading;
  21. using System.Threading.Tasks;
  22. namespace BPASmartClient.ViewModel
  23. {
  24. public class MorkT_DebugViewModel : ObservableObject
  25. {
  26. #region 乐白机器人
  27. /// <summary>
  28. /// 乐白机器人连接状态
  29. /// </summary>
  30. public string RobotConnected { get; set; }
  31. /// <summary>
  32. /// 乐白机器人的模式状态
  33. /// </summary>
  34. public ELebaiRModel RobotMode { get; set; }
  35. /// <summary>
  36. /// 机器人控制指令
  37. /// </summary>
  38. public RelayCommand<object> Button_RobotControlCommand { get; set; }
  39. /// <summary>
  40. /// 机器人控制
  41. /// </summary>
  42. /// <param name="o"></param>
  43. private void Button_RobotControl(object o)
  44. {
  45. ActionManage.GetInstance.Send("调试控制-机器人控制",o.ToString());
  46. }
  47. #endregion
  48. #region 冰淇淋机器
  49. /// <summary>
  50. /// 制作冰淇淋
  51. /// </summary>
  52. public RelayCommand Button_MakeIceCreamCommand { get; set; }
  53. /// <summary>
  54. /// 选择冰淇淋模式
  55. /// </summary>
  56. public RelayCommand Button_SetIceCreamModelCommand { get; set; }
  57. /// <summary>
  58. /// 冰淇淋连接状态
  59. /// </summary>
  60. public string IceCreamConnected { get; set; }
  61. /// <summary>
  62. /// 预冷温度
  63. /// </summary>
  64. public short YLWD { get; set; }
  65. /// <summary>
  66. /// 回气温度
  67. /// </summary>
  68. public short HQWD { get; set; }
  69. /// <summary>
  70. /// 环境温度
  71. /// </summary>
  72. public short HJWD { get; set; }
  73. /// <summary>
  74. /// 电流
  75. /// </summary>
  76. public short DL { get; set; }
  77. /// <summary>
  78. /// 电压
  79. /// </summary>
  80. public short DY { get; set; }
  81. /// <summary>
  82. /// 当前模式
  83. /// </summary>
  84. public MORKI_MODE CurrentMode { get; set; }
  85. /// <summary>
  86. /// 故障
  87. /// </summary>
  88. public MORKI_FAULT IceCreamFault { get; set; }
  89. /// <summary>
  90. /// 成型比
  91. /// </summary>
  92. public byte CXB { get; set; }
  93. /// <summary>
  94. /// 打料完成状态
  95. /// </summary>
  96. public string DLCompleted { get; set; }
  97. public List<string> IceCreamModes { get; set; } = new List<string>();
  98. public string SelecteIceCreamdMode { get; set; }
  99. private void Button_MakeIceCream()
  100. {
  101. }
  102. private void Button_SetIceCreamModel()
  103. {
  104. MORKI_MODE mORKI_MODE = (MORKI_MODE)Enum.Parse(typeof(MORKI_MODE), SelecteIceCreamdMode);
  105. new GSIceCream_ModeSetEvent() { Mode = mORKI_MODE }.Publish();
  106. }
  107. #endregion
  108. #region 咖啡机
  109. /// <summary>
  110. /// 咖啡机连接状态
  111. /// </summary>
  112. public string CoffeeConnected { get; set; }
  113. /// <summary>
  114. /// 咖啡机状态
  115. /// </summary>
  116. public DrCoffeeStatus CoffeeStatus { get; set; }
  117. /// <summary>
  118. /// 应用状态
  119. /// </summary>
  120. public DrCoffeeAppStatus AppStatus { get; set; }
  121. /// <summary>
  122. /// 告警
  123. /// </summary>
  124. public DrCoffeeWarning Warning { get; set; }
  125. /// <summary>
  126. /// 故障信息
  127. /// </summary>
  128. public DrCoffeeFault CaffeeFault { get; set; }
  129. public List<string> Coffees { get; set; } = new List<string>();
  130. public string SelectedCoffee { get; set; }
  131. public List<string> CoffeeCmds { get; set; } = new List<string>();
  132. public string SelectedCoffeeCmd { get; set; }
  133. #endregion
  134. Dictionary<string, object> CurrentData { get; set; }
  135. public MorkT_DebugViewModel()
  136. {
  137. Button_RobotControlCommand = new RelayCommand<object>(Button_RobotControl);
  138. Button_MakeIceCreamCommand = new RelayCommand(Button_MakeIceCream);
  139. Button_SetIceCreamModelCommand = new RelayCommand(Button_SetIceCreamModel);
  140. foreach (DrCoffeeDrinksCode code in Enum.GetValues(typeof(DrCoffeeDrinksCode)))
  141. {
  142. Coffees.Add(code.ToString());
  143. }
  144. SelectedCoffee = Coffees[0];
  145. foreach (DrCoffeeCommCmd code in Enum.GetValues(typeof(DrCoffeeCommCmd)))
  146. {
  147. CoffeeCmds.Add(code.ToString());
  148. }
  149. SelectedCoffeeCmd = CoffeeCmds[0];
  150. foreach (MORKI_MODE code in Enum.GetValues(typeof(MORKI_MODE)))
  151. {
  152. IceCreamModes.Add(code.ToString());
  153. }
  154. SelecteIceCreamdMode = IceCreamModes[0];
  155. ThreadManage.GetInstance().StartLong(new Action(() =>
  156. {
  157. Plugin.GetInstance()?.GetPlugin<DeviceMgr>()?.GetDevices().ForEach(device =>
  158. {
  159. if (device.Name == "MorkT") CurrentData = device.Status.GetStatus();
  160. });
  161. if (CurrentData != null && CurrentData.Count != 0)
  162. {
  163. RobotConnected = (bool)CurrentData["Lebai.LebaiRobot.Connected"] ? "已连接" : "未连接";
  164. IceCreamConnected = (bool)CurrentData["GSIceCream.IceCreamMachine.IsConnected"] ? "已连接" : "未连接";
  165. CoffeeConnected = (bool)CurrentData["GSIceCream.IceCreamMachine.IsConnected"] ? "已连接" : "未连接";
  166. RobotMode = (ELebaiRModel)CurrentData["Lebai.LebaiRobot.RobotMode"];
  167. CoffeeStatus = (DrCoffeeStatus)CurrentData["DRCoffee.CoffeeMachine.Status"];
  168. AppStatus = (DrCoffeeAppStatus)CurrentData["DRCoffee.CoffeeMachine.AppStatus"];
  169. Warning = (DrCoffeeWarning)CurrentData["DRCoffee.CoffeeMachine.Warning"];
  170. CaffeeFault = (DrCoffeeFault)CurrentData["DRCoffee.CoffeeMachine.Fault"];
  171. YLWD = (short)CurrentData["GSIceCream.IceCreamMachine.YLWD"];
  172. HQWD = (short)CurrentData["GSIceCream.IceCreamMachine.HQWD"];
  173. HJWD = (short)CurrentData["GSIceCream.IceCreamMachine.HJWD"];
  174. DL = (short)CurrentData["GSIceCream.IceCreamMachine.DL"];
  175. DY = (short)CurrentData["GSIceCream.IceCreamMachine.DY"];
  176. CurrentMode = (MORKI_MODE)CurrentData["GSIceCream.IceCreamMachine.CurrentMode"];
  177. IceCreamFault = (MORKI_FAULT)CurrentData["GSIceCream.IceCreamMachine.Fault"];
  178. CXB = (byte)CurrentData["GSIceCream.IceCreamMachine.CXB"];
  179. DLCompleted = (bool)CurrentData["GSIceCream.IceCreamMachine.DLCompleted"] ? "打料完成" : "打料中";
  180. }
  181. Thread.Sleep(500);
  182. }), "MorkT-状态刷新");
  183. }
  184. }
  185. }