From 72359bb6e10b4a863b5f9faac97bc8d49b85d10c Mon Sep 17 00:00:00 2001 From: whycq <10027870+whycq@user.noreply.gitee.com> Date: 星期六, 27 八月 2022 16:02:39 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/thread/SiemensDevpThread.java | 24 +++++++++++++++++------- 1 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java index 25d9512..bde3131 100644 --- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java +++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java @@ -51,7 +51,17 @@ * 鏉$爜鏁伴噺 */ private int barcodeSize = 3; - public IoModeType ioMode = IoModeType.NONE; + + /** + * 鍏ュ嚭搴撴ā寮� + * 0锛氭湭鐭� + * 1锛氬叆搴撳惎鍔ㄤ腑 + * 2.鍏ュ簱妯″紡 + * 3.鍑哄簱鍚姩涓� 锛堜笉鑳界敓鎴愬叆搴撳伐浣滄。锛� + * 4.鍑哄簱妯″紡 + */ + public IoModeType ioModeOf2F = IoModeType.NONE; +// public IoModeType ioMode = IoModeType.NONE; public SiemensDevpThread(DevpSlave slave) { this.slave = slave; @@ -114,7 +124,7 @@ */ private void read() throws InterruptedException { // // 鏇存柊鍏ュ嚭搴撴ā寮� -// updateIoMode(); + updateIoMode(); int staNoSize = staNos.size(); OperateResultExOne<byte[]> result = siemensS7Net.Read("DB100.0", (short) (staNoSize*4)); if (result.IsSuccess) { @@ -221,7 +231,7 @@ return; } int index = staNos.indexOf(staProtocol.getSiteId()); - short[] array = new short[10]; + short[] array = new short[2]; array[0] = staProtocol.getWorkNo(); array[1] = staProtocol.getStaNo(); OperateResult write = siemensS7Net.Write("DB100." + index*4, array); @@ -245,10 +255,10 @@ // 鏇存柊鍏ュ嚭搴撴ā寮� private void updateIoMode() throws InterruptedException { - if (this.ioMode != IoModeType.NONE) { - if (!siemensS7Net.Write("DB200", this.ioMode.id).IsSuccess) { - OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎1F鍏ュ嚭搴撴ā寮忓け璐ャ�傝緭閫佺嚎plc缂栧彿={1}", slave.getId())); - log.error("鍐欏叆杈撻�佺嚎1F鍏ュ嚭搴撴ā寮忓け璐ャ�傝緭閫佺嚎plc缂栧彿={}", slave.getId()); + if (this.ioModeOf2F != IoModeType.NONE) { + if (!siemensS7Net.Write("DB100.180", this.ioModeOf2F.id).IsSuccess) { + OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎2F鍏ュ嚭搴撴ā寮忓け璐ャ�傝緭閫佺嚎plc缂栧彿={1}", slave.getId())); + log.error("鍐欏叆杈撻�佺嚎2F鍏ュ嚭搴撴ā寮忓け璐ャ�傝緭閫佺嚎plc缂栧彿={}", slave.getId()); } } } -- Gitblit v1.9.1