From ab18ecb1c25613535c2047467cf8c14d3b41b047 Mon Sep 17 00:00:00 2001 From: zjj <3272660260@qq.com> Date: 星期二, 07 五月 2024 15:46:58 +0800 Subject: [PATCH] #空桶入库完成 --- src/main/java/com/zy/core/thread/SiemensDevpThread.java | 81 +++++++++++++++++++++++++++++++++++----- 1 files changed, 71 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java index c360820..70a9ffa 100644 --- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java +++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java @@ -59,9 +59,7 @@ }}; public static final ArrayList<Integer> staNos3 = new ArrayList<Integer>() {{ - add(2007);add(2008);add(2009);add(2010);add(2011);add(2012);add(2013); - add(2108);add(2109);add(2110);add(2111);add(2112);add(2113);add(2114); - add(2401);add(2402);add(2403); + add(5001);add(5002); }}; public static final ArrayList<Integer> staNos4 = new ArrayList<Integer>() {{ @@ -88,15 +86,13 @@ }}; public static final ArrayList<Integer> writeStaNos2 = new ArrayList<Integer>() {{ - add(2001);add(2002);add(2003); - add(2101);add(2102);add(2103); - add(2301); + add(2001);add(2002);add(2101);add(2102);add(2301);add(2302); + add(2303);add(2304);add(2305);add(2306);add(2003);add(2004);add(2005); + add(2006);add(2103);add(2104);add(2105);add(2106);add(2107); }}; public static final ArrayList<Integer> writeStaNos3 = new ArrayList<Integer>() {{ - add(2013); - add(2114); - add(2401);add(2402); + add(5001);add(5002); }}; public static final ArrayList<Integer> writeStaNos4 = new ArrayList<Integer>() {{ @@ -209,7 +205,12 @@ switch (step) { // 璇绘暟鎹� case 1: - read(); + if (slave.getId() ==3){ + read30(); + }else { + read(); + } + break; // 鍐欐暟鎹� ID+鐩爣绔� case 2: @@ -356,6 +357,66 @@ } } + private void read30() 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()*4)); + 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 count = siemensS7Net.getByteTransform().TransInt16(result.Content, i * 4 + 2); + + 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.setOutEnable(status[3]);// 鍙嚭 + staProtocol.setForce(status[4]); + staProtocol.setAmount(count); + + + 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