From a532e4af87e8e76771a187c6cbaef1a023376052 Mon Sep 17 00:00:00 2001 From: "USER-20220102CG\\noblelift" <546428999@qq.com> Date: Thu, 20 Apr 2023 15:24:14 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E6=B5=8B=E8=AF=95=E5=9C=BA=E5=9C=B0?= =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=92=8Cagv=E4=BA=A4=E4=BA=92=20=E7=8E=B0?= =?UTF-8?q?=E5=9C=BA=E5=AE=9E=E9=99=85=E9=9C=80=E8=A6=81=E8=B0=83=E6=95=B4?= =?UTF-8?q?=20=E4=BB=BB=E5=8A=A1=E9=93=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basedriver/agv/xg_agv/ItemProtocol.java | 3 + .../agv/xg_agv/XgagvDeviceDriver.java | 221 ++++++++++++++---- .../src/views/system/monitor/device/index.vue | 16 +- 3 files changed, 183 insertions(+), 57 deletions(-) diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/xg_agv/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/xg_agv/ItemProtocol.java index ac4ee84..8031e89 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/xg_agv/ItemProtocol.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/xg_agv/ItemProtocol.java @@ -67,6 +67,8 @@ public class ItemProtocol { public static String to_di_height = "to_di_height"; //虚拟低电平写 public static String to_di_low = "to_di_low"; + //下发任务链 + public static String to_line = "to_line"; public int getIs_charging() { @@ -353,6 +355,7 @@ public class ItemProtocol { list.add(new ItemDto(to_clear_error, "to_clear_error", "40090")); list.add(new ItemDto(to_di_height, "虚拟高电平写", "40063")); list.add(new ItemDto(to_di_low, "虚拟低电平写", "40064")); + list.add(new ItemDto(to_line, "to_line", "40043")); return list; } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/xg_agv/XgagvDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/xg_agv/XgagvDeviceDriver.java index 6cbb792..216af47 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/xg_agv/XgagvDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/xg_agv/XgagvDeviceDriver.java @@ -61,7 +61,7 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device String last_mode = "0"; private Date instruction_require_time = new Date(); - private int instruction_require_time_out = 1000; + private int instruction_require_time_out = 3000; int is_charging = 0; int stop = 0; int DI0 = 0; @@ -186,6 +186,7 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device } if (address != last_address) { + LuceneLogDto logDto = new LuceneLogDto(); logDto.setDevice_code(device_code); logDto.setContent("信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.address + "变更从" + this.last_address + "->" + this.address); @@ -249,11 +250,11 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device if (ObjectUtil.isEmpty(inst)) { if (electricity != 0 && electricity < min_electric && address != charge_point && (navigation_status == 0 || navigation_status == 4)) { log.info("下发充电:{}", charge_point); - writing("to_address", charge_point); + feedAgvTaskStatus(inst, "5"); } if (electricity != 0 && electricity > cancle_electric && address == charge_point && (navigation_status == 0 || navigation_status == 4)) { log.info("下发回休息点:{}", relax_point); - writing("to_address", relax_point); + } } else { TaskDto task = taskserver.findByCodeFromCache(inst.getTask_code()); @@ -268,40 +269,42 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device if (StrUtil.equals("0", inst.getInstruction_status())) { log.info("下发指令号{},起点{}", inst.getInstruction_code(), start_device); //判断指令起点与任务起点是否相同 - if(StrUtil.equals(task.getStart_device_code(),inst.getStart_device_code())){ - feedAgvTaskStatus(inst, "1"); - } else { - //不同的话是按照路由生成的指令 - LuceneLogDto logDto = new LuceneLogDto(); - logDto.setDevice_code(device_code); - logDto.setInstruct_code(inst.getInstruction_code()); - logDto.setTask_code(inst.getTask_code()); - logDto.setContent("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_address + " value:" + start_device_code); - luceneExecuteLogService.deviceExecuteLog(logDto); - writing("to_address", start_device_code); - inst.setInstruction_status("1"); - instructionService.update(inst); - } + feedAgvTaskStatus(inst, "1"); } //取货完成请求离开 - if (StrUtil.equals("1", inst.getInstruction_status()) && address == start_device_code && stop == 1 && StrUtil.equals(inst.getExecute_status(),"1")) { + if (StrUtil.equals("1", inst.getInstruction_status()) && address == 5 && stop == 1 && StrUtil.equals(inst.getExecute_status(),"1")) { //请求wms是否允许从取货点离开 feedAgvTaskStatus(inst, "2"); } //请求放货 - if (StrUtil.equals("1", inst.getInstruction_status()) && address == next_device_code && stop == 1 && StrUtil.equals(inst.getExecute_status(),"2")) { + if (StrUtil.equals("1", inst.getInstruction_status()) && address == 2 && stop == 1 && StrUtil.equals(inst.getExecute_status(),"2")) { //请求wms是否允许进入放货 feedAgvTaskStatus(inst, "3"); } //放货完成 完成任务回休息点 - if (StrUtil.equals("1", inst.getInstruction_status()) && address == next_device_code && stop == 1 && StrUtil.equals(inst.getExecute_status(),"3")) { + if (StrUtil.equals("1", inst.getInstruction_status()) && address == 1 && stop == 1 && StrUtil.equals(inst.getExecute_status(),"3")) { feedAgvTaskStatus(inst, "4"); } + } + //请求开门 + if ( (address == 3 || address == 11 ) && stop == 1 ) { + feedAgvAction("5"); + } + + //请求关门 + if ( (address == 9 || address == 10 ) && stop == 1 ) { + feedAgvAction("6"); + } + + //请求充电 + if ( address == 4 && stop == 1 ) { + feedAgvAction( "7"); + } last_home_relocation = home_relocation; last_address = address; last_next_address = next_address; @@ -326,9 +329,13 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device JSONObject jo = new JSONObject(); String mode = ""; jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("mode", mode); jo.put("message", this.getMessage()); jo.put("is_click", true); + jo.put("address", address); + jo.put("stop", stop); + jo.put("electricity", electricity); + jo.put("is_charging", is_charging); + return jo; } @@ -350,12 +357,13 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); return false; } else { - Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code()); - Device next_device = deviceAppService.findDeviceByCode(inst.getNext_device_code()); - int start_device_code = Integer.parseInt(start_device.getAddress()); - int next_device_code = Integer.parseInt(next_device.getAddress()); + //请求WMS允许取货 if (StrUtil.equals(type, "1")) { + Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code()); + Device next_device = deviceAppService.findDeviceByCode(inst.getNext_device_code()); + int start_device_code = Integer.parseInt(start_device.getAddress()); + int next_device_code = Integer.parseInt(next_device.getAddress()); JSONArray ja = new JSONArray(); JSONObject jo = new JSONObject(); jo.put("vehicle_code", inst.getVehicle_code()); @@ -364,22 +372,30 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device jo.put("task_code", inst.getTask_code()); ja.add(jo); HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja); + LuceneLogDto logDto = new LuceneLogDto(); + + logDto.setDevice_code(device_code); + logDto.setContent("请求参数:" + ja.toString() ); + luceneExecuteLogService.deviceExecuteLog(logDto); + luceneExecuteLogService.deviceExecuteLog(logDto); + if (resp.getStatus() ==200) { - LuceneLogDto logDto = new LuceneLogDto(); - logDto.setDevice_code(device_code); - logDto.setInstruct_code(inst.getInstruction_code()); - logDto.setTask_code(inst.getTask_code()); - logDto.setContent("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_address + " value:" + start_device_code); - luceneExecuteLogService.deviceExecuteLog(logDto); - writing("to_address", start_device_code); + inst.setInstruction_status("1"); inst.setExecute_status("1"); instructionService.update(inst); + writing("to_line", 1); + } else { + writing("to_line", 1); } //取货完成请求离开 } else if (StrUtil.equals(type, "2")) { + Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code()); + Device next_device = deviceAppService.findDeviceByCode(inst.getNext_device_code()); + int start_device_code = Integer.parseInt(start_device.getAddress()); + int next_device_code = Integer.parseInt(next_device.getAddress()); JSONArray ja = new JSONArray(); JSONObject jo = new JSONObject(); jo.put("vehicle_code", inst.getVehicle_code()); @@ -389,13 +405,7 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device ja.add(jo); HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja); if (resp.getStatus() ==200) { - LuceneLogDto logDto = new LuceneLogDto(); - logDto.setDevice_code(device_code); - logDto.setInstruct_code(inst.getInstruction_code()); - logDto.setTask_code(inst.getTask_code()); - logDto.setContent("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_address + " value:" + start_device_code); - luceneExecuteLogService.deviceExecuteLog(logDto); - writing("to_address", next_device_code); + inst.setInstruction_status("1"); inst.setExecute_status("2"); instructionService.update(inst); @@ -404,6 +414,10 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device } //请求放货 } else if (StrUtil.equals(type, "3")) { + Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code()); + Device next_device = deviceAppService.findDeviceByCode(inst.getNext_device_code()); + int start_device_code = Integer.parseInt(start_device.getAddress()); + int next_device_code = Integer.parseInt(next_device.getAddress()); JSONArray ja = new JSONArray(); JSONObject jo = new JSONObject(); jo.put("vehicle_code", inst.getVehicle_code()); @@ -413,20 +427,17 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device ja.add(jo); HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja); if (resp.getStatus() ==200) { - LuceneLogDto logDto = new LuceneLogDto(); - logDto.setDevice_code(device_code); - logDto.setInstruct_code(inst.getInstruction_code()); - logDto.setTask_code(inst.getTask_code()); - logDto.setContent("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_address + " value:" + start_device_code); - luceneExecuteLogService.deviceExecuteLog(logDto); inst.setInstruction_status("1"); inst.setExecute_status("3"); instructionService.update(inst); - writing("to_address", start_device_code); } else { } } else if (StrUtil.equals(type, "4")) { + Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code()); + Device next_device = deviceAppService.findDeviceByCode(inst.getNext_device_code()); + int start_device_code = Integer.parseInt(start_device.getAddress()); + int next_device_code = Integer.parseInt(next_device.getAddress()); JSONArray ja = new JSONArray(); JSONObject jo = new JSONObject(); jo.put("vehicle_code", inst.getVehicle_code()); @@ -440,16 +451,128 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device logDto.setDevice_code(device_code); logDto.setInstruct_code(inst.getInstruction_code()); logDto.setTask_code(inst.getTask_code()); - logDto.setContent("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_address + " value:" + start_device_code); + logDto.setContent("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_line + " value:" + 2); luceneExecuteLogService.deviceExecuteLog(logDto); - writing("to_address", relax_point); + writing("to_line", 2); inst.setInstruction_status("2"); - inst.setInstruction_status("1"); inst.setExecute_status("4"); instructionService.finish(inst); } else { } + } else if (StrUtil.equals(type, "5")) { + JSONArray ja = new JSONArray(); + JSONObject jo = new JSONObject(); + jo.put("status", "5"); + jo.put("device_code", this.address); + ja.add(jo); + HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja); + if (resp.getStatus() == 200) { + LuceneLogDto logDto = new LuceneLogDto(); + logDto.setDevice_code(device_code); + logDto.setContent("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_di_low + " value:" + 0); + luceneExecuteLogService.deviceExecuteLog(logDto); + writing("to_di_low", 0); + writing("to_di_height", 0); + } else { + + } + } else if (StrUtil.equals(type, "6")) { + JSONArray ja = new JSONArray(); + JSONObject jo = new JSONObject(); + jo.put("status", "6"); + jo.put("device_code", this.device_code); + ja.add(jo); + HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja); + if (resp.getStatus() == 200) { + LuceneLogDto logDto = new LuceneLogDto(); + logDto.setDevice_code(device_code); + logDto.setContent("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_di_low + " value:" + 0); + luceneExecuteLogService.deviceExecuteLog(logDto); + writing("to_di_height", 0); + writing("to_di_low", 0); + } else { + + } + } else if (StrUtil.equals(type, "7")) { + JSONArray ja = new JSONArray(); + JSONObject jo = new JSONObject(); + jo.put("status", "7"); + jo.put("device_code", this.device_code); + ja.add(jo); + HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja); + if (resp.getStatus() == 200) { + LuceneLogDto logDto = new LuceneLogDto(); + logDto.setDevice_code(device_code); + logDto.setContent("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_di_low + " value:" + 0); + luceneExecuteLogService.deviceExecuteLog(logDto); + writing("to_di_low", 0); + } else { + + } + } + } + return true; + } + + public boolean feedAgvAction(String type) throws Exception { + 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); + return false; + } else { + if (StrUtil.equals(type, "5")) { + JSONArray ja = new JSONArray(); + JSONObject jo = new JSONObject(); + jo.put("status", "5"); + jo.put("device_code", "A4"); + ja.add(jo); + HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja); + if (resp.getStatus() == 200) { + LuceneLogDto logDto = new LuceneLogDto(); + logDto.setDevice_code(device_code); + logDto.setContent("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_di_low + " value:" + 0); + luceneExecuteLogService.deviceExecuteLog(logDto); + writing("to_di_low", 0); + writing("to_di_height", 0); + } else { + writing("to_di_low", 0); + writing("to_di_height", 0); + } + } else if (StrUtil.equals(type, "6")) { + JSONArray ja = new JSONArray(); + JSONObject jo = new JSONObject(); + jo.put("status", "6"); + jo.put("device_code", "A4"); + ja.add(jo); + HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja); + if (resp.getStatus() == 200) { + LuceneLogDto logDto = new LuceneLogDto(); + logDto.setDevice_code(device_code); + logDto.setContent("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_di_low + " value:" + 0); + luceneExecuteLogService.deviceExecuteLog(logDto); + writing("to_di_height", 0); + writing("to_di_low", 0); + } else { + writing("to_di_height", 0); + writing("to_di_low", 0); + } + } else if (StrUtil.equals(type, "7")) { + JSONArray ja = new JSONArray(); + JSONObject jo = new JSONObject(); + jo.put("status", "7"); + jo.put("device_code", "A4"); + ja.add(jo); + HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja); + if (resp.getStatus() == 200) { + LuceneLogDto logDto = new LuceneLogDto(); + logDto.setDevice_code(device_code); + logDto.setContent("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + ItemProtocol.to_di_low + " value:" + 0); + luceneExecuteLogService.deviceExecuteLog(logDto); + writing("to_di_height", 0); + } else { + writing("to_di_height", 0); + } } } return true; diff --git a/acs/nladmin-ui/src/views/system/monitor/device/index.vue b/acs/nladmin-ui/src/views/system/monitor/device/index.vue index fc0af8e..af7710f 100644 --- a/acs/nladmin-ui/src/views/system/monitor/device/index.vue +++ b/acs/nladmin-ui/src/views/system/monitor/device/index.vue @@ -456,11 +456,11 @@ export default { } else if (val === 'tray_crib_qty') { const obj = { name: '托盘垛数', value: data[val] } this.arr.push(obj) - } else if (val === 'move_1') { - const obj = { name: '前工位光电信号', value: data[val] } + } else if (val === 'address') { + const obj = { name: '当前站点', value: data[val] } this.arr.push(obj) - } else if (val === 'move_2') { - const obj = { name: '后工位光电信号', value: data[val] } + } else if (val === 'stop') { + const obj = { name: '是否停止', value: data[val] } this.arr.push(obj) } else if (val === 'action_1') { const obj = { name: '前工位动作信号', value: data[val] } @@ -471,11 +471,11 @@ export default { } else if (val === 'walk_y') { const obj = { name: '行走列', value: data[val] } this.arr.push(obj) - } else if (val === 'task1') { - const obj = { name: '前工位任务号', value: data[val] } + } else if (val === 'is_charging') { + const obj = { name: '是否充电', value: data[val] } this.arr.push(obj) - } else if (val === 'task2') { - const obj = { name: '后工位任务号', value: data[val] } + } else if (val === 'electricity') { + const obj = { name: '电量', value: data[val] } this.arr.push(obj) } else if (val === 'task') { const obj = { name: '任务号', value: data[val] }