终端一体化运控平台
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 

1139 righe
56 KiB

  1. using BPASmartClient.Helper;
  2. using BPASmartClient.MorkF.Model;
  3. using Google.Protobuf.WellKnownTypes;
  4. using Microsoft.Toolkit.Mvvm.ComponentModel;
  5. using Microsoft.Toolkit.Mvvm.Input;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows;
  12. namespace BPASmartClient.MorkF.ViewModel
  13. {
  14. internal class MaterialCalibrationViewModel : ObservableObject
  15. {
  16. #region 菜品库控制
  17. #region 点位1
  18. public bool PositionOne { get { return _PositionOne; } set { _PositionOne = value; OnPropertyChanged(); } }
  19. private bool _PositionOne;
  20. public int OneX { get { return _OneX; } set { _OneX = value; OnPropertyChanged(); } }
  21. private int _OneX;
  22. public int OneY { get { return _OneY; } set { _OneY = value; OnPropertyChanged(); } }
  23. private int _OneY;
  24. #endregion
  25. #region 点位2
  26. public bool PositionTwo { get { return _PositionTwo; } set { _PositionTwo = value; OnPropertyChanged(); } }
  27. private bool _PositionTwo;
  28. public int TwoX { get { return _TwoX; } set { _TwoX = value; OnPropertyChanged(); } }
  29. private int _TwoX;
  30. public int TwoY { get { return _TwoY; } set { _TwoY = value; OnPropertyChanged(); } }
  31. private int _TwoY;
  32. #endregion
  33. #region 点位3
  34. public bool PositionThree { get { return _PositionThree; } set { _PositionThree = value; OnPropertyChanged(); } }
  35. private bool _PositionThree;
  36. public int ThreeX { get { return _ThreeX; } set { _ThreeX = value; OnPropertyChanged(); } }
  37. private int _ThreeX;
  38. public int ThreeY { get { return _ThreeY; } set { _ThreeY = value; OnPropertyChanged(); } }
  39. private int _ThreeY;
  40. #endregion
  41. #region 点位4
  42. public bool PositionFour { get { return _PositionFour; } set { _PositionFour = value; OnPropertyChanged(); } }
  43. private bool _PositionFour;
  44. public int FourX { get { return _FourX; } set { _FourX = value; OnPropertyChanged(); } }
  45. private int _FourX;
  46. public int FourY { get { return _FourY; } set { _FourY = value; OnPropertyChanged(); } }
  47. private int _FourY;
  48. #endregion
  49. #region 点位5
  50. public bool PositionFive { get { return _PositionFive; } set { _PositionFive = value; OnPropertyChanged(); } }
  51. private bool _PositionFive;
  52. public int FiveX { get { return _FiveX; } set { _FiveX = value; OnPropertyChanged(); } }
  53. private int _FiveX;
  54. public int FiveY { get { return _FiveY; } set { _FiveY = value; OnPropertyChanged(); } }
  55. private int _FiveY;
  56. #endregion
  57. #region 点位6
  58. public bool PositionSix { get { return _PositionSix; } set { _PositionSix = value; OnPropertyChanged(); } }
  59. private bool _PositionSix;
  60. public int SixX { get { return _SixX; } set { _SixX = value; OnPropertyChanged(); } }
  61. private int _SixX;
  62. public int SixY { get { return _SixY; } set { _SixY = value; OnPropertyChanged(); } }
  63. private int _SixY;
  64. #endregion
  65. #region 点位7
  66. public bool PositionSeven { get { return _PositionSeven; } set { _PositionSeven = value; OnPropertyChanged(); } }
  67. private bool _PositionSeven;
  68. public int SevenX { get { return _SevenX; } set { _SevenX = value; OnPropertyChanged(); } }
  69. private int _SevenX;
  70. public int SevenY { get { return _SevenY; } set { _SevenY = value; OnPropertyChanged(); } }
  71. private int _SevenY;
  72. #endregion
  73. #region 点位8
  74. public bool PositionEight { get { return _PositionEight; } set { _PositionEight = value; OnPropertyChanged(); } }
  75. private bool _PositionEight;
  76. public int EightX { get { return _EightX; } set { _EightX = value; OnPropertyChanged(); } }
  77. private int _EightX;
  78. public int EightY { get { return _EightY; } set { _EightY = value; OnPropertyChanged(); } }
  79. private int _EightY;
  80. #endregion
  81. #region 点位9
  82. public bool PositionNine { get { return _PositionNine; } set { _PositionNine = value; OnPropertyChanged(); } }
  83. private bool _PositionNine;
  84. public int NineX { get { return _NineX; } set { _NineX = value; OnPropertyChanged(); } }
  85. private int _NineX;
  86. public int NineY { get { return _NineY; } set { _NineY = value; OnPropertyChanged(); } }
  87. private int _NineY;
  88. #endregion
  89. #region 点位10
  90. public bool PositionTen { get { return _PositionTen; } set { _PositionTen = value; OnPropertyChanged(); } }
  91. private bool _PositionTen;
  92. public int TenX { get { return _TenX; } set { _TenX = value; OnPropertyChanged(); } }
  93. private int _TenX;
  94. public int TenY { get { return _TenY; } set { _TenY = value; OnPropertyChanged(); } }
  95. private int _TenY;
  96. #endregion
  97. #region 点位11
  98. public bool PositionEleven { get { return _PositionEleven; } set { _PositionEleven = value; OnPropertyChanged(); } }
  99. private bool _PositionEleven;
  100. public int ElevenX { get { return _ElevenX; } set { _ElevenX = value; OnPropertyChanged(); } }
  101. private int _ElevenX;
  102. public int ElevenY { get { return _ElevenY; } set { _ElevenY = value; OnPropertyChanged(); } }
  103. private int _ElevenY;
  104. #endregion
  105. #region 点位12
  106. public bool PositionTwelve { get { return _PositionTwelve; } set { _PositionTwelve = value; OnPropertyChanged(); } }
  107. private bool _PositionTwelve;
  108. public int TwelveX { get { return _TwelveX; } set { _TwelveX = value; OnPropertyChanged(); } }
  109. private int _TwelveX;
  110. public int TwelveY { get { return _TwelveY; } set { _TwelveY = value; OnPropertyChanged(); } }
  111. private int _TwelveY;
  112. #endregion
  113. #region 点位13
  114. public bool PositionThirteen { get { return _PositionThirteen; } set { _PositionThirteen = value; OnPropertyChanged(); } }
  115. private bool _PositionThirteen;
  116. public int ThirteenX { get { return _ThirteenX; } set { _ThirteenX = value; OnPropertyChanged(); } }
  117. private int _ThirteenX;
  118. public int ThirteenY { get { return _ThirteenY; } set { _ThirteenY = value; OnPropertyChanged(); } }
  119. private int _ThirteenY;
  120. #endregion
  121. #region 点位14
  122. public bool PositionFourteen { get { return _PositionFourteen; } set { _PositionFourteen = value; OnPropertyChanged(); } }
  123. private bool _PositionFourteen;
  124. public int FourteenX { get { return _FourteenX; } set { _FourteenX = value; OnPropertyChanged(); } }
  125. private int _FourteenX;
  126. public int FourteenY { get { return _FourteenY; } set { _FourteenY = value; OnPropertyChanged(); } }
  127. private int _FourteenY;
  128. #endregion
  129. #region 点位15
  130. public bool PositionFifteen { get { return _PositionFifteen; } set { _PositionFifteen = value; OnPropertyChanged(); } }
  131. private bool _PositionFifteen;
  132. public int FifteenX { get { return _FifteenX; } set { _FifteenX = value; OnPropertyChanged(); } }
  133. private int _FifteenX;
  134. public int FifteenY { get { return _FifteenY; } set { _FifteenY = value; OnPropertyChanged(); } }
  135. private int _FifteenY;
  136. #endregion
  137. #region 点位16
  138. public bool PositionSixteen { get { return _PositionSixteen; } set { _PositionSixteen = value; OnPropertyChanged(); } }
  139. private bool _PositionSixteen;
  140. public int SixteenX { get { return _SixteenX; } set { _SixteenX = value; OnPropertyChanged(); } }
  141. private int _SixteenX;
  142. public int SixteenY { get { return _SixteenY; } set { _SixteenY = value; OnPropertyChanged(); } }
  143. private int _SixteenY;
  144. #endregion
  145. #region 点位17
  146. public bool PositionSeventeen { get { return _PositionSeventeen; } set { _PositionSeventeen = value; OnPropertyChanged(); } }
  147. private bool _PositionSeventeen;
  148. public int SeventeenX { get { return _SeventeenX; } set { _SeventeenX = value; OnPropertyChanged(); } }
  149. private int _SeventeenX;
  150. public int SeventeenY { get { return _SeventeenY; } set { _SeventeenY = value; OnPropertyChanged(); } }
  151. private int _SeventeenY;
  152. #endregion
  153. #region 点位18
  154. public bool PositionEighteen { get { return _PositionEighteen; } set { _PositionEighteen = value; OnPropertyChanged(); } }
  155. private bool _PositionEighteen;
  156. public int EighteenX { get { return _EighteenX; } set { _EighteenX = value; OnPropertyChanged(); } }
  157. private int _EighteenX;
  158. public int EighteenY { get { return _EighteenY; } set { _EighteenY = value; OnPropertyChanged(); } }
  159. private int _EighteenY;
  160. #endregion
  161. #region 点位19
  162. public bool PositionNineteen { get { return _PositionNineteen; } set { _PositionNineteen = value; OnPropertyChanged(); } }
  163. private bool _PositionNineteen;
  164. public int NineteenX { get { return _NineteenX; } set { _NineteenX = value; OnPropertyChanged(); } }
  165. private int _NineteenX;
  166. public int NineteenY { get { return _NineteenY; } set { _NineteenY = value; OnPropertyChanged(); } }
  167. private int _NineteenY;
  168. #endregion
  169. #region 点位20
  170. public bool PositionTwenty { get { return _PositionTwenty; } set { _PositionTwenty = value; OnPropertyChanged(); } }
  171. private bool _PositionTwenty;
  172. public int TwentyX { get { return _TwentyX; } set { _TwentyX = value; OnPropertyChanged(); } }
  173. private int _TwentyX;
  174. public int TwentyY { get { return _TwentyY; } set { _TwentyY = value; OnPropertyChanged(); } }
  175. private int _TwentyY;
  176. #endregion
  177. #region 点位21
  178. public bool PositionTwentyOne { get { return _PositionTwentyOne; } set { _PositionTwentyOne = value; OnPropertyChanged(); } }
  179. private bool _PositionTwentyOne;
  180. public int TwentyOneX { get { return _TwentyOneX; } set { _TwentyOneX = value; OnPropertyChanged(); } }
  181. private int _TwentyOneX;
  182. public int TwentyOneY { get { return _TwentyOneY; } set { _TwentyOneY = value; OnPropertyChanged(); } }
  183. private int _TwentyOneY;
  184. #endregion
  185. #region 点位22
  186. public bool PositionTwentyTwo { get { return _PositionTwentyTwo; } set { _PositionTwentyTwo = value; OnPropertyChanged(); } }
  187. private bool _PositionTwentyTwo;
  188. public int TwentyTwoX { get { return _TwentyTwoX; } set { _TwentyTwoX = value; OnPropertyChanged(); } }
  189. private int _TwentyTwoX;
  190. public int TwentyTwoY { get { return _TwentyTwoY; } set { _TwentyTwoY = value; OnPropertyChanged(); } }
  191. private int _TwentyTwoY;
  192. #endregion
  193. #region 点位23
  194. public bool PositionTwentyThree { get { return _PositionTwentyThree; } set { _PositionTwentyThree = value; OnPropertyChanged(); } }
  195. private bool _PositionTwentyThree;
  196. public int TwentyThreeX { get { return _TwentyThreeX; } set { _TwentyThreeX = value; OnPropertyChanged(); } }
  197. private int _TwentyThreeX;
  198. public int TwentyThreeY { get { return _TwentyThreeY; } set { _TwentyThreeY = value; OnPropertyChanged(); } }
  199. private int _TwentyThreeY;
  200. #endregion
  201. #region 点位24
  202. public bool PositionTwentyFour { get { return _PositionTwentyFour; } set { _PositionTwentyFour = value; OnPropertyChanged(); } }
  203. private bool _PositionTwentyFour;
  204. public int TwentyFourX { get { return _TwentyFourX; } set { _TwentyFourX = value; OnPropertyChanged(); } }
  205. private int _TwentyFourX;
  206. public int TwentyFourY { get { return _TwentyFourY; } set { _TwentyFourY = value; OnPropertyChanged(); } }
  207. private int _TwentyFourY;
  208. #endregion
  209. #region 点位25
  210. public bool PositionTwentyFive { get { return _PositionTwentyFive; } set { _PositionTwentyFive = value; OnPropertyChanged(); } }
  211. private bool _PositionTwentyFive;
  212. public int TwentyFiveX { get { return _TwentyFiveX; } set { _TwentyFiveX = value; OnPropertyChanged(); } }
  213. private int _TwentyFiveX;
  214. public int TwentyFiveY { get { return _TwentyFiveY; } set { _TwentyFiveY = value; OnPropertyChanged(); } }
  215. private int _TwentyFiveY;
  216. #endregion
  217. #region 点位26
  218. public bool PositionTwentySix { get { return _PositionTwentySix; } set { _PositionTwentySix = value; OnPropertyChanged(); } }
  219. private bool _PositionTwentySix;
  220. public int TwentySixX { get { return _TwentySixX; } set { _TwentySixX = value; OnPropertyChanged(); } }
  221. private int _TwentySixX;
  222. public int TwentySixY { get { return _TwentySixY; } set { _TwentySixY = value; OnPropertyChanged(); } }
  223. private int _TwentySixY;
  224. #endregion
  225. #region 点位27
  226. public bool PositionTwentySeven { get { return _PositionTwentySeven; } set { _PositionTwentySeven = value; OnPropertyChanged(); } }
  227. private bool _PositionTwentySeven;
  228. public int TwentySevenX { get { return _TwentySevenX; } set { _TwentySevenX = value; OnPropertyChanged(); } }
  229. private int _TwentySevenX;
  230. public int TwentySevenY { get { return _TwentySevenY; } set { _TwentySevenY = value; OnPropertyChanged(); } }
  231. private int _TwentySevenY;
  232. #endregion
  233. #region 菜品库高度测距点位
  234. public bool PositionMaterialHeight { get { return _PositionMaterialHeight; } set { _PositionMaterialHeight = value; OnPropertyChanged(); } }
  235. private bool _PositionMaterialHeight;
  236. public int MaterialHeightX { get { return _MaterialHeightX; } set { _MaterialHeightX = value; OnPropertyChanged(); } }
  237. private int _MaterialHeightX;
  238. public int MaterialHeightY { get { return _MaterialHeightY; } set { _MaterialHeightY = value; OnPropertyChanged(); } }
  239. private int _MaterialHeightY;
  240. #endregion
  241. #region 炒锅1菜品交互位置
  242. public bool PositionFrying1 { get { return _PositionFrying1; } set { _PositionFrying1 = value; OnPropertyChanged(); } }
  243. private bool _PositionFrying1;
  244. public int Frying1X { get { return _Frying1X; } set { _Frying1X = value; OnPropertyChanged(); } }
  245. private int _Frying1X;
  246. public int Frying1Y { get { return _Frying1Y; } set { _Frying1Y = value; OnPropertyChanged(); } }
  247. private int _Frying1Y;
  248. #endregion
  249. #region 炒锅2菜品交互位置
  250. public bool PositionFrying2 { get { return _PositionFrying2; } set { _PositionFrying2 = value; OnPropertyChanged(); } }
  251. private bool _PositionFrying2;
  252. public int Frying2X { get { return _Frying2X; } set { _Frying2X = value; OnPropertyChanged(); } }
  253. private int _Frying2X;
  254. public int Frying2Y { get { return _Frying2Y; } set { _Frying2Y = value; OnPropertyChanged(); } }
  255. private int _Frying2Y;
  256. #endregion
  257. #region 第一层菜品库出菜位置
  258. public bool PositionMaterialOne { get { return _PositionMaterialOne; } set { _PositionMaterialOne = value; OnPropertyChanged(); } }
  259. private bool _PositionMaterialOne;
  260. public int MaterialOneX { get { return _MaterialOneX; } set { _MaterialOneX = value; OnPropertyChanged(); } }
  261. private int _MaterialOneX;
  262. #endregion
  263. #region 第二层菜品库出菜位置
  264. public bool PositionMaterialTwo { get { return _PositionMaterialTwo; } set { _PositionMaterialTwo = value; OnPropertyChanged(); } }
  265. private bool _PositionMaterialTwo;
  266. public int MaterialTwoX { get { return _MaterialTwoX; } set { _MaterialTwoX = value; OnPropertyChanged(); } }
  267. private int _MaterialTwoX;
  268. #endregion
  269. #region 第三层菜品库出菜位置
  270. public bool PositionMaterialThree { get { return _PositionMaterialThree; } set { _PositionMaterialThree = value; OnPropertyChanged(); } }
  271. private bool _PositionMaterialThree;
  272. public int MaterialThreeX { get { return _MaterialThreeX; } set { _MaterialThreeX = value; OnPropertyChanged(); } }
  273. private int _MaterialThreeX;
  274. #endregion
  275. #region 菜品库各传感器高度临时值
  276. public int Distance_1 { get { return _Distance_1; } set { _Distance_1 = value; OnPropertyChanged(); } }
  277. private int _Distance_1;
  278. public int Distance_2 { get { return _Distance_2; } set { _Distance_2 = value; OnPropertyChanged(); } }
  279. private int _Distance_2;
  280. public int Distance_3 { get { return _Distance_3; } set { _Distance_3 = value; OnPropertyChanged(); } }
  281. private int _Distance_3;
  282. #endregion
  283. public bool Up { get { return _Up; } set { _Up = value; OnPropertyChanged(); } }
  284. private bool _Up;
  285. public bool Down { get { return _Down; } set { _Down = value; OnPropertyChanged(); } }
  286. private bool _Down;
  287. public bool Left { get { return _Left; } set { _Left = value; OnPropertyChanged(); } }
  288. private bool _Left;
  289. public bool Right { get { return _Right; } set { _Right = value; OnPropertyChanged(); } }
  290. private bool _Right;
  291. public bool Point { get { return _Point; } set { _Point = value; OnPropertyChanged(); } }
  292. private bool _Point;
  293. public string Str { get { return _str; }set { _str = value;OnPropertyChanged(); } }
  294. private string _str;
  295. /// <summary>
  296. /// 操作时,x轴移动的距离
  297. /// </summary>
  298. public int OperationX { get; set; } = 0;
  299. /// <summary>
  300. /// 操作时,y轴移动的距离
  301. /// </summary>
  302. public int OperationY { get; set; } = 0;
  303. /// <summary>
  304. /// Y轴大菜品库的间隙
  305. /// </summary>
  306. private const int bigMaterialClearanceY = 54000;
  307. /// <summary>
  308. /// Y轴小菜品库的间隙
  309. /// </summary>
  310. private const int smartMaterialClearanceY = 28000;
  311. /// <summary>
  312. /// X轴菜品库的间隙
  313. /// </summary>
  314. private const int materialClearanceX1 = 78000;
  315. /// <summary>
  316. /// X轴菜品库的间隙
  317. /// </summary>
  318. private const int materialClearanceX2 = 88000;
  319. /// <summary>
  320. /// 移动系数
  321. /// </summary>
  322. public int Factor = 1;
  323. /// <summary>
  324. /// 移动基础点位
  325. /// </summary>
  326. private int BasicPosition { get; set; } = 100;
  327. public RelayCommand SetNowPosition { get; set; }//设置机械臂当前坐标
  328. public RelayCommand SaveCoordinate { get; set; }//设置机械臂基于当前坐标往左移动
  329. public RelayCommand ReadCoordinate { get; set; }//设置机械臂基于当前坐标往右移动
  330. public RelayCommand AutoCalculation { get; set; }//设置机械臂基于当前坐标往上移动
  331. public RelayCommand SetNowDownPosition { get; set; }//设置机械臂基于当前坐标往下移动
  332. public RelayCommand FoodLibInit { get; set; }//初始化
  333. public RelayCommand StartElectromagnetism { get; set; }//电磁阀启动
  334. public RelayCommand StopElectromagnetism { get; set; }
  335. public RelayCommand PawTurnFront { get; set; }//夹爪正转
  336. public RelayCommand PawTurnBack { get; set; }//夹爪反转
  337. public RelayCommand PawToPoint1 { get; set; }//感应测距1
  338. public RelayCommand PawToPoint2 { get; set; }//感应测距2
  339. public RelayCommand PawToPoint3 { get; set; }//感应测距3
  340. public RelayCommand GetDistance_1 { get; set; }//感应测距1
  341. public RelayCommand GetDistance_2 { get; set; }//感应测距2
  342. public RelayCommand GetDistance_3 { get; set; }//感应测距3
  343. private static object saveMaterialCoordinateLock = new object();
  344. /// <summary>
  345. /// 保存当前的坐标系
  346. /// </summary>
  347. public void SaveMaterialCoordinate()
  348. {
  349. MaterialCoordinate materialCoordinate = new MaterialCoordinate();
  350. foreach(var dicNoMaterialCoordinate in materialCoordinate.dicNoMaterialCoordinate)
  351. {
  352. switch(dicNoMaterialCoordinate.Key)
  353. {
  354. case "1":
  355. dicNoMaterialCoordinate.Value.X = OneX;
  356. dicNoMaterialCoordinate.Value.Y = OneY;
  357. break;
  358. case "2":
  359. dicNoMaterialCoordinate.Value.X = TwoX;
  360. dicNoMaterialCoordinate.Value.Y = TwoY;
  361. break;
  362. case "3":
  363. dicNoMaterialCoordinate.Value.X = ThreeX;
  364. dicNoMaterialCoordinate.Value.Y = ThreeY;
  365. break;
  366. case "4":
  367. dicNoMaterialCoordinate.Value.X = FourX;
  368. dicNoMaterialCoordinate.Value.Y = FourY;
  369. break;
  370. case "5":
  371. dicNoMaterialCoordinate.Value.X = FiveX;
  372. dicNoMaterialCoordinate.Value.Y = FiveY;
  373. break;
  374. case "6":
  375. dicNoMaterialCoordinate.Value.X = SixX;
  376. dicNoMaterialCoordinate.Value.Y = SixY;
  377. break;
  378. case "7":
  379. dicNoMaterialCoordinate.Value.X = SevenX;
  380. dicNoMaterialCoordinate.Value.Y = SevenY;
  381. break;
  382. case "8":
  383. dicNoMaterialCoordinate.Value.X = EightX;
  384. dicNoMaterialCoordinate.Value.Y = EightY;
  385. break;
  386. case "9":
  387. dicNoMaterialCoordinate.Value.X = NineX;
  388. dicNoMaterialCoordinate.Value.Y = NineY;
  389. break;
  390. case "10":
  391. dicNoMaterialCoordinate.Value.X = TenX;
  392. dicNoMaterialCoordinate.Value.Y = TenY;
  393. break;
  394. case "11":
  395. dicNoMaterialCoordinate.Value.X = ElevenX;
  396. dicNoMaterialCoordinate.Value.Y = ElevenY;
  397. break;
  398. case "12":
  399. dicNoMaterialCoordinate.Value.X = TwelveX;
  400. dicNoMaterialCoordinate.Value.Y = TwelveY;
  401. break;
  402. case "13":
  403. dicNoMaterialCoordinate.Value.X = ThirteenX;
  404. dicNoMaterialCoordinate.Value.Y = ThirteenY;
  405. break;
  406. case "14":
  407. dicNoMaterialCoordinate.Value.X = FourteenX;
  408. dicNoMaterialCoordinate.Value.Y = FourteenY;
  409. break;
  410. case "15":
  411. dicNoMaterialCoordinate.Value.X = FifteenX;
  412. dicNoMaterialCoordinate.Value.Y = FifteenY;
  413. break;
  414. case "16":
  415. dicNoMaterialCoordinate.Value.X = SixteenX;
  416. dicNoMaterialCoordinate.Value.Y = SixteenY;
  417. break;
  418. case "17":
  419. dicNoMaterialCoordinate.Value.X = SeventeenX;
  420. dicNoMaterialCoordinate.Value.Y = SeventeenY;
  421. break;
  422. case "18":
  423. dicNoMaterialCoordinate.Value.X = EighteenX;
  424. dicNoMaterialCoordinate.Value.Y = EighteenY;
  425. break;
  426. case "19":
  427. dicNoMaterialCoordinate.Value.X = NineteenX;
  428. dicNoMaterialCoordinate.Value.Y = NineteenY;
  429. break;
  430. case "20":
  431. dicNoMaterialCoordinate.Value.X = TwentyX;
  432. dicNoMaterialCoordinate.Value.Y = TwentyY;
  433. break;
  434. case "21":
  435. dicNoMaterialCoordinate.Value.X = TwentyOneX;
  436. dicNoMaterialCoordinate.Value.Y = TwentyOneY;
  437. break;
  438. case "22":
  439. dicNoMaterialCoordinate.Value.X = TwentyTwoX;
  440. dicNoMaterialCoordinate.Value.Y = TwentyTwoY;
  441. break;
  442. case "23":
  443. dicNoMaterialCoordinate.Value.X = TwentyThreeX;
  444. dicNoMaterialCoordinate.Value.Y = TwentyThreeY;
  445. break;
  446. case "24":
  447. dicNoMaterialCoordinate.Value.X = TwentyFourX;
  448. dicNoMaterialCoordinate.Value.Y = TwentyFourY;
  449. break;
  450. case "25":
  451. dicNoMaterialCoordinate.Value.X = TwentyFiveX;
  452. dicNoMaterialCoordinate.Value.Y = TwentyFiveY;
  453. break;
  454. case "26":
  455. dicNoMaterialCoordinate.Value.X = TwentySixX;
  456. dicNoMaterialCoordinate.Value.Y = TwentySixY;
  457. break;
  458. case "27":
  459. dicNoMaterialCoordinate.Value.X = TwentySevenX;
  460. dicNoMaterialCoordinate.Value.Y = TwentySevenY;
  461. break;
  462. default:
  463. break;
  464. }
  465. }
  466. materialCoordinate.frying1.X = Frying1X;
  467. materialCoordinate.frying1.Y = Frying1Y;
  468. materialCoordinate.frying2.X = Frying2X;
  469. materialCoordinate.frying2.Y = Frying2Y;
  470. materialCoordinate.materialHeight.X = MaterialHeightX;
  471. materialCoordinate.materialHeight.Y = MaterialHeightY;
  472. materialCoordinate.distance_1 = Distance_1;
  473. materialCoordinate.distance_2 = Distance_2;
  474. materialCoordinate.distance_3 = Distance_3;
  475. materialCoordinate.MaterialOneX = MaterialOneX;
  476. materialCoordinate.MaterialTwoX = MaterialTwoX;
  477. materialCoordinate.MaterialThreeX = MaterialThreeX;
  478. Json<MaterialCoordinate>.Data = materialCoordinate;
  479. Json<MaterialCoordinate>.Save();
  480. //更新当前的菜品库数据
  481. MaterialCoordinate.GetInstance().frying1 = materialCoordinate.frying1;
  482. MaterialCoordinate.GetInstance().frying2 = materialCoordinate.frying2;
  483. MaterialCoordinate.GetInstance().materialHeight = materialCoordinate.materialHeight;
  484. MaterialCoordinate.GetInstance().dicNoMaterialCoordinate = materialCoordinate.dicNoMaterialCoordinate;
  485. MaterialCoordinate.GetInstance().MaterialOneX = materialCoordinate.MaterialOneX;
  486. MaterialCoordinate.GetInstance().MaterialTwoX = materialCoordinate.MaterialTwoX;
  487. MaterialCoordinate.GetInstance().MaterialThreeX = materialCoordinate.MaterialThreeX;
  488. }
  489. /// <summary>
  490. /// 读取坐标系
  491. /// </summary>
  492. /// <returns></returns>
  493. private MaterialCoordinate ReadMaterialCoordinate()
  494. {
  495. try
  496. {
  497. Json<MaterialCoordinate>.Read();
  498. MaterialCoordinate materialCoordinate = Json<MaterialCoordinate>.Data;
  499. return materialCoordinate;
  500. }
  501. catch (Exception ex)
  502. {
  503. return null;
  504. }
  505. }
  506. /// <summary>
  507. /// 从json文件中读取菜品库坐标系数据
  508. /// </summary>
  509. private void PhysicalMaterialCoordinate()
  510. {
  511. MaterialCoordinate materialCoordinate = ReadMaterialCoordinate();
  512. if(materialCoordinate == null)
  513. {
  514. return;
  515. }
  516. if (materialCoordinate.dicNoMaterialCoordinate.Count == 27)
  517. {
  518. foreach (var dicNoMaterialCoordinate in materialCoordinate.dicNoMaterialCoordinate)
  519. {
  520. switch (dicNoMaterialCoordinate.Key)
  521. {
  522. case "1":
  523. OneX = dicNoMaterialCoordinate.Value.X;
  524. OneY = dicNoMaterialCoordinate.Value.Y;
  525. break;
  526. case "2":
  527. TwoX = dicNoMaterialCoordinate.Value.X;
  528. TwoY = dicNoMaterialCoordinate.Value.Y;
  529. break;
  530. case "3":
  531. ThreeX = dicNoMaterialCoordinate.Value.X;
  532. ThreeY = dicNoMaterialCoordinate.Value.Y;
  533. break;
  534. case "4":
  535. FourX = dicNoMaterialCoordinate.Value.X;
  536. FourY = dicNoMaterialCoordinate.Value.Y;
  537. break;
  538. case "5":
  539. FiveX = dicNoMaterialCoordinate.Value.X;
  540. FiveY = dicNoMaterialCoordinate.Value.Y;
  541. break;
  542. case "6":
  543. SixX = dicNoMaterialCoordinate.Value.X;
  544. SixY = dicNoMaterialCoordinate.Value.Y;
  545. break;
  546. case "7":
  547. SevenX = dicNoMaterialCoordinate.Value.X;
  548. SevenY = dicNoMaterialCoordinate.Value.Y;
  549. break;
  550. case "8":
  551. EightX = dicNoMaterialCoordinate.Value.X;
  552. EightY = dicNoMaterialCoordinate.Value.Y;
  553. break;
  554. case "9":
  555. NineX = dicNoMaterialCoordinate.Value.X;
  556. NineY = dicNoMaterialCoordinate.Value.Y;
  557. break;
  558. case "10":
  559. TenX = dicNoMaterialCoordinate.Value.X;
  560. TenY = dicNoMaterialCoordinate.Value.Y;
  561. break;
  562. case "11":
  563. ElevenX = dicNoMaterialCoordinate.Value.X;
  564. ElevenY = dicNoMaterialCoordinate.Value.Y;
  565. break;
  566. case "12":
  567. TwelveX = dicNoMaterialCoordinate.Value.X;
  568. TwelveY = dicNoMaterialCoordinate.Value.Y;
  569. break;
  570. case "13":
  571. ThirteenX = dicNoMaterialCoordinate.Value.X;
  572. ThirteenY = dicNoMaterialCoordinate.Value.Y;
  573. break;
  574. case "14":
  575. FourteenX = dicNoMaterialCoordinate.Value.X;
  576. FourteenY = dicNoMaterialCoordinate.Value.Y;
  577. break;
  578. case "15":
  579. FifteenX = dicNoMaterialCoordinate.Value.X;
  580. FifteenY = dicNoMaterialCoordinate.Value.Y;
  581. break;
  582. case "16":
  583. SixteenX = dicNoMaterialCoordinate.Value.X;
  584. SixteenY = dicNoMaterialCoordinate.Value.Y;
  585. break;
  586. case "17":
  587. SeventeenX = dicNoMaterialCoordinate.Value.X;
  588. SeventeenY = dicNoMaterialCoordinate.Value.Y;
  589. break;
  590. case "18":
  591. EighteenX = dicNoMaterialCoordinate.Value.X;
  592. EighteenY = dicNoMaterialCoordinate.Value.Y;
  593. break;
  594. case "19":
  595. NineteenX = dicNoMaterialCoordinate.Value.X;
  596. NineteenY = dicNoMaterialCoordinate.Value.Y;
  597. break;
  598. case "20":
  599. TwentyX = dicNoMaterialCoordinate.Value.X;
  600. TwentyY = dicNoMaterialCoordinate.Value.Y;
  601. break;
  602. case "21":
  603. TwentyOneX = dicNoMaterialCoordinate.Value.X;
  604. TwentyOneY = dicNoMaterialCoordinate.Value.Y;
  605. break;
  606. case "22":
  607. TwentyTwoX = dicNoMaterialCoordinate.Value.X;
  608. TwentyTwoY = dicNoMaterialCoordinate.Value.Y;
  609. break;
  610. case "23":
  611. TwentyThreeX = dicNoMaterialCoordinate.Value.X;
  612. TwentyThreeY = dicNoMaterialCoordinate.Value.Y;
  613. break;
  614. case "24":
  615. TwentyFourX = dicNoMaterialCoordinate.Value.X;
  616. TwentyFourY = dicNoMaterialCoordinate.Value.Y;
  617. break;
  618. case "25":
  619. TwentyFiveX = dicNoMaterialCoordinate.Value.X;
  620. TwentyFiveY = dicNoMaterialCoordinate.Value.Y;
  621. break;
  622. case "26":
  623. TwentySixX = dicNoMaterialCoordinate.Value.X;
  624. TwentySixY = dicNoMaterialCoordinate.Value.Y;
  625. break;
  626. case "27":
  627. TwentySevenX = dicNoMaterialCoordinate.Value.X;
  628. TwentySevenY = dicNoMaterialCoordinate.Value.Y;
  629. break;
  630. case "MaterialHeight":
  631. MaterialHeightX = materialCoordinate.materialHeight.X;
  632. MaterialHeightY = materialCoordinate.materialHeight.Y;
  633. break;
  634. case "Frying1":
  635. Frying1X = materialCoordinate.frying1.X;
  636. Frying1Y = materialCoordinate.frying1.Y;
  637. break;
  638. case "Frying2":
  639. Frying2X = materialCoordinate.frying2.X;
  640. Frying2Y = materialCoordinate.frying2.Y;
  641. break;
  642. default:
  643. break;
  644. }
  645. }
  646. }
  647. MaterialOneX = materialCoordinate.MaterialOneX;
  648. MaterialTwoX = materialCoordinate.MaterialTwoX;
  649. MaterialThreeX = materialCoordinate.MaterialThreeX;
  650. MaterialHeightX = materialCoordinate.materialHeight.X;
  651. MaterialHeightY = materialCoordinate.materialHeight.Y;
  652. Frying1X = materialCoordinate.frying1.X;
  653. Frying1Y = materialCoordinate.frying1.Y;
  654. Frying2X = materialCoordinate.frying2.X;
  655. Frying2Y = materialCoordinate.frying2.Y;
  656. Distance_1 = materialCoordinate.distance_1;
  657. Distance_2 = materialCoordinate.distance_2;
  658. Distance_3 = materialCoordinate.distance_3;
  659. }
  660. /// <summary>
  661. ///
  662. /// </summary>
  663. /// <param name="Num"></param>
  664. private void Calibration(string Num)
  665. {
  666. switch (Num)
  667. {
  668. case "1":
  669. OneX = OneX + OperationX;
  670. OneY = OneY + OperationX;
  671. break;
  672. case "2":
  673. TwoX = TwoX + OperationX;
  674. TwoY = TwoY + OperationY;
  675. break;
  676. case "3":
  677. ThreeX = ThreeX + OperationX;
  678. ThreeY = ThreeY + OperationY;
  679. break;
  680. case "4":
  681. FourX = FourX + OperationX;
  682. FourY = FourY + OperationY;
  683. break;
  684. case "5":
  685. FiveX = FiveX + OperationX;
  686. FiveY = FiveY + OperationY;
  687. break;
  688. case "6":
  689. SixX = SixX + OperationX;
  690. SixY = SixY + OperationY;
  691. break;
  692. case "7":
  693. SevenX = SevenX + OperationX;
  694. SevenY = SevenY + OperationY;
  695. break;
  696. case "8":
  697. EightX = EightX + OperationX;
  698. EightY = EightY + OperationY;
  699. break;
  700. case "9":
  701. NineX = NineX + OperationX;
  702. NineY = NineY + OperationY;
  703. break;
  704. case "10":
  705. TenX = TenX + OperationX;
  706. TenY = TenY + OperationY;
  707. break;
  708. case "11":
  709. ElevenX = ElevenX + OperationX;
  710. ElevenY = ElevenY + OperationY;
  711. break;
  712. case "12":
  713. TwelveX = TwelveX + OperationX;
  714. TwelveY = TwelveY + OperationY;
  715. break;
  716. case "13":
  717. ThirteenX = ThirteenX + OperationX;
  718. ThirteenY = ThirteenY + OperationY;
  719. break;
  720. case "14":
  721. FourteenX = FourteenX + OperationX;
  722. FourteenY = FourteenY + OperationY;
  723. break;
  724. case "15":
  725. FifteenX = FifteenX + OperationX;
  726. FifteenY = FifteenY + OperationY;
  727. break;
  728. case "16":
  729. SixteenX = SixteenX + OperationX;
  730. SixteenY = SixteenY + OperationY;
  731. break;
  732. case "17":
  733. SeventeenX = SeventeenX + OperationX;
  734. SeventeenY = SeventeenY + OperationY;
  735. break;
  736. case "18":
  737. EighteenX = EighteenX + OperationX;
  738. EighteenY = EighteenY + OperationY;
  739. break;
  740. case "19":
  741. NineteenX = NineteenX + OperationX;
  742. NineteenY = NineteenY + OperationY;
  743. break;
  744. case "20":
  745. TwentyX = TwentyX + OperationX;
  746. TwentyY = TwentyY + OperationY;
  747. break;
  748. case "21":
  749. TwentyOneX = TwentyOneX + OperationX;
  750. TwentyOneY = TwentyOneY + OperationY;
  751. break;
  752. case "22":
  753. TwentyTwoX = TwentyTwoX + OperationX;
  754. TwentyTwoY = TwentyTwoY + OperationY;
  755. break;
  756. case "23":
  757. TwentyThreeX = TwentyThreeX + OperationX;
  758. TwentyThreeY = TwentyThreeY + OperationY;
  759. break;
  760. case "24":
  761. TwentyFourX = TwentyFourX + OperationX;
  762. TwentyFourY = TwentyFourY + OperationY;
  763. break;
  764. case "25":
  765. TwentyFiveX = TwentyFiveX + OperationX;
  766. TwentyFiveY = TwentyFiveY + OperationY;
  767. break;
  768. case "26":
  769. TwentySixX = TwentySixX + OperationX;
  770. TwentySixY = TwentySixY + OperationY;
  771. break;
  772. case "27":
  773. TwentySevenX = TwentySevenX + OperationX;
  774. TwentySevenY = TwentySevenY + OperationY;
  775. break;
  776. case "MaterialHeight":
  777. MaterialHeightX = MaterialHeightX + OperationX;
  778. MaterialHeightY = MaterialHeightY + OperationY;
  779. break;
  780. case "Frying1":
  781. Frying1X = Frying1X + OperationX;
  782. Frying1Y = Frying1Y + OperationY;
  783. break;
  784. case "Frying2":
  785. Frying2X = Frying2X + OperationX;
  786. Frying2Y = Frying2Y + OperationY;
  787. break;
  788. case "MaterialOne":
  789. MaterialOneX = MaterialOneX + OperationX;
  790. break;
  791. case "MaterialTwo":
  792. MaterialTwoX = MaterialTwoX + OperationX;
  793. break;
  794. case "MaterialThree":
  795. MaterialThreeX = MaterialThreeX + OperationX;
  796. break;
  797. default:
  798. break;
  799. }
  800. OperationX = 0;
  801. OperationY = 0;
  802. }
  803. private void SetPosition()
  804. {
  805. //判断是否有选择下发的设备
  806. if (!PositionOne && !PositionTwo && !PositionThree && !PositionFour && !PositionFive && !PositionSix && !PositionSeven && !PositionEight && !PositionNine
  807. && !PositionTen && !PositionEleven && !PositionTwelve && !PositionThirteen && !PositionFourteen && !PositionFifteen && !PositionSixteen && !PositionSeventeen && !PositionEighteen
  808. && !PositionNineteen && !PositionTwenty && !PositionTwentyOne && !PositionTwentyTwo && !PositionTwentyThree && !PositionTwentyFour && !PositionTwentyFive && !PositionTwentySix && !PositionTwentySeven
  809. && !PositionMaterialHeight && !PositionFrying1 && !PositionFrying2 && !PositionMaterialOne && !PositionMaterialThree &&!PositionMaterialTwo)
  810. {
  811. MessageBox.Show("未选择点位");
  812. return;
  813. }
  814. if (PositionOne)
  815. {
  816. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> {"1", OneX + OperationX, OneY + OperationY });//设定机械臂当前位置
  817. }
  818. if (PositionTwo)
  819. {
  820. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "2", TwoX + OperationX, TwoY + OperationY });//设定机械臂当前位置
  821. }
  822. if (PositionThree)
  823. {
  824. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "3", ThreeX + OperationX, ThreeY + OperationY });//设定机械臂当前位置
  825. }
  826. if (PositionFour)
  827. {
  828. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "4", FourX + OperationX, FourY + OperationY });//设定机械臂当前位置
  829. }
  830. if (PositionFive)
  831. {
  832. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "5", FiveX + OperationX, FiveY + OperationY });//设定机械臂当前位置
  833. }
  834. if (PositionSix)
  835. {
  836. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "6", SixX + OperationX, SixY + OperationY });//设定机械臂当前位置
  837. }
  838. if (PositionSeven)
  839. {
  840. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "7", SevenX + OperationX, SevenY + OperationY });//设定机械臂当前位置
  841. }
  842. if (PositionEight)
  843. {
  844. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "8", EightX + OperationX, EightY + OperationY });//设定机械臂当前位置
  845. }
  846. if (PositionNine)
  847. {
  848. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "9", NineX + OperationX, NineY + OperationY });//设定机械臂当前位置
  849. }
  850. if (PositionTen)
  851. {
  852. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "10", TenX + OperationX, TenY + OperationY });//设定机械臂当前位置
  853. }
  854. if (PositionEleven)
  855. {
  856. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "11", ElevenX + OperationX, ElevenY + OperationY });//设定机械臂当前位置
  857. }
  858. if (PositionTwelve)
  859. {
  860. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "12", TwelveX + OperationX, TwelveY + OperationY });//设定机械臂当前位置
  861. }
  862. if (PositionThirteen)
  863. {
  864. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "13", ThirteenX + OperationX, ThirteenY + OperationY });//设定机械臂当前位置
  865. }
  866. if (PositionFourteen)
  867. {
  868. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "14", FourteenX + OperationX, FourteenY + OperationY });//设定机械臂当前位置
  869. }
  870. if (PositionFifteen)
  871. {
  872. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "15", FifteenX + OperationX, FifteenY + OperationY });//设定机械臂当前位置
  873. }
  874. if (PositionSixteen)
  875. {
  876. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "16", SixteenX + OperationX, SixteenY + OperationY });//设定机械臂当前位置
  877. }
  878. if (PositionSeventeen)
  879. {
  880. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "17", SeventeenX + OperationX, SeventeenY + OperationY });//设定机械臂当前位置
  881. }
  882. if (PositionEighteen)
  883. {
  884. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "18", EighteenX + OperationX, EighteenY + OperationY });//设定机械臂当前位置
  885. }
  886. if (PositionNineteen)
  887. {
  888. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "19", NineteenX + OperationX, NineteenY + OperationY });//设定机械臂当前位置
  889. }
  890. if (PositionTwenty)
  891. {
  892. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "20", TwentyX + OperationX, TwentyY + OperationY });//设定机械臂当前位置
  893. }
  894. if (PositionTwentyOne)
  895. {
  896. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "21", TwentyOneX + OperationX, TwentyOneY + OperationY });//设定机械臂当前位置
  897. }
  898. if (PositionTwentyTwo)
  899. {
  900. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "22", TwentyTwoX + OperationX, TwentyTwoY + OperationY });//设定机械臂当前位置
  901. }
  902. if (PositionTwentyThree)
  903. {
  904. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "23", TwentyThreeX + OperationX, TwentyThreeY + OperationY });//设定机械臂当前位置
  905. }
  906. if (PositionTwentyFour)
  907. {
  908. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "24", TwentyFourX + OperationX, TwentyFourY + OperationY });//设定机械臂当前位置
  909. }
  910. if (PositionTwentyFive)
  911. {
  912. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "25", TwentyFiveX + OperationX, TwentyFiveY + OperationY });//设定机械臂当前位置
  913. }
  914. if (PositionTwentySix)
  915. {
  916. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "26", TwentySixX + OperationX, TwentySixY + OperationY });//设定机械臂当前位置
  917. }
  918. if (PositionTwentySeven)
  919. {
  920. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "27", TwentySevenX + OperationX, TwentySevenY + OperationY });//设定机械臂当前位置
  921. }
  922. if (PositionMaterialHeight)
  923. {
  924. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "MaterialHeight", MaterialHeightX + OperationX, MaterialHeightY + OperationY });//设定机械臂当前位置
  925. }
  926. if (PositionFrying1)
  927. {
  928. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "Frying1", Frying1X + OperationX, Frying1Y + OperationY });//设定机械臂当前位置
  929. }
  930. if (PositionFrying2)
  931. {
  932. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "Frying2", Frying2X + OperationX, Frying2Y + OperationY });//设定机械臂当前位置
  933. }
  934. if(PositionMaterialOne)
  935. {
  936. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "MaterialOne", MaterialOneX + OperationX, 0 });//设定机械臂当前位置
  937. }
  938. if (PositionMaterialTwo)
  939. {
  940. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "MaterialTwo", MaterialTwoX + OperationX, 0 });//设定机械臂当前位置
  941. }
  942. if (PositionMaterialThree)
  943. {
  944. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "MaterialThree", MaterialThreeX + OperationX, 0 });//设定机械臂当前位置
  945. }
  946. }
  947. public MaterialCalibrationViewModel()
  948. {
  949. StartElectromagnetism = new RelayCommand(() => { ActionManage.GetInstance.Send("Electromagnetism", new List<bool> { false }); });//电磁阀启动
  950. StopElectromagnetism = new RelayCommand(() => { ActionManage.GetInstance.Send("Electromagnetism", new List<bool> { true }); });//电磁阀关闭
  951. FoodLibInit = new RelayCommand(() => { ActionManage.GetInstance.Send("FoodLibInit"); });//菜品库初始化
  952. PawToPoint1 = new RelayCommand(() => { ActionManage.GetInstance.Send("PawToPoint1"); });//爪子去1号位
  953. PawToPoint2 = new RelayCommand(() => { ActionManage.GetInstance.Send("PawToPoint2"); });//爪子去2号位
  954. PawToPoint3 = new RelayCommand(() => { ActionManage.GetInstance.Send("PawToPoint3"); });//爪子去3号位
  955. PawTurnFront = new RelayCommand(() => { ActionManage.GetInstance.Send("PawTurnFront"); });//夹爪正转
  956. PawTurnBack = new RelayCommand(() => { ActionManage.GetInstance.Send("PawTurnBack"); });//夹爪反转
  957. GetDistance_1 = new RelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_1"); });//感应距离1
  958. GetDistance_2 = new RelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_2"); });//感应距离2
  959. GetDistance_3 = new RelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_3"); });//感应距离3
  960. PhysicalMaterialCoordinate();
  961. ActionManage.GetInstance.Register(new Action<object>((o) =>
  962. {
  963. ThreadManage.GetInstance().Start(new Action(() =>
  964. {
  965. if(o is List<string> nums)
  966. {
  967. Calibration(nums[0]);
  968. }
  969. }), "CalibrationCallBack");
  970. }), "CalibrationCallBack");
  971. ActionManage.GetInstance.Register(new Action<object>((o) =>
  972. {
  973. ThreadManage.GetInstance().Start(new Action(() =>
  974. {
  975. if (o is List<string> nums)
  976. {
  977. int distance = 0;
  978. bool ret = false;
  979. ret = int.TryParse(nums[1], out distance);
  980. if (ret == false) { return; }
  981. if (nums[0] == "1")
  982. {
  983. Distance_1= distance;
  984. }
  985. else if (nums[0] == "2")
  986. {
  987. Distance_2 = distance;
  988. }
  989. else if (nums[0] == "3")
  990. {
  991. Distance_3 = distance;
  992. }
  993. }
  994. }), "GetDistanceCallBack");
  995. }), "GetDistanceCallBack");
  996. SetNowPosition = new RelayCommand(() =>
  997. {
  998. if(!Point && !Left && !Right && !Down && !Up)
  999. {
  1000. MessageBox.Show("请选择需要移动的方式");
  1001. return;
  1002. }
  1003. if (!Point)
  1004. {
  1005. if (!int.TryParse(Str, out Factor))
  1006. {
  1007. Factor = 1;
  1008. }
  1009. if(Factor > 100 || Factor<0)
  1010. {
  1011. MessageBox.Show("请输入有效系数");
  1012. return;
  1013. }
  1014. }
  1015. if(Left)
  1016. {
  1017. OperationX = -1 * BasicPosition * Factor;
  1018. }
  1019. else if(Right)
  1020. {
  1021. OperationX = BasicPosition * Factor;
  1022. }
  1023. else if(Down)
  1024. {
  1025. OperationY = BasicPosition * Factor;
  1026. }
  1027. else if(Up)
  1028. {
  1029. OperationY = -1 * BasicPosition * Factor;
  1030. }
  1031. else
  1032. {
  1033. OperationX = 0;
  1034. OperationY = 0;
  1035. }
  1036. SetPosition();
  1037. });
  1038. SaveCoordinate = new RelayCommand(() =>
  1039. {
  1040. SaveMaterialCoordinate();
  1041. });
  1042. ReadCoordinate = new RelayCommand(() =>
  1043. {
  1044. PhysicalMaterialCoordinate();
  1045. });
  1046. AutoCalculation = new RelayCommand(() =>
  1047. {
  1048. AutoCalculationCoordination();
  1049. });
  1050. }
  1051. /// <summary>
  1052. /// 自动计算坐标
  1053. /// </summary>
  1054. private void AutoCalculationCoordination()
  1055. {
  1056. #region 菜品库一层计算
  1057. //X轴改变
  1058. TwoX = ThreeX = FourX = FiveX = SixX = SevenX = EightX = NineX = OneX;
  1059. TwoY = OneY + 1000;
  1060. ThreeY = OneY + 1000+smartMaterialClearanceY;
  1061. FourY = OneY + 1000 + smartMaterialClearanceY + bigMaterialClearanceY;
  1062. FiveY = OneY + 1000 + 2 * smartMaterialClearanceY + bigMaterialClearanceY;
  1063. SixY = OneY + 3 * smartMaterialClearanceY + bigMaterialClearanceY;
  1064. SevenY = OneY + 3 * smartMaterialClearanceY + 2*bigMaterialClearanceY;
  1065. EightY = OneY + 4 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
  1066. NineY = OneY + 5 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
  1067. #endregion
  1068. #region 菜品库二层计算
  1069. //X轴改变
  1070. TenX = ElevenX = TwelveX = ThirteenX = FourteenX = FifteenX = SixteenX = SeventeenX = EighteenX = (OneX + materialClearanceX1);
  1071. TenY = OneY;
  1072. ElevenY = OneY + 1000;
  1073. TwelveY = OneY + smartMaterialClearanceY;
  1074. ThirteenY = OneY + smartMaterialClearanceY + bigMaterialClearanceY;
  1075. FourteenY = OneY + 2 * smartMaterialClearanceY + bigMaterialClearanceY;
  1076. FifteenY = OneY + 3 * smartMaterialClearanceY + bigMaterialClearanceY;
  1077. SixteenY = OneY + 3 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
  1078. SeventeenY = OneY + 4 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
  1079. EighteenY = OneY + 5 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
  1080. #endregion
  1081. #region 菜品库三层计算
  1082. //X轴改变
  1083. NineteenX = TwentyX = TwentyOneX = TwentyTwoX = TwentyThreeX = TwentyFourX = TwentyFiveX = TwentySixX = TwentySevenX = (OneX + 2 * materialClearanceX2);
  1084. NineteenY = OneY;
  1085. TwentyY = OneY + 1000;
  1086. TwentyOneY = OneY + smartMaterialClearanceY;
  1087. TwentyTwoY = OneY + smartMaterialClearanceY + bigMaterialClearanceY;
  1088. TwentyThreeY = OneY + 2 * smartMaterialClearanceY + bigMaterialClearanceY;
  1089. TwentyFourY = OneY + 3 * smartMaterialClearanceY + bigMaterialClearanceY;
  1090. TwentyFiveY = OneY + 3 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
  1091. TwentySixY = OneY + 4 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
  1092. TwentySevenY = OneY + 5 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
  1093. #endregion
  1094. }
  1095. #endregion
  1096. }
  1097. }