From 2fc41a25a6acfad60e1ec6fa1234f98efb0b3a82 Mon Sep 17 00:00:00 2001 From: yxFwq <1> Date: 星期六, 10 八月 2024 17:57:54 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/thread/SiemensDevpThread.java | 45 +++++++++++++++++++++++++-------------------- 1 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java index 49bce81..f005729 100644 --- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java +++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java @@ -133,7 +133,7 @@ /** * 鏉$爜鏁伴噺 */ - private int barcodeSize = 9; + private int barcodeSize = 5; /** * 鍏ュ嚭搴撴ā寮� @@ -318,6 +318,7 @@ staProtocol.setEndRow(siemensS7Net.getByteTransform().TransInt16(resultRgv2.Content, 0)); // 灏忚溅鐩爣浣� staProtocol.setNowRow(siemensS7Net.getByteTransform().TransInt16(resultRgv.Content, 2)); // 褰撳墠浣嶇疆 +// staProtocol.setNowRow((short)2); // 褰撳墠浣嶇疆 boolean[] status = siemensS7Net.getByteTransform().TransBool(resultRgv.Content, 4, 1); staProtocol.setRGV1(status[0]); // 灏忚溅鏃犺揣绌洪棽 @@ -353,11 +354,15 @@ Thread.sleep(200); OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.2440",(short)(barcodeSize*8)); if (result2.IsSuccess) { - int[] staNosRgv = {281,292,173,214,120,100,101,102,103}; - - for (int i = 0; i < barcodeSize; i++) { //1:281 2:292 3:174(173) 4:214 5:120 + int[] staNosRgv = new int[]{281,292,173,214,120}; + if (slave.getId()==2){ + staNosRgv = new int[]{453,460,508,534,611}; + } + for (int i = 0; i < barcodeSize; i++) { + //1:281 2:292 3:174(173) 4:214 5:120 + //6:453 7:460 8:508 9:534 10:611 String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*8,8, "UTF-8"); - BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i + 1); + BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, (i + 1+((slave.getId()-1)*5))); if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { Integer siteId = staNosRgv[i]; // 绔欑偣缂栧彿 StaProtocol staProtocol = station.get(siteId); @@ -370,19 +375,19 @@ } } - //RGV灏忚溅 - Thread.sleep(200); - OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB100.160",(short)2); - if (result3.IsSuccess) { - Integer siteId = 2000; - 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, 0))); - } +// //RGV灏忚溅 +// Thread.sleep(200); +// OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB100.160",(short)2); +// if (result3.IsSuccess) { +// Integer siteId = 2000; +// 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, 0))); +// } if (result.IsSuccess) { @@ -477,7 +482,7 @@ //浠诲姟涓嬪彂娆℃暟 int writeCount = 0; do { - write = siemensS7Net.Write("DB100.1872", 1); // 浠诲姟瀹屾垚 + write = siemensS7Net.Write("DB100.1872", (short) 1); // 浠诲姟瀹屾垚 if(write.IsSuccess){ writeCount=6; }else { @@ -517,7 +522,7 @@ //浠诲姟涓嬪彂娆℃暟 int writeCount = 0; do { - write = siemensS7Net.Write("DB100.1872", 0); // 浠诲姟瀹屾垚澶嶄綅 + write = siemensS7Net.Write("DB100.1872", (short) 0); // 浠诲姟瀹屾垚澶嶄綅 if(write.IsSuccess){ writeCount=6; } else { -- Gitblit v1.9.1