From 880794f63e27b64ae03c40afc55a34928d090d57 Mon Sep 17 00:00:00 2001 From: 野心家 <1051256694@qq.com> Date: 星期三, 28 五月 2025 10:08:18 +0800 Subject: [PATCH] #ZH --- src/main/java/com/zy/core/thread/SiemensDevpThread.java | 42 ++++++++++++++++++++++++++++++++++++++---- 1 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java index 7a88f83..11ccf15 100644 --- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java +++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java @@ -213,14 +213,37 @@ //鏉$爜 Thread.sleep(200); - OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.840.0",(short) (barcodeSize*8)); + OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB400.100.0",(short) (barcodeSize*8)); if (result2.IsSuccess) { for (int i = 0; i < barcodeSize; i++) { - String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*8,8, "UTF-8"); + String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*8,6, "UTF-8"); BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i + 1); if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { barcodeThread.setBarcode(barcode); } + } + } + + //鏉$爜 + Thread.sleep(200); + int[] staW = new int[]{1004,1014,1020}; + + OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB400.148.0",(short) (staW.length*4)); + if (result3.IsSuccess) { + for (int i = 0; i < staW.length; i++) { + Integer siteId = staW[i]; // 绔欑偣缂栧彿 + StaProtocol staProtocol = station.get(siteId); + if (null == staProtocol) { + staProtocol = new StaProtocol(); + station.put(siteId, staProtocol); + } + staProtocol.setSiteId(siteId); + boolean[] status = siemensS7Net.getByteTransform().TransBool(result3.Content, i*4 + 2, 2); + staProtocol.setFrontErr(status[0]); // 鍓嶈秴闄� + staProtocol.setBackErr(status[1]); // 鍚庤秴闄� + staProtocol.setHighErr(status[2]); // 楂樿秴闄� + staProtocol.setLeftErr(status[3]); // 宸﹁秴闄� + staProtocol.setRightErr(status[4]); // 鍙宠秴闄� } } @@ -241,7 +264,7 @@ throw new Exception("鏇存柊鏁版嵁搴撴暟鎹け璐�"); } } catch (Exception e){ - log.error("e:"+e.getMessage()); +// log.error("e:"+e.getMessage()); } } catch (Exception e) { @@ -254,7 +277,7 @@ DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); deviceErrorService.deleteDeviceError("devp", slave.getId()); } catch (Exception e){ - log.error("e:"+e.getMessage()); +// log.error("e:"+e.getMessage()); } } 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())); @@ -437,6 +460,17 @@ } } + /** + * 璁剧疆鍏ュ簱鏍囪 + */ + @Override + public void setErrorDev(Integer siteId, String msgErr) { + StaProtocol staProtocol = station.get(siteId); + if (null != staProtocol) { + staProtocol.setErrorDev(msgErr); + } + } + @Override public void close() { siemensS7Net.ConnectClose(); -- Gitblit v1.9.1