From f895522bda8f02e42cad121d19c48c45caa676bc Mon Sep 17 00:00:00 2001 From: zjj <3272660260@qq.com> Date: 星期四, 21 三月 2024 12:45:45 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/thread/SiemensDevpThread.java | 47 ++++++++++++++++++++++++++--------------------- 1 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java index 668c8e3..632d9f8 100644 --- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java +++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java @@ -338,25 +338,45 @@ staProtocol.setBarcodeErr(status[6]); } } else if (slave.getId() == 3) { - //鏉$爜 //Thread.sleep(200); OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.18",(short)10); if (result2.IsSuccess) { - String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,0,8, "UTF-8"); BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, 7); if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { barcodeThread.setBarcode(barcode); } + } + 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]); + } + } else if (slave.getId() == 4) { + //鏉$爜 + OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.18",(short)10); + if (result2.IsSuccess) { + String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,0,8, "UTF-8"); + BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, 8); + if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { + barcodeThread.setBarcode(barcode); + } } // 澶栧舰妫�娴� - 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 staProtocol = station.get(401); staProtocol.setFrontErr(status[0]); staProtocol.setBackErr(status[1]); staProtocol.setHighErr(status[2]); @@ -573,20 +593,12 @@ return; } else { OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆� 杈撻�佺嚎鍛戒护涓嬪彂鎴愬姛 [id:{1}] >>>>> {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(staProtocol))); - log.info("杈撻�佺嚎鍛戒护涓嬪彂 [id:{}] >>>>> 鍛戒护涓嬪彂鎴愬姛锛� {}", slave.getId(), JSON.toJSON(staProtocol)); + //log.info("杈撻�佺嚎鍛戒护涓嬪彂 [id:{}] >>>>> 鍛戒护涓嬪彂鎴愬姛锛� {}", slave.getId(), JSON.toJSON(staProtocol)); Integer siteId = staProtocol.getSiteId(); staProtocol = station.get(siteId); if ((siteId == 101 || siteId == 201)&&(staProtocol.getWorkNo() == 0 && staProtocol.getStaNo() ==0)) { staProtocol.setPakMk(true); - } - - //鏇存柊浠诲姟姝ュ簭 - TaskWrkService taskWrkService = SpringUtils.getBean(TaskWrkService.class); - TaskWrk taskWrk = taskWrkService.selectByWrkNo(staProtocol.getWorkNo().intValue()); - if (taskWrk != null) { - taskWrk.setCommandStep(taskWrk.getCommandStep() + 1);//鏇存柊鎸囦护姝ュ簭 - taskWrkService.updateById(taskWrk); } } @@ -657,12 +669,12 @@ log.error("鍐欏叆杈撻�佺嚎鍛戒护灏濊瘯5娆″け璐ャ�傝緭閫佺嚎plc缂栧彿={}锛岀珯鐐规暟鎹�={}", slave.getId(), JSON.toJSON(staProtocol)); //閲嶆柊娣诲姞鏁版嵁鍒颁换鍔¢槦鍒� - boolean result = MessageQueue.offer(SlaveType.Devp, slave.getId(), new Task(2, staProtocol)); + boolean result = MessageQueue.offer(SlaveType.Devp, slave.getId(), new Task(3, staProtocol)); read();//璇诲彇1娆¤澶囩姸鎬� return; } else { OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆� 杈撻�佺嚎鍛戒护涓嬪彂鎴愬姛 [id:{1}] >>>>> {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(staProtocol))); - log.info("杈撻�佺嚎鍛戒护涓嬪彂 [id:{}] >>>>> 鍛戒护涓嬪彂鎴愬姛锛� {}", slave.getId(), JSON.toJSON(staProtocol)); + //log.info("杈撻�佺嚎鍛戒护涓嬪彂 [id:{}] >>>>> 鍛戒护涓嬪彂鎴愬姛锛� {}", slave.getId(), JSON.toJSON(staProtocol)); Integer siteId = staProtocol.getSiteId(); staProtocol = station.get(siteId); @@ -670,13 +682,6 @@ staProtocol.setPakMk(true); } - //鏇存柊浠诲姟姝ュ簭 - TaskWrkService taskWrkService = SpringUtils.getBean(TaskWrkService.class); - TaskWrk taskWrk = taskWrkService.selectByWrkNo(staProtocol.getWorkNo().intValue()); - if (taskWrk != null) { - taskWrk.setCommandStep(taskWrk.getCommandStep() + 1);//鏇存柊鎸囦护姝ュ簭 - taskWrkService.updateById(taskWrk); - } } } -- Gitblit v1.9.1