From a245a921bb6662415bfbbe1d37af933d1c0f7d8e Mon Sep 17 00:00:00 2001 From: gengby <858962040@qq.com> Date: Fri, 22 Jul 2022 13:17:24 +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 --- .../StandardInspectSiteDeviceDriver.java | 60 ++++++++++++------- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java index d845893..2dc22d6 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java @@ -93,6 +93,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp private int instruction_require_time_out; boolean requireSucess = false; boolean inrequireSucess = false; + boolean emptyrequireSucess = false; private int instruction_finished_time_out; @@ -110,6 +111,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp //上次指令 Instruction last_inst = null; + Object object = new Object(); //触摸屏手动触发任务 private Boolean is_has_task = false; @@ -141,7 +143,12 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp hasGoods = this.itemProtocol.getMove(); if (mode != last_mode) { - this.setRequireSucess(false); + if (mode == 5){ + this.setEmptyrequireSucess(false); + } + if (mode == 6){ + this.setInrequireSucess(false); + } this.execute_log.setResource(this.devicecode, this.device.getDevice_name()); this.execute_log.log("设备:" + device_code + ",last_mode -> mode:" + last_mode + "->" + mode); } @@ -226,6 +233,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp message = ""; Instruction instruction = null; List toInstructions; + switch (mode) { case 1: log.debug("设备运转模式:等待工作"); @@ -285,15 +293,15 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp this.instruction_require(container); } - case 5: - if (!requireSucess){ + if (!emptyrequireSucess){ //mode = 5 并且工位上无货时申请空托盘 if (move == 0){ this.execute_log.log("设备:" + devicecode + ",move:" + move); this.apply_empty_require(container); } } + break; case 6: if (!inrequireSucess){ if (move == 1){ @@ -301,6 +309,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp this.apply_in_require(container); } } + break; } switch (flag) { @@ -420,10 +429,10 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp public boolean instruction_require(String container_code) { return instruction_require(container_code, WcsConfig.task_container_type_default_desc); } - public boolean apply_empty_require(String container_code) { + public synchronized boolean apply_empty_require(String container_code) { return apply_empty_require(container_code, WcsConfig.task_container_type_default_desc); } - public boolean apply_in_require(String container_code) { + public synchronized boolean apply_in_require(String container_code) { return apply_in_require(container_code, WcsConfig.task_container_type_default_desc); } @@ -466,12 +475,12 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp if (num != 0) { continue; } - //判断检测站点是否锁定,如果锁定就结束本次循环 + /* //判断检测站点是否锁定,如果锁定就结束本次循环 JSONObject jsonObject = runpointwo.query("device_code = '" + next_device_code + "' and islock = '1'").uniqueResult(0); if (ObjectUtil.isNotEmpty(jsonObject)) { this.execute_log.log("设备:" + devicecode+ "", "", "对应路由设备," + next_device_code + "已锁定"); continue; - } + }*/ //创建任务 TaskDto dto = new TaskDto(); String now = DateUtil.now(); @@ -492,12 +501,12 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp dto.setNext_point_code(next_device_code); try { taskserver.create(dto); - //任务创建成功 锁定终点设备 +/* //任务创建成功 锁定终点设备 JSONObject map = new JSONObject(); - map.put("islock", "1"); + map.put("islock", "true"); map.put("update_by", "auto"); map.put("update_time", DateUtil.now()); - runpointwo.update(map, "device_code = '" + next_device_code + "'"); + runpointwo.update(map, "device_code = '" + next_device_code + "'");*/ flag = true; break; } catch (Exception e) { @@ -508,7 +517,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp //生成任务成功 if (flag) { - requireSucess = false; + inrequireSucess = true; this.execute_log.log("设备:" + devicecode+ "", "", "对应路由设备,生成任务成功已锁定"); } return true; @@ -546,24 +555,31 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp if (route_link_device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver){ standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) route_link_device.getDeviceDriver(); // TODO 判断堆叠位是否有货,没货就结束本次循环 - if (standardEmptyPalletSiteDeviceDriver.getMove() != 1) { - continue; - } //判断堆叠位的数量是否大于0,如果=0就结束本次循环 - if (standardEmptyPalletSiteDeviceDriver.getNumber() == 0){ + if (standardEmptyPalletSiteDeviceDriver.getMove() != 1 || standardEmptyPalletSiteDeviceDriver.getNumber() == 0) { continue; } - //判断是否已经有到该终点设备的任务,如果有就结束循环 + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + //判断是否已经有该起点设备的任务,如果有就结束循环 int num = taskserver.querySameOriginTask(start_device_code); if (num != 0) { continue; } - //判断终点是否锁定,如果被锁定就结束循环 - JSONObject jsonObject = runpointwo.query("device_code = '" + next_device_code + "' and islock = '1'").uniqueResult(0); + //判断是否已经有到该起点设备的任务,如果有就结束循环 + int num1 = taskserver.querySameDestinationTask(next_device_code); + if (num1 != 0) { + continue; + } +/* //判断起点是否锁定,如果被锁定就结束循环 + JSONObject jsonObject = runpointwo.query("device_code = '" + next_device_code + "' and islock = 'true'").uniqueResult(0); if (ObjectUtil.isNotEmpty(jsonObject)) { this.execute_log.log("设备:" + devicecode+ "", "", "对应路由设备," + next_device_code + "已锁定"); continue; - } + }*/ //创建任务 TaskDto dto = new TaskDto(); String now = DateUtil.now(); @@ -586,10 +602,10 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp taskserver.create(dto); //任务创建成功 锁定该终点设备 JSONObject map = new JSONObject(); - map.put("islock", "1"); + map.put("islock", "true"); map.put("update_by", "auto"); map.put("update_time", DateUtil.now()); - runpointwo.update(map, "device_code = '" + next_device_code + "'"); + runpointwo.update(map, "device_code = '" + start_device_code + "'"); flag = true; break; } catch (Exception e) { @@ -600,7 +616,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp //生成任务成功 if (flag) { - requireSucess = false; + emptyrequireSucess = true; this.execute_log.log("设备:" + devicecode+ "", "", "对应路由设备,生成任务成功已锁定"); } return true;