From f7c06595e0fdbed9e65d6362cc26f05c9da27eb4 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期二, 08 九月 2020 16:31:53 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/thread/DevpThread.java | 23 +++++++++++++++++++---- 1 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/zy/core/thread/DevpThread.java b/src/main/java/com/zy/core/thread/DevpThread.java index 6fcc130..e7670f0 100644 --- a/src/main/java/com/zy/core/thread/DevpThread.java +++ b/src/main/java/com/zy/core/thread/DevpThread.java @@ -128,9 +128,14 @@ staProtocol.setInEnable(result1.Content[(i-1)*8+2]); // 鍙叆 staProtocol.setOutEnable(result1.Content[(i-1)*8+3]);// 鍙嚭 staProtocol.setEmptyMk(result1.Content[(i-1)*8+4]); // 绌烘澘淇″彿 + + if (!staProtocol.isPakMk() && !staProtocol.isLoading()) { + staProtocol.setPakMk(true); + } } } if (result.IsSuccess && result1.IsSuccess) { + OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆慬id:{1}] <<<<< 瀹炴椂鏁版嵁鏇存柊鎴愬姛",DateUtils.convert(new Date()), slave.getId())); // 鏍规嵁瀹炴椂淇℃伅鏇存柊鏁版嵁搴� @@ -151,7 +156,7 @@ } else { OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戣鍙栬緭閫佺嚎plc鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort())); - log.error("璇诲彇鍫嗗灈鏈簆lc鐘舵�佷俊鎭け璐� ===>> [id:{}] [ip:{}] [port:{}] ", slave.getId(), slave.getIp(), slave.getPort()); + log.error("璇诲彇杈撻�佺嚎plc鐘舵�佷俊鎭け璐� ===>> [id:{}] [ip:{}] [port:{}] ", slave.getId(), slave.getIp(), slave.getPort()); } } @@ -173,10 +178,14 @@ // status[4] = staProtocol.isEmptyMk(); // OperateResult write2 = siemensS7Net.Write("DB100." + ((staProtocol.getSiteId() - 1) + 40), status); // 鐘舵�� if (!write.IsSuccess || !write1.IsSuccess) { + if (staProtocol.getWorkNo() == 0 && staProtocol.getStaNo() ==0) { + staProtocol.setPakMk(true); + } OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎绔欑偣鏁版嵁澶辫触銆傝緭閫佺嚎plc缂栧彿={1}锛岀珯鐐规暟鎹�={2}", slave.getId(), JSON.toJSON(staProtocol))); log.error("鍐欏叆杈撻�佺嚎绔欑偣鏁版嵁澶辫触銆傝緭閫佺嚎plc缂栧彿={}锛岀珯鐐规暟鎹�={}", slave.getId(), JSON.toJSON(staProtocol)); } else { - OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆慬id:{1}] >>>>> 鍛戒护涓嬪彂锛� {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(staProtocol))); + 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)); } } @@ -238,7 +247,13 @@ slave.setPort(6000); DevpThread devpThread = new DevpThread(slave); devpThread.connect(); - devpThread.read(); + OperateResult d1021 = devpThread.melsecMcNet.Write("D102", (short) 234); + if (d1021.IsSuccess) { + System.out.println("success"); + } + OperateResultExOne<Short> d102 = devpThread.melsecMcNet.ReadInt16("D102"); + System.out.println(d102.Content); +// devpThread.read(); System.out.println("绗竴娆¤"); // 鍐� // StaProtocol staProtocol = devpThread.getStation().get(1); @@ -251,7 +266,7 @@ // System.out.println("----------------------------------------"); Thread.sleep(400); // 璇� - devpThread.read(); +// devpThread.read(); System.out.println("绗簩娆¤"); System.out.println(JSON.toJSONString(devpThread.station)); -- Gitblit v1.9.1