From db7317a220d5ad4b22d2ccc580ecd342d76d1c4f Mon Sep 17 00:00:00 2001 From: gengby <858962040@qq.com> Date: Wed, 28 Dec 2022 17:55:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SiemensConveyorDeviceDriver.java | 127 +++++++++++++++++- .../SlitTwoManipulatorDeviceDriver.java | 12 +- 2 files changed, 130 insertions(+), 9 deletions(-) diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/SiemensConveyorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/SiemensConveyorDeviceDriver.java index 2285c66d0..22d829982 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/SiemensConveyorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/siemens_conveyor/SiemensConveyorDeviceDriver.java @@ -17,6 +17,7 @@ import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.RouteableDeviceDriver; import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingRequest; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.dto.Instruction; @@ -30,6 +31,7 @@ import org.nl.acs.route.service.dto.RouteLineDto; import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; import org.nl.modules.system.service.ParamService; +import org.nl.modules.wql.core.bean.WQLObject; import org.nl.modules.wql.util.SpringContextHolder; import org.openscada.opc.lib.da.Server; import org.springframework.beans.factory.annotation.Autowired; @@ -89,10 +91,18 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme Integer heartbeat_tag; private Date instruction_require_time = new Date(); + private Date require_apply_labeling_time = new Date(); + private Date require_apply_strangulation_time = new Date(); + private Date require_empty_in_time = new Date(); + private Date require_empty_out_time = new Date(); private int instruction_require_time_out; //行架机械手申请任务成功标识 boolean requireSucess = false; + boolean requireApplyLabelingSuccess = false; + boolean requireApplyLaStrangulationSuccess = false; + boolean requireEmptyInSuccess = false; + boolean requireEmptyOutSuccess = false; private int instruction_finished_time_out; int branchProtocol = 0; @@ -124,7 +134,29 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme task = this.itemProtocol.getTask(); if (mode != last_mode) { if (mode == 2) { - this.setRequireSucess(false); + logServer.deviceExecuteLog(device_code, "", "", "开始请求标记复位`此时请求标记值为requireSucess:" + requireSucess); + requireSucess = false; + logServer.deviceExecuteLog(device_code, "", "", "请求标记复位成功`此时请求标记值为requireSucess:" + requireSucess); + } + if (mode == 4) { + logServer.deviceExecuteLog(device_code, "", "", "开始请求标记复位`此时请求标记值为requireApplyLabelingSuccess:" + requireApplyLabelingSuccess); + requireApplyLabelingSuccess = false; + logServer.deviceExecuteLog(device_code, "", "", "请求标记复位成功`此时请求标记值为requireApplyLabelingSuccess:" + requireApplyLabelingSuccess); + } + if (mode == 5) { + logServer.deviceExecuteLog(device_code, "", "", "开始请求标记复位`此时请求标记值为requireApplyLaStrangulationSuccess:" + requireApplyLaStrangulationSuccess); + requireApplyLaStrangulationSuccess = false; + logServer.deviceExecuteLog(device_code, "", "", "请求标记复位成功`此时请求标记值为requireApplyLaStrangulationSuccess:" + requireApplyLaStrangulationSuccess); + } + if (mode == 6) { + logServer.deviceExecuteLog(device_code, "", "", "开始请求标记复位`此时请求标记值为requireEmptyInSuccess:" + requireEmptyInSuccess); + requireEmptyInSuccess = false; + logServer.deviceExecuteLog(device_code, "", "", "请求标记复位成功`此时请求标记值为requireEmptyInSuccess:" + requireEmptyInSuccess); + } + if (mode == 7) { + logServer.deviceExecuteLog(device_code, "", "", "开始请求标记复位`此时请求标记值为requireEmptyOutSuccess:" + requireEmptyOutSuccess); + requireEmptyOutSuccess = false; + logServer.deviceExecuteLog(device_code, "", "", "请求标记复位成功`此时请求标记值为requireEmptyOutSuccess:" + requireEmptyOutSuccess); } logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); @@ -233,6 +265,31 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme if (move > 0 && !requireSucess) { instruction_require(); } + break; + case 4: + //申请贴标 + if (move > 0 && !requireApplyLabelingSuccess) { + applyLabeling(); + } + break; + case 5: + //申请困扎 + if (move > 0 && !requireApplyLaStrangulationSuccess) { + applyLaStrangulation(); + } + break; + case 6: + //空托盘满垛入库申请 + if (move > 0 && !requireEmptyInSuccess) { + emptyIn(); + } + break; + case 7: + //空托盘满垛出库申请 + if (move > 0 && !requireEmptyOutSuccess) { + emptyOut(); + } + break; } } @@ -274,7 +331,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme protected void thingToNothing() throws Exception { - this.setRequireSucess(false); + requireSucess = false; } @@ -356,9 +413,9 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme public void setDeviceStatus(JSONObject data) { String requestSucess = data.getString("requireSucess"); if (StrUtil.equals(requestSucess, "0")) { - this.setRequireSucess(false); + this.requireSucess = false; } else { - this.setRequireSucess(true); + this.requireSucess = true; } } @@ -475,4 +532,66 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme } } + public synchronized void applyLabeling() { + Date date = new Date(); + if (date.getTime() - this.require_apply_labeling_time.getTime() < (long) this.instruction_require_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); + return; + } else { + this.require_apply_labeling_time = date; + ApplyLabelingAndBindingRequest applyLabelingAndBindingRequest = + new ApplyLabelingAndBindingRequest(); + JSONObject device_json = WQLObject.getWQLObject("acs_storage_cell").query("storage_code ='" + this.device_code + "'").uniqueResult(0); + String start_point_code = null; + if (!ObjectUtil.isEmpty(device_json)) { + start_point_code = (String) device_json.get("parent_storage_code") == null ? this.device_code : (String) device_json.get("parent_storage_code"); + } + applyLabelingAndBindingRequest.setDevice_code(start_point_code); + applyLabelingAndBindingRequest.setType("1"); + acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest); + requireApplyLabelingSuccess = true; + } + } + + public synchronized void applyLaStrangulation() { + Date date = new Date(); + if (date.getTime() - this.require_apply_strangulation_time.getTime() < (long) this.instruction_require_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); + return; + } else { + this.require_apply_strangulation_time = date; + ApplyLabelingAndBindingRequest applyLabelingAndBindingRequest = + new ApplyLabelingAndBindingRequest(); + JSONObject device_json = WQLObject.getWQLObject("acs_storage_cell").query("storage_code ='" + this.device_code + "'").uniqueResult(0); + String start_point_code = null; + if (!ObjectUtil.isEmpty(device_json)) { + start_point_code = (String) device_json.get("parent_storage_code") == null ? this.device_code : (String) device_json.get("parent_storage_code"); + } + applyLabelingAndBindingRequest.setDevice_code(start_point_code); + applyLabelingAndBindingRequest.setType("2"); + acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest); + requireApplyLaStrangulationSuccess = true; + } + } + + public synchronized void emptyIn() { + Date date = new Date(); + if (date.getTime() - this.require_empty_in_time.getTime() < (long) this.instruction_require_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); + return; + } else { + this.require_empty_in_time = date; + } + } + + public synchronized void emptyOut() { + Date date = new Date(); + if (date.getTime() - this.require_empty_out_time.getTime() < (long) this.instruction_require_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); + return; + } else { + this.require_empty_out_time = date; + } + } + } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java index c26f2a786..a5e36819a 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java @@ -157,9 +157,11 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl task2 = this.itemProtocol.getTask2(); if (mode != last_mode) { - //if (mode == 2) { - this.setRequireSucess(false); - //} + if (mode == 2) { + logServer.deviceExecuteLog(device_code, "", "", "开始请求标记复位`此时请求标记值为:" + requireSucess); + requireSucess = false; + logServer.deviceExecuteLog(device_code, "", "", "请求标记复位成功`此时请求标记值为:" + requireSucess); + } logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); } @@ -840,7 +842,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl this.sendSignalType(instructionDto, type); //请求任务成功 - this.setRequireSucess(true); + requireSucess = true; return flag; } @@ -949,7 +951,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl this.sendSignalType(instdto, type); //请求任务成功 - this.setRequireSucess(true); + requireSucess = true; return flag; }