From a4ce1862c60445b34a1d9dd804fd8339c3a8d3c2 Mon Sep 17 00:00:00 2001 From: "USER-20220102CG\\noblelift" <546428999@qq.com> Date: Mon, 15 Aug 2022 16:59:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=8F=8C=E5=B7=A5rgv?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lnsh/lnsh_rgv/LnshRGVDeviceDriver.java | 277 +++++++++++++++++- .../views/acs/device/driver/lnsh/lnsh_rgv.vue | 61 +++- 2 files changed, 323 insertions(+), 15 deletions(-) diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/LnshRGVDeviceDriver.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/LnshRGVDeviceDriver.java index e01bbbf..a981efb 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/LnshRGVDeviceDriver.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/LnshRGVDeviceDriver.java @@ -2,6 +2,7 @@ package org.nl.acs.device_driver.lnsh.lnsh_rgv; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; import lombok.Data; @@ -17,6 +18,8 @@ import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.dto.Instruction; import org.nl.acs.log.service.LogServer; import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceAppService; +import org.nl.acs.opc.DeviceAppServiceImpl; import org.nl.acs.opc.WcsConfig; import org.nl.acs.route.service.RouteLineService; import org.nl.acs.route.service.dto.RouteLineDto; @@ -29,10 +32,7 @@ import org.nl.wql.core.bean.WQLObject; import org.openscada.opc.lib.da.Server; import org.springframework.beans.factory.annotation.Autowired; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 嘉耐双工位RGV @@ -52,13 +52,23 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); @Autowired LogServer logServer = SpringContextHolder.getBean("logServerImpl"); + @Autowired + DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + + //当前指令1 + Instruction inst1 = null; + //当前指令2 + Instruction inst2 = null; + int mode = 0; int error = 0; int last_mode = 0; int last_error = 0; Boolean isonline = true; - Boolean requireSucess = false; + Boolean requireSucess1 = false; + Boolean requireSucess2 = false; + int hasGoods = 0; String message = null; Boolean iserror = false; @@ -113,6 +123,11 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi String specifications = ""; String last_specifications = ""; + private Date instruction_require_time = new Date(); + private Date instruction_finished_time = new Date(); + private Date instruction_apply_time = new Date(); + private int instruction_require_time_out = 3000; + @Override public Device getDevice() { return this.device; @@ -120,7 +135,7 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi @Override - public void execute() { + public void execute() throws Exception { String message = null; try { device_code = this.getDeviceCode(); @@ -145,7 +160,6 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi qty = this.itemProtocol.getQty(); if (mode != last_mode) { - this.setRequireSucess(false); logServer.deviceLog(this.device_code,"mode" ,String.valueOf(mode)); logServer.deviceLogToacs(this.device_code,"","","信号mode:" + last_mode + "->" + mode); } @@ -158,10 +172,16 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi logServer.deviceLogToacs(this.device_code,"","","信号status:" + last_status + "->" + status); } if (move_1 != last_move_1) { + if(move_1 == 0){ + this.setRequireSucess1(false); + } logServer.deviceLog(this.device_code,"move_1" ,String.valueOf(move_1)); logServer.deviceLogToacs(this.device_code,"","","信号move_1:" + last_move_1 + "->" + move_1); } if (move_2 != last_move_2) { + if(move_2 == 0){ + this.setRequireSucess2(false); + } logServer.deviceLog(this.device_code,"move_2" ,String.valueOf(move_2)); logServer.deviceLogToacs(this.device_code,"","","信号move_2:" + last_move_2 + "->" + move_2); } @@ -222,6 +242,58 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi logServer.deviceLogToacs(this.device_code,"","","信号specifications:" + last_specifications + "->" + specifications); } + + if (task1 > 0) { + //inst_message + inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); + if (inst1 != null) { + if (StrUtil.equals(inst1.getInstruction_status(), "0")) { + inst1.setInstruction_status("1"); + instructionService.update(inst1); + } + } + } + if ( action_1 == 4 && move_1 == 0 && task1 > 0) { + //inst_message + inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); + if (inst1 != null) { + if (StrUtil.equals(inst1.getInstruction_status(), "1")) { + finish_instruction(inst1); + } + } + } + + if (task2 > 0) { + //inst_message + inst2 = instructionService.findByCodeFromCache(String.valueOf(task2)); + if (inst2 != null) { + if (StrUtil.equals(inst2.getInstruction_status(), "0")) { + inst2.setInstruction_status("1"); + instructionService.update(inst2); + } + } + } + if ( action_2 == 4 && move_2 == 0 && task2 > 0) { + //inst_message + inst2 = instructionService.findByCodeFromCache(String.valueOf(task2)); + if (inst2 != null) { + if (StrUtil.equals(inst2.getInstruction_status(), "1")) { + finish_instruction(inst2); + } + } + } + + //给后工位下发空盘放货信号 + if(mode ==3 && action_1 == 2 && action_2 == 2 && move_1 == 1 && move_2 == 1 && task1>0 && task2>0 ){ + writing("to_command2","2"); + } + + + //给前工位下发放货信号 + if(mode ==3 && action_2 == 4 && move_1 == 1 && move_2 == 0 && task1>0 ){ + writing("to_command1","2"); + } + } catch (Exception var17) { return; } @@ -252,8 +324,16 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi log.debug("设备运转模式:等待工作"); return; case 2: - + //后工位申请任务 + if (mode == 2 && move_2 == 0 && action_2 == 0 && !requireSucess2) { + instruction_require2(); + } break; + case 3: + //前工位申请任务 + if (mode == 3 && move_2 == 1 && action_2 == 1 && move_1 == 0 && !requireSucess1) { + instruction_require(); + } } switch (flag) { @@ -291,6 +371,168 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi } + //申请前工位任务 + public synchronized boolean instruction_require() throws Exception { + Date date = new Date(); + if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); + return false; + } else { + this.instruction_apply_time = date; + String linkobj = (String)this.getDevice().getExtraValue().get("get_device_code1"); + String demosub = linkobj.substring(1,linkobj.length()-1); + String demoArray[] = demosub.split(","); + List device_code_list = Arrays.asList(demoArray); + TaskDto task = null; + for(int i=0;i device_code_list = Arrays.asList(demoArray); + TaskDto task = null; + for(int i=0;i itemMap = new HashMap(); + itemMap.put(to_param, value); + + ReadUtil.write(itemMap, server); + } + public boolean exe_business() { return true; } @@ -317,6 +571,13 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi } + + public synchronized boolean finish_instruction(Instruction inst) throws Exception { + instructionService.finish(inst); + return true; + } + + public void executing(Server server, Map itemMap) { ReadUtil.write(itemMap, server); } diff --git a/acs/qd/src/views/acs/device/driver/lnsh/lnsh_rgv.vue b/acs/qd/src/views/acs/device/driver/lnsh/lnsh_rgv.vue index 6f7f537..653c054 100644 --- a/acs/qd/src/views/acs/device/driver/lnsh/lnsh_rgv.vue +++ b/acs/qd/src/views/acs/device/driver/lnsh/lnsh_rgv.vue @@ -56,9 +56,9 @@ - + @@ -69,9 +69,24 @@ /> - + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + +