From c1c1dd685aead50b2e4d3b46ef931a6f7e8b1bf3 Mon Sep 17 00:00:00 2001 From: liuxy Date: Wed, 3 Sep 2025 12:20:13 +0800 Subject: [PATCH] =?UTF-8?q?rev=EF=BC=9A=E5=8A=A0=E5=AE=9A=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LampThreecolorDeviceDriver.java | 140 +++++++++++------- 1 file changed, 84 insertions(+), 56 deletions(-) diff --git a/acs2/nladmin-system/src/main/java/org/nl/acs/device_driver/lamp_three_color/LampThreecolorDeviceDriver.java b/acs2/nladmin-system/src/main/java/org/nl/acs/device_driver/lamp_three_color/LampThreecolorDeviceDriver.java index 2f08103..8168f43 100644 --- a/acs2/nladmin-system/src/main/java/org/nl/acs/device_driver/lamp_three_color/LampThreecolorDeviceDriver.java +++ b/acs2/nladmin-system/src/main/java/org/nl/acs/device_driver/lamp_three_color/LampThreecolorDeviceDriver.java @@ -24,6 +24,7 @@ import org.nl.modules.quartz.task.QueryXGTGroupStatus; import org.nl.modules.wql.util.SpringContextHolder; import java.util.Arrays; +import java.util.Date; import java.util.List; @Slf4j @@ -109,6 +110,9 @@ public class LampThreecolorDeviceDriver extends AbstractOpcDeviceDriver implemen * 车号 */ private String car_no; + private Date instruction_require_time = new Date(); + + private int instruction_require_time_out = 5000; @Override public Device getDevice() { @@ -133,8 +137,16 @@ public class LampThreecolorDeviceDriver extends AbstractOpcDeviceDriver implemen @Override public void executeLogic() { + if (this.error != this.lastError ) { + if (this.error == 1 || this.error == 5) { + this.requireSuccess = false; + } + } + + if (!this.requireSuccess) { + this.executeLogicBefore(); + } - this.executeLogicBefore(); if (!this.online) { this.message = "设备离线"; } else if (this.mode == 0) { @@ -150,74 +162,90 @@ public class LampThreecolorDeviceDriver extends AbstractOpcDeviceDriver implemen } private void executeLogicBefore() { - // 告诉agv急停(车辆) - if (error == 1) { - // 只给agv下发第二个互斥组,例如GS01A2 - String substring = this.currentDeviceCode.substring(this.currentDeviceCode.length() - 1); - if (substring.equals("2")) { - // 根据当前互斥组设备里的状态 - JSONObject param = new JSONObject(); - String[] paramArr = {this.currentDeviceCode}; - param.put("blockGroup", paramArr); + Date date = new Date(); + if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); + } else { + this.instruction_require_time = date; + // 告诉agv急停(车辆) + if (error == 1) { + // 只给agv下发第二个互斥组,例如GS01A2 + String substring = this.currentDeviceCode.substring(this.currentDeviceCode.length() - 1); + if (substring.equals("2")) { + // 根据当前互斥组设备里的状态 + JSONObject param = new JSONObject(); + String[] paramArr = {this.currentDeviceCode}; + param.put("blockGroup", paramArr); - UnifiedResponse> objectUnifiedResponse = SpringContextHolder.getBean(XianGongAgvService.class).blockGroupStatus(param); - List dataList = objectUnifiedResponse.getData(); + UnifiedResponse> objectUnifiedResponse = SpringContextHolder.getBean(XianGongAgvService.class).blockGroupStatus(param); + List dataList = objectUnifiedResponse.getData(); - String[] carArr = {dataList.get(0).getString("id")}; - JSONObject json = new JSONObject(); - json.put("vehicles", carArr); - if (ObjectUtil.isNotEmpty(carArr[0])) { - // 请求下发agv急停 - XianGongAgvServiceImpl xianGongAgv = SpringContextHolder.getBean(XianGongAgvServiceImpl.class); - //创建订单序列 - xianGongAgv.sendOrderStopToXZ(json); + boolean success1 = objectUnifiedResponse.isSuccess(); + if (success1) { + requireSuccess = true; + } + + String[] carArr = {dataList.get(0).getString("id")}; + JSONObject json = new JSONObject(); + json.put("vehicles", carArr); + if (ObjectUtil.isNotEmpty(carArr[0])) { + // 请求下发agv急停 + XianGongAgvServiceImpl xianGongAgv = SpringContextHolder.getBean(XianGongAgvServiceImpl.class); + //创建订单序列 + UnifiedResponse objectUnifiedResponse1 = xianGongAgv.sendOrderStopToXZ(json); + boolean success = objectUnifiedResponse1.isSuccess(); + if (success) { + requireSuccess = true; + } else { + requireSuccess = false; + } + } } } - } - /* // 告诉agv急停(互斥组) - if (error == 1) { - JSONObject json = new JSONObject(); - // 只给agv下发第二个互斥组,例如GS01A2 + // 给光栅下发命令5 + if (error == 5) { + String substring = this.currentDeviceCode.substring(this.currentDeviceCode.length() - 1); + if (substring.equals("2")) { + // 给输送线写5 + String[] key = {"toCommand"}; + Integer[] value = {5}; + writing(Arrays.asList(key),Arrays.asList(value)); - String substring = this.currentDeviceCode.substring(this.currentDeviceCode.length() - 1); - if (substring.equals("2")) { - json.put("block_name", this.currentDeviceCode); + // 根据当前互斥组设备里的状态 + JSONObject param = new JSONObject(); + String[] paramArr = {this.currentDeviceCode}; + param.put("blockGroup", paramArr); - // 请求下发agv急停 - XianGongAgvServiceImpl xianGongAgv = SpringContextHolder.getBean(XianGongAgvServiceImpl.class); - //创建订单序列 - xianGongAgv.sendOrderStopToXZ(json); - } - }*/ + UnifiedResponse> objectUnifiedResponse = SpringContextHolder.getBean(XianGongAgvService.class).blockGroupStatus(param); + List dataList = objectUnifiedResponse.getData(); - // 给光栅下发命令5 - if (error == 5) { - String substring = this.currentDeviceCode.substring(this.currentDeviceCode.length() - 1); - if (substring.equals("2")) { - // 给输送线写5 - String[] key = {"toCommand"}; - Integer[] value = {5}; - writing(Arrays.asList(key),Arrays.asList(value)); + boolean success1 = objectUnifiedResponse.isSuccess(); + if (success1) { + requireSuccess = true; + } - // 根据当前互斥组设备里的状态 - JSONObject param = new JSONObject(); - String[] paramArr = {this.currentDeviceCode}; - param.put("blockGroup", paramArr); + String[] carArr = {dataList.get(0).getString("id")}; + JSONObject json = new JSONObject(); + json.put("vehicles", carArr); - UnifiedResponse> objectUnifiedResponse = SpringContextHolder.getBean(XianGongAgvService.class).blockGroupStatus(param); - List dataList = objectUnifiedResponse.getData(); + // 请求下发agv继续 + XianGongAgvServiceImpl xianGongAgv = SpringContextHolder.getBean(XianGongAgvServiceImpl.class); + //创建订单序列 + UnifiedResponse objectUnifiedResponse1 = xianGongAgv.sendOrderContinueToXZ(json); - String[] carArr = {dataList.get(0).getString("id")}; - JSONObject json = new JSONObject(); - json.put("vehicles", carArr); - - // 请求下发agv继续 - XianGongAgvServiceImpl xianGongAgv = SpringContextHolder.getBean(XianGongAgvServiceImpl.class); - //创建订单序列 - xianGongAgv.sendOrderContinueToXZ(json); + boolean success = objectUnifiedResponse1.isSuccess(); + if (success) { + requireSuccess = true; + } else { + requireSuccess = false; + } + } } } + + + } @Override