终端一体化运控平台
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.
 
 
 

374 lines
11 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using BPASmartClient.Helper;
  8. using CommunityToolkit.Mvvm.ComponentModel;
  9. using CommunityToolkit.Mvvm.Input;
  10. namespace BPASmartClient.MorkBF.ViewModel
  11. {
  12. [INotifyPropertyChanged]
  13. partial class DebugViewModel
  14. {
  15. /// <summary>
  16. /// 加热挡位
  17. /// </summary>
  18. public ObservableCollection<int> FireGear { get; set; } = new ObservableCollection<int>() { 1, 2, 3, 4, 5 };
  19. /// <summary>
  20. /// 搅拌挡位
  21. /// </summary>
  22. public ObservableCollection<int> StirGear { get; set; } = new ObservableCollection<int>() { 1, 2, 3, 4, 5 };
  23. [ObservableProperty]
  24. private int _firePot1_FireGear = 0;
  25. [ObservableProperty]
  26. private int _firePot2_FireGear = 0;
  27. [ObservableProperty]
  28. private int _firePot1_StirGear = 0;
  29. [ObservableProperty]
  30. private int _firePot2_StirGear = 0;
  31. [ObservableProperty]
  32. private int _firePot1_TurnSpeed;
  33. [ObservableProperty]
  34. private int _firePot2_TurnSpeed;
  35. #region 炒锅1
  36. /// <summary>
  37. /// 设定加热挡位
  38. /// </summary>
  39. [RelayCommand]
  40. private void FirePot1_SetFireGear()
  41. {
  42. ActionManage.GetInstance.Send("FirePot1_SetFireGear",new List<int> { FirePot1_FireGear});
  43. }
  44. /// <summary>
  45. /// 加热启动
  46. /// </summary>
  47. [RelayCommand]
  48. private void FirePot1_StartFire()
  49. {
  50. ActionManage.GetInstance.Send("FirePot1_StartFire",true);
  51. }
  52. /// <summary>
  53. /// 关闭加热
  54. /// </summary>
  55. [RelayCommand]
  56. private void FirePot1_StopFire()
  57. {
  58. ActionManage.GetInstance.Send("FirePot1_StopFire",false);
  59. }
  60. /// <summary>
  61. /// 设定搅拌挡位
  62. /// </summary>
  63. [RelayCommand]
  64. private void FirePot1_SetStirGear()
  65. {
  66. ActionManage.GetInstance.Send("FirePot1_SetStirGear",new List<int> { FirePot1_StirGear});
  67. }
  68. /// <summary>
  69. /// 搅拌启动
  70. /// </summary>
  71. [RelayCommand]
  72. private void FirePot1_StartStir()
  73. {
  74. ActionManage.GetInstance.Send("FirePot1_StartStir",true);
  75. }
  76. /// <summary>
  77. /// 搅拌停止
  78. /// </summary>
  79. [RelayCommand]
  80. private void FirePot1_StopStir()
  81. {
  82. ActionManage.GetInstance.Send("FirePot1_StopStir",false);
  83. }
  84. /// <summary>
  85. /// 翻转频率设定
  86. /// </summary>
  87. [RelayCommand]
  88. private void FirePot1_SetTurnSpeed()
  89. {
  90. if (FirePot1_TurnSpeed > 800) FirePot1_TurnSpeed = 800;
  91. ActionManage.GetInstance.Send("FirePot1_SetTurnSpeed",new List<int> { FirePot1_TurnSpeed});
  92. }
  93. #endregion
  94. #region 炒锅2
  95. /// <summary>
  96. /// 设定加热挡位
  97. /// </summary>
  98. [RelayCommand]
  99. private void FirePot2_SetFireGear()
  100. {
  101. ActionManage.GetInstance.Send("FirePot2_SetFireGear", new List<int> { FirePot2_FireGear });
  102. }
  103. /// <summary>
  104. /// 加热启动
  105. /// </summary>
  106. [RelayCommand]
  107. private void FirePot2_StartFire()
  108. {
  109. ActionManage.GetInstance.Send("FirePot2_StartFire", true);
  110. }
  111. /// <summary>
  112. /// 关闭加热
  113. /// </summary>
  114. [RelayCommand]
  115. private void FirePot2_StopFire()
  116. {
  117. ActionManage.GetInstance.Send("FirePot2_StopFire", false);
  118. }
  119. /// <summary>
  120. /// 设定搅拌挡位
  121. /// </summary>
  122. [RelayCommand]
  123. private void FirePot2_SetStirGear()
  124. {
  125. ActionManage.GetInstance.Send("FirePot2_SetStirGear", new List<int> { FirePot2_StirGear });
  126. }
  127. /// <summary>
  128. /// 搅拌启动
  129. /// </summary>
  130. [RelayCommand]
  131. private void FirePot2_StartStir()
  132. {
  133. ActionManage.GetInstance.Send("FirePot2_StartStir", true);
  134. }
  135. /// <summary>
  136. /// 搅拌停止
  137. /// </summary>
  138. [RelayCommand]
  139. private void FirePot2_StopStir()
  140. {
  141. ActionManage.GetInstance.Send("FirePot1_StopStir", false);
  142. }
  143. /// <summary>
  144. /// 翻转频率设定
  145. /// </summary>
  146. [RelayCommand]
  147. private void FirePot2_SetTurnSpeed()
  148. {
  149. if (FirePot1_TurnSpeed > 800) FirePot1_TurnSpeed = 800;
  150. ActionManage.GetInstance.Send("FirePot2_SetTurnSpeed", new List<int> { FirePot2_TurnSpeed });
  151. }
  152. #endregion
  153. #region 炒锅通用
  154. /// <summary>
  155. /// 复位
  156. /// </summary>
  157. [RelayCommand]
  158. private void FirePot_Reset(object o)
  159. {
  160. ActionManage.GetInstance.Send("FirePot1_Reset", o);
  161. }
  162. /// <summary>
  163. /// 炒锅回原点
  164. /// </summary>
  165. [RelayCommand]
  166. private void FirePot_PotGotoOrigin(object o)
  167. {
  168. ActionManage.GetInstance.Send("FirePot_PotGotoOrigin", o);
  169. }
  170. /// <summary>
  171. /// 炒锅去位置1
  172. /// </summary>
  173. [RelayCommand]
  174. private void FirePot_PotGotoP1(object o)
  175. {
  176. ActionManage.GetInstance.Send("FirePot_PotGotoP1", o);
  177. }
  178. /// <summary>
  179. ///炒锅去位置2
  180. /// </summary>
  181. [RelayCommand]
  182. private void FirePot_PotGotoP2(object o)
  183. {
  184. ActionManage.GetInstance.Send("FirePot_PotGotoP2", o);
  185. }
  186. /// <summary>
  187. /// 炒锅去位置3
  188. /// </summary>
  189. [RelayCommand]
  190. private void FirePot_PotGotoP3(object o)
  191. {
  192. ActionManage.GetInstance.Send("FirePot_PotGotoP3", o);
  193. }
  194. /// <summary>
  195. /// 炒锅去位置4
  196. /// </summary>
  197. [RelayCommand]
  198. private void FirePot_PotGotoP4(object o)
  199. {
  200. ActionManage.GetInstance.Send("FirePot_PotGotoP4", o);
  201. }
  202. /// <summary>
  203. /// 炒锅去出餐位置
  204. /// </summary>
  205. [RelayCommand]
  206. private void FirePot_PotGotoOutFoodPositiong(object o)
  207. {
  208. ActionManage.GetInstance.Send("FirePot_PotGotoOutFoodPositiong", o);
  209. }
  210. /// <summary>
  211. /// 炒锅去投料位置
  212. /// </summary>
  213. [RelayCommand]
  214. private void FirePot_PotGotoInFoodPosition(object o)
  215. {
  216. ActionManage.GetInstance.Send("FirePot_PotGotoInFoodPosition", o);
  217. }
  218. /// <summary>
  219. /// 出餐启动
  220. /// </summary>
  221. [RelayCommand]
  222. private void FirePot_StartOutFood(object o)
  223. {
  224. ActionManage.GetInstance.Send("FirePot_StartOutFood", o);
  225. }
  226. /// <summary>
  227. /// 清洗
  228. /// </summary>
  229. [RelayCommand]
  230. private void FirePot_Clean(object o)
  231. {
  232. ActionManage.GetInstance.Send("FirePot_Clean",o);
  233. }
  234. /// <summary>
  235. /// 抽水启动
  236. /// </summary>
  237. [RelayCommand]
  238. private void FirePot_StartPumpWater(object o)
  239. {
  240. ActionManage.GetInstance.Send("FirePot_StartPumpWater", o);
  241. }
  242. /// <summary>
  243. /// 抽油启动
  244. /// </summary>
  245. [RelayCommand]
  246. private void FirePot_StartPumpOil(object o)
  247. {
  248. ActionManage.GetInstance.Send("FirePot_StartPumpOil", o);
  249. }
  250. #endregion
  251. #region 机器人
  252. public Dictionary<int,string> RobotActions { get; set; } = new Dictionary<int, string>()
  253. {
  254. {0, "无任务"},
  255. {1, "取1号炒锅荤菜盆倒1号炒锅"},
  256. {2, "取1号炒锅素菜盆1倒1号炒锅"},
  257. {3, "取1号炒锅素菜盆2倒1号炒锅"},
  258. {4, "取1号炒锅调料盆倒入1号炒锅"},
  259. {5, "取1号炒锅辅料盆1倒入1号炒锅"},
  260. {6, "取1号空盆出餐"},
  261. {20, "取2号炒锅荤菜盆1倒1号炒锅"},
  262. {21, "取2号炒锅素菜盆1倒1号炒锅"},
  263. {22, "取2号炒锅素菜盆2倒1号炒锅"},
  264. {23, "取2号炒锅调料盆倒入1号炒锅"},
  265. {24, "取2号炒锅辅料盆1倒入1号炒锅"},
  266. {25, "取2号空盆出餐"},
  267. };
  268. [ObservableProperty]
  269. private int _robotAction;
  270. /// <summary>
  271. /// 机器人启动
  272. /// </summary>
  273. [RelayCommand]
  274. private void RobotStart()
  275. {
  276. ActionManage.GetInstance.Send("RobotStart");
  277. }
  278. /// <summary>
  279. /// 机器人停止
  280. /// </summary>
  281. [RelayCommand]
  282. private void RobotStop()
  283. {
  284. ActionManage.GetInstance.Send("RobotStop");
  285. }
  286. /// <summary>
  287. /// 复位
  288. /// </summary>
  289. [RelayCommand]
  290. private void RobotReset()
  291. {
  292. ActionManage.GetInstance.Send("RobotReset");
  293. }
  294. /// <summary>
  295. /// 程序启动
  296. /// </summary>
  297. [RelayCommand]
  298. private void RobotProgramStart()
  299. {
  300. ActionManage.GetInstance.Send("RobotProgramStart");
  301. }
  302. /// <summary>
  303. /// 1号炒锅允许机器人投料
  304. /// </summary>
  305. [RelayCommand]
  306. private void Robot_Pot1AllowInMaterail()
  307. {
  308. ActionManage.GetInstance.Send("Robot_Pot1AllowInMaterail");
  309. }
  310. /// <summary>
  311. /// 1号炒锅出餐倒料到减速位
  312. /// </summary>
  313. [RelayCommand]
  314. private void Robot_Pot1OutFoodInSlowDown()
  315. {
  316. ActionManage.GetInstance.Send("Robot_Pot1OutFoodInSlowDown");
  317. }
  318. /// <summary>
  319. /// 1号炒锅出餐倒料完成
  320. /// </summary>
  321. [RelayCommand]
  322. private void Robot_Pot1OutFood()
  323. {
  324. ActionManage.GetInstance.Send("Robot_Pot1OutFood");
  325. }
  326. /// <summary>
  327. /// 2号炒锅允许机器人投料
  328. /// </summary>
  329. [RelayCommand]
  330. private void Robot_Pot2AllowInMaterail()
  331. {
  332. ActionManage.GetInstance.Send("Robot_Pot2AllowInMaterail");
  333. }
  334. /// <summary>
  335. /// 2号炒锅出餐倒料到减速位
  336. /// </summary>
  337. [RelayCommand]
  338. private void Robot_Pot2OutFoodInSlowDown()
  339. {
  340. ActionManage.GetInstance.Send("Robot_Pot2OutFoodInSlowDown");
  341. }
  342. /// <summary>
  343. /// 2号炒锅出餐倒料完成
  344. /// </summary>
  345. [RelayCommand]
  346. private void Robot_Pot2OutFood()
  347. {
  348. ActionManage.GetInstance.Send("Robot_Pot2OutFood");
  349. }
  350. /// <summary>
  351. /// 机器人动作启动
  352. /// </summary>
  353. [RelayCommand]
  354. private void RobotActionStart()
  355. {
  356. ActionManage.GetInstance.Send("RobotProgramStart",RobotAction );
  357. }
  358. #endregion
  359. }
  360. }