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

416 line
13 KiB

  1. global using CommunityToolkit.Mvvm.ComponentModel;
  2. global using CommunityToolkit.Mvvm.Input;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Collections.ObjectModel;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using BPASmartClient.Helper;
  10. using BPASmartClient.Model.大炒;
  11. using BPASmartClient.MorkBF.Model;
  12. using BPASmartClient.MorkBF.VIew;
  13. namespace BPASmartClient.MorkBF.ViewModel
  14. {
  15. [INotifyPropertyChanged]
  16. partial class DebugViewModel
  17. {
  18. /// <summary>
  19. /// 加热挡位
  20. /// </summary>
  21. public ObservableCollection<int> FireGear { get; set; } = new ObservableCollection<int>() { 1, 2, 3, 4, 5 };
  22. /// <summary>
  23. /// 搅拌挡位
  24. /// </summary>
  25. public ObservableCollection<int> StirGear { get; set; } = new ObservableCollection<int>() { 1, 2, 3, 4, 5 };
  26. /// <summary>
  27. /// 炒锅角度
  28. /// </summary>
  29. public ObservableCollection<int> PotAngle { get; set; } = new ObservableCollection<int>() { 1, 2, 3, 4, };
  30. /// <summary>
  31. /// 通道号
  32. /// </summary>
  33. public ObservableCollection<int> PassWay { get; set; } = new ObservableCollection<int>() { 1, 2, 3, 4,5,6,7,8 };
  34. [ObservableProperty]
  35. private int _firePot1_FireGear = 1;//加热挡位
  36. [ObservableProperty]
  37. private int _firePot2_FireGear = 1;
  38. [ObservableProperty]
  39. private int _firePot1_StirGear = 1;//搅拌挡位
  40. [ObservableProperty]
  41. private int _firePot2_StirGear = 1;
  42. [ObservableProperty]
  43. private int _firePot1_TurnSpeed;//翻转速度
  44. [ObservableProperty]
  45. private int _firePot2_TurnSpeed;
  46. [ObservableProperty]
  47. private int _firePot1_PotAngle = 1;//炒锅角度
  48. [ObservableProperty]
  49. private int _firePot2_PotAngle = 1;
  50. [ObservableProperty]
  51. private int _firePot1_PassWay = 1;//通道号
  52. [ObservableProperty]
  53. private int _firePot2_PassWay = 1;
  54. [ObservableProperty]
  55. private int _firePot1_PassValue = 0;//通道需求值
  56. [ObservableProperty]
  57. private int _firePot2_PassValue = 0;
  58. #region 炒锅
  59. /// <summary>
  60. /// 设定加热挡位
  61. /// </summary>
  62. [RelayCommand]
  63. private void FirePot_SetFireGear(object o)
  64. {
  65. if(o == null) return;
  66. if(int.TryParse(o.ToString(),out int i))
  67. {
  68. int value = 0;
  69. if(i == 1)
  70. {
  71. value = FirePot1_FireGear;
  72. }
  73. else if(i == 2)
  74. {
  75. value = FirePot2_FireGear;
  76. }
  77. ActionManage.GetInstance.Send("FirePot_SetFireGear", new object[] { i, value});
  78. }
  79. }
  80. /// <summary>
  81. /// 加热启动
  82. /// </summary>
  83. [RelayCommand]
  84. private void FirePot_StartFire(object o)
  85. {
  86. if (o == null) return;
  87. if (int.TryParse(o.ToString(), out int i))
  88. {
  89. ActionManage.GetInstance.Send("FirePot_StartFire", new object[] { i, true });
  90. }
  91. }
  92. /// <summary>
  93. /// 关闭加热
  94. /// </summary>
  95. [RelayCommand]
  96. private void FirePot_StopFire(object o)
  97. {
  98. if (o == null) return;
  99. if (int.TryParse(o.ToString(), out int i))
  100. {
  101. ActionManage.GetInstance.Send("FirePot_StopFire", new object[] { i, false });
  102. }
  103. }
  104. /// <summary>
  105. /// 设定搅拌挡位
  106. /// </summary>
  107. [RelayCommand]
  108. private void FirePot_SetStirGear(object o)
  109. {
  110. if (o == null) return;
  111. if (int.TryParse(o.ToString(), out int i))
  112. {
  113. int value = 0;
  114. if (i == 1)
  115. {
  116. value = FirePot1_StirGear;
  117. }
  118. else if (i == 2)
  119. {
  120. value = FirePot2_StirGear;
  121. }
  122. ActionManage.GetInstance.Send("FirePot_SetStirGear",new object[] { i, value });
  123. }
  124. }
  125. /// <summary>
  126. /// 搅拌启动
  127. /// </summary>
  128. [RelayCommand]
  129. private void FirePot_StartStir(object o)
  130. {
  131. if (o == null) return;
  132. if (int.TryParse(o.ToString(), out int i))
  133. {
  134. ActionManage.GetInstance.Send("FirePot_StartStir", new object[] { i, true });
  135. }
  136. }
  137. /// <summary>
  138. /// 搅拌停止
  139. /// </summary>
  140. [RelayCommand]
  141. private void FirePot_StopStir(object o)
  142. {
  143. if (o == null) return;
  144. if (int.TryParse(o.ToString(), out int i))
  145. {
  146. ActionManage.GetInstance.Send("FirePot_StopStir", new object[] { i, false });
  147. }
  148. }
  149. /// <summary>
  150. /// 翻转频率设定
  151. /// </summary>
  152. [RelayCommand]
  153. private void FirePot_SetTurnSpeed(object o)
  154. {
  155. if (o == null) return;
  156. if (int.TryParse(o.ToString(), out int i))
  157. {
  158. int value = 0;
  159. if (i == 1)
  160. {
  161. value = FirePot1_TurnSpeed;
  162. }
  163. else if (i == 2)
  164. {
  165. value = FirePot2_TurnSpeed;
  166. }
  167. if (value > 800) value = 800;
  168. ActionManage.GetInstance.Send("FirePot_SetTurnSpeed", new object[] { i, value });
  169. }
  170. }
  171. /// <summary>
  172. /// 设定炒锅角度
  173. /// </summary>
  174. [RelayCommand]
  175. private void FirePot_SetPotAngle(object o)
  176. {
  177. if (o == null) return;
  178. if (int.TryParse(o.ToString(), out int i))
  179. {
  180. int value = 0;
  181. if (i == 1)
  182. {
  183. value = FirePot1_PotAngle;
  184. }
  185. else if (i == 2)
  186. {
  187. value = FirePot2_PotAngle;
  188. }
  189. ActionManage.GetInstance.Send("FirePot_SetPotAngle", new object[] { i, value });
  190. }
  191. }
  192. /// <summary>
  193. /// 通道出料启动
  194. /// </summary>
  195. [RelayCommand]
  196. private void FirePot_StartPassWay(object o)
  197. {
  198. if (o == null) return;
  199. if (int.TryParse(o.ToString(), out int i))
  200. {
  201. int value1 = 0;
  202. int value2 = 0;
  203. if (i == 1)
  204. {
  205. value1 = FirePot1_PassWay;
  206. value2 = FirePot1_PassValue;
  207. }
  208. else if (i == 2)
  209. {
  210. value1 = FirePot2_PassWay;
  211. value2 = FirePot2_PassValue;
  212. }
  213. ActionManage.GetInstance.Send("FirePot_StartPassWay", new object[] { i, value1,value2 });
  214. }
  215. }
  216. /// <summary>
  217. /// 复位
  218. /// </summary>
  219. [RelayCommand]
  220. private void FirePot_Reset(object o)
  221. {
  222. //ActionManage.GetInstance.Send("FirePot1_Reset", o);
  223. }
  224. /// <summary>
  225. /// 炒锅回原点
  226. /// </summary>
  227. [RelayCommand]
  228. private void FirePot_PotGotoOrigin(object o)
  229. {
  230. ActionManage.GetInstance.Send("FirePot_PotGotoOrigin", int.Parse(o.ToString()));
  231. }
  232. /// <summary>
  233. /// 炒锅去投料位置
  234. /// </summary>
  235. [RelayCommand]
  236. private void FirePot_PotGotoInFoodPosition(object o)
  237. {
  238. ActionManage.GetInstance.Send("FirePot_PotGotoInFoodPosition", int.Parse(o.ToString()));
  239. }
  240. /// <summary>
  241. /// 出餐启动
  242. /// </summary>
  243. [RelayCommand]
  244. private void FirePot_StartOutFood(object o)
  245. {
  246. ActionManage.GetInstance.Send("FirePot_StartOutFood", int.Parse(o.ToString()));
  247. }
  248. /// <summary>
  249. /// 清洗
  250. /// </summary>
  251. [RelayCommand]
  252. private void FirePot_Clean(object o)
  253. {
  254. ActionManage.GetInstance.Send("FirePot_Clean", int.Parse(o.ToString()));
  255. }
  256. /// <summary>
  257. /// 抽水启动
  258. /// </summary>
  259. [RelayCommand]
  260. private void FirePot_StartPumpWater(object o)
  261. {
  262. ActionManage.GetInstance.Send("FirePot_StartPumpWater", new object[] { int.Parse(o.ToString()), true });
  263. }
  264. /// <summary>
  265. /// 抽水关闭
  266. /// </summary>
  267. [RelayCommand]
  268. private void FirePot_StopPumpWater(object o)
  269. {
  270. ActionManage.GetInstance.Send("FirePot_StopPumpWater", new object[] { int.Parse(o.ToString()), false });
  271. }
  272. /// <summary>
  273. /// 推杆伸出
  274. /// </summary>
  275. [RelayCommand]
  276. private void FirePot_PushReach(object o)
  277. {
  278. ActionManage.GetInstance.Send("FirePot_PushReach", int.Parse(o.ToString()) );
  279. }
  280. /// <summary>
  281. /// 推杆缩回
  282. /// </summary>
  283. [RelayCommand]
  284. private void FirePot_PushRetract(object o)
  285. {
  286. ActionManage.GetInstance.Send("FirePot_PushRetract", int.Parse(o.ToString()));
  287. }
  288. /// <summary>
  289. /// 翻转正转
  290. /// </summary>
  291. [RelayCommand]
  292. private void FirePot_PotForward(object o)
  293. {
  294. ActionManage.GetInstance.Send("FirePot_PotForward", int.Parse(o.ToString()));
  295. }
  296. /// <summary>
  297. /// 翻转反转
  298. /// </summary>
  299. [RelayCommand]
  300. private void FirePot_PotReversal(object o)
  301. {
  302. ActionManage.GetInstance.Send("FirePot_PotReversal", int.Parse(o.ToString()) );
  303. }
  304. #endregion
  305. #region 机器人
  306. public ObservableCollection<MainTask> RobotMainTask { get; set; } = new ObservableCollection<MainTask>(Enum.GetValues<MainTask>());
  307. public ObservableCollection<SubTask1> RobotSubTask1 { get; set; } = new ObservableCollection<SubTask1>(Enum.GetValues<SubTask1>());
  308. public ObservableCollection<SubTask2> RobotSubTask2 { get; set; } = new ObservableCollection<SubTask2>(Enum.GetValues<SubTask2>());
  309. public ObservableCollection<SubTask3> RobotSubTask3 { get; set; } = new ObservableCollection<SubTask3>(Enum.GetValues<SubTask3>());
  310. public ObservableCollection<SubTask4> RobotSubTask4 { get; set; } = new ObservableCollection<SubTask4>(Enum.GetValues<SubTask4>());
  311. [ObservableProperty]
  312. private MainTask _mainTask;
  313. [ObservableProperty]
  314. private SubTask1 _subTask1;
  315. [ObservableProperty]
  316. private SubTask2 _subTask2;
  317. [ObservableProperty]
  318. private SubTask3 _subTask3;
  319. [ObservableProperty]
  320. private SubTask4 _subTask4;
  321. /// <summary>
  322. /// 机器人启动
  323. /// </summary>
  324. [RelayCommand]
  325. private void RobotStart()
  326. {
  327. ActionManage.GetInstance.Send("RobotStart");
  328. }
  329. /// <summary>
  330. /// 机器人停止
  331. /// </summary>
  332. [RelayCommand]
  333. private void RobotStop()
  334. {
  335. ActionManage.GetInstance.Send("RobotStop");
  336. }
  337. /// <summary>
  338. /// 复位
  339. /// </summary>
  340. [RelayCommand]
  341. private void RobotReset()
  342. {
  343. ActionManage.GetInstance.Send("RobotReset");
  344. }
  345. /// <summary>
  346. /// 机器人上使能
  347. /// </summary>
  348. [RelayCommand]
  349. private void RobotEnable()
  350. {
  351. ActionManage.GetInstance.Send("RobotEnable");
  352. }
  353. /// <summary>
  354. /// 机器人动作
  355. /// </summary>
  356. [RelayCommand]
  357. private void RobotAction(object o)
  358. {
  359. if(int.TryParse(o.ToString(), out int value))
  360. {
  361. object item = new object();
  362. switch (value)
  363. {
  364. case 0:
  365. item = MainTask;
  366. break;
  367. case 1:
  368. item = SubTask1;
  369. break;
  370. case 2:
  371. item = SubTask2;
  372. break;
  373. case 3:
  374. item = SubTask3;
  375. break;
  376. case 4:
  377. item = SubTask4;
  378. break;
  379. default:
  380. break;
  381. }
  382. ActionManage.GetInstance.Send("RobotAction", new object[] { value, item });
  383. }
  384. }
  385. #endregion
  386. }
  387. }