终端一体化运控平台
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 

337 Zeilen
19 KiB

  1. using BPASmartClient.Business;
  2. using BPASmartClient.Device;
  3. using BPA.Helper;
  4. using BPASmartClient.MorkF.Model;
  5. using BPA.Helper;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Collections.ObjectModel;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. namespace BPASmartClient.MorkF.ViewModel
  13. {
  14. internal class DebugViewModel : NotifyBase
  15. {
  16. public bool SimOrderEnable { get { return General_Config.SimOrderAllow; } set { General_Config.SimOrderAllow = value; OnPropertyChanged(); } }
  17. /// <summary>
  18. /// 设备数据
  19. /// </summary>
  20. public ObservableCollection<VariableMonitor> variableMonitors { get; set; }
  21. /// <summary>
  22. /// 设备ID
  23. /// </summary>
  24. public int DeviceId { get; set; }
  25. #region 设备控制
  26. public int FoodMenuID { get { return _foodMenuID; } set { _foodMenuID = value; OnPropertyChanged(); } }
  27. private int _foodMenuID;
  28. public BPARelayCommand PlcInite { get; set; }
  29. public BPARelayCommand FoodPlcInite { get; set; }
  30. public BPARelayCommand Plc1Reset { get; set; }
  31. public BPARelayCommand StartOrder { get; set; }
  32. public BPARelayCommand StopLocalOrder { get; set; }
  33. public BPARelayCommand ModeChange { get; set; }
  34. #endregion
  35. #region 菜品控制
  36. public string RealX { get { return _realX; } set { _realX = value; OnPropertyChanged(); } }
  37. private string _realX;
  38. public string RealY { get { return _realY; } set { _realY = value; OnPropertyChanged(); } }
  39. private string _realY;
  40. public int SettingX { get { return _settingX; } set { _settingX = value; OnPropertyChanged(); } }
  41. private int _settingX = 0;
  42. public int SettingY { get { return _settingY; } set { _settingY = value; OnPropertyChanged(); } }
  43. private int _settingY = 0;
  44. public int SettingNowX { get { return _settingNowX; } set { _settingNowX = value; OnPropertyChanged(); } }
  45. private int _settingNowX = 0;
  46. public int SettingNowY { get { return _settingNowY; } set { _settingNowY = value; OnPropertyChanged(); } }
  47. private int _settingNowY = 0;
  48. public int MoveSpeed { get { return _moveSpeed; } set { _moveSpeed = value; OnPropertyChanged(); } }
  49. private int _moveSpeed;
  50. public string SensingDistance_1 { get { return _sensingDistance_1; } set { _sensingDistance_1 = value; OnPropertyChanged(); } }
  51. private string _sensingDistance_1;
  52. public string SensingDistance_2 { get { return _sensingDistance_2; } set { _sensingDistance_2 = value; OnPropertyChanged(); } }
  53. private string _sensingDistance_2;
  54. public string SensingDistance_3 { get { return _sensingDistance_3; } set { _sensingDistance_3 = value; OnPropertyChanged(); } }
  55. private string _sensingDistance_3;
  56. public bool PawPositon1 { get { return _pawPositon1; } set { _pawPositon1 = value; OnPropertyChanged(); } }
  57. private bool _pawPositon1;
  58. public bool PawPositon2 { get { return _pawPositon2; } set { _pawPositon2 = value; OnPropertyChanged(); } }
  59. private bool _pawPositon2;
  60. public bool PawPositon3 { get { return _pawPositon3; } set { _pawPositon3 = value; OnPropertyChanged(); } }
  61. private bool _pawPositon3;
  62. public bool ArmRunUp { get { return _armRunUp; } set { _armRunUp = value; OnPropertyChanged(); } }
  63. private bool _armRunUp;
  64. public bool ArmRunDown { get { return _armRunDown; } set { _armRunDown = value; OnPropertyChanged(); } }
  65. private bool _armRunDown;
  66. public bool ArmRunLeft { get { return _armRunLeft; } set { _armRunLeft = value; OnPropertyChanged(); } }
  67. private bool _armRunLeft;
  68. public bool ArmRunRight { get { return _armRunRight; } set { _armRunRight = value; OnPropertyChanged(); } }
  69. private bool _armRunRight;
  70. public bool ArmRunEnable { get { return _ArmRunEnable; } set { _ArmRunEnable = value; OnPropertyChanged(); } }
  71. private bool _ArmRunEnable = true;
  72. public string ArmButtonName { get { return _ArmButtonName; } set { _ArmButtonName = value; OnPropertyChanged(); } }
  73. private string _ArmButtonName = "启动";
  74. public string ModeButten { get { return _ModeButten; } set { _ModeButten = value; OnPropertyChanged(); } }
  75. private string _ModeButten = "联网模式";
  76. public BPARelayCommand SetNowPosition { get; set; }//设置机械臂当前坐标
  77. public BPARelayCommand FoodLibInit { get; set; }//初始化
  78. public BPARelayCommand SurplusCheck { get; set; }//初始化
  79. public BPARelayCommand StartElectromagnetism { get; set; }//电磁阀启动
  80. public BPARelayCommand StopElectromagnetism { get; set; }
  81. public BPARelayCommand SetSpeed { get; set; }//速度设定
  82. public BPARelayCommand GetDistance_1 { get; set; }//感应测距1
  83. public BPARelayCommand GetDistance_2 { get; set; }//感应测距2
  84. public BPARelayCommand GetDistance_3 { get; set; }//感应测距3
  85. public BPARelayCommand PawTurnFront { get; set; }//夹爪正转
  86. public BPARelayCommand PawTurnBack { get; set; }//夹爪反转
  87. public BPARelayCommand SetArmPosition { get; set; }//机器臂位置设定
  88. public BPARelayCommand ArmRun { get; set; }//机械臂运动
  89. public BPARelayCommand PawToPoint1 { get; set; }//感应测距1
  90. public BPARelayCommand PawToPoint2 { get; set; }//感应测距2
  91. public BPARelayCommand PawToPoint3 { get; set; }//感应测距3
  92. #endregion
  93. #region 配料仓控制
  94. public List<string> PassageWays { get; set; } = new List<string>()
  95. {
  96. "通道1",
  97. "通道2",
  98. "通道3",
  99. "通道4",
  100. "通道5",
  101. "通道6",
  102. "通道7",
  103. "通道8",
  104. "通道9",
  105. "通道10",
  106. "通道11",
  107. "通道12",
  108. "通道13",
  109. "通道14",
  110. };
  111. public int PassagePosition { get { return _passagePosition; } set { _passagePosition = value; OnPropertyChanged(); } }
  112. private int _passagePosition;
  113. public int Weight { get { return _weight; } set { _weight = value; OnPropertyChanged(); } }
  114. private int _weight;
  115. public BPARelayCommand OutMaterials { get; set; }
  116. #endregion
  117. #region 炒锅1
  118. public BPARelayCommand Pot1SimOrder { get; set; }
  119. public BPARelayCommand AddOil { get; set; }
  120. public BPARelayCommand StartFire { get; set; }
  121. public BPARelayCommand StopFire { get; set; }
  122. public BPARelayCommand StartStir { get; set; }
  123. public BPARelayCommand StopStir { get; set; }
  124. public BPARelayCommand MagnetOn { get; set; }
  125. public BPARelayCommand MagnetOff { get; set; }
  126. public BPARelayCommand OutFood { get; set; }
  127. public BPARelayCommand StirArmGoOrigin { get; set; }
  128. public BPARelayCommand StirArmGoWork { get; set; }
  129. public BPARelayCommand HBOTGoWork { get; set; }
  130. public BPARelayCommand OutMeal { get; set; }
  131. public BPARelayCommand SetFire { get; set; }
  132. public BPARelayCommand SetFry { get; set; }
  133. public BPARelayCommand SetStir { get; set; }
  134. public List<int> lstFire { get; set; } = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
  135. public List<int> lstFry { get; set; } = new List<int>() { 1, 2 };
  136. public List<int> lstStir { get; set; } = new List<int>() { 1, 2, 3 };
  137. public int FireGear { get { return _fireGear; } set { _fireGear = value; OnPropertyChanged(); } }
  138. private int _fireGear;
  139. public int FryGear { get { return _fryeGear; } set { _fryeGear = value; OnPropertyChanged(); } }
  140. private int _fryeGear;
  141. public int StirGear { get { return _stirGear; } set { _stirGear = value; OnPropertyChanged(); } }
  142. private int _stirGear;
  143. #region 模拟
  144. public int OilTime { get { return _oilTime; } set { _oilTime = value; OnPropertyChanged(); } }
  145. private int _oilTime = 10;
  146. public int OilFirGear { get { return _oilFirGear; } set { _oilFirGear = value; OnPropertyChanged(); } }
  147. private int _oilFirGear = 3;
  148. public int OilStrGear { get { return _oilStrGear; } set { _oilStrGear = value; OnPropertyChanged(); } }
  149. private int _oilStrGear = 1;
  150. public int Food1Time { get { return _food1Time; } set { _food1Time = value; OnPropertyChanged(); } }
  151. private int _food1Time = 30;
  152. public int Food1FirGear { get { return _food1FirGear; } set { _food1FirGear = value; OnPropertyChanged(); } }
  153. private int _food1FirGear = 6;
  154. public int Food1StrGear { get { return _food1StrGear; } set { _food1StrGear = value; OnPropertyChanged(); } }
  155. private int _food1StrGear = 2;
  156. public int Food2Time { get { return _food2Time; } set { _food2Time = value; OnPropertyChanged(); } }
  157. private int _food2Time = 30;
  158. public int Food2FirGear { get { return _food2FirGear; } set { _food2FirGear = value; OnPropertyChanged(); } }
  159. private int _food2FirGear = 6;
  160. public int Food2StrGear { get { return _food2StrGear; } set { _food2StrGear = value; OnPropertyChanged(); } }
  161. private int _food2StrGear = 2;
  162. #endregion
  163. #endregion
  164. #region 炒锅2
  165. public BPARelayCommand SecAddOil { get; set; }
  166. public BPARelayCommand SecTempTurnOff { get; set; }
  167. public BPARelayCommand SecOneBlock { get; set; }
  168. public BPARelayCommand SecTwoBlock { get; set; }
  169. public BPARelayCommand SecThreeBlock { get; set; }
  170. public BPARelayCommand SecOverTurnOff { get; set; }
  171. public BPARelayCommand SecOverOneBlock { get; set; }
  172. public BPARelayCommand SecOverTwoBlock { get; set; }
  173. public BPARelayCommand SecOverThreeBlock { get; set; }
  174. public BPARelayCommand SecOverGoOn { get; set; }
  175. public BPARelayCommand SecOverGoDown { get; set; }
  176. public BPARelayCommand SecAutoModel { get; set; }
  177. public BPARelayCommand SecManualModel { get; set; }
  178. #endregion
  179. public DebugViewModel()
  180. {
  181. #region 设备控制
  182. PlcInite = new BPARelayCommand(() => { ActionManage.GetInstance.Send("InitCommand"); });
  183. Plc1Reset = new BPARelayCommand(() => { ActionManage.GetInstance.Send("Plc1Reset"); });
  184. StartOrder = new BPARelayCommand(() => { ActionManage.GetInstance.Send(FoodMenuID, "StartOrder"); });
  185. StopLocalOrder = new BPARelayCommand(() => { ActionManage.GetInstance.Send("StopLocalOrder"); });
  186. ModeChange = new BPARelayCommand(() =>
  187. {
  188. ActionManage.GetInstance.Send("ModeChange");
  189. if (ModeButten == "联网模式")
  190. {
  191. ModeButten = "本地模式";
  192. }
  193. else
  194. {
  195. ModeButten = "联网模式";
  196. }
  197. });
  198. #endregion
  199. #region 菜品控制
  200. FoodLibInit = new BPARelayCommand(() => { ActionManage.GetInstance.Send("FoodLibInit"); });//菜品库初始化
  201. SurplusCheck = new BPARelayCommand(() => { ActionManage.GetInstance.Send("SurplusCheck"); });//菜品库初始化
  202. StartElectromagnetism = new BPARelayCommand(() => { ActionManage.GetInstance.Send(new List<bool> { false }, "Electromagnetism"); });//电磁阀启动
  203. StopElectromagnetism = new BPARelayCommand(() => { ActionManage.GetInstance.Send(new List<bool> { true }, "Electromagnetism"); });//电磁阀关闭
  204. SetSpeed = new BPARelayCommand(() =>
  205. {
  206. ActionManage.GetInstance.Send(new List<int> { MoveSpeed }, "SetSpeed");
  207. });//设定速度
  208. PawToPoint1 = new BPARelayCommand(() => { ActionManage.GetInstance.Send("PawToPoint1"); });//爪子去1号位
  209. PawToPoint2 = new BPARelayCommand(() => { ActionManage.GetInstance.Send("PawToPoint2"); });//爪子去2号位
  210. PawToPoint3 = new BPARelayCommand(() => { ActionManage.GetInstance.Send("PawToPoint3"); });//爪子去3号位
  211. GetDistance_1 = new BPARelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_1"); });//感应距离1
  212. GetDistance_2 = new BPARelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_2"); });//感应距离2
  213. GetDistance_3 = new BPARelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_3"); });//感应距离3
  214. PawTurnFront = new BPARelayCommand(() => { ActionManage.GetInstance.Send("PawTurnFront"); });//夹爪正转
  215. PawTurnBack = new BPARelayCommand(() => { ActionManage.GetInstance.Send("PawTurnBack"); });//夹爪反转
  216. SetArmPosition = new BPARelayCommand(() => { ActionManage.GetInstance.Send(new List<int> { SettingX, SettingY }, "SetArmPosition"); });//设定机械臂位置
  217. SetNowPosition = new BPARelayCommand(() => { ActionManage.GetInstance.Send(new List<int> { SettingX, SettingY }, "SetNowPosition"); });//设定机械臂当前位置
  218. ArmRun = new BPARelayCommand(() =>
  219. {
  220. //判断是否都未点击
  221. if (!ArmRunDown && !ArmRunUp && !ArmRunLeft && !ArmRunRight)
  222. {
  223. return;
  224. }
  225. ArmRunEnable = !ArmRunEnable;
  226. if (ArmRunEnable)
  227. {
  228. ArmButtonName = "启动";
  229. }
  230. else
  231. {
  232. ArmButtonName = "停止";
  233. }
  234. if (ArmRunUp)
  235. {
  236. ActionManage.GetInstance.Send(!ArmRunEnable, "ArmRunUp");
  237. }
  238. else if (ArmRunDown)
  239. {
  240. ActionManage.GetInstance.Send(!ArmRunEnable, "ArmRunDown");
  241. }
  242. else if (ArmRunLeft)
  243. {
  244. ActionManage.GetInstance.Send(!ArmRunEnable, "ArmRunLeft");
  245. }
  246. else if (ArmRunRight)
  247. {
  248. ActionManage.GetInstance.Send(!ArmRunEnable, "ArmRunRight");
  249. }
  250. });//设定机械臂位置
  251. #endregion
  252. #region 配料仓控制
  253. OutMaterials = new BPARelayCommand(() => { ActionManage.GetInstance.Send(new List<int> { PassagePosition + 1, Weight }, "OutMaterials"); });
  254. #endregion
  255. #region 炒锅1
  256. Pot1SimOrder = new BPARelayCommand(() => { ActionManage.GetInstance.Send(new List<int> { OilTime, OilFirGear, OilStrGear, Food1Time, Food1FirGear, Food1StrGear, Food2Time, Food2FirGear, Food2StrGear }, "模拟小炒锅1订单"); });//模拟订单
  257. AddOil = new BPARelayCommand(() => { ActionManage.GetInstance.Send(1, "AddOil"); });//加油
  258. StartFire = new BPARelayCommand(() => { ActionManage.GetInstance.Send("StartFire"); });//加热启动
  259. StopFire = new BPARelayCommand(() => { ActionManage.GetInstance.Send("StopFire"); });//加热停止
  260. StartStir = new BPARelayCommand(() => { ActionManage.GetInstance.Send("StartStir"); });//搅拌启动
  261. StopStir = new BPARelayCommand(() => { ActionManage.GetInstance.Send("StopStir"); });//搅拌停止
  262. MagnetOn = new BPARelayCommand(() => { ActionManage.GetInstance.Send("MagnetOn"); });//磁吸开启
  263. MagnetOff = new BPARelayCommand(() => { ActionManage.GetInstance.Send("MagnetOff"); });//磁吸开启
  264. OutFood = new BPARelayCommand(() => { ActionManage.GetInstance.Send("OutFood"); });//倒菜启动
  265. StirArmGoOrigin = new BPARelayCommand(() => { ActionManage.GetInstance.Send("StirArmGoOrigin"); });//搅拌臂去原点位
  266. StirArmGoWork = new BPARelayCommand(() => { ActionManage.GetInstance.Send("StirArmGoWork"); });//搅拌臂去炒制位
  267. HBOTGoWork = new BPARelayCommand(() => { ActionManage.GetInstance.Send("HBOTGoWork"); });//放盒子到位
  268. OutMeal = new BPARelayCommand(() => { ActionManage.GetInstance.Send("OutMeal"); });//出餐启动
  269. SetFire = new BPARelayCommand(() => { ActionManage.GetInstance.Send(new List<int> { FireGear }, "SetFire"); });//加热挡位设定
  270. SetStir = new BPARelayCommand(() => { ActionManage.GetInstance.Send(new List<int> { StirGear }, "SetStir"); });//搅拌挡位设定
  271. SetFry = new BPARelayCommand(() => { ActionManage.GetInstance.Send(new List<int> { FryGear }, "SetFry"); });//炒锅选择
  272. #endregion
  273. #region 炒锅2
  274. SecAddOil = new BPARelayCommand(() => { ActionManage.GetInstance.Send(2, "AddOil"); });
  275. SecTempTurnOff = new BPARelayCommand(() => { ActionManage.GetInstance.Send(2, "TakeOff"); });
  276. SecOneBlock = new BPARelayCommand(() => { ActionManage.GetInstance.Send(2, "OneBlock"); });
  277. SecTwoBlock = new BPARelayCommand(() => { ActionManage.GetInstance.Send(2, "TwoBlock"); });
  278. SecThreeBlock = new BPARelayCommand(() => { ActionManage.GetInstance.Send(2, "ThreeBlock"); });
  279. SecOverTurnOff = new BPARelayCommand(() => { ActionManage.GetInstance.Send(2, "OverTurnOff"); });
  280. SecOverOneBlock = new BPARelayCommand(() => { ActionManage.GetInstance.Send(2, "OverOneBlock"); });
  281. SecOverTwoBlock = new BPARelayCommand(() => { ActionManage.GetInstance.Send(2, "OverTwoBlock"); });
  282. SecOverThreeBlock = new BPARelayCommand(() => { ActionManage.GetInstance.Send(2, "OverThreeBlock"); });
  283. SecOverGoOn = new BPARelayCommand(() => { ActionManage.GetInstance.Send(2, "OverGoOn"); });
  284. SecOverGoDown = new BPARelayCommand(() => { ActionManage.GetInstance.Send(2, "OverGoDown"); });
  285. SecAutoModel = new BPARelayCommand(() => { ActionManage.GetInstance.Send(2, "AutoModel"); });
  286. SecManualModel = new BPARelayCommand(() => { ActionManage.GetInstance.Send(2, "ManualModel"); });
  287. #endregion
  288. Plugin.GetInstance?.GetPlugin<DeviceMgr>()?.GetDevices().ForEach(device =>
  289. {
  290. if (device.Name == "MorkT") DeviceId = device.DeviceId
  291. ;
  292. });
  293. TaskManage.GetInstance.StartLong(new Action(() =>
  294. {
  295. //variableMonitors = Plugin.GetInstance?.GetPlugin<DeviceMgr>()?.GetDevices()?.FirstOrDefault(p => p.DeviceId == DeviceId)?.variableMonitors;
  296. if (variableMonitors != null)
  297. {
  298. RealX = variableMonitors.FirstOrDefault(p => p.Notes == "机械手臂X").CurrentValue;
  299. RealY = variableMonitors.FirstOrDefault(p => p.Notes == "机械手臂Y").CurrentValue;
  300. }
  301. }), "获取小炒数据");
  302. }
  303. }
  304. }