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

257 lines
14 KiB

  1. using BPASmartClient.Business;
  2. using BPASmartClient.Device;
  3. using BPASmartClient.Helper;
  4. using BPASmartClient.MorkF.Model;
  5. using Microsoft.Toolkit.Mvvm.ComponentModel;
  6. using Microsoft.Toolkit.Mvvm.Input;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Collections.ObjectModel;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. namespace BPASmartClient.MorkF.ViewModel
  14. {
  15. internal class DebugViewModel : ObservableObject
  16. {
  17. public bool SimOrderEnable { get { return General_Config.SimOrderAllow; } set { General_Config.SimOrderAllow = value; OnPropertyChanged(); } }
  18. /// <summary>
  19. /// 设备数据
  20. /// </summary>
  21. public ObservableCollection<VariableMonitor> variableMonitors { get; set; }
  22. /// <summary>
  23. /// 设备ID
  24. /// </summary>
  25. public int DeviceId { get; set; }
  26. #region 设备控制
  27. public int FoodMenuID { get { return _foodMenuID; } set { _foodMenuID = value; OnPropertyChanged(); } }
  28. private int _foodMenuID;
  29. public RelayCommand PlcInite { get; set; }
  30. public RelayCommand FoodPlcInite { get; set; }
  31. public RelayCommand Plc1Reset { get; set; }
  32. public RelayCommand StartOrder { get; set; }
  33. public RelayCommand StartLocalOrder { get; set; }
  34. public RelayCommand StopLocalOrder { get; set; }
  35. #endregion
  36. #region 菜品控制
  37. public string RealX { get { return _realX; } set { _realX = value; OnPropertyChanged(); } }
  38. private string _realX;
  39. public string RealY { get { return _realY; } set { _realY = value; OnPropertyChanged(); } }
  40. private string _realY;
  41. public int SettingX { get { return _settingX; } set { _settingX = value; OnPropertyChanged(); } }
  42. private int _settingX = 0;
  43. public int SettingY { get { return _settingY; } set { _settingY = value; OnPropertyChanged(); } }
  44. private int _settingY = 0;
  45. public int MoveSpeed { get { return _moveSpeed; } set { _moveSpeed = value; OnPropertyChanged(); } }
  46. private int _moveSpeed;
  47. public string SensingDistance_1 { get { return _sensingDistance_1; } set { _sensingDistance_1 = value; OnPropertyChanged(); } }
  48. private string _sensingDistance_1 ;
  49. public string SensingDistance_2 { get { return _sensingDistance_2; } set { _sensingDistance_2 = value; OnPropertyChanged(); } }
  50. private string _sensingDistance_2 ;
  51. public string SensingDistance_3 { get { return _sensingDistance_3; } set { _sensingDistance_3 = value; OnPropertyChanged(); } }
  52. private string _sensingDistance_3;
  53. public bool PawPositon1 { get { return _pawPositon1; } set { _pawPositon1 = value; OnPropertyChanged(); } }
  54. private bool _pawPositon1;
  55. public bool PawPositon2 { get { return _pawPositon2; } set { _pawPositon2 = value; OnPropertyChanged(); } }
  56. private bool _pawPositon2;
  57. public bool PawPositon3 { get { return _pawPositon3; } set { _pawPositon3 = value; OnPropertyChanged(); } }
  58. private bool _pawPositon3;
  59. public RelayCommand FoodLibInit { get; set; }//初始化
  60. public RelayCommand StartElectromagnetism { get; set; }//电磁阀启动
  61. public RelayCommand StopElectromagnetism { get; set; }
  62. public RelayCommand SetSpeed { get; set; }//速度设定
  63. public RelayCommand GetDistance_1 { get; set; }//感应测距1
  64. public RelayCommand GetDistance_2 { get; set; }//感应测距2
  65. public RelayCommand GetDistance_3 { get; set; }//感应测距3
  66. public RelayCommand PawTurnFront { get; set; }//夹爪正转
  67. public RelayCommand PawTurnBack { get; set; }//夹爪反转
  68. public RelayCommand SetArmPosition { get; set; }//机器臂位置设定
  69. #endregion
  70. #region 配料仓控制
  71. public List<string> PassageWays { get; set; } = new List<string>()
  72. {
  73. "通道1",
  74. "通道2",
  75. "通道3",
  76. "通道4",
  77. "通道5",
  78. "通道6",
  79. "通道7",
  80. "通道8",
  81. "通道9",
  82. "通道10",
  83. "通道11",
  84. "通道12",
  85. "通道13",
  86. "通道14",
  87. };
  88. public int PassagePosition { get { return _passagePosition; } set { _passagePosition = value; OnPropertyChanged(); } }
  89. private int _passagePosition;
  90. public int Weight { get { return _weight; } set { _weight = value; OnPropertyChanged(); } }
  91. private int _weight;
  92. public RelayCommand OutMaterials { get; set; }
  93. #endregion
  94. #region 炒锅1
  95. public RelayCommand Pot1SimOrder { get; set; }
  96. public RelayCommand AddOil { get; set; }
  97. public RelayCommand StartFire { get; set; }
  98. public RelayCommand StopFire { get; set; }
  99. public RelayCommand StartStir { get; set; }
  100. public RelayCommand StopStir { get; set; }
  101. public RelayCommand OutFood { get; set; }
  102. public RelayCommand StirArmGoOrigin { get; set; }
  103. public RelayCommand StirArmGoWork { get; set; }
  104. public RelayCommand HBOTGoWork { get; set; }
  105. public RelayCommand OutMeal { get; set; }
  106. public RelayCommand SetFire { get; set; }
  107. public RelayCommand SetFry { get; set; }
  108. public RelayCommand SetStir { get; set; }
  109. public List<int> lstFire { get; set; } = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
  110. public List<int> lstFry { get; set; } = new List<int>() { 1, 2 };
  111. public List<int> lstStir { get; set; } = new List<int>() { 1, 2, 3 };
  112. public int FireGear { get { return _fireGear; } set { _fireGear = value; OnPropertyChanged(); } }
  113. private int _fireGear;
  114. public int FryGear { get { return _fryeGear; } set { _fryeGear = value; OnPropertyChanged(); } }
  115. private int _fryeGear;
  116. public int StirGear { get { return _stirGear; } set { _stirGear = value; OnPropertyChanged(); } }
  117. private int _stirGear;
  118. #region 模拟
  119. public int OilTime { get { return _oilTime; } set { _oilTime = value; OnPropertyChanged(); } }
  120. private int _oilTime = 10;
  121. public int OilFirGear { get { return _oilFirGear; } set { _oilFirGear = value; OnPropertyChanged(); } }
  122. private int _oilFirGear = 3;
  123. public int OilStrGear { get { return _oilStrGear; } set { _oilStrGear = value; OnPropertyChanged(); } }
  124. private int _oilStrGear = 1;
  125. public int Food1Time { get { return _food1Time; } set { _food1Time = value; OnPropertyChanged(); } }
  126. private int _food1Time = 30;
  127. public int Food1FirGear { get { return _food1FirGear; } set { _food1FirGear = value; OnPropertyChanged(); } }
  128. private int _food1FirGear = 6;
  129. public int Food1StrGear { get { return _food1StrGear; } set { _food1StrGear = value; OnPropertyChanged(); } }
  130. private int _food1StrGear = 2;
  131. public int Food2Time { get { return _food2Time; } set { _food2Time = value; OnPropertyChanged(); } }
  132. private int _food2Time = 30;
  133. public int Food2FirGear { get { return _food2FirGear; } set { _food2FirGear = value; OnPropertyChanged(); } }
  134. private int _food2FirGear = 6;
  135. public int Food2StrGear { get { return _food2StrGear; } set { _food2StrGear = value; OnPropertyChanged(); } }
  136. private int _food2StrGear = 2;
  137. #endregion
  138. #endregion
  139. #region 炒锅2
  140. public RelayCommand SecAddOil { get; set; }
  141. public RelayCommand SecTempTurnOff { get; set; }
  142. public RelayCommand SecOneBlock { get; set; }
  143. public RelayCommand SecTwoBlock { get; set; }
  144. public RelayCommand SecThreeBlock { get; set; }
  145. public RelayCommand SecOverTurnOff { get; set; }
  146. public RelayCommand SecOverOneBlock { get; set; }
  147. public RelayCommand SecOverTwoBlock { get; set; }
  148. public RelayCommand SecOverThreeBlock { get; set; }
  149. public RelayCommand SecOverGoOn { get; set; }
  150. public RelayCommand SecOverGoDown { get; set; }
  151. public RelayCommand SecAutoModel { get; set; }
  152. public RelayCommand SecManualModel { get; set; }
  153. #endregion
  154. public DebugViewModel()
  155. {
  156. #region 设备控制
  157. PlcInite = new RelayCommand(() => { ActionManage.GetInstance.Send("InitCommand"); });
  158. Plc1Reset = new RelayCommand(() => { ActionManage.GetInstance.Send("Plc1Reset"); });
  159. StartOrder = new RelayCommand(() => { ActionManage.GetInstance.Send("StartOrder", FoodMenuID); });
  160. StartLocalOrder = new RelayCommand(() => { ActionManage.GetInstance.Send("StartLocalOrder"); });
  161. StopLocalOrder = new RelayCommand(() => { ActionManage.GetInstance.Send("StopLocalOrder"); });
  162. #endregion
  163. #region 菜品控制
  164. FoodLibInit = new RelayCommand(() => { ActionManage.GetInstance.Send("FoodLibInit"); });//菜品库初始化
  165. StartElectromagnetism = new RelayCommand(() => { ActionManage.GetInstance.Send("Electromagnetism", new List<bool> { true }); });//电磁阀启动
  166. StopElectromagnetism = new RelayCommand(() => { ActionManage.GetInstance.Send("Electromagnetism", new List<bool> { false });});//电磁阀关闭
  167. SetSpeed = new RelayCommand(() =>
  168. {
  169. ActionManage.GetInstance.Send("SetSpeed", new List<int> { MoveSpeed });
  170. });//设定速度
  171. GetDistance_1 = new RelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_1"); });//感应距离1
  172. GetDistance_2 = new RelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_2"); });//感应距离2
  173. GetDistance_3 = new RelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_3"); });//感应距离3
  174. PawTurnFront = new RelayCommand(() => { ActionManage.GetInstance.Send("PawTurnFront"); });//夹爪正转
  175. PawTurnBack = new RelayCommand(() => { ActionManage.GetInstance.Send("PawTurnBack"); });//夹爪反转
  176. SetArmPosition = new RelayCommand(() => { ActionManage.GetInstance.Send("SetArmPosition", new List<int> { SettingX, SettingY }); });//设定机械臂位置
  177. #endregion
  178. #region 配料仓控制
  179. OutMaterials = new RelayCommand(() => { ActionManage.GetInstance.Send("OutMaterials" ,new List<int> { PassagePosition + 1,Weight } ); });
  180. #endregion
  181. #region 炒锅1
  182. Pot1SimOrder = new RelayCommand(() => { ActionManage.GetInstance.Send("模拟小炒锅1订单",new List<int> { OilTime,OilFirGear,OilStrGear,Food1Time,Food1FirGear,Food1StrGear,Food2Time,Food2FirGear,Food2StrGear }); });//模拟订单
  183. AddOil = new RelayCommand(() => { ActionManage.GetInstance.Send("AddOil", 1); });//加油
  184. StartFire = new RelayCommand(() => { ActionManage.GetInstance.Send("StartFire"); });//加热启动
  185. StopFire = new RelayCommand(() => { ActionManage.GetInstance.Send("StopFire"); });//加热停止
  186. StartStir = new RelayCommand(() => { ActionManage.GetInstance.Send("StartStir"); });//搅拌启动
  187. StopStir = new RelayCommand(() => { ActionManage.GetInstance.Send("StopStir"); });//搅拌停止
  188. OutFood = new RelayCommand(() => { ActionManage.GetInstance.Send("OutFood"); });//倒菜启动
  189. StirArmGoOrigin = new RelayCommand(() => { ActionManage.GetInstance.Send("StirArmGoOrigin"); });//搅拌臂去原点位
  190. StirArmGoWork = new RelayCommand(() => { ActionManage.GetInstance.Send("StirArmGoWork"); });//搅拌臂去炒制位
  191. HBOTGoWork = new RelayCommand(() => { ActionManage.GetInstance.Send("HBOTGoWork"); });//放盒子到位
  192. OutMeal = new RelayCommand(() => { ActionManage.GetInstance.Send("OutMeal"); });//出餐启动
  193. SetFire = new RelayCommand(() => { ActionManage.GetInstance.Send("SetFire", new List<int> { FireGear }); });//加热挡位设定
  194. SetStir = new RelayCommand(() => { ActionManage.GetInstance.Send("SetStir", new List<int> { StirGear }); });//搅拌挡位设定
  195. SetFry = new RelayCommand(() => { ActionManage.GetInstance.Send("SetFry", new List<int> { FryGear }); });//炒锅选择
  196. #endregion
  197. #region 炒锅2
  198. SecAddOil = new RelayCommand(() => { ActionManage.GetInstance.Send("AddOil", 2); });
  199. SecTempTurnOff = new RelayCommand(() => { ActionManage.GetInstance.Send("TakeOff", 2); });
  200. SecOneBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("OneBlock", 2); });
  201. SecTwoBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("TwoBlock", 2); });
  202. SecThreeBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("ThreeBlock", 2); });
  203. SecOverTurnOff = new RelayCommand(() => { ActionManage.GetInstance.Send("OverTurnOff", 2); });
  204. SecOverOneBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("OverOneBlock", 2); });
  205. SecOverTwoBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("OverTwoBlock", 2); });
  206. SecOverThreeBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("OverThreeBlock", 2); });
  207. SecOverGoOn = new RelayCommand(() => { ActionManage.GetInstance.Send("OverGoOn", 2); });
  208. SecOverGoDown = new RelayCommand(() => { ActionManage.GetInstance.Send("OverGoDown", 2); });
  209. SecAutoModel = new RelayCommand(() => { ActionManage.GetInstance.Send("AutoModel", 2); });
  210. SecManualModel = new RelayCommand(() => { ActionManage.GetInstance.Send("ManualModel", 2); });
  211. #endregion
  212. Plugin.GetInstance()?.GetPlugin<DeviceMgr>()?.GetDevices().ForEach(device =>
  213. {
  214. if (device.Name == "MorkT") DeviceId = device.DeviceId
  215. ;
  216. });
  217. ThreadManage.GetInstance().StartLong(new Action(() =>
  218. {
  219. //variableMonitors = Plugin.GetInstance()?.GetPlugin<DeviceMgr>()?.GetDevices()?.FirstOrDefault(p => p.DeviceId == DeviceId)?.variableMonitors;
  220. if(variableMonitors != null)
  221. {
  222. RealX = variableMonitors.FirstOrDefault(p => p.Notes == "机械手臂X").CurrentValue;
  223. RealY = variableMonitors.FirstOrDefault(p => p.Notes == "机械手臂Y").CurrentValue;
  224. }
  225. }), "获取小炒数据");
  226. }
  227. }
  228. }