终端一体化运控平台
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

564 líneas
27 KiB

  1. using BPASmartClient.CustomResource.Pages.Model;
  2. using BPASmartClient.Helper;
  3. using BPASmartClient.DosingHKProject.Model.HK_PLC;
  4. using BPASmartClient.DosingHKProject.Model.Siemens;
  5. using BPASmartClient.Modbus;
  6. using System;
  7. using System.Collections.Concurrent;
  8. using System.Collections.Generic;
  9. using System.Collections.ObjectModel;
  10. using System.Configuration;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading;
  14. using System.Threading.Tasks;
  15. using BPASmartClient.DosingProject;
  16. namespace BPASmartClient.DosingHKProject.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 HKDeviceStatus HKDevice = new HKDeviceStatus();
  37. public void Init()
  38. {
  39. for (int i = 0; i < 16; i++)
  40. {
  41. if (DeviceInquire.GetInstance.GetDevice(i).DeviceName != null)
  42. {
  43. if (!RawMaterialsNamePos.ContainsKey(DeviceInquire.GetInstance.GetDevice(i).DeviceName))
  44. {
  45. RawMaterialsNamePos.Add(DeviceInquire.GetInstance.GetDevice(i).DeviceName, (short)DeviceInquire.GetInstance.GetDevice(i).deviceStatus.DeviceNum);
  46. }
  47. }
  48. }
  49. string HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"];
  50. try
  51. {
  52. //HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, HK_PLC_IP);
  53. if (HKDevice.IsConnected)
  54. {
  55. HKDevice.Init();
  56. MessageNotify.GetInstance.ShowUserLog("海科plc连接成功,并初始化完成");
  57. }
  58. }
  59. catch(Exception ex)
  60. {
  61. }
  62. RecipeQueue.Clear();
  63. ThreadManage.GetInstance().StartLong(new Action(() =>
  64. {
  65. ReceviceData();
  66. RecipeInfoToHKPLC();
  67. Thread.Sleep(10);
  68. }), "流程处理", true);
  69. ThreadManage.GetInstance().StartLong(new Action(() =>
  70. {
  71. if (HKDevice.IsConnected)
  72. {
  73. GetStatus();
  74. ManualOpen();
  75. ManualClose();
  76. }
  77. Thread.Sleep(10);
  78. }), "手动操作", true);
  79. }
  80. private void GetStatus()
  81. {
  82. for (int i = 0; i < 8; i++)
  83. {
  84. HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX0." + i);
  85. }
  86. for (int i = 0; i < 8; i++)
  87. {
  88. HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX1." + i);
  89. }
  90. }
  91. private void ManualOpen()
  92. {
  93. ActionManage.GetInstance.Register(new Action<object>((o) =>
  94. {
  95. if (o != null)
  96. {
  97. if (o.ToString().Contains("升降气缸"))
  98. {
  99. int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1));
  100. switch (index)
  101. {
  102. case 1:
  103. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX0.0", true);
  104. break;
  105. case 2:
  106. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX0.1", true);
  107. break;
  108. case 3:
  109. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX0.2", true);
  110. break;
  111. case 4:
  112. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX0.3", true);
  113. break;
  114. case 5:
  115. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX0.4", true);
  116. break;
  117. case 6:
  118. HKDevice.HK_PLC_S7.Write<bool>("DB5.DBX0.5", true);
  119. break;
  120. default:
  121. break;
  122. }
  123. }
  124. }
  125. }), "ManualOpen", true);//根据下发的配方ID将 托盘的位置信息添加到配方中
  126. }
  127. private void ManualClose()
  128. {
  129. ActionManage.GetInstance.Register(new Action<object>((o) =>
  130. {
  131. if (o != null)
  132. {
  133. if (o.ToString().Contains("升降气缸"))
  134. {
  135. int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1));
  136. switch (index)
  137. {
  138. case 1:
  139. HKDevice.HK_PLC_S7.Write("DB5.DBX0.0", false);
  140. break;
  141. case 2:
  142. HKDevice.HK_PLC_S7.Write("DB5.DBX0.1", false);
  143. break;
  144. case 3:
  145. HKDevice.HK_PLC_S7.Write("DB5.DBX0.2", false);
  146. break;
  147. case 4:
  148. HKDevice.HK_PLC_S7.Write("DB5.DBX0.3", false);
  149. break;
  150. case 5:
  151. HKDevice.HK_PLC_S7.Write("DB5.DBX0.4", false);
  152. break;
  153. case 6:
  154. HKDevice.HK_PLC_S7.Write("DB5.DBX0.5", false);
  155. break;
  156. default:
  157. break;
  158. }
  159. }
  160. }
  161. }), "ManualClose", true);//根据下发的配方ID将 托盘的位置信息添加到配方中
  162. }
  163. /// <summary>
  164. /// 将配方添加到配方队列中
  165. /// </summary>
  166. private void ReceviceData()
  167. {
  168. RemoteRecipes = Json<RemoteRecipeDataColl>.Data.Recipes;
  169. if (RemoteRecipes.Count > 0)
  170. {
  171. foreach (var data in RemoteRecipes)
  172. {
  173. if (!(RecipeQueue.Contains(data.RecipeCode)))
  174. {
  175. RecipeQueue.Enqueue(data.RecipeCode);
  176. }
  177. }
  178. }
  179. else
  180. {
  181. RecipeQueue.Clear();
  182. GVL_SmallStation.GetInstance.RecipeStatusID = 0;
  183. }
  184. }
  185. int cnt_sensor1 = 0;
  186. int cnt_sensor2 = 0;
  187. int cnt_sensor3 = 0;
  188. int cnt_sensor4 = 0;
  189. int cnt_sensor5 = 0;
  190. int cnt_sensor6 = 0;
  191. int cnt_sensor7 = 0;
  192. int cnt_sensor8 = 0;
  193. int barrel1 = 0;
  194. /// <summary>
  195. /// 执行配方队列中的第一个配方
  196. /// </summary>
  197. private void RecipeInfoToHKPLC()
  198. {
  199. if (RecipeQueue.Count > 0)
  200. {
  201. int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueue.ElementAt(0));
  202. if (index >= 0 && index < RemoteRecipes.Count)
  203. {
  204. string code = RemoteRecipes.ElementAt(index).RecipeCode;
  205. string recipeName = RemoteRecipes.ElementAt(index).RecipeName;
  206. #region sensor处理
  207. if (GVL_SmallStation.GetInstance.plcRead.Sensor_Load)
  208. {
  209. cnt_sensor1++;
  210. }
  211. else
  212. {
  213. if (cnt_sensor1 >= 50)
  214. {
  215. if (barrel1 >= 0 && barrel1 < GVL_SmallStation.MaxBarrelNum)
  216. {
  217. if (GVL_SmallStation.GetInstance.Barrel_Location[barrel1] == 0)
  218. {
  219. GVL_SmallStation.GetInstance.Barrel_Location[barrel1] = 1;
  220. barrel1++;
  221. }
  222. }
  223. else
  224. {
  225. //报错,超过最大的桶号数
  226. }
  227. }
  228. cnt_sensor1 = 0;
  229. }
  230. if (GVL_SmallStation.GetInstance.plcRead.Sensor_Station1)
  231. {
  232. cnt_sensor2++;
  233. }
  234. else
  235. {
  236. if (cnt_sensor2 >= 50)
  237. {
  238. for (int i = 0; i < GVL_SmallStation.GetInstance.Barrel_Location.Length; i++)
  239. {
  240. if (GVL_SmallStation.GetInstance.Barrel_Location[i] == 1)
  241. {
  242. GVL_SmallStation.GetInstance.Barrel_Location[i] = 2;
  243. }
  244. }
  245. }
  246. cnt_sensor2 = 0;
  247. }
  248. if (GVL_SmallStation.GetInstance.plcRead.Sensor_Station2)
  249. {
  250. cnt_sensor3++;
  251. }
  252. else
  253. {
  254. if (cnt_sensor3 >= 50)
  255. {
  256. for (int i = 0; i < GVL_SmallStation.GetInstance.Barrel_Location.Length; i++)
  257. {
  258. if (GVL_SmallStation.GetInstance.Barrel_Location[i] == 2)
  259. {
  260. GVL_SmallStation.GetInstance.Barrel_Location[i] = 3;
  261. }
  262. }
  263. }
  264. cnt_sensor3 = 0;
  265. }
  266. if (GVL_SmallStation.GetInstance.plcRead.Sensor_Station3)
  267. {
  268. cnt_sensor4++;
  269. }
  270. else
  271. {
  272. if (cnt_sensor4 >= 50)
  273. {
  274. for (int i = 0; i < GVL_SmallStation.GetInstance.Barrel_Location.Length; i++)
  275. {
  276. if (GVL_SmallStation.GetInstance.Barrel_Location[i] == 3)
  277. {
  278. GVL_SmallStation.GetInstance.Barrel_Location[i] = 4;
  279. }
  280. }
  281. }
  282. cnt_sensor4 = 0;
  283. }
  284. if (GVL_SmallStation.GetInstance.plcRead.Sensor_Station4)
  285. {
  286. cnt_sensor5++;
  287. }
  288. else
  289. {
  290. if (cnt_sensor5 >= 50)
  291. {
  292. for (int i = 0; i < GVL_SmallStation.GetInstance.Barrel_Location.Length; i++)
  293. {
  294. if (GVL_SmallStation.GetInstance.Barrel_Location[i] == 4)
  295. {
  296. GVL_SmallStation.GetInstance.Barrel_Location[i] = 5;
  297. }
  298. }
  299. }
  300. cnt_sensor5 = 0;
  301. }
  302. if (GVL_SmallStation.GetInstance.plcRead.Sensor_Station5)
  303. {
  304. cnt_sensor6++;
  305. }
  306. else
  307. {
  308. if (cnt_sensor6 >= 50)
  309. {
  310. for (int i = 0; i < GVL_SmallStation.GetInstance.Barrel_Location.Length; i++)
  311. {
  312. if (GVL_SmallStation.GetInstance.Barrel_Location[i] == 5)
  313. {
  314. GVL_SmallStation.GetInstance.Barrel_Location[i] = 6;
  315. }
  316. }
  317. }
  318. cnt_sensor6 = 0;
  319. }
  320. if (GVL_SmallStation.GetInstance.plcRead.Sensor_Station6)
  321. {
  322. cnt_sensor7++;
  323. }
  324. else
  325. {
  326. if (cnt_sensor7 >= 50)
  327. {
  328. for (int i = 0; i < GVL_SmallStation.GetInstance.Barrel_Location.Length; i++)
  329. {
  330. if (GVL_SmallStation.GetInstance.Barrel_Location[i] == 6)
  331. {
  332. GVL_SmallStation.GetInstance.Barrel_Location[i] = 7;
  333. }
  334. }
  335. }
  336. cnt_sensor7 = 0;
  337. }
  338. if (GVL_SmallStation.GetInstance.plcRead.Sensor_Unload)
  339. {
  340. HKDevice.HK_PLC_S7.Write<bool>("DB2.DBX3.0", false);
  341. HKDevice.HK_PLC_S7.Write<bool>("DB2.DBX3.1", false);
  342. MessageNotify.GetInstance.ShowRunLog($"下料桶堵料,线体不运行");
  343. cnt_sensor8++;
  344. }
  345. else
  346. {
  347. if (cnt_sensor8 >= 50)
  348. {
  349. for (int i = 0; i < GVL_SmallStation.GetInstance.Barrel_Location.Length; i++)
  350. {
  351. if (GVL_SmallStation.GetInstance.Barrel_Location[i] == 7)
  352. {
  353. GVL_SmallStation.GetInstance.Barrel_Location[i] = 0;
  354. }
  355. }
  356. }
  357. cnt_sensor8 = 0;
  358. }
  359. #endregion
  360. for (int i = 0; i < GVL_SmallStation.GetInstance.Barrel_Location.Length; i++)
  361. {
  362. if (GVL_SmallStation.GetInstance.plcRead.Sensor_Station1 && GVL_SmallStation.GetInstance.Barrel_Location[i] == 1)
  363. {
  364. foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
  365. {
  366. if ((item.RawMaterialLocation == i+1 || item.RawMaterialLocation == i+7) && item.IsDosingFinish == false && item.RawMaterialBarrelNum == i+1)
  367. {
  368. GVL_SmallStation.GetInstance.AllowDosing_Pos[i] = true;
  369. }
  370. }
  371. }
  372. }
  373. if (GVL_SmallStation.GetInstance.plcRead.Sensor_Station1 && GVL_SmallStation.GetInstance.Barrel_Location[0] == 1)
  374. {
  375. foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
  376. {
  377. if ((item.RawMaterialLocation == 1 || item.RawMaterialLocation == 7) && item.IsDosingFinish == false && item.RawMaterialBarrelNum == 1)
  378. {
  379. GVL_SmallStation.GetInstance.AllowDosing_Pos[0] = true;
  380. }
  381. }
  382. }
  383. if (GVL_SmallStation.GetInstance.plcRead.Sensor_Station2 && GVL_SmallStation.GetInstance.Barrel_Location[1] == 1)
  384. {
  385. GVL_SmallStation.GetInstance.AllowDosing_Pos[1] = true;
  386. }
  387. if (GVL_SmallStation.GetInstance.plcRead.Sensor_Station3 && GVL_SmallStation.GetInstance.Barrel_Location[2] == 1)
  388. {
  389. GVL_SmallStation.GetInstance.AllowDosing_Pos[2] = true;
  390. }
  391. if (GVL_SmallStation.GetInstance.plcRead.Sensor_Station4 && GVL_SmallStation.GetInstance.Barrel_Location[3] == 1)
  392. {
  393. GVL_SmallStation.GetInstance.AllowDosing_Pos[3] = true;
  394. }
  395. if (GVL_SmallStation.GetInstance.plcRead.Sensor_Station5 && GVL_SmallStation.GetInstance.Barrel_Location[4] == 1)
  396. {
  397. GVL_SmallStation.GetInstance.AllowDosing_Pos[4] = true;
  398. }
  399. if (GVL_SmallStation.GetInstance.plcRead.Sensor_Station6 && GVL_SmallStation.GetInstance.Barrel_Location[5] == 1)
  400. {
  401. GVL_SmallStation.GetInstance.AllowDosing_Pos[5] = true;
  402. }
  403. foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
  404. {
  405. }
  406. if (GVL_SmallStation.GetInstance.RecipeStatusID == 0)
  407. {
  408. if (RunInit() == 1)
  409. {
  410. GVL_SmallStation.GetInstance.RecipeStatusID = 1;
  411. }
  412. }
  413. if (GVL_SmallStation.GetInstance.RecipeStatusID == 1)
  414. {
  415. HKDevice.HK_PLC_S7.Write<bool>("DB2.DBX3.0", true);
  416. HKDevice.HK_PLC_S7.Write<bool>("DB2.DBX3.1", true);
  417. GVL_SmallStation.GetInstance.RecipeStatusID = 2;
  418. }
  419. if (HKDevice.HK_PLC_S7.Read<bool>("DB2.DBX3.0") && HKDevice.HK_PLC_S7.Read<bool>("DB2.DBX3.1") && GVL_SmallStation.GetInstance.RecipeStatusID == 2)
  420. {
  421. GVL_SmallStation.GetInstance.RecipeStatusID = 3;
  422. }
  423. if (GVL_SmallStation.GetInstance.RecipeStatusID == 3)
  424. {
  425. for (int i = 0; i < 6; i++)
  426. {
  427. }
  428. if (GVL_SmallStation.GetInstance.AllowDosing_Pos[0])
  429. {
  430. int res = 1;
  431. MessageNotify.GetInstance.ShowRunLog($"配方:{recipeName},1号桶,{res}料仓,允许配料");
  432. if (res > 0 )
  433. {
  434. int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == res);
  435. float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
  436. if (loc_index >= 0)
  437. {
  438. DeviceInquire.GetInstance.GetDevice((int)res)?.Start(weight);//根据料仓编号 启动并写入每个原料重量
  439. GVL_SmallStation.GetInstance.StockInIsWork = (int)res;
  440. }
  441. GVL_SmallStation.GetInstance.DosingTray1 = true;
  442. MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{(int)res}号仓,配料完成");
  443. }
  444. }
  445. else if(RTrig.GetInstance("DB3.DBX50.1").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.1")))
  446. {
  447. var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD14");
  448. MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{res}料仓,允许配料");
  449. if (res > 0 && res is float loc)
  450. {
  451. int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
  452. float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
  453. if (loc_index >= 0)
  454. {
  455. DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
  456. GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
  457. }
  458. GVL_SmallStation.GetInstance.DosingTray1 = true;
  459. MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{(int)loc}号仓,配料完成");
  460. }
  461. }
  462. else if (RTrig.GetInstance("DB3.DBX50.2").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.2")))
  463. {
  464. var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD18");
  465. MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{res}料仓,允许配料");
  466. if (res > 0 && res is float loc)
  467. {
  468. int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
  469. float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
  470. if (loc_index >= 0)
  471. {
  472. DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
  473. GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
  474. }
  475. GVL_SmallStation.GetInstance.DosingTray1 = true;
  476. MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{(int)loc}号仓,配料完成");
  477. }
  478. }
  479. else if (RTrig.GetInstance("DB3.DBX50.3").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.3")))
  480. {
  481. var res = HKDevice.HK_PLC_S7.Read<float>("DB3.DBD22");
  482. MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{res}料仓,允许配料");
  483. if (res > 0 && res is float loc)
  484. {
  485. int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
  486. float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
  487. if (loc_index >= 0)
  488. {
  489. DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
  490. GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
  491. }
  492. GVL_SmallStation.GetInstance.DosingTray1 = true;
  493. MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{(int)loc}号仓,配料完成");
  494. }
  495. }
  496. if (GVL_SmallStation.GetInstance.DosingTray1)
  497. {
  498. for (int i = 1; i < 16; i++)
  499. {
  500. if (RTrig.GetInstance("GetDeviceRunStatus").Start(DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3))
  501. {
  502. MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘1,配方:{recipeName},{i}号仓,配料完成");
  503. int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
  504. RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.CutWeightFeedback;
  505. DeviceInquire.GetInstance.GetDevice(i).StatusReset();
  506. if (i >= 1 && i <= 8)
  507. {
  508. HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true);
  509. }
  510. else if (i >= 9 && i <= 15)
  511. {
  512. HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true);
  513. }
  514. GVL_SmallStation.GetInstance.DosingTray1 = false;
  515. }
  516. }
  517. }
  518. if (RTrig.GetInstance("配方配料完成").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.1")) && (GVL_SmallStation.GetInstance.WindSendDosingFinish || !GVL_SmallStation.GetInstance.IsUseWindSend))
  519. {
  520. var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code);
  521. MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成");
  522. App.Current.Dispatcher.Invoke(() =>
  523. {
  524. Json<RemoteRecipeDataColl>.Data.Recipes.Remove(res);
  525. });
  526. RecipeQueue.TryDequeue(out code);
  527. HKDevice.HK_PLC_S7.Write("DB3.DBX1.1", false);
  528. GVL_SmallStation.GetInstance.RecipeStatusID = 0;
  529. }
  530. }
  531. }
  532. }
  533. }
  534. private int RunInit()
  535. {
  536. if (HKDevice.IsConnected)
  537. {
  538. try
  539. {
  540. HKPlcCommWrite signReset = new HKPlcCommWrite();
  541. HKDevice.HK_PLC_S7.WriteClass<HKPlcCommWrite>(signReset, 2);
  542. return 1;
  543. }
  544. catch (Exception ex)
  545. {
  546. return 2;
  547. }
  548. }else
  549. {
  550. return 2;
  551. }
  552. }
  553. }
  554. }