终端一体化运控平台
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 

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