From cb15c6400b7dfc3855e5fdd76b8b217bf6bc9567 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <xltys1995> Date: 星期三, 30 十二月 2020 10:55:09 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/thread/MelsecDevpThread.java | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/zy/core/thread/MelsecDevpThread.java b/src/main/java/com/zy/core/thread/MelsecDevpThread.java index 198a4de..1cfa839 100644 --- a/src/main/java/com/zy/core/thread/MelsecDevpThread.java +++ b/src/main/java/com/zy/core/thread/MelsecDevpThread.java @@ -72,7 +72,7 @@ } // 蹇冭烦 - heartbeat(); +// heartbeat(); Thread.sleep(400); } catch (Exception e) { e.printStackTrace(); @@ -116,11 +116,12 @@ staProtocol.setSiteId(siteId); station.put(siteId, staProtocol); } - staProtocol.setWorkNo(melsecMcNet.getByteTransform().TransInt16(result.Content, (i)*2)); // 宸ヤ綔鍙� + short workNo = melsecMcNet.getByteTransform().TransInt16(result.Content, (i) * 2); + staProtocol.setWorkNo(workNo==-1?0:workNo); // 宸ヤ綔鍙� staProtocol.setStaNo(melsecMcNet.getByteTransform().TransInt16(result.Content, (i)*2+40)); // 鐩爣绔� } } - Thread.sleep(500); + Thread.sleep(200); OperateResultExOne<boolean[]> result1 = melsecMcNet.ReadBool("M800", (short) 64); if (result1.IsSuccess) { for (int i = 0; i < staNos.size(); i++) { @@ -180,9 +181,9 @@ return; } System.out.println(); - OperateResult write = melsecMcNet.Write("D1" + Utils.zerofill(String.valueOf(staNos.indexOf(staProtocol.getSiteId())+1), 2), staProtocol.getWorkNo()); // 宸ヤ綔鍙� - Thread.sleep(400); OperateResult write1 = melsecMcNet.Write("D1" + Utils.zerofill(String.valueOf(staNos.indexOf(staProtocol.getSiteId())+21), 2), staProtocol.getStaNo()); // 鐩爣绔� + Thread.sleep(200); + OperateResult write = melsecMcNet.Write("D1" + Utils.zerofill(String.valueOf(staNos.indexOf(staProtocol.getSiteId())+1), 2), staProtocol.getWorkNo()); // 宸ヤ綔鍙� if (!write.IsSuccess || !write1.IsSuccess) { staProtocol = station.get(staProtocol.getSiteId()); if (staProtocol.getWorkNo() == 0 && staProtocol.getStaNo() ==0) { @@ -191,7 +192,6 @@ OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎绔欑偣鏁版嵁澶辫触銆傝緭閫佺嚎plc缂栧彿={1}锛岀珯鐐规暟鎹�={2}", slave.getId(), JSON.toJSON(staProtocol))); log.error("鍐欏叆杈撻�佺嚎绔欑偣鏁版嵁澶辫触銆傝緭閫佺嚎plc缂栧彿={}锛岀珯鐐规暟鎹�={}", slave.getId(), JSON.toJSON(staProtocol)); } else { - log.error("-------------------------------------------绗笁姝ャ�乕绔欑偣鍙凤細{}][宸ヤ綔鍙凤細{}]==>> 涓嬪彂杈撻�佺嚎鍚姩淇″彿鎴愬姛锛侊紒",staProtocol.getSiteId(),staProtocol.getWorkNo()); OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆� 杈撻�佺嚎鍛戒护涓嬪彂 [id:{1}] >>>>> {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(staProtocol))); log.info("杈撻�佺嚎鍛戒护涓嬪彂 [id:{}] >>>>> 鍛戒护涓嬪彂锛� {}", slave.getId(), JSON.toJSON(staProtocol)); } -- Gitblit v1.9.1