From f5646b75344aff023817472a5a13f75dbfe05c28 Mon Sep 17 00:00:00 2001 From: tqs <56479841@qq.com> Date: 星期五, 10 二月 2023 11:00:31 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/thread/SiemensDevpThread.java | 97 ++++++++++++++---------------------------------- 1 files changed, 29 insertions(+), 68 deletions(-) diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java index 3e6a271..8f384df 100644 --- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java +++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java @@ -181,79 +181,40 @@ // } Thread.sleep(200); OperateResultExOne<byte[]> result1 = null; - if (slave.getId() == 1) { - result1 = siemensS7Net.Read("DB102.100", (short) (staNoSize * 2)); - if (result1.IsSuccess) { - for (int i = 0; i < staNoSize; i++) { - Integer siteId = staNos.get(i); // 绔欑偣缂栧彿 - boolean[] status = siemensS7Net.getByteTransform().TransBool(result1.Content, i*2, 1); - StaProtocol staProtocol = station.get(siteId); - staProtocol.setAutoing(status[0]); // 鑷姩 - staProtocol.setLoading(status[1]); // 鏈夌墿 - staProtocol.setInEnable(status[2]); // 鍙叆 - staProtocol.setOutEnable(status[3]);// 鍙嚭 - staProtocol.setEmptyMk(status[4]); // 绌烘澘淇″彿 - staProtocol.setFullPlt(status[5]); // 婊℃墭鐩� - staProtocol.setHigh(status[6]); // 楂樺簱浣� - staProtocol.setLow(status[7]); // 浣庡簱浣� + result1 = siemensS7Net.Read("DB102.100", (short) (staNoSize * 2)); + if (result1.IsSuccess) { + for (int i = 0; i < staNoSize; i++) { + Integer siteId = staNos.get(i); // 绔欑偣缂栧彿 + boolean[] status = siemensS7Net.getByteTransform().TransBool(result1.Content, i*2, 1); + StaProtocol staProtocol = station.get(siteId); + staProtocol.setAutoing(status[0]); // 鑷姩 + staProtocol.setLoading(status[1]); // 鏈夌墿 + staProtocol.setInEnable(status[2]); // 鍙叆 + staProtocol.setOutEnable(status[3]);// 鍙嚭 + staProtocol.setEmptyMk(status[4]); // 绌烘澘淇″彿 + staProtocol.setFullPlt(status[5]); // 婊℃墭鐩� + staProtocol.setHigh(status[6]); // 楂樺簱浣� + staProtocol.setLow(status[7]); // 浣庡簱浣� - if (!staProtocol.isPakMk() && !staProtocol.isLoading()) { - staProtocol.setPakMk(true); - } - } - } - } else if (slave.getId() == 2) { - result1 = siemensS7Net.Read("DB102.100", (short) (staNoSize * 2)); - if (result1.IsSuccess) { - for (int i = 0; i < staNoSize; i++) { - Integer siteId = staNos.get(i); // 绔欑偣缂栧彿 - boolean[] status = siemensS7Net.getByteTransform().TransBool(result1.Content, i*2, 1); - StaProtocol staProtocol = station.get(siteId); - staProtocol.setAutoing(status[0]); // 鑷姩 - staProtocol.setLoading(status[1]); // 鏈夌墿 - staProtocol.setInEnable(status[2]); // 鍙叆 - staProtocol.setOutEnable(status[3]);// 鍙嚭 - staProtocol.setEmptyMk(status[4]); // 绌烘澘淇″彿 - staProtocol.setFullPlt(status[5]); // 婊℃墭鐩� - staProtocol.setHigh(status[6]); // 楂樺簱浣� - staProtocol.setLow(status[7]); // 浣庡簱浣� - - if (!staProtocol.isPakMk() && !staProtocol.isLoading()) { - staProtocol.setPakMk(true); - } + if (!staProtocol.isPakMk() && !staProtocol.isLoading()) { + staProtocol.setPakMk(true); } } } - //鏉$爜鎵弿鍣� - Thread.sleep(200); - OperateResultExOne<byte[]> result2 = null; - if (slave.getId() == 1) { - result2 = siemensS7Net.Read("DB100.200",(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"); - BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i + 1); - if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { - barcodeThread.setBarcode(barcode); - } - } - - } - } else if (slave.getId() == 2) { - result2 = siemensS7Net.Read("DB100.200",(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"); - BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i + 3); - if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { - barcodeThread.setBarcode(barcode); - } - } - - } - } + //Thread.sleep(200); + //OperateResultExOne<byte[]> result2 = null; + //result2 = siemensS7Net.Read("DB100.200",(short)(barcodeSize*16)); + //if (result2.IsSuccess) { + // for (int i = 0; i < barcodeSize; i++) { + // String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*16,8, "UTF-8"); + // BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, slave.getId() == 1 ? i + 1 : i + 3); + // if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { + // barcodeThread.setBarcode(barcode); + // } + // } + //} // //RGV灏忚溅 // Thread.sleep(200); @@ -314,7 +275,7 @@ // OperateResult write = siemensS7Net.Write("DB100." + index*4, array); OperateResult write = siemensS7Net.Write("DB100." + index*2, staProtocol.getWorkNo()); // 宸ヤ綔鍙� - Thread.sleep(500); + Thread.sleep(300); OperateResult write1 = siemensS7Net.Write("DB101." + index*2, staProtocol.getStaNo()); // 鐩爣绔� if (!write.IsSuccess) { -- Gitblit v1.9.1