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

963 lines
54 KiB

  1. using BPASmartClient.CustomResource.Pages.Model;
  2. using BPASmartClient.Helper;
  3. using BPASmartClient.JXJFoodSmallStation.Model.HK_PLC;
  4. using BPASmartClient.JXJFoodSmallStation.Model.Siemens;
  5. using BPASmartClient.JXJFoodSmallStation.Model.WindSend;
  6. using BPASmartClient.Modbus;
  7. using System;
  8. using System.Collections.Concurrent;
  9. using System.Collections.Generic;
  10. using System.Collections.ObjectModel;
  11. using System.Configuration;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Threading;
  15. using System.Threading.Tasks;
  16. namespace BPASmartClient.JXJFoodSmallStation.Model
  17. {
  18. public class ProcessControl
  19. {
  20. private volatile static ProcessControl _Instance;
  21. public static ProcessControl GetInstance => _Instance ?? (_Instance = new ProcessControl());
  22. private ProcessControl() { }
  23. /// <summary>
  24. /// 配方数据
  25. /// </summary>
  26. public ObservableCollection<RemoteRecipeData> RemoteRecipes = new ObservableCollection<RemoteRecipeData>();
  27. /// <summary>
  28. /// 原料的名称和料仓的位置对应
  29. /// </summary>
  30. public Dictionary<string, short> RawMaterialsNamePos = new Dictionary<string, short>();
  31. /// <summary>
  32. /// 配方队列
  33. /// </summary>
  34. public ConcurrentQueue<string> RecipeQueue = new ConcurrentQueue<string>();
  35. public ConcurrentQueue<string> RecipeQueueTray2 = new ConcurrentQueue<string>();
  36. public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus();
  37. public HKDeviceStatus HKDevice = new HKDeviceStatus();
  38. public WindSendDeviceStatus WindSendDevice = new WindSendDeviceStatus();
  39. XL_Finish_DB RecipeFinishInfo = new XL_Finish_DB();
  40. XL_WindSendData_DB WindSendData = new XL_WindSendData_DB();
  41. /// <summary>
  42. /// 接收原料数据
  43. /// </summary>
  44. public RecipeRawMaterial RawMaterial;
  45. public void Init()
  46. {
  47. for (int i = 0; i < 16; i++)
  48. {
  49. if (DeviceInquire.GetInstance.GetDevice(i).DeviceName != null)
  50. {
  51. if (!RawMaterialsNamePos.ContainsKey(DeviceInquire.GetInstance.GetDevice(i).DeviceName))
  52. {
  53. RawMaterialsNamePos.Add(DeviceInquire.GetInstance.GetDevice(i).DeviceName, (short)DeviceInquire.GetInstance.GetDevice(i).deviceStatus.DeviceNum);
  54. }
  55. }
  56. }
  57. ActionManage.GetInstance.CancelRegister("SiemensRecipeRecive");
  58. ActionManage.GetInstance.Register(new Action<object>((res) =>
  59. {
  60. ObservableCollection<RemoteRecipeRawMaterial> RawMaterials = new ObservableCollection<RemoteRecipeRawMaterial>();
  61. if (SiemensDevice.IsConnected)
  62. {
  63. if (res != null && res is XL_Start_DB recipe)
  64. {
  65. RawMaterials.Clear();
  66. for (int i = 0; i < 15; i++)
  67. {
  68. if (RawMaterialsNamePos.ContainsKey(recipe.Material[i].Material_Name))
  69. {
  70. RawMaterials.Add(new RemoteRecipeRawMaterial()
  71. {
  72. RawMaterialName = recipe.Material[i].Material_Name,
  73. RawMaterialBarrelNum = recipe.Material[i].Material_BarrelNum,
  74. RawMaterialWeight = recipe.Material[i].Material_Weight,
  75. RawMaterialLocation = (int)RawMaterialsNamePos[recipe.Material[i].Material_Name]
  76. });
  77. }
  78. else
  79. {
  80. MessageLog.GetInstance.AlarmLog("配方名称与本地不符合");
  81. }
  82. }
  83. Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData()
  84. {
  85. RecipeName = recipe.RecipeName,
  86. RecipeCode = recipe.RecipeCode,
  87. RawMaterial = RawMaterials,
  88. TrayCode = recipe.TrayCode
  89. });
  90. }
  91. }
  92. }), "SiemensRecipeRecive", true);
  93. ActionManage.GetInstance.CancelRegister("WindSendDosingFinish");
  94. ActionManage.GetInstance.Register(new Action(() =>
  95. {
  96. GVL_SmallStation.GetInstance.WindSendDosingFinish = true;
  97. }),"WindSendDosingFinish",true);
  98. ActionManage.GetInstance.CancelRegister("LocalSimulationRecipeIssue");
  99. ActionManage.GetInstance.Register(new Action<Object>((res) =>
  100. {
  101. if (res != null && res is RemoteRecipeData recipe)
  102. {
  103. Json<RemoteRecipeDataColl>.Data.Recipes.Add(recipe);
  104. }
  105. }), "LocalSimulationRecipeIssue", true);
  106. string HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"];
  107. string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"];
  108. string WindSend_PLC_IP = ConfigurationManager.AppSettings["WindSend_IP"];
  109. try
  110. {
  111. //HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, HK_PLC_IP);
  112. //SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
  113. //WindSendDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71200,WindSend_PLC_IP);
  114. if (HKDevice.IsConnected)
  115. {
  116. HKDevice.Init();
  117. MessageLog.GetInstance.ShowUserLog("海科plc连接成功,并初始化完成");
  118. }
  119. if (SiemensDevice.IsConnected)
  120. {
  121. SiemensDevice.Init();
  122. MessageLog.GetInstance.ShowUserLog("西门子plc连接成功,并初始化完成");
  123. }
  124. if (WindSendDevice.IsConnected)
  125. {
  126. WindSendDevice.Init();
  127. MessageLog.GetInstance.ShowUserLog("风送plc连接成功,并初始化完成");
  128. }
  129. }
  130. catch(Exception ex)
  131. {
  132. }
  133. RecipeQueue.Clear();
  134. //Json<RemoteRecipeDataColl>.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据
  135. ThreadManage.GetInstance().StartLong(new Action(() =>
  136. {
  137. ReceviceData();
  138. RecipeInfoToHKPLC();
  139. Thread.Sleep(10);
  140. }), "西门子配发下发流程处理", true);
  141. ThreadManage.GetInstance().StartLong(new Action(() =>
  142. {
  143. if (SiemensDevice.IsConnected && HKDevice.IsConnected)
  144. {
  145. /*AgvGetInDelivery();
  146. AgvGetInPickUp();*/
  147. }
  148. Thread.Sleep(10);
  149. }), "AGV进站送取货", true);
  150. ThreadManage.GetInstance().StartLong(new Action(() =>
  151. {
  152. if (HKDevice.IsConnected)
  153. {
  154. GetStatus();
  155. ManualOpen();
  156. ManualClose();
  157. }
  158. Thread.Sleep(10);
  159. }), "手动操作", true);
  160. }
  161. private void GetStatus()
  162. {
  163. for (int i = 0; i < 8; i++)
  164. {
  165. GVL_SmallStation.GetInstance.Cylinder_JackInfo[i] = HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX0." + i);
  166. }
  167. for (int i = 0; i < 7; i++)
  168. {
  169. GVL_SmallStation.GetInstance.Cylinder_JackInfo[i + 8] = HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX0." + i);
  170. }
  171. ActionManage.GetInstance.Register(new Action(() =>
  172. {
  173. HKDevice.HK_PLC_S7.Write<bool>("M10.0", true);
  174. }), "ManualEStop", true);
  175. ActionManage.GetInstance.Register(new Action(() =>
  176. {
  177. HKDevice.HK_PLC_S7.Write<bool>("M10.0", false);
  178. }), "ManualEReset", true);
  179. }
  180. private void ManualOpen()
  181. {
  182. ActionManage.GetInstance.Register(new Action<object>((o) =>
  183. {
  184. if (o != null)
  185. {
  186. if (o.ToString().Contains("升降气缸"))
  187. {
  188. int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1));
  189. switch (index)
  190. {
  191. case 1:
  192. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX0.0", true);
  193. break;
  194. case 2:
  195. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX0.1", true);
  196. break;
  197. case 3:
  198. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX0.2", true);
  199. break;
  200. case 4:
  201. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX0.3", true);
  202. break;
  203. case 5:
  204. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX0.4", true);
  205. break;
  206. case 6:
  207. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX0.5", true);
  208. break;
  209. case 7:
  210. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX0.6", true);
  211. break;
  212. case 8:
  213. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX0.7", true);
  214. break;
  215. case 9:
  216. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX1.0", true);
  217. break;
  218. case 10:
  219. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX1.1", true);
  220. break;
  221. case 11:
  222. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX1.2", true);
  223. break;
  224. case 12:
  225. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX1.3", true);
  226. break;
  227. case 13:
  228. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX1.4", true);
  229. break;
  230. case 14:
  231. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX1.5", true);
  232. break;
  233. case 15:
  234. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX1.6", true);
  235. break;
  236. default:
  237. break;
  238. }
  239. }
  240. else if (o.ToString().Contains("阻挡气缸"))
  241. {
  242. int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1));
  243. switch (index)
  244. {
  245. case 1:
  246. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX1.7", true);
  247. break;
  248. case 2:
  249. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX2.0", true);
  250. break;
  251. case 3:
  252. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX2.1", true);
  253. break;
  254. case 4:
  255. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX2.2", true);
  256. break;
  257. case 5:
  258. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX2.3", true);
  259. break;
  260. case 6:
  261. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX2.4", true);
  262. break;
  263. case 7:
  264. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX2.5", true);
  265. break;
  266. case 8:
  267. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX2.6", true);
  268. break;
  269. case 9:
  270. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX2.7", true);
  271. break;
  272. case 10:
  273. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX3.0", true);
  274. break;
  275. case 11:
  276. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX3.1", true);
  277. break;
  278. case 12:
  279. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX3.2", true);
  280. break;
  281. case 13:
  282. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX3.3", true);
  283. break;
  284. case 14:
  285. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX3.4", true);
  286. break;
  287. case 15:
  288. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX3.5", true);
  289. break;
  290. default:
  291. break;
  292. }
  293. }
  294. else if (o.ToString().Contains("进料桶顶升气缸"))
  295. {
  296. HKDevice.HK_PLC_S7.Write("DB5.DBX3.6", true);
  297. }
  298. else if (o.ToString().Contains("出料桶顶升气缸1"))
  299. {
  300. HKDevice.HK_PLC_S7.Write("DB5.DBX3.7", true);
  301. }
  302. else if (o.ToString().Contains("出料桶顶升气缸2"))
  303. {
  304. HKDevice.HK_PLC_S7.Write("DB5.DBX4.0", true);
  305. }
  306. else if (o.ToString().Contains("出料桶顶升气缸3"))
  307. {
  308. HKDevice.HK_PLC_S7.Write("DB5.DBX4.1", true);
  309. }
  310. else if (o.ToString().Contains("托盘气缸1_1"))
  311. {
  312. HKDevice.HK_PLC_S7.Write("DB5.DBX4.2", true);
  313. }
  314. else if (o.ToString().Contains("托盘气缸1_2"))
  315. {
  316. HKDevice.HK_PLC_S7.Write("DB5.DBX4.3", true);
  317. }
  318. else if (o.ToString().Contains("托盘气缸2_1"))
  319. {
  320. HKDevice.HK_PLC_S7.Write("DB5.DBX4.4", true);
  321. }
  322. else if (o.ToString().Contains("托盘气缸2_2"))
  323. {
  324. HKDevice.HK_PLC_S7.Write("DB5.DBX4.5", true);
  325. }
  326. }
  327. }), "ManualOpen", true);//根据下发的配方ID将 托盘的位置信息添加到配方中
  328. }
  329. private void ManualClose()
  330. {
  331. ActionManage.GetInstance.Register(new Action<object>((o) =>
  332. {
  333. if (o != null)
  334. {
  335. if (o.ToString().Contains("升降气缸"))
  336. {
  337. int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1));
  338. switch (index)
  339. {
  340. case 1:
  341. HKDevice.HK_PLC_S7.Write("DB5.DBX0.0", false);
  342. break;
  343. case 2:
  344. HKDevice.HK_PLC_S7.Write("DB5.DBX0.1", false);
  345. break;
  346. case 3:
  347. HKDevice.HK_PLC_S7.Write("DB5.DBX0.2", false);
  348. break;
  349. case 4:
  350. HKDevice.HK_PLC_S7.Write("DB5.DBX0.3", false);
  351. break;
  352. case 5:
  353. HKDevice.HK_PLC_S7.Write("DB5.DBX0.4", false);
  354. break;
  355. case 6:
  356. HKDevice.HK_PLC_S7.Write("DB5.DBX0.5", false);
  357. break;
  358. case 7:
  359. HKDevice.HK_PLC_S7.Write("DB5.DBX0.6", false);
  360. break;
  361. case 8:
  362. HKDevice.HK_PLC_S7.Write("DB5.DBX0.7", false);
  363. break;
  364. case 9:
  365. HKDevice.HK_PLC_S7.Write("DB5.DBX1.0", false);
  366. break;
  367. case 10:
  368. HKDevice.HK_PLC_S7.Write("DB5.DBX1.1", false);
  369. break;
  370. case 11:
  371. HKDevice.HK_PLC_S7.Write("DB5.DBX1.2", false);
  372. break;
  373. case 12:
  374. HKDevice.HK_PLC_S7.Write("DB5.DBX1.3", false);
  375. break;
  376. case 13:
  377. HKDevice.HK_PLC_S7.Write("DB5.DBX1.4", false);
  378. break;
  379. case 14:
  380. HKDevice.HK_PLC_S7.Write("DB5.DBX1.5", false);
  381. break;
  382. case 15:
  383. HKDevice.HK_PLC_S7.Write("DB5.DBX1.6", false);
  384. break;
  385. default:
  386. break;
  387. }
  388. }
  389. else if (o.ToString().Contains("阻挡气缸"))
  390. {
  391. int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1));
  392. switch (index)
  393. {
  394. case 1:
  395. HKDevice.HK_PLC_S7.Write("DB5.DBX1.7", false);
  396. break;
  397. case 2:
  398. HKDevice.HK_PLC_S7.Write("DB5.DBX2.0", false);
  399. break;
  400. case 3:
  401. HKDevice.HK_PLC_S7.Write("DB5.DBX2.1", false);
  402. break;
  403. case 4:
  404. HKDevice.HK_PLC_S7.Write("DB5.DBX2.2", false);
  405. break;
  406. case 5:
  407. HKDevice.HK_PLC_S7.Write("DB5.DBX2.3", false);
  408. break;
  409. case 6:
  410. HKDevice.HK_PLC_S7.Write("DB5.DBX2.4", false);
  411. break;
  412. case 7:
  413. HKDevice.HK_PLC_S7.Write("DB5.DBX2.5", false);
  414. break;
  415. case 8:
  416. HKDevice.HK_PLC_S7.Write("DB5.DBX2.6", false);
  417. break;
  418. case 9:
  419. HKDevice.HK_PLC_S7.Write("DB5.DBX2.7", false);
  420. break;
  421. case 10:
  422. HKDevice.HK_PLC_S7.Write("DB5.DBX3.0", false);
  423. break;
  424. case 11:
  425. HKDevice.HK_PLC_S7.Write("DB5.DBX3.1", false);
  426. break;
  427. case 12:
  428. HKDevice.HK_PLC_S7.Write("DB5.DBX3.2", false);
  429. break;
  430. case 13:
  431. HKDevice.HK_PLC_S7.Write("DB5.DBX3.3", false);
  432. break;
  433. case 14:
  434. HKDevice.HK_PLC_S7.Write("DB5.DBX3.4", false);
  435. break;
  436. case 15:
  437. HKDevice.HK_PLC_S7.Write("DB5.DBX3.5", false);
  438. break;
  439. default:
  440. break;
  441. }
  442. }
  443. else if (o.ToString().Contains("进料桶顶升气缸"))
  444. {
  445. HKDevice.HK_PLC_S7.Write("DB5.DBX3.6", false);
  446. }
  447. else if (o.ToString().Contains("出料桶顶升气缸1"))
  448. {
  449. HKDevice.HK_PLC_S7.Write("DB5.DBX3.7", false);
  450. }
  451. else if (o.ToString().Contains("出料桶顶升气缸2"))
  452. {
  453. HKDevice.HK_PLC_S7.Write("DB5.DBX4.0", false);
  454. }
  455. else if (o.ToString().Contains("出料桶顶升气缸3"))
  456. {
  457. HKDevice.HK_PLC_S7.Write("DB5.DBX4.1", false);
  458. }
  459. else if (o.ToString().Contains("托盘气缸1_1"))
  460. {
  461. HKDevice.HK_PLC_S7.Write("DB5.DBX4.2", false);
  462. }
  463. else if (o.ToString().Contains("托盘气缸1_2"))
  464. {
  465. HKDevice.HK_PLC_S7.Write("DB5.DBX4.3", false);
  466. }
  467. else if (o.ToString().Contains("托盘气缸2_1"))
  468. {
  469. HKDevice.HK_PLC_S7.Write("DB5.DBX4.4", false);
  470. }
  471. else if (o.ToString().Contains("托盘气缸2_2"))
  472. {
  473. HKDevice.HK_PLC_S7.Write("DB5.DBX4.5", false);
  474. }
  475. }
  476. }), "ManualClose", true);//根据下发的配方ID将 托盘的位置信息添加到配方中
  477. }
  478. /// <summary>
  479. /// AGV进站送货
  480. /// </summary>
  481. private void AgvGetInDelivery()
  482. {
  483. switch (GVL_SmallStation.GetInstance.AgvDeliveryPosition)
  484. {
  485. case 0:
  486. if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read<object>(SiemensCommAddress.DeliveryAGVApply) is bool))
  487. {
  488. GVL_SmallStation.GetInstance.AgvDeliveryPosition = 1;
  489. HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVApply, true);
  490. }
  491. break;
  492. case 1:
  493. if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.DeliveryAGVIsApply)))
  494. {
  495. GVL_SmallStation.GetInstance.AgvDeliveryPosition = 2;
  496. SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.DeliveryAGVIsApply, true);
  497. }
  498. break;
  499. case 2:
  500. if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read<object>(SiemensCommAddress.DeliveryAGVApplyJack) is bool))
  501. {
  502. GVL_SmallStation.GetInstance.AgvDeliveryPosition = 3;
  503. HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVApplyJack, true);
  504. }
  505. break;
  506. case 3:
  507. if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.DeliveryAGVIsApplyJack)))
  508. {
  509. GVL_SmallStation.GetInstance.AgvDeliveryPosition = 4;
  510. SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.DeliveryAGVIsApplyJack, true);
  511. }
  512. break;
  513. case 4:
  514. if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read<object>(SiemensCommAddress.DeliveryAGVFinsih) is bool))
  515. {
  516. GVL_SmallStation.GetInstance.AgvDeliveryPosition = 5;
  517. HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVFinsih, true);
  518. }
  519. break;
  520. case 5:
  521. if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.StationHaveCargo)))
  522. {
  523. GVL_SmallStation.GetInstance.AgvDeliveryPosition = 0;
  524. SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationHaveCargo, true);
  525. }
  526. break;
  527. default:
  528. break;
  529. }
  530. //获取工位上是否有小车
  531. SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationIsExistCar, (bool)
  532. HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.StationIsExistTray));
  533. }
  534. /// <summary>
  535. /// AGV进站取货
  536. /// </summary>
  537. private void AgvGetInPickUp()
  538. {
  539. switch (GVL_SmallStation.GetInstance.AgvPickUpPosition)
  540. {
  541. case 0:
  542. if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read<bool>(SiemensCommAddress.PickAGVApply)))
  543. {
  544. GVL_SmallStation.GetInstance.AgvPickUpPosition = 1;
  545. HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.PickAGVApply, true);
  546. }
  547. break;
  548. case 1:
  549. if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.PickAGVIsApply)))
  550. {
  551. GVL_SmallStation.GetInstance.AgvPickUpPosition = 2;
  552. SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.PickAGVIsApply, true);
  553. }
  554. break;
  555. case 2:
  556. if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read<bool>(SiemensCommAddress.PickCargoAGVFinish)))
  557. {
  558. GVL_SmallStation.GetInstance.AgvPickUpPosition = 3;
  559. HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.PickCargoAGVFinish, true);
  560. }
  561. break;
  562. case 3:
  563. if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read<bool>(HKPlcCommAddress.PickAGVFinish)))
  564. {
  565. GVL_SmallStation.GetInstance.AgvPickUpPosition = 0;
  566. SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.PickAGVFinish, true);
  567. }
  568. break;
  569. default:
  570. break;
  571. }
  572. }
  573. /// <summary>
  574. /// 将配方添加到配方队列中
  575. /// </summary>
  576. private void ReceviceData()
  577. {
  578. RemoteRecipes = Json<RemoteRecipeDataColl>.Data.Recipes;
  579. if (RemoteRecipes.Count > 0)
  580. {
  581. foreach (var data in RemoteRecipes)
  582. {
  583. if (data.TrayCode == 1)
  584. {
  585. if (!(RecipeQueue.Contains(data.RecipeCode)))
  586. {
  587. RecipeQueue.Enqueue(data.RecipeCode);
  588. }
  589. }
  590. else if(data.TrayCode == 2)
  591. {
  592. if (!(RecipeQueueTray2.Contains(data.RecipeCode)))
  593. {
  594. RecipeQueueTray2.Enqueue(data.RecipeCode);
  595. }
  596. }
  597. }
  598. }
  599. else
  600. {
  601. RecipeQueue.Clear();
  602. RecipeQueueTray2.Clear();
  603. GVL_SmallStation.GetInstance.RecipeStatusID = 0;
  604. GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0;
  605. }
  606. }
  607. /// <summary>
  608. /// 执行配方队列中的第一个配方
  609. /// </summary>
  610. private void RecipeInfoToHKPLC()
  611. {
  612. if (RecipeQueue.Count > 0)
  613. {
  614. int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueue.ElementAt(0));
  615. if (index >= 0 && index < RemoteRecipes.Count)
  616. {
  617. string code = RemoteRecipes.ElementAt(index).RecipeCode;
  618. int trayCode = RemoteRecipes.ElementAt(index).TrayCode;
  619. string recipeName = RemoteRecipes.ElementAt(index).RecipeName;
  620. string windSend = RemoteRecipes.ElementAt(index).ToString();
  621. if (trayCode == 1)
  622. {
  623. if (GVL_SmallStation.GetInstance.RecipeStatusID == 0)
  624. {
  625. if (GVL_SmallStation.GetInstance.IsUseWindSend)
  626. {
  627. GVL_SmallStation.GetInstance.IsUseWindSend = false;
  628. WindSendData.TargetRecipeCode = code;
  629. if (RemoteRecipes.ElementAt(index).WindSendRawMaterial.ElementAt(0).RawMaterialName == DeviceName.原料1.ToString())
  630. {
  631. WindSendData.RawMaterial1_SetWeight = RemoteRecipes.ElementAt(index).WindSendRawMaterial.ElementAt(0).RawMaterialWeight;
  632. }
  633. if (RemoteRecipes.ElementAt(index).WindSendRawMaterial.ElementAt(1).RawMaterialName == DeviceName.原料2.ToString())
  634. {
  635. WindSendData.RawMaterial2_SetWeight = RemoteRecipes.ElementAt(index).WindSendRawMaterial.ElementAt(1).RawMaterialWeight;
  636. }
  637. if (RemoteRecipes.ElementAt(index).WindSendRawMaterial.ElementAt(2).RawMaterialName == DeviceName.原料3.ToString())
  638. {
  639. WindSendData.RawMaterial3_SetWeight = RemoteRecipes.ElementAt(index).WindSendRawMaterial.ElementAt(2).RawMaterialWeight;
  640. }
  641. if (RemoteRecipes.ElementAt(index).WindSendRawMaterial.ElementAt(3).RawMaterialName == DeviceName.原料4.ToString())
  642. {
  643. WindSendData.RawMaterial4_SetWeight = RemoteRecipes.ElementAt(index).WindSendRawMaterial.ElementAt(3).RawMaterialWeight;
  644. }
  645. if (RemoteRecipes.ElementAt(index).WindSendRawMaterial.ElementAt(4).RawMaterialName == DeviceName.原料5.ToString())
  646. {
  647. WindSendData.RawMaterial5_SetWeight = RemoteRecipes.ElementAt(index).WindSendRawMaterial.ElementAt(4).RawMaterialWeight;
  648. }
  649. WindSendDevice.Siemens_PLC_S7.WriteClass<XL_WindSendData_DB>(WindSendData, 5);
  650. }
  651. foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
  652. {
  653. HKDevice.StockBinPar((uint)item.RawMaterialBarrelNum, (ushort)item.RawMaterialLocation);
  654. }
  655. HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", true);
  656. GVL_SmallStation.GetInstance.RecipeStatusID = 1;
  657. MessageLog.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},下发完成");
  658. HKDevice.HK_PLC_S7.Write("DB3.DBX1.3", true);
  659. }
  660. if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.3") && GVL_SmallStation.GetInstance.RecipeStatusID == 1)
  661. {
  662. HKDevice.HK_PLC_S7.Write("DB3.DBX1.3", false);
  663. GVL_SmallStation.GetInstance.RecipeStatusID = 2;
  664. MessageLog.GetInstance.ShowRunLog($"托盘1,{ recipeName}plc端 配方接收完成");
  665. }
  666. if (GVL_SmallStation.GetInstance.RecipeStatusID == 2)
  667. {
  668. if (RTrig.GetInstance("DB3.DBX50.0").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.0")))
  669. {
  670. var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD10");
  671. MessageLog.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{res}料仓,允许配料");
  672. if (res > 0 && res is float loc)
  673. {
  674. int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
  675. float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
  676. if (loc_index >= 0)
  677. {
  678. DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//根据料仓编号 启动并写入每个原料重量
  679. GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
  680. //HKDevice.HK_PLC_S7.Write("DB3.DBX50.0", false);
  681. }
  682. GVL_SmallStation.GetInstance.DosingTray1 = true;
  683. MessageLog.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{(int)loc}号仓,配料完成");
  684. }
  685. }
  686. else if(RTrig.GetInstance("DB3.DBX50.1").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.1")))
  687. {
  688. var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD14");
  689. MessageLog.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{res}料仓,允许配料");
  690. if (res > 0 && res is float loc)
  691. {
  692. int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
  693. float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
  694. if (loc_index >= 0)
  695. {
  696. DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
  697. GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
  698. //HKDevice.HK_PLC_S7.Write("DB3.DBX50.1", false);
  699. }
  700. GVL_SmallStation.GetInstance.DosingTray1 = true;
  701. MessageLog.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{(int)loc}号仓,配料完成");
  702. }
  703. }
  704. else if (RTrig.GetInstance("DB3.DBX50.2").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.2")))
  705. {
  706. var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD18");
  707. MessageLog.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{res}料仓,允许配料");
  708. if (res > 0 && res is float loc)
  709. {
  710. int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
  711. float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
  712. if (loc_index >= 0)
  713. {
  714. DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
  715. GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
  716. //HKDevice.HK_PLC_S7.Write("DB3.DBX50.2", false);
  717. }
  718. GVL_SmallStation.GetInstance.DosingTray1 = true;
  719. MessageLog.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{(int)loc}号仓,配料完成");
  720. }
  721. }
  722. else if (RTrig.GetInstance("DB3.DBX50.3").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.3")))
  723. {
  724. var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD22");
  725. MessageLog.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{res}料仓,允许配料");
  726. if (res > 0 && res is float loc)
  727. {
  728. int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
  729. float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
  730. if (loc_index >= 0)
  731. {
  732. DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
  733. GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
  734. //HKDevice.HK_PLC_S7.Write("DB3.DBX50.3", false);
  735. }
  736. GVL_SmallStation.GetInstance.DosingTray1 = true;
  737. MessageLog.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{(int)loc}号仓,配料完成");
  738. }
  739. }
  740. if (GVL_SmallStation.GetInstance.DosingTray1)
  741. {
  742. for (int i = 1; i < 16; i++)
  743. {
  744. if (RTrig.GetInstance("GetDeviceRunStatus").Start(DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3))
  745. {
  746. MessageLog.GetInstance.ShowRunLog($"柔性味魔方,托盘1,配方:{recipeName},{i}号仓,配料完成");
  747. int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
  748. RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.CutWeightFeedback;
  749. DeviceInquire.GetInstance.GetDevice(i).StatusReset();
  750. if (i >= 1 && i <= 8)
  751. {
  752. HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true);
  753. }
  754. else if (i >= 9 && i <= 15)
  755. {
  756. HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true);
  757. }
  758. GVL_SmallStation.GetInstance.DosingTray1 = false;
  759. }
  760. }
  761. }
  762. if (RTrig.GetInstance("配方配料完成").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.1")) && (GVL_SmallStation.GetInstance.WindSendDosingFinish || !GVL_SmallStation.GetInstance.IsUseWindSend))
  763. {
  764. var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code);
  765. MessageLog.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成");
  766. RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode;
  767. RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName;
  768. for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++)
  769. {
  770. RecipeFinishInfo.Material[i] = new UDT1();
  771. RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
  772. RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
  773. RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight;
  774. }
  775. if (SiemensDevice.IsConnected)
  776. {
  777. RecipeFinishInfo.Ask_For_Finish = true;
  778. SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 3);
  779. }
  780. App.Current.Dispatcher.Invoke(() =>
  781. {
  782. Json<RemoteRecipeDataColl>.Data.Recipes.Remove(res);
  783. });
  784. RecipeQueue.TryDequeue(out code);
  785. HKDevice.HK_PLC_S7.Write("DB3.DBX1.1", false);
  786. GVL_SmallStation.GetInstance.RecipeStatusID = 0;
  787. }
  788. }
  789. }
  790. }
  791. }
  792. if (RecipeQueueTray2.Count > 0)
  793. {
  794. int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueueTray2.ElementAt(0));
  795. if (index >= 0 && index < RemoteRecipes.Count)
  796. {
  797. string code = RemoteRecipes.ElementAt(index).RecipeCode;
  798. int trayCode = RemoteRecipes.ElementAt(index).TrayCode;
  799. string recipeName = RemoteRecipes.ElementAt(index).RecipeName;
  800. if (trayCode == 2)
  801. {
  802. if (GVL_SmallStation.GetInstance.RecipeStatusIDTray2 == 0)
  803. {
  804. MessageLog.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},初始化");
  805. foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
  806. {
  807. HKDevice.StockBinPar((uint)item.RawMaterialBarrelNum, (ushort)item.RawMaterialLocation, 2);
  808. }
  809. HKDevice.HK_PLC_S7.Write("DB4.DBX1.4", true);
  810. GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 1;
  811. MessageLog.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},下发完成");
  812. HKDevice.HK_PLC_S7.Write("DB3.DBX1.4", true);
  813. }
  814. if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.4") && GVL_SmallStation.GetInstance.RecipeStatusIDTray2 == 1)
  815. {
  816. HKDevice.HK_PLC_S7.Write("DB3.DBX1.4", false);
  817. GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 2;
  818. MessageLog.GetInstance.ShowRunLog($"配方:{recipeName},plc端 配方接收完成");
  819. }
  820. if (GVL_SmallStation.GetInstance.RecipeStatusIDTray2 == 2)
  821. {
  822. if (RTrig.GetInstance("DB3.DBX50.4").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.4")))
  823. {
  824. var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD26");
  825. MessageLog.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},1号桶,{res}料仓,允许配料");
  826. if (res > 0 && res is float loc)
  827. {
  828. //int decimalNum = Convert.ToInt32(loc.ToString().Substring(loc.ToString().IndexOf(".") + 1));
  829. int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
  830. double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
  831. if (loc_index >= 0)
  832. {
  833. DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//根据料仓编号 启动并写入每个原料重量
  834. GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
  835. //HKDevice.HK_PLC_S7.Write("DB3.DBX50.0", false);
  836. }
  837. GVL_SmallStation.GetInstance.DosingTray2 = true;
  838. MessageLog.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},1号桶,{(int)loc}号仓,配料完成");
  839. }
  840. }
  841. else if (RTrig.GetInstance("DB3.DBX50.5").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.5")))
  842. {
  843. var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD30");
  844. MessageLog.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},2号桶,{res}料仓,允许配料");
  845. if (res > 0 && res is float loc)
  846. {
  847. int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
  848. double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
  849. if (loc_index >= 0)
  850. {
  851. DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//启动并写入每个原料重量
  852. GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
  853. //HKDevice.HK_PLC_S7.Write("DB3.DBX50.5", false);
  854. }
  855. GVL_SmallStation.GetInstance.DosingTray2 = true;
  856. MessageLog.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},2号桶,{(int)loc}号仓,配料完成");
  857. }
  858. }
  859. else if (RTrig.GetInstance("DB3.DBX50.6").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.6")))
  860. {
  861. var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD34");
  862. MessageLog.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},3号桶,{res}料仓,允许配料");
  863. if (res > 0 && res is float loc)
  864. {
  865. int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
  866. double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
  867. if (loc_index >= 0)
  868. {
  869. DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//启动并写入每个原料重量
  870. GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
  871. //HKDevice.HK_PLC_S7.Write("DB3.DBX50.6", false);
  872. }
  873. GVL_SmallStation.GetInstance.DosingTray2 = true;
  874. MessageLog.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},3号桶,{(int)loc}号仓,配料完成");
  875. }
  876. }
  877. else if (RTrig.GetInstance("DB3.DBX50.7").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.7")))
  878. {
  879. var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD38");
  880. MessageLog.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},4号桶,{res}料仓,允许配料");
  881. if (res > 0 && res is float loc)
  882. {
  883. int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
  884. double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
  885. if (loc_index >= 0)
  886. {
  887. DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//启动并写入每个原料重量
  888. GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
  889. //HKDevice.HK_PLC_S7.Write("DB3.DBX50.7", false);
  890. }
  891. GVL_SmallStation.GetInstance.DosingTray2 = true;
  892. MessageLog.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},4号桶,{(int)loc}号仓,配料完成");
  893. }
  894. }
  895. if (GVL_SmallStation.GetInstance.DosingTray2 == true)
  896. {
  897. for (int i = 1; i < 16; i++)
  898. {
  899. if (RTrig.GetInstance("柔性味魔方配料完成").Start(DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3))
  900. {
  901. MessageLog.GetInstance.ShowRunLog($"柔性味魔方,托盘2,配方:{recipeName},{i}号仓,配料完成");
  902. int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
  903. RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.CutWeightFeedback;
  904. DeviceInquire.GetInstance.GetDevice(i).StatusReset();
  905. if (i >= 1 && i <= 8)
  906. {
  907. HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true);
  908. }
  909. else if (i >= 9 && i <= 15)
  910. {
  911. HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true);
  912. }
  913. GVL_SmallStation.GetInstance.DosingTray2 = false;
  914. }
  915. }
  916. }
  917. if (RTrig.GetInstance("DB3.DBX1.2").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.2")))
  918. {
  919. var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code);
  920. MessageLog.GetInstance.ShowRunLog($"托盘2配方{res.RecipeName}配料完成");
  921. RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode;
  922. RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName;
  923. for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++)
  924. {
  925. RecipeFinishInfo.Material[i] = new UDT1();
  926. RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
  927. RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
  928. RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight;
  929. }
  930. if (SiemensDevice.IsConnected)
  931. {
  932. RecipeFinishInfo.Ask_For_Finish = true;
  933. SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 3);
  934. }
  935. App.Current.Dispatcher.Invoke(() =>
  936. {
  937. Json<RemoteRecipeDataColl>.Data.Recipes.Remove(res);
  938. });
  939. RecipeQueueTray2.TryDequeue(out code);
  940. HKDevice.HK_PLC_S7.Write("DB3.DBX1.2", false);
  941. GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0;
  942. }
  943. }
  944. }
  945. }
  946. }
  947. }
  948. }
  949. }