From cb2d5d9ac39efdb38d8a301f7396ac1ab171efc1 Mon Sep 17 00:00:00 2001 From: zjj <3272660260@qq.com> Date: 星期四, 09 五月 2024 21:49:11 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/thread/SiemensDevpThread.java | 75 ++++++++++++++++++++++++++++++++++--- 1 files changed, 68 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 70a9ffa..81e9870 100644 --- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java +++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java @@ -63,9 +63,7 @@ }}; public static final ArrayList<Integer> staNos4 = new ArrayList<Integer>() {{ - add(3001);add(3002);add(3003);add(3004);add(3005); - add(3006);add(3007);add(3008);add(3009);add(3010); - add(3011);add(3012); + add(4007); }}; public static final ArrayList<Integer> staNos5 = new ArrayList<Integer>() {{ @@ -205,10 +203,14 @@ switch (step) { // 璇绘暟鎹� case 1: - if (slave.getId() ==3){ - read30(); - }else { - read(); + switch (slave.getId()){ + case 1: + case 2: + read();break; + case 3: + read30();break; + case 4: + read33();break; } break; @@ -417,6 +419,65 @@ } } + private void read33() throws InterruptedException { + ArrayList<Integer> staNos = getStaNo(); + int staNoSize = staNos.size(); + OperateResultExOne<byte[]> result = siemensS7Net.Read("DB101.0", (short) (getStaNo().size() * 8)); + + result = siemensS7Net.Read("DB101.0", (short) (getStaNo().size()*6)); + if (result.IsSuccess) { + for (int i = 0; i < staNoSize; i++) { + Integer siteId = staNos.get(i); // 绔欑偣缂栧彿 + boolean[] status = siemensS7Net.getByteTransform().TransBool(result.Content, i*4, 1); + short tongType = siemensS7Net.getByteTransform().TransInt16(result.Content, i * 4 + 2); + short matnr = siemensS7Net.getByteTransform().TransInt16(result.Content, i * 4 + 4); + StaProtocol staProtocol = station.get(siteId); + if (null == staProtocol) { + staProtocol = new StaProtocol(); + staProtocol.setSiteId(siteId); + station.put(siteId, staProtocol); + } + staProtocol.setAutoing(status[0]); // 鑷姩 + staProtocol.setLoading(status[1]); // 鏈夌墿 + staProtocol.setInEnable(status[2]); // 鍙叆 + staProtocol.setAmount(matnr); + + + + if (!staProtocol.isPakMk() && !staProtocol.isLoading()) { + staProtocol.setPakMk(true); + } + } + } + + if (result.IsSuccess) { + + OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆慬id:{1}] <<<<< 瀹炴椂鏁版嵁鏇存柊鎴愬姛",DateUtils.convert(new Date()), slave.getId())); + + // 鏍规嵁瀹炴椂淇℃伅鏇存柊鏁版嵁搴� + try { + List<BasDevp> basDevps = new ArrayList<>(); + for (Integer siteId : staNos) { + StaProtocol staProtocol = station.get(siteId); + basDevps.add(staProtocol.toSqlModel()); + } + + BasDevpService basDevpService = SpringUtils.getBean(BasDevpService.class); + if (null != basDevpService && !basDevpService.updateBatchById(basDevps)) { + throw new Exception("鏇存柊鏁版嵁搴撴暟鎹け璐�"); + } + } catch (Exception e) { + e.printStackTrace(); + OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戞洿鏂版暟鎹簱鏁版嵁澶辫触 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot())); + log.error("鏇存柊鏁版嵁搴撴暟鎹け璐� ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()); + } + + } else { + OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戣鍙栬緭閫佺嚎plc鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot())); +// log.error("璇诲彇杈撻�佺嚎plc鐘舵�佷俊鎭け璐� ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()); + } + } + /** * 鍐欏叆 ID+鐩爣绔� =====> 鍗曠珯鐐瑰啓鍏� */ -- Gitblit v1.9.1