终端一体化运控平台
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

1172 satır
58 KiB

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