终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1172 lines
58 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. #region 控制
  284. public int SettingX { get { return _settingX; } set { _settingX = value; OnPropertyChanged(); } }
  285. private int _settingX = 0;
  286. public int SettingY { get { return _settingY; } set { _settingY = value; OnPropertyChanged(); } }
  287. private int _settingY = 0;
  288. public int MoveSpeed { get { return _moveSpeed; } set { _moveSpeed = value; OnPropertyChanged(); } }
  289. private int _moveSpeed;
  290. public int SensingDistance_1 { get { return _sensingDistance_1; } set { _sensingDistance_1 = value; OnPropertyChanged(); } }
  291. private int _sensingDistance_1;
  292. public int SensingDistance_2 { get { return _sensingDistance_2; } set { _sensingDistance_2 = value; OnPropertyChanged(); } }
  293. private int _sensingDistance_2;
  294. public int SensingDistance_3 { get { return _sensingDistance_3; } set { _sensingDistance_3 = value; OnPropertyChanged(); } }
  295. private int _sensingDistance_3;
  296. public RelayCommand SetSpeed { get; set; }//速度设定
  297. public RelayCommand SetArmPosition { get; set; }//机器臂位置设定
  298. public RelayCommand GetTestDistance_1 { get; set; }//获取感应器距离1
  299. public RelayCommand GetTestDistance_2 { get; set; }//获取感应器距离2
  300. public RelayCommand GetTestDistance_3 { get; set; }//获取感应器距离3
  301. #endregion
  302. public bool Up { get { return _Up; } set { _Up = value; OnPropertyChanged(); } }
  303. private bool _Up;
  304. public bool Down { get { return _Down; } set { _Down = value; OnPropertyChanged(); } }
  305. private bool _Down;
  306. public bool Left { get { return _Left; } set { _Left = value; OnPropertyChanged(); } }
  307. private bool _Left;
  308. public bool Right { get { return _Right; } set { _Right = value; OnPropertyChanged(); } }
  309. private bool _Right;
  310. public bool Point { get { return _Point; } set { _Point = value; OnPropertyChanged(); } }
  311. private bool _Point;
  312. public string Str { get { return _str; }set { _str = value;OnPropertyChanged(); } }
  313. private string _str;
  314. /// <summary>
  315. /// 操作时,x轴移动的距离
  316. /// </summary>
  317. public int OperationX { get; set; } = 0;
  318. /// <summary>
  319. /// 操作时,y轴移动的距离
  320. /// </summary>
  321. public int OperationY { get; set; } = 0;
  322. /// <summary>
  323. /// Y轴大菜品库的间隙
  324. /// </summary>
  325. private const int bigMaterialClearanceY = 54000;
  326. /// <summary>
  327. /// Y轴小菜品库的间隙
  328. /// </summary>
  329. private const int smartMaterialClearanceY = 28000;
  330. /// <summary>
  331. /// X轴菜品库的间隙
  332. /// </summary>
  333. private const int materialClearanceX1 = 78000;
  334. /// <summary>
  335. /// X轴菜品库的间隙
  336. /// </summary>
  337. private const int materialClearanceX2 = 88000;
  338. /// <summary>
  339. /// 移动系数
  340. /// </summary>
  341. public int Factor = 1;
  342. /// <summary>
  343. /// 移动基础点位
  344. /// </summary>
  345. private int BasicPosition { get; set; } = 100;
  346. public RelayCommand SetNowPosition { get; set; }//设置机械臂当前坐标
  347. public RelayCommand SaveCoordinate { get; set; }//设置机械臂基于当前坐标往左移动
  348. public RelayCommand ReadCoordinate { get; set; }//设置机械臂基于当前坐标往右移动
  349. public RelayCommand AutoCalculation { get; set; }//设置机械臂基于当前坐标往上移动
  350. public RelayCommand SetNowDownPosition { get; set; }//设置机械臂基于当前坐标往下移动
  351. public RelayCommand FoodLibInit { get; set; }//初始化
  352. public RelayCommand StartElectromagnetism { get; set; }//电磁阀启动
  353. public RelayCommand StopElectromagnetism { get; set; }
  354. public RelayCommand PawTurnFront { get; set; }//夹爪正转
  355. public RelayCommand PawTurnBack { get; set; }//夹爪反转
  356. public RelayCommand PawToPoint1 { get; set; }//夹爪位置1
  357. public RelayCommand PawToPoint2 { get; set; }//夹爪位置2
  358. public RelayCommand PawToPoint3 { get; set; }//夹爪位置3
  359. public RelayCommand GetDistance_1 { get; set; }//感应测距1
  360. public RelayCommand GetDistance_2 { get; set; }//感应测距2
  361. public RelayCommand GetDistance_3 { get; set; }//感应测距3
  362. private static object saveMaterialCoordinateLock = new object();
  363. /// <summary>
  364. /// 保存当前的坐标系
  365. /// </summary>
  366. public void SaveMaterialCoordinate()
  367. {
  368. MaterialCoordinate materialCoordinate = new MaterialCoordinate();
  369. foreach(var dicNoMaterialCoordinate in materialCoordinate.dicNoMaterialCoordinate)
  370. {
  371. switch(dicNoMaterialCoordinate.Key)
  372. {
  373. case "1":
  374. dicNoMaterialCoordinate.Value.X = OneX;
  375. dicNoMaterialCoordinate.Value.Y = OneY;
  376. break;
  377. case "2":
  378. dicNoMaterialCoordinate.Value.X = TwoX;
  379. dicNoMaterialCoordinate.Value.Y = TwoY;
  380. break;
  381. case "3":
  382. dicNoMaterialCoordinate.Value.X = ThreeX;
  383. dicNoMaterialCoordinate.Value.Y = ThreeY;
  384. break;
  385. case "4":
  386. dicNoMaterialCoordinate.Value.X = FourX;
  387. dicNoMaterialCoordinate.Value.Y = FourY;
  388. break;
  389. case "5":
  390. dicNoMaterialCoordinate.Value.X = FiveX;
  391. dicNoMaterialCoordinate.Value.Y = FiveY;
  392. break;
  393. case "6":
  394. dicNoMaterialCoordinate.Value.X = SixX;
  395. dicNoMaterialCoordinate.Value.Y = SixY;
  396. break;
  397. case "7":
  398. dicNoMaterialCoordinate.Value.X = SevenX;
  399. dicNoMaterialCoordinate.Value.Y = SevenY;
  400. break;
  401. case "8":
  402. dicNoMaterialCoordinate.Value.X = EightX;
  403. dicNoMaterialCoordinate.Value.Y = EightY;
  404. break;
  405. case "9":
  406. dicNoMaterialCoordinate.Value.X = NineX;
  407. dicNoMaterialCoordinate.Value.Y = NineY;
  408. break;
  409. case "10":
  410. dicNoMaterialCoordinate.Value.X = TenX;
  411. dicNoMaterialCoordinate.Value.Y = TenY;
  412. break;
  413. case "11":
  414. dicNoMaterialCoordinate.Value.X = ElevenX;
  415. dicNoMaterialCoordinate.Value.Y = ElevenY;
  416. break;
  417. case "12":
  418. dicNoMaterialCoordinate.Value.X = TwelveX;
  419. dicNoMaterialCoordinate.Value.Y = TwelveY;
  420. break;
  421. case "13":
  422. dicNoMaterialCoordinate.Value.X = ThirteenX;
  423. dicNoMaterialCoordinate.Value.Y = ThirteenY;
  424. break;
  425. case "14":
  426. dicNoMaterialCoordinate.Value.X = FourteenX;
  427. dicNoMaterialCoordinate.Value.Y = FourteenY;
  428. break;
  429. case "15":
  430. dicNoMaterialCoordinate.Value.X = FifteenX;
  431. dicNoMaterialCoordinate.Value.Y = FifteenY;
  432. break;
  433. case "16":
  434. dicNoMaterialCoordinate.Value.X = SixteenX;
  435. dicNoMaterialCoordinate.Value.Y = SixteenY;
  436. break;
  437. case "17":
  438. dicNoMaterialCoordinate.Value.X = SeventeenX;
  439. dicNoMaterialCoordinate.Value.Y = SeventeenY;
  440. break;
  441. case "18":
  442. dicNoMaterialCoordinate.Value.X = EighteenX;
  443. dicNoMaterialCoordinate.Value.Y = EighteenY;
  444. break;
  445. case "19":
  446. dicNoMaterialCoordinate.Value.X = NineteenX;
  447. dicNoMaterialCoordinate.Value.Y = NineteenY;
  448. break;
  449. case "20":
  450. dicNoMaterialCoordinate.Value.X = TwentyX;
  451. dicNoMaterialCoordinate.Value.Y = TwentyY;
  452. break;
  453. case "21":
  454. dicNoMaterialCoordinate.Value.X = TwentyOneX;
  455. dicNoMaterialCoordinate.Value.Y = TwentyOneY;
  456. break;
  457. case "22":
  458. dicNoMaterialCoordinate.Value.X = TwentyTwoX;
  459. dicNoMaterialCoordinate.Value.Y = TwentyTwoY;
  460. break;
  461. case "23":
  462. dicNoMaterialCoordinate.Value.X = TwentyThreeX;
  463. dicNoMaterialCoordinate.Value.Y = TwentyThreeY;
  464. break;
  465. case "24":
  466. dicNoMaterialCoordinate.Value.X = TwentyFourX;
  467. dicNoMaterialCoordinate.Value.Y = TwentyFourY;
  468. break;
  469. case "25":
  470. dicNoMaterialCoordinate.Value.X = TwentyFiveX;
  471. dicNoMaterialCoordinate.Value.Y = TwentyFiveY;
  472. break;
  473. case "26":
  474. dicNoMaterialCoordinate.Value.X = TwentySixX;
  475. dicNoMaterialCoordinate.Value.Y = TwentySixY;
  476. break;
  477. case "27":
  478. dicNoMaterialCoordinate.Value.X = TwentySevenX;
  479. dicNoMaterialCoordinate.Value.Y = TwentySevenY;
  480. break;
  481. default:
  482. break;
  483. }
  484. }
  485. materialCoordinate.frying1.X = Frying1X;
  486. materialCoordinate.frying1.Y = Frying1Y;
  487. materialCoordinate.frying2.X = Frying2X;
  488. materialCoordinate.frying2.Y = Frying2Y;
  489. materialCoordinate.materialHeight.X = MaterialHeightX;
  490. materialCoordinate.materialHeight.Y = MaterialHeightY;
  491. materialCoordinate.distance_1 = Distance_1;
  492. materialCoordinate.distance_2 = Distance_2;
  493. materialCoordinate.distance_3 = Distance_3;
  494. materialCoordinate.MaterialOneX = MaterialOneX;
  495. materialCoordinate.MaterialTwoX = MaterialTwoX;
  496. materialCoordinate.MaterialThreeX = MaterialThreeX;
  497. Json<MaterialCoordinate>.Data = materialCoordinate;
  498. Json<MaterialCoordinate>.Save();
  499. //更新当前的菜品库数据
  500. MaterialCoordinate.GetInstance().frying1 = materialCoordinate.frying1;
  501. MaterialCoordinate.GetInstance().frying2 = materialCoordinate.frying2;
  502. MaterialCoordinate.GetInstance().materialHeight = materialCoordinate.materialHeight;
  503. MaterialCoordinate.GetInstance().dicNoMaterialCoordinate = materialCoordinate.dicNoMaterialCoordinate;
  504. MaterialCoordinate.GetInstance().MaterialOneX = materialCoordinate.MaterialOneX;
  505. MaterialCoordinate.GetInstance().MaterialTwoX = materialCoordinate.MaterialTwoX;
  506. MaterialCoordinate.GetInstance().MaterialThreeX = materialCoordinate.MaterialThreeX;
  507. }
  508. /// <summary>
  509. /// 读取坐标系
  510. /// </summary>
  511. /// <returns></returns>
  512. private MaterialCoordinate ReadMaterialCoordinate()
  513. {
  514. try
  515. {
  516. Json<MaterialCoordinate>.Read();
  517. MaterialCoordinate materialCoordinate = Json<MaterialCoordinate>.Data;
  518. return materialCoordinate;
  519. }
  520. catch (Exception ex)
  521. {
  522. return null;
  523. }
  524. }
  525. /// <summary>
  526. /// 从json文件中读取菜品库坐标系数据
  527. /// </summary>
  528. private void PhysicalMaterialCoordinate()
  529. {
  530. MaterialCoordinate materialCoordinate = ReadMaterialCoordinate();
  531. if(materialCoordinate == null)
  532. {
  533. return;
  534. }
  535. if (materialCoordinate.dicNoMaterialCoordinate.Count == 27)
  536. {
  537. foreach (var dicNoMaterialCoordinate in materialCoordinate.dicNoMaterialCoordinate)
  538. {
  539. switch (dicNoMaterialCoordinate.Key)
  540. {
  541. case "1":
  542. OneX = dicNoMaterialCoordinate.Value.X;
  543. OneY = dicNoMaterialCoordinate.Value.Y;
  544. break;
  545. case "2":
  546. TwoX = dicNoMaterialCoordinate.Value.X;
  547. TwoY = dicNoMaterialCoordinate.Value.Y;
  548. break;
  549. case "3":
  550. ThreeX = dicNoMaterialCoordinate.Value.X;
  551. ThreeY = dicNoMaterialCoordinate.Value.Y;
  552. break;
  553. case "4":
  554. FourX = dicNoMaterialCoordinate.Value.X;
  555. FourY = dicNoMaterialCoordinate.Value.Y;
  556. break;
  557. case "5":
  558. FiveX = dicNoMaterialCoordinate.Value.X;
  559. FiveY = dicNoMaterialCoordinate.Value.Y;
  560. break;
  561. case "6":
  562. SixX = dicNoMaterialCoordinate.Value.X;
  563. SixY = dicNoMaterialCoordinate.Value.Y;
  564. break;
  565. case "7":
  566. SevenX = dicNoMaterialCoordinate.Value.X;
  567. SevenY = dicNoMaterialCoordinate.Value.Y;
  568. break;
  569. case "8":
  570. EightX = dicNoMaterialCoordinate.Value.X;
  571. EightY = dicNoMaterialCoordinate.Value.Y;
  572. break;
  573. case "9":
  574. NineX = dicNoMaterialCoordinate.Value.X;
  575. NineY = dicNoMaterialCoordinate.Value.Y;
  576. break;
  577. case "10":
  578. TenX = dicNoMaterialCoordinate.Value.X;
  579. TenY = dicNoMaterialCoordinate.Value.Y;
  580. break;
  581. case "11":
  582. ElevenX = dicNoMaterialCoordinate.Value.X;
  583. ElevenY = dicNoMaterialCoordinate.Value.Y;
  584. break;
  585. case "12":
  586. TwelveX = dicNoMaterialCoordinate.Value.X;
  587. TwelveY = dicNoMaterialCoordinate.Value.Y;
  588. break;
  589. case "13":
  590. ThirteenX = dicNoMaterialCoordinate.Value.X;
  591. ThirteenY = dicNoMaterialCoordinate.Value.Y;
  592. break;
  593. case "14":
  594. FourteenX = dicNoMaterialCoordinate.Value.X;
  595. FourteenY = dicNoMaterialCoordinate.Value.Y;
  596. break;
  597. case "15":
  598. FifteenX = dicNoMaterialCoordinate.Value.X;
  599. FifteenY = dicNoMaterialCoordinate.Value.Y;
  600. break;
  601. case "16":
  602. SixteenX = dicNoMaterialCoordinate.Value.X;
  603. SixteenY = dicNoMaterialCoordinate.Value.Y;
  604. break;
  605. case "17":
  606. SeventeenX = dicNoMaterialCoordinate.Value.X;
  607. SeventeenY = dicNoMaterialCoordinate.Value.Y;
  608. break;
  609. case "18":
  610. EighteenX = dicNoMaterialCoordinate.Value.X;
  611. EighteenY = dicNoMaterialCoordinate.Value.Y;
  612. break;
  613. case "19":
  614. NineteenX = dicNoMaterialCoordinate.Value.X;
  615. NineteenY = dicNoMaterialCoordinate.Value.Y;
  616. break;
  617. case "20":
  618. TwentyX = dicNoMaterialCoordinate.Value.X;
  619. TwentyY = dicNoMaterialCoordinate.Value.Y;
  620. break;
  621. case "21":
  622. TwentyOneX = dicNoMaterialCoordinate.Value.X;
  623. TwentyOneY = dicNoMaterialCoordinate.Value.Y;
  624. break;
  625. case "22":
  626. TwentyTwoX = dicNoMaterialCoordinate.Value.X;
  627. TwentyTwoY = dicNoMaterialCoordinate.Value.Y;
  628. break;
  629. case "23":
  630. TwentyThreeX = dicNoMaterialCoordinate.Value.X;
  631. TwentyThreeY = dicNoMaterialCoordinate.Value.Y;
  632. break;
  633. case "24":
  634. TwentyFourX = dicNoMaterialCoordinate.Value.X;
  635. TwentyFourY = dicNoMaterialCoordinate.Value.Y;
  636. break;
  637. case "25":
  638. TwentyFiveX = dicNoMaterialCoordinate.Value.X;
  639. TwentyFiveY = dicNoMaterialCoordinate.Value.Y;
  640. break;
  641. case "26":
  642. TwentySixX = dicNoMaterialCoordinate.Value.X;
  643. TwentySixY = dicNoMaterialCoordinate.Value.Y;
  644. break;
  645. case "27":
  646. TwentySevenX = dicNoMaterialCoordinate.Value.X;
  647. TwentySevenY = dicNoMaterialCoordinate.Value.Y;
  648. break;
  649. case "MaterialHeight":
  650. MaterialHeightX = materialCoordinate.materialHeight.X;
  651. MaterialHeightY = materialCoordinate.materialHeight.Y;
  652. break;
  653. case "Frying1":
  654. Frying1X = materialCoordinate.frying1.X;
  655. Frying1Y = materialCoordinate.frying1.Y;
  656. break;
  657. case "Frying2":
  658. Frying2X = materialCoordinate.frying2.X;
  659. Frying2Y = materialCoordinate.frying2.Y;
  660. break;
  661. default:
  662. break;
  663. }
  664. }
  665. }
  666. MaterialOneX = materialCoordinate.MaterialOneX;
  667. MaterialTwoX = materialCoordinate.MaterialTwoX;
  668. MaterialThreeX = materialCoordinate.MaterialThreeX;
  669. MaterialHeightX = materialCoordinate.materialHeight.X;
  670. MaterialHeightY = materialCoordinate.materialHeight.Y;
  671. Frying1X = materialCoordinate.frying1.X;
  672. Frying1Y = materialCoordinate.frying1.Y;
  673. Frying2X = materialCoordinate.frying2.X;
  674. Frying2Y = materialCoordinate.frying2.Y;
  675. Distance_1 = materialCoordinate.distance_1;
  676. Distance_2 = materialCoordinate.distance_2;
  677. Distance_3 = materialCoordinate.distance_3;
  678. }
  679. /// <summary>
  680. ///
  681. /// </summary>
  682. /// <param name="Num"></param>
  683. private void Calibration(string Num)
  684. {
  685. switch (Num)
  686. {
  687. case "1":
  688. OneX = OneX + OperationX;
  689. OneY = OneY + OperationX;
  690. break;
  691. case "2":
  692. TwoX = TwoX + OperationX;
  693. TwoY = TwoY + OperationY;
  694. break;
  695. case "3":
  696. ThreeX = ThreeX + OperationX;
  697. ThreeY = ThreeY + OperationY;
  698. break;
  699. case "4":
  700. FourX = FourX + OperationX;
  701. FourY = FourY + OperationY;
  702. break;
  703. case "5":
  704. FiveX = FiveX + OperationX;
  705. FiveY = FiveY + OperationY;
  706. break;
  707. case "6":
  708. SixX = SixX + OperationX;
  709. SixY = SixY + OperationY;
  710. break;
  711. case "7":
  712. SevenX = SevenX + OperationX;
  713. SevenY = SevenY + OperationY;
  714. break;
  715. case "8":
  716. EightX = EightX + OperationX;
  717. EightY = EightY + OperationY;
  718. break;
  719. case "9":
  720. NineX = NineX + OperationX;
  721. NineY = NineY + OperationY;
  722. break;
  723. case "10":
  724. TenX = TenX + OperationX;
  725. TenY = TenY + OperationY;
  726. break;
  727. case "11":
  728. ElevenX = ElevenX + OperationX;
  729. ElevenY = ElevenY + OperationY;
  730. break;
  731. case "12":
  732. TwelveX = TwelveX + OperationX;
  733. TwelveY = TwelveY + OperationY;
  734. break;
  735. case "13":
  736. ThirteenX = ThirteenX + OperationX;
  737. ThirteenY = ThirteenY + OperationY;
  738. break;
  739. case "14":
  740. FourteenX = FourteenX + OperationX;
  741. FourteenY = FourteenY + OperationY;
  742. break;
  743. case "15":
  744. FifteenX = FifteenX + OperationX;
  745. FifteenY = FifteenY + OperationY;
  746. break;
  747. case "16":
  748. SixteenX = SixteenX + OperationX;
  749. SixteenY = SixteenY + OperationY;
  750. break;
  751. case "17":
  752. SeventeenX = SeventeenX + OperationX;
  753. SeventeenY = SeventeenY + OperationY;
  754. break;
  755. case "18":
  756. EighteenX = EighteenX + OperationX;
  757. EighteenY = EighteenY + OperationY;
  758. break;
  759. case "19":
  760. NineteenX = NineteenX + OperationX;
  761. NineteenY = NineteenY + OperationY;
  762. break;
  763. case "20":
  764. TwentyX = TwentyX + OperationX;
  765. TwentyY = TwentyY + OperationY;
  766. break;
  767. case "21":
  768. TwentyOneX = TwentyOneX + OperationX;
  769. TwentyOneY = TwentyOneY + OperationY;
  770. break;
  771. case "22":
  772. TwentyTwoX = TwentyTwoX + OperationX;
  773. TwentyTwoY = TwentyTwoY + OperationY;
  774. break;
  775. case "23":
  776. TwentyThreeX = TwentyThreeX + OperationX;
  777. TwentyThreeY = TwentyThreeY + OperationY;
  778. break;
  779. case "24":
  780. TwentyFourX = TwentyFourX + OperationX;
  781. TwentyFourY = TwentyFourY + OperationY;
  782. break;
  783. case "25":
  784. TwentyFiveX = TwentyFiveX + OperationX;
  785. TwentyFiveY = TwentyFiveY + OperationY;
  786. break;
  787. case "26":
  788. TwentySixX = TwentySixX + OperationX;
  789. TwentySixY = TwentySixY + OperationY;
  790. break;
  791. case "27":
  792. TwentySevenX = TwentySevenX + OperationX;
  793. TwentySevenY = TwentySevenY + OperationY;
  794. break;
  795. case "MaterialHeight":
  796. MaterialHeightX = MaterialHeightX + OperationX;
  797. MaterialHeightY = MaterialHeightY + OperationY;
  798. break;
  799. case "Frying1":
  800. Frying1X = Frying1X + OperationX;
  801. Frying1Y = Frying1Y + OperationY;
  802. break;
  803. case "Frying2":
  804. Frying2X = Frying2X + OperationX;
  805. Frying2Y = Frying2Y + OperationY;
  806. break;
  807. case "MaterialOne":
  808. MaterialOneX = MaterialOneX + OperationX;
  809. break;
  810. case "MaterialTwo":
  811. MaterialTwoX = MaterialTwoX + OperationX;
  812. break;
  813. case "MaterialThree":
  814. MaterialThreeX = MaterialThreeX + OperationX;
  815. break;
  816. default:
  817. break;
  818. }
  819. OperationX = 0;
  820. OperationY = 0;
  821. }
  822. private void SetPosition()
  823. {
  824. //判断是否有选择下发的设备
  825. if (!PositionOne && !PositionTwo && !PositionThree && !PositionFour && !PositionFive && !PositionSix && !PositionSeven && !PositionEight && !PositionNine
  826. && !PositionTen && !PositionEleven && !PositionTwelve && !PositionThirteen && !PositionFourteen && !PositionFifteen && !PositionSixteen && !PositionSeventeen && !PositionEighteen
  827. && !PositionNineteen && !PositionTwenty && !PositionTwentyOne && !PositionTwentyTwo && !PositionTwentyThree && !PositionTwentyFour && !PositionTwentyFive && !PositionTwentySix && !PositionTwentySeven
  828. && !PositionMaterialHeight && !PositionFrying1 && !PositionFrying2 && !PositionMaterialOne && !PositionMaterialThree &&!PositionMaterialTwo)
  829. {
  830. MessageBox.Show("未选择点位");
  831. return;
  832. }
  833. //if (PositionOne)
  834. //{
  835. // ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> {"1", OneX + OperationX, OneY + OperationY });//设定机械臂当前位置
  836. //}
  837. if (PositionTwo)
  838. {
  839. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "2", TwoX + OperationX, TwoY + OperationY });//设定机械臂当前位置
  840. }
  841. if (PositionThree)
  842. {
  843. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "3", ThreeX + OperationX, ThreeY + OperationY });//设定机械臂当前位置
  844. }
  845. if (PositionFour)
  846. {
  847. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "4", FourX + OperationX, FourY + OperationY });//设定机械臂当前位置
  848. }
  849. if (PositionFive)
  850. {
  851. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "5", FiveX + OperationX, FiveY + OperationY });//设定机械臂当前位置
  852. }
  853. if (PositionSix)
  854. {
  855. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "6", SixX + OperationX, SixY + OperationY });//设定机械臂当前位置
  856. }
  857. if (PositionSeven)
  858. {
  859. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "7", SevenX + OperationX, SevenY + OperationY });//设定机械臂当前位置
  860. }
  861. if (PositionEight)
  862. {
  863. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "8", EightX + OperationX, EightY + OperationY });//设定机械臂当前位置
  864. }
  865. //if (PositionNine)
  866. //{
  867. // ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "9", NineX + OperationX, NineY + OperationY });//设定机械臂当前位置
  868. //}
  869. //if (PositionTen)
  870. //{
  871. // ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "10", TenX + OperationX, TenY + OperationY });//设定机械臂当前位置
  872. //}
  873. if (PositionEleven)
  874. {
  875. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "11", ElevenX + OperationX, ElevenY + OperationY });//设定机械臂当前位置
  876. }
  877. if (PositionTwelve)
  878. {
  879. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "12", TwelveX + OperationX, TwelveY + OperationY });//设定机械臂当前位置
  880. }
  881. if (PositionThirteen)
  882. {
  883. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "13", ThirteenX + OperationX, ThirteenY + OperationY });//设定机械臂当前位置
  884. }
  885. if (PositionFourteen)
  886. {
  887. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "14", FourteenX + OperationX, FourteenY + OperationY });//设定机械臂当前位置
  888. }
  889. if (PositionFifteen)
  890. {
  891. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "15", FifteenX + OperationX, FifteenY + OperationY });//设定机械臂当前位置
  892. }
  893. if (PositionSixteen)
  894. {
  895. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "16", SixteenX + OperationX, SixteenY + OperationY });//设定机械臂当前位置
  896. }
  897. if (PositionSeventeen)
  898. {
  899. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "17", SeventeenX + OperationX, SeventeenY + OperationY });//设定机械臂当前位置
  900. }
  901. //if (PositionEighteen)
  902. //{
  903. // ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "18", EighteenX + OperationX, EighteenY + OperationY });//设定机械臂当前位置
  904. //}
  905. //if (PositionNineteen)
  906. //{
  907. // ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "19", NineteenX + OperationX, NineteenY + OperationY });//设定机械臂当前位置
  908. //}
  909. if (PositionTwenty)
  910. {
  911. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "20", TwentyX + OperationX, TwentyY + OperationY });//设定机械臂当前位置
  912. }
  913. if (PositionTwentyOne)
  914. {
  915. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "21", TwentyOneX + OperationX, TwentyOneY + OperationY });//设定机械臂当前位置
  916. }
  917. if (PositionTwentyTwo)
  918. {
  919. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "22", TwentyTwoX + OperationX, TwentyTwoY + OperationY });//设定机械臂当前位置
  920. }
  921. if (PositionTwentyThree)
  922. {
  923. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "23", TwentyThreeX + OperationX, TwentyThreeY + OperationY });//设定机械臂当前位置
  924. }
  925. if (PositionTwentyFour)
  926. {
  927. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "24", TwentyFourX + OperationX, TwentyFourY + OperationY });//设定机械臂当前位置
  928. }
  929. if (PositionTwentyFive)
  930. {
  931. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "25", TwentyFiveX + OperationX, TwentyFiveY + OperationY });//设定机械臂当前位置
  932. }
  933. if (PositionTwentySix)
  934. {
  935. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "26", TwentySixX + OperationX, TwentySixY + OperationY });//设定机械臂当前位置
  936. }
  937. //if (PositionTwentySeven)
  938. //{
  939. // ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "27", TwentySevenX + OperationX, TwentySevenY + OperationY });//设定机械臂当前位置
  940. //}
  941. if (PositionMaterialHeight)
  942. {
  943. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "MaterialHeight", MaterialHeightX + OperationX, MaterialHeightY + OperationY });//设定机械臂当前位置
  944. }
  945. if (PositionFrying1)
  946. {
  947. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "Frying1", Frying1X + OperationX, Frying1Y + OperationY });//设定机械臂当前位置
  948. }
  949. if (PositionFrying2)
  950. {
  951. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "Frying2", Frying2X + OperationX, Frying2Y + OperationY });//设定机械臂当前位置
  952. }
  953. if(PositionMaterialOne)
  954. {
  955. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "MaterialOne", MaterialOneX + OperationX, 0 });//设定机械臂当前位置
  956. }
  957. if (PositionMaterialTwo)
  958. {
  959. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "MaterialTwo", MaterialTwoX + OperationX, 0 });//设定机械臂当前位置
  960. }
  961. if (PositionMaterialThree)
  962. {
  963. ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "MaterialThree", MaterialThreeX + OperationX, 0 });//设定机械臂当前位置
  964. }
  965. }
  966. public MaterialCalibrationViewModel()
  967. {
  968. StartElectromagnetism = new RelayCommand(() => { ActionManage.GetInstance.Send("Electromagnetism", new List<bool> { false }); });//电磁阀启动
  969. StopElectromagnetism = new RelayCommand(() => { ActionManage.GetInstance.Send("Electromagnetism", new List<bool> { true }); });//电磁阀关闭
  970. FoodLibInit = new RelayCommand(() => { ActionManage.GetInstance.Send("FoodLibInit"); });//菜品库初始化
  971. PawToPoint1 = new RelayCommand(() => { ActionManage.GetInstance.Send("PawToPoint1"); });//爪子去1号位
  972. PawToPoint2 = new RelayCommand(() => { ActionManage.GetInstance.Send("PawToPoint2"); });//爪子去2号位
  973. PawToPoint3 = new RelayCommand(() => { ActionManage.GetInstance.Send("PawToPoint3"); });//爪子去3号位
  974. PawTurnFront = new RelayCommand(() => {
  975. ActionManage.GetInstance.Send("PawTurnFront");
  976. });//夹爪伸出
  977. PawTurnBack = new RelayCommand(() => {
  978. ActionManage.GetInstance.Send("PawTurnBack");
  979. });//夹爪收缩
  980. GetDistance_1 = new RelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_1"); });//感应距离1
  981. GetDistance_2 = new RelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_2"); });//感应距离2
  982. GetDistance_3 = new RelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_3"); });//感应距离3
  983. SetSpeed = new RelayCommand(() => { ActionManage.GetInstance.Send("SetSpeed", new List<int> { MoveSpeed }); });//速度设定
  984. SetArmPosition = new RelayCommand(() => {
  985. ActionManage.GetInstance.Send("SetArmPosition", new List<int> { SettingX, SettingY });
  986. });//设定移动位置
  987. PhysicalMaterialCoordinate();
  988. ActionManage.GetInstance.Register(new Action<object>((o) =>
  989. {
  990. ThreadManage.GetInstance().Start(new Action(() =>
  991. {
  992. if(o is List<string> nums)
  993. {
  994. Calibration(nums[0]);
  995. }
  996. }), "CalibrationCallBack");
  997. }), "CalibrationCallBack");
  998. ActionManage.GetInstance.Register(new Action<object>((o) =>
  999. {
  1000. ThreadManage.GetInstance().Start(new Action(() =>
  1001. {
  1002. if (o is List<string> nums)
  1003. {
  1004. int distance = 0;
  1005. bool ret = false;
  1006. ret = int.TryParse(nums[1], out distance);
  1007. if (ret == false) { return; }
  1008. if (nums[0] == "1")
  1009. {
  1010. Distance_1= distance;
  1011. }
  1012. else if (nums[0] == "2")
  1013. {
  1014. Distance_2 = distance;
  1015. }
  1016. else if (nums[0] == "3")
  1017. {
  1018. Distance_3 = distance;
  1019. }
  1020. }
  1021. }), "GetDistanceCallBack");
  1022. }), "GetDistanceCallBack");
  1023. SetNowPosition = new RelayCommand(() =>
  1024. {
  1025. if(!Point && !Left && !Right && !Down && !Up)
  1026. {
  1027. MessageBox.Show("请选择需要移动的方式");
  1028. return;
  1029. }
  1030. if (!Point)
  1031. {
  1032. if (!int.TryParse(Str, out Factor))
  1033. {
  1034. Factor = 1;
  1035. }
  1036. if(Factor > 100 || Factor<0)
  1037. {
  1038. MessageBox.Show("请输入有效系数");
  1039. return;
  1040. }
  1041. }
  1042. if(Left)
  1043. {
  1044. OperationX = -1 * BasicPosition * Factor;
  1045. }
  1046. else if(Right)
  1047. {
  1048. OperationX = BasicPosition * Factor;
  1049. }
  1050. else if(Down)
  1051. {
  1052. OperationY = BasicPosition * Factor;
  1053. }
  1054. else if(Up)
  1055. {
  1056. OperationY = -1 * BasicPosition * Factor;
  1057. }
  1058. else
  1059. {
  1060. OperationX = 0;
  1061. OperationY = 0;
  1062. }
  1063. SetPosition();
  1064. });
  1065. SaveCoordinate = new RelayCommand(() =>
  1066. {
  1067. SaveMaterialCoordinate();
  1068. });
  1069. ReadCoordinate = new RelayCommand(() =>
  1070. {
  1071. PhysicalMaterialCoordinate();
  1072. });
  1073. AutoCalculation = new RelayCommand(() =>
  1074. {
  1075. AutoCalculationCoordination();
  1076. });
  1077. }
  1078. /// <summary>
  1079. /// 自动计算坐标
  1080. /// </summary>
  1081. private void AutoCalculationCoordination()
  1082. {
  1083. #region 菜品库一层计算
  1084. //X轴改变
  1085. TwoX = ThreeX = FourX = FiveX = SixX = SevenX = EightX = NineX = OneX;
  1086. TwoY = OneY + 1000;
  1087. ThreeY = OneY + 1000+smartMaterialClearanceY;
  1088. FourY = OneY + 1000 + smartMaterialClearanceY + bigMaterialClearanceY;
  1089. FiveY = OneY + 1000 + 2 * smartMaterialClearanceY + bigMaterialClearanceY;
  1090. SixY = OneY + 3 * smartMaterialClearanceY + bigMaterialClearanceY;
  1091. SevenY = OneY + 3 * smartMaterialClearanceY + 2*bigMaterialClearanceY;
  1092. EightY = OneY + 4 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
  1093. NineY = OneY + 5 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
  1094. #endregion
  1095. #region 菜品库二层计算
  1096. //X轴改变
  1097. TenX = ElevenX = TwelveX = ThirteenX = FourteenX = FifteenX = SixteenX = SeventeenX = EighteenX = (OneX + materialClearanceX1);
  1098. TenY = OneY;
  1099. ElevenY = OneY + 1000;
  1100. TwelveY = OneY + smartMaterialClearanceY;
  1101. ThirteenY = OneY + smartMaterialClearanceY + bigMaterialClearanceY;
  1102. FourteenY = OneY + 2 * smartMaterialClearanceY + bigMaterialClearanceY;
  1103. FifteenY = OneY + 3 * smartMaterialClearanceY + bigMaterialClearanceY;
  1104. SixteenY = OneY + 3 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
  1105. SeventeenY = OneY + 4 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
  1106. EighteenY = OneY + 5 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
  1107. #endregion
  1108. #region 菜品库三层计算
  1109. //X轴改变
  1110. NineteenX = TwentyX = TwentyOneX = TwentyTwoX = TwentyThreeX = TwentyFourX = TwentyFiveX = TwentySixX = TwentySevenX = (OneX + 2 * materialClearanceX2);
  1111. NineteenY = OneY;
  1112. TwentyY = OneY + 1000;
  1113. TwentyOneY = OneY + smartMaterialClearanceY;
  1114. TwentyTwoY = OneY + smartMaterialClearanceY + bigMaterialClearanceY;
  1115. TwentyThreeY = OneY + 2 * smartMaterialClearanceY + bigMaterialClearanceY;
  1116. TwentyFourY = OneY + 3 * smartMaterialClearanceY + bigMaterialClearanceY;
  1117. TwentyFiveY = OneY + 3 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
  1118. TwentySixY = OneY + 4 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
  1119. TwentySevenY = OneY + 5 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
  1120. #endregion
  1121. }
  1122. #endregion
  1123. }
  1124. }