From df97828efc49f2db6bdeb1832e1c8c5286de2b69 Mon Sep 17 00:00:00 2001 From: loujf Date: Thu, 28 Jul 2022 17:16:44 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BA=BD=E8=BF=AA=E5=B8=8C=E4=BA=9A2=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../acs/agv/server/impl/AgvServiceImpl.java | 22 +++++- .../ElectricFenceDeviceDriver.java | 7 +- .../ndxy_special_two/ItemProtocol.java | 28 ++++---- .../NdxySpecialTwoDefination.java | 5 +- .../NdxySpecialTwoDeviceDriver.java | 69 +++++++++---------- .../StandardInspectSiteDeviceDriver.java | 4 +- 6 files changed, 76 insertions(+), 59 deletions(-) diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java b/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java index c3aa9a5..beecf19 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java @@ -667,6 +667,24 @@ public class AgvServiceImpl implements AgvService { } } } + if (addressdevice.getDeviceDriver() instanceof NdxySpecialTwoDeviceDriver) { + ndxySpecialTwoDeviceDriver = (NdxySpecialTwoDeviceDriver) addressdevice.getDeviceDriver(); + //请求取货 + if ("Load".equals(action)) { + if (ndxySpecialTwoDeviceDriver.getMode() == 2 && ndxySpecialTwoDeviceDriver.getMove() > 0) { + inst.setExecute_status("1"); + ndxySpecialTwoDeviceDriver.writing(1); + is_feedback = true; + } + //请求放货 + } else if ("Unload".equals(action)) { + if (ndxySpecialTwoDeviceDriver.getMode() == 2 && ndxySpecialTwoDeviceDriver.getMove() == 0) { + inst.setExecute_status("3"); + ndxySpecialTwoDeviceDriver.writing(3); + is_feedback = true; + } + } + } if (addressdevice.getDeviceDriver() instanceof SpecialOrdinarySiteDeviceDriver) { specialOrdinarySiteDeviceDriver = (SpecialOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver(); //请求取货 @@ -745,7 +763,7 @@ public class AgvServiceImpl implements AgvService { if (ndxySpecialTwoDeviceDriver.getMode() == 2 && ndxySpecialTwoDeviceDriver.getMove() == 0) { inst.setExecute_device_code(processingVehicle); inst.setExecute_status("2"); - ndxySpecialTwoDeviceDriver.setFlag(2); + ndxySpecialTwoDeviceDriver.writing(2); is_feedback = true; } //放货完成 @@ -753,7 +771,7 @@ public class AgvServiceImpl implements AgvService { if (ndxySpecialTwoDeviceDriver.getMode() == 2 && ndxySpecialTwoDeviceDriver.getMove() > 0) { inst.setExecute_device_code(address); inst.setExecute_status("4"); - ndxySpecialTwoDeviceDriver.setFlag(4); + ndxySpecialTwoDeviceDriver.writing(4); is_feedback = true; } } diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/electric_fence/ElectricFenceDeviceDriver.java b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/electric_fence/ElectricFenceDeviceDriver.java index fd2f5fe..50a9953 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/electric_fence/ElectricFenceDeviceDriver.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/electric_fence/ElectricFenceDeviceDriver.java @@ -67,13 +67,16 @@ public class ElectricFenceDeviceDriver extends AbstractOpcDeviceDriver implement this.execute_log.log("设备:" + device_code + ",last_mode -> mode:" + last_mode + "->" + mode); } if (action != last_action) { + if (action == 1) { + agvService.pause(); + } this.execute_log.log("设备:" + device_code + ",last_action -> action:" + last_action + "->" + action); } if (error != last_error) { - if (this.error == 1) { + if (error == 1) { agvService.pause(); } - if (this.error == 0){ + if (error == 0) { agvService.resume(); } //this.execute_log.setContainer(""); diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/ndxy_special_two/ItemProtocol.java b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/ndxy_special_two/ItemProtocol.java index 1e07bc1..87b0e06 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/ndxy_special_two/ItemProtocol.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/ndxy_special_two/ItemProtocol.java @@ -15,11 +15,11 @@ public class ItemProtocol { public static String item_mode = "mode"; public static String item_move = "move"; public static String item_action = "action"; + public static String item_mode_switch = "mode_switch"; public static String item_error = "error"; - public static String item_task = "task"; + public static String item_ioaction = "ioaction"; public static String item_to_command = "to_command"; - public static String item_to_target = "to_target"; - public static String item_to_task = "to_task"; + public static String item_to_mode_switch = "to_mode_switch"; public static String item_weight = "weight"; private NdxySpecialTwoDeviceDriver driver; @@ -44,24 +44,24 @@ public class ItemProtocol { return this.getOpcIntegerValue(item_action); } + public int getMode_switch() { + return this.getOpcIntegerValue(item_mode_switch); + } + public int getError() { return this.getOpcIntegerValue(item_error); } - public int getTask() { - return this.getOpcIntegerValue(item_task); + public int getIoaction() { + return this.getOpcIntegerValue(item_ioaction); } public int getToCommand() { return this.getOpcIntegerValue(item_to_command); } - public int getToTarget() { - return this.getOpcIntegerValue(item_to_target); - } - - public int getToTask() { - return this.getOpcIntegerValue(item_to_task); + public int getTo_mode_switch() { + return this.getOpcIntegerValue(item_to_mode_switch); } //是否有货 @@ -90,16 +90,16 @@ public class ItemProtocol { list.add(new ItemDto(item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); list.add(new ItemDto(item_move, "光电开关信号", "DB600.B2")); list.add(new ItemDto(item_action, "取放信号", "DB600.B3")); + list.add(new ItemDto(item_ioaction, "进出信号", "DB600.B4")); + list.add(new ItemDto(item_mode_switch, "允许模式切换信号", "DB600.B5")); list.add(new ItemDto(item_error, "报警信号", "DB600.B6")); - list.add(new ItemDto(item_task, "任务号", "DB600.D8")); return list; } public static List getWriteableItemDtos() { ArrayList list = new ArrayList(); list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_target, "目标站", "DB601.W4")); - list.add(new ItemDto(item_to_task, "任务号", "DB601.D8")); + list.add(new ItemDto(item_to_mode_switch, "切换模式", "DB601.W4")); return list; } diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/ndxy_special_two/NdxySpecialTwoDefination.java b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/ndxy_special_two/NdxySpecialTwoDefination.java index 794b9b8..44b39d5 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/ndxy_special_two/NdxySpecialTwoDefination.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/ndxy_special_two/NdxySpecialTwoDefination.java @@ -58,11 +58,12 @@ public class NdxySpecialTwoDefination implements OpcDeviceDriverDefination { public static List getReadableItemDtos2() { List list = new ArrayList(); list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", true)); + list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); list.add(new ItemDto(ItemProtocol.item_move, "光电开关信号", "DB600.B2")); list.add(new ItemDto(ItemProtocol.item_action, "取放信号", "DB600.B3")); + list.add(new ItemDto(ItemProtocol.item_ioaction, "进出信号", "DB600.B4")); + list.add(new ItemDto(ItemProtocol.item_mode_switch, "允许模式切换信号", "DB600.B5")); list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B6")); - list.add(new ItemDto(ItemProtocol.item_task, "任务号", "DB600.D7")); return list; } diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/ndxy_special_two/NdxySpecialTwoDeviceDriver.java b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/ndxy_special_two/NdxySpecialTwoDeviceDriver.java index de6f21a..3ead2d4 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/ndxy_special_two/NdxySpecialTwoDeviceDriver.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/ndxy_special_two/NdxySpecialTwoDeviceDriver.java @@ -67,11 +67,13 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen int move = 0; int task = 0; int action = 0; + int ioaction = 0; int last_mode = 0; int last_error = 0; int last_move = 0; int last_task = 0; int last_action = 0; + int last_ioaction = 0; Boolean isonline = true; int hasGoods = 0; String message = null; @@ -122,6 +124,10 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 int flag; + //允许模式切换 0不允许 1允许 + int mode_switch = 0; + int last_mode_switch = 0; + String devicecode; @Override @@ -139,7 +145,8 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen error = this.itemProtocol.getError(); move = this.itemProtocol.getMove(); action = this.itemProtocol.getAction(); - task = this.itemProtocol.getTask(); + ioaction = this.itemProtocol.getIoaction(); + mode_switch = this.itemProtocol.getMode_switch(); hasGoods = this.itemProtocol.getMove(); if (mode != last_mode) { @@ -154,6 +161,15 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen this.execute_log.log("设备:" + device_code + ",last_move -> move:" + last_mode + "->" + move); } if (error != last_error) { + if (error != 0) { + if (mode_switch == 1) { + this.writing(1); + } + } else { + if (mode_switch == 1) { + this.writing(2); + } + } this.execute_log.setResource(this.devicecode, this.device.getDevice_name()); this.execute_log.log("设备:" + device_code + ",last_error -> error:" + last_error + "->" + error); } @@ -161,6 +177,14 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen this.execute_log.setResource(this.devicecode, this.device.getDevice_name()); this.execute_log.log("设备:" + device_code + ",last_action -> action:" + last_action + "->" + action); } + if (ioaction != last_ioaction) { + this.execute_log.setResource(this.devicecode, this.device.getDevice_name()); + this.execute_log.log("设备:" + device_code + ",last_ioaction -> ioaction:" + last_ioaction + "->" + ioaction); + } + if (mode_switch != last_mode_switch) { + this.execute_log.setResource(this.devicecode, this.device.getDevice_name()); + this.execute_log.log("设备:" + device_code + ",last_mode_switch -> mode_switch:" + last_mode_switch + "->" + mode_switch); + } if (this.getApply_handling()) { String link_device_code = this.getDevice().getExtraValue().get("link_device_code").toString(); @@ -252,6 +276,8 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen last_move = move; last_task = task; last_action = action; + last_ioaction = ioaction; + last_mode_switch = mode_switch; } @@ -308,8 +334,7 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); if (standardOrdinarySiteDeviceDriver.getHasGoods() == 0 && ObjectUtil.isEmpty(taskserver.findByNextCode(next_device_code)) - && ObjectUtil.isEmpty(taskserver.findByStartCode(this.device_code)) - && this.action == 1) { + && ObjectUtil.isEmpty(taskserver.findByStartCode(this.device_code))) { break; } else { next_device_code = ""; @@ -351,32 +376,6 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen return true; } - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - if (appendMessage == null) { - appendMessage = ""; - } - if (instruction != null) { - instruction_num = Integer.parseInt(instruction.getInstruction_code()); - } - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, 1); - itemMap.put(to_task, instruction_num); - ReadUtil.write(itemMap, server); - - } - public void executing(Server server, Map itemMap) { ReadUtil.write(itemMap, server); } @@ -396,20 +395,16 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen public void writing(int type, int command) { String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; + String to_mode_switch = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_mode_switch; + String opcservcerid = this.getDevice().getOpc_server_id(); Server server = ReadUtil.getServer(opcservcerid); Map itemMap = new HashMap(); if (type == 1) { itemMap.put(to_command, command); } else if (type == 2) { - itemMap.put(to_target, command); - - } else if (type == 3) { - itemMap.put(to_task, command); + itemMap.put(to_mode_switch, command); } ReadUtil.write(itemMap, server); 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 10b4967..e6ebbcc 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 @@ -282,11 +282,11 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp switch (flag) { //取货完成 - case 1: + case 2: writing(2); return; //放货完成 - case 2: + case 4: writing(3); return;