From 6dfd04425f11f9c538715a12bb16722a1fbad103 Mon Sep 17 00:00:00 2001 From: cpT <1@123> Date: 星期二, 01 七月 2025 13:53:55 +0800 Subject: [PATCH] #改造 --- src/main/java/com/zy/core/thread/SiemensDevpThread.java | 39 ++++++++++++++++++++++++++++----------- 1 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java index 890e381..1975c34 100644 --- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java +++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java @@ -340,8 +340,10 @@ BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i + 1); if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { barcodeThread.setBarcode(barcode); - if (!barcode.equals("000000")){ + if (!Cools.isEmpty(barcode) && !barcode.equals("000000")){ staProtocol.setBarcodeNow(barcode); + } else if (Cools.isEmpty(barcode)){ + staProtocol.setBarcodeNow("-"); } } @@ -352,7 +354,6 @@ // Thread.sleep(50); OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB400.148.0",(short) (staW.length*4)); - OperateResultExOne<byte[]> resultErr = siemensS7Net.Read("DB101.922.0",(short) (staW.length*4)); if (result3.IsSuccess) { for (int i = 0; i < staW.length; i++) { Integer siteId = staW[i]; // 绔欑偣缂栧彿 @@ -370,18 +371,34 @@ staProtocol.setRightErr(status[4]); // 鍙宠秴闄� staProtocol.setWeightErr(status[5]); // 瓒呴噸 staProtocol.setBarcodeErr(status[6]); // 鎵爜澶辫触 - if (resultErr.IsSuccess){ - boolean[] statusErr = siemensS7Net.getByteTransform().TransBool(resultErr.Content, i*4 + 2, 2); + } + } + + try{ + OperateResultExOne<byte[]> resultErr = siemensS7Net.Read("DB101.922.0",(short) (staNoSize*4)); + if (resultErr.IsSuccess){ + for (int i = 0; i < staNoSize; i++) { + Integer siteId = staNos.get(i); // 绔欑偣缂栧彿 + StaProtocol staProtocol = station.get(siteId); + if (null == staProtocol) { + staProtocol = new StaProtocol(); + staProtocol.setSiteId(siteId); + station.put(siteId, staProtocol); + } + staProtocol.setSiteId(siteId); + boolean[] statusErr = siemensS7Net.getByteTransform().TransBool(resultErr.Content, i*4, 1); staProtocol.setErrOther1(statusErr[0]); // 鐢佃矾淇濇姢鍣ㄦ柇寮� - staProtocol.setErrOther1(statusErr[1]); // 鍏夌數寮傚父 - staProtocol.setErrOther1(statusErr[2]); // 杩愯瓒呮椂 - staProtocol.setErrOther1(statusErr[3]); // 鍗犱綅瓒呮椂 - staProtocol.setErrOther1(statusErr[4]); // 鏈変换鍔℃棤璐ф晠闅� - staProtocol.setErrOther1(statusErr[5]); // 鍙橀鍣ㄦ晠闅� - staProtocol.setErrOther1(statusErr[6]); // 鎺ヨЕ鍣ㄦ晠闅� - staProtocol.setErrOther1(statusErr[7]); // 椤跺崌鐢垫満鎺ヨЕ鍣ㄦ晠闅� + staProtocol.setErrOther2(statusErr[1]); // 鍏夌數寮傚父 + staProtocol.setErrOther3(statusErr[2]); // 杩愯瓒呮椂 + staProtocol.setErrOther4(statusErr[3]); // 鍗犱綅瓒呮椂 + staProtocol.setErrOther5(statusErr[4]); // 鏈変换鍔℃棤璐ф晠闅� + staProtocol.setErrOther6(statusErr[5]); // 鍙橀鍣ㄦ晠闅� + staProtocol.setErrOther7(statusErr[6]); // 鎺ヨЕ鍣ㄦ晠闅� + staProtocol.setErrOther8(statusErr[7]); // 椤跺崌鐢垫満鎺ヨЕ鍣ㄦ晠闅� } } + } catch (Exception e){ + } if (result.IsSuccess) { -- Gitblit v1.9.1