From 3b5b98a9911e3231cefe5ab4f47a4c9d94e5a2f7 Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期二, 28 十一月 2023 16:15:01 +0800 Subject: [PATCH] #将错误码存入备注字段进行展示 --- src/main/java/com/zy/core/thread/SiemensDevpThread.java | 159 +++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 131 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java index 82f75cd..30e8f67 100644 --- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java +++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java @@ -73,7 +73,7 @@ /** * 鏉$爜鏁伴噺 */ - private int barcodeSize = 3; + private int barcodeSize = 7; /** * 鍏ュ嚭搴撴ā寮� @@ -232,38 +232,141 @@ } } -// //鏉$爜 -// Thread.sleep(200); -// OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB100.160",(short)4); -// 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); -// } -// } -// -// } - //RGV鍙拌溅浣嶇疆 - Thread.sleep(200); - OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB100.0",(short)4); - if (result3.IsSuccess) { - for (int i = 0; i < 2; i++) { - Integer siteId = i==0 ? 112 : 212; // 绔欑偣缂栧彿 - StaProtocol staProtocol = station.get(siteId); - if (null == staProtocol) { - staProtocol = new StaProtocol(); - staProtocol.setSiteId(siteId); - station.put(siteId, staProtocol); + if (slave.getId() == 1){ + //鏉$爜 + Thread.sleep(200); + OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.102",(short)60); + if (result2.IsSuccess) { + for (int i = 0; i < 6; 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); + } } - staProtocol.setNearbySta(String.valueOf(siemensS7Net.getByteTransform().TransInt16(result3.Content, i*2))); -// String aa = staProtocol.getNearbySta(); -// System.out.println(siteId + "===>>" + staProtocol.getNearbySta()); + } + + // 澶栧舰妫�娴� - 102 + Thread.sleep(100); + OperateResultExOne<byte[]> result4 = siemensS7Net.Read("DB101.150", (short)1); + if (result4.IsSuccess) { + boolean[] status = siemensS7Net.getByteTransform().TransBool(result4.Content, 0, 1); + StaProtocol staProtocol = station.get(103); + staProtocol.setFrontErr(status[0]); + staProtocol.setBackErr(status[1]); + staProtocol.setHighErr(status[2]); + staProtocol.setLeftErr(status[3]); + staProtocol.setRightErr(status[4]); + staProtocol.setWeightErr(status[5]); + staProtocol.setBarcodeErr(status[6]); + } + // 澶栧舰妫�娴� - 107 + Thread.sleep(50); + OperateResultExOne<byte[]> result5 = siemensS7Net.Read("DB101.154", (short)1); + if (result5.IsSuccess) { + boolean[] status = siemensS7Net.getByteTransform().TransBool(result5.Content, 0, 1); + StaProtocol staProtocol = station.get(107); + staProtocol.setFrontErr(status[0]); + staProtocol.setBackErr(status[1]); + staProtocol.setHighErr(status[2]); + staProtocol.setLeftErr(status[3]); + staProtocol.setRightErr(status[4]); + staProtocol.setWeightErr(status[5]); + staProtocol.setBarcodeErr(status[6]); + } + // 澶栧舰妫�娴� - 111 + Thread.sleep(50); + OperateResultExOne<byte[]> result6 = siemensS7Net.Read("DB101.158", (short)1); + if (result6.IsSuccess) { + boolean[] status = siemensS7Net.getByteTransform().TransBool(result6.Content, 0, 1); + StaProtocol staProtocol = station.get(111); + staProtocol.setFrontErr(status[0]); + staProtocol.setBackErr(status[1]); + staProtocol.setHighErr(status[2]); + staProtocol.setLeftErr(status[3]); + staProtocol.setRightErr(status[4]); + staProtocol.setWeightErr(status[5]); + staProtocol.setBarcodeErr(status[6]); + } + // 澶栧舰妫�娴� - 115 + Thread.sleep(50); + OperateResultExOne<byte[]> result7 = siemensS7Net.Read("DB101.162", (short)1); + if (result7.IsSuccess) { + boolean[] status = siemensS7Net.getByteTransform().TransBool(result7.Content, 0, 1); + StaProtocol staProtocol = station.get(115); + staProtocol.setFrontErr(status[0]); + staProtocol.setBackErr(status[1]); + staProtocol.setHighErr(status[2]); + staProtocol.setLeftErr(status[3]); + staProtocol.setRightErr(status[4]); + staProtocol.setWeightErr(status[5]); + staProtocol.setBarcodeErr(status[6]); + } + // 澶栧舰妫�娴� - 119 + Thread.sleep(50); + OperateResultExOne<byte[]> result8 = siemensS7Net.Read("DB101.166", (short)1); + if (result8.IsSuccess) { + boolean[] status = siemensS7Net.getByteTransform().TransBool(result8.Content, 0, 1); + StaProtocol staProtocol = station.get(119); + staProtocol.setFrontErr(status[0]); + staProtocol.setBackErr(status[1]); + staProtocol.setHighErr(status[2]); + staProtocol.setLeftErr(status[3]); + staProtocol.setRightErr(status[4]); + staProtocol.setWeightErr(status[5]); + staProtocol.setBarcodeErr(status[6]); + } + // 澶栧舰妫�娴� - 123 + Thread.sleep(50); + OperateResultExOne<byte[]> result9 = siemensS7Net.Read("DB101.170", (short)1); + if (result9.IsSuccess) { + boolean[] status = siemensS7Net.getByteTransform().TransBool(result9.Content, 0, 1); + StaProtocol staProtocol = station.get(123); + staProtocol.setFrontErr(status[0]); + staProtocol.setBackErr(status[1]); + staProtocol.setHighErr(status[2]); + staProtocol.setLeftErr(status[3]); + staProtocol.setRightErr(status[4]); + staProtocol.setWeightErr(status[5]); + staProtocol.setBarcodeErr(status[6]); + } + } else if (slave.getId() == 3) { + // 澶栧舰妫�娴� - 111 + Thread.sleep(50); + OperateResultExOne<byte[]> result10 = siemensS7Net.Read("DB101.26", (short)1); + if (result10.IsSuccess) { + boolean[] status = siemensS7Net.getByteTransform().TransBool(result10.Content, 0, 1); + StaProtocol staProtocol = station.get(301); + staProtocol.setFrontErr(status[0]); + staProtocol.setBackErr(status[1]); + staProtocol.setHighErr(status[2]); + staProtocol.setLeftErr(status[3]); + staProtocol.setRightErr(status[4]); + staProtocol.setWeightErr(status[5]); + staProtocol.setBarcodeErr(status[6]); } } + +// //RGV鍙拌溅浣嶇疆 +// Thread.sleep(200); +// OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB100.0",(short)4); +// if (result3.IsSuccess) { +// for (int i = 0; i < 2; i++) { +// Integer siteId = i==0 ? 1 : 2; // 绔欑偣缂栧彿 +// StaProtocol staProtocol = station.get(siteId); +// if (null == staProtocol) { +// staProtocol = new StaProtocol(); +// staProtocol.setSiteId(siteId); +// station.put(siteId, staProtocol); +// } +// staProtocol.setNearbySta(String.valueOf(siemensS7Net.getByteTransform().TransInt16(result3.Content, i*2))); +//// String aa = staProtocol.getNearbySta(); +//// System.out.println(siteId + "===>>" + staProtocol.getNearbySta()); +// } +// } + // OperateResultExOne<Short> result2 = siemensS7Net.ReadInt16("DB200.0"); // if (result2.IsSuccess) { // this.ioMode = IoModeType.get(result2.Content); -- Gitblit v1.9.1