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 7e46f99..ed51be1 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 @@ -672,10 +672,16 @@ public class AgvServiceImpl implements AgvService { ndxySpecialTwoDeviceDriver = (NdxySpecialTwoDeviceDriver) addressdevice.getDeviceDriver(); //请求取货 if ("Load".equals(action)) { - ndxySpecialTwoDeviceDriver.writing("item_to_address",1); - ndxySpecialTwoDeviceDriver.writing("to_pick_ready",1); - if (ndxySpecialTwoDeviceDriver.getMode() == 1 && ndxySpecialTwoDeviceDriver.getMove() > 0 && ndxySpecialTwoDeviceDriver.getAction()==1) { + 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; } } @@ -758,7 +764,7 @@ public class AgvServiceImpl implements AgvService { if (ndxySpecialTwoDeviceDriver.getMode() == 2 && ndxySpecialTwoDeviceDriver.getMove() == 0) { inst.setExecute_device_code(processingVehicle); inst.setExecute_status("2"); -// ndxySpecialTwoDeviceDriver.writing(2); + ndxySpecialTwoDeviceDriver.writing(2); is_feedback = true; } //放货完成 @@ -766,7 +772,7 @@ public class AgvServiceImpl implements AgvService { if (ndxySpecialTwoDeviceDriver.getMode() == 2 && ndxySpecialTwoDeviceDriver.getMove() > 0) { inst.setExecute_device_code(address); inst.setExecute_status("4"); -// ndxySpecialTwoDeviceDriver.writing(4); + ndxySpecialTwoDeviceDriver.writing(4); is_feedback = true; } } @@ -1027,15 +1033,25 @@ public class AgvServiceImpl implements AgvService { ndxySpecialTwoDeviceDriver = (NdxySpecialTwoDeviceDriver) device.getDeviceDriver(); //请求取货 if (StrUtil.equals(type, "01") && ndxySpecialTwoDeviceDriver.getMove() != 0) { -// ndxySpecialTwoDeviceDriver.writing(1, 1); + ndxySpecialTwoDeviceDriver.writing(1, 1); is_feedback = true; } //取货完成 else if (StrUtil.equals(type, "02")) { - ndxySpecialTwoDeviceDriver.writing("to_pick_finish", 1); + ndxySpecialTwoDeviceDriver.writing(1, 2); is_feedback = true; } + //请求放货 + else if (StrUtil.equals(type, "03") && ndxySpecialTwoDeviceDriver.getMove() == 0) { + ndxySpecialTwoDeviceDriver.writing(1, 3); + is_feedback = true; + } + //放货完成 + else if (StrUtil.equals(type, "04")) { + ndxySpecialTwoDeviceDriver.writing(1, 4); + is_feedback = true; + } } if (device.getDeviceDriver() instanceof YkbkSpecialDeviceDriver) { ykbkSpecialDeviceDriver = (YkbkSpecialDeviceDriver) device.getDeviceDriver(); diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/ndxy_special/ItemProtocol.java b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/ndxy_special/ItemProtocol.java index 676af02..da70171 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/ndxy_special/ItemProtocol.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/ndxy_special/ItemProtocol.java @@ -95,7 +95,7 @@ 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_ioaction, "进出信号", "DB600.B4")); list.add(new ItemDto(item_error, "报警信号", "DB600.B6")); list.add(new ItemDto(item_task, "任务号", "DB600.D8")); return list; diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/ndxy_special/NdxySpecialDefination.java b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/ndxy_special/NdxySpecialDefination.java index 92f1e91..c8f26d9 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/ndxy_special/NdxySpecialDefination.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/ndxy_special/NdxySpecialDefination.java @@ -60,7 +60,7 @@ public class NdxySpecialDefination implements OpcDeviceDriverDefination { list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", 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_ioaction, "进出信号", "DB600.B4")); list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B6")); list.add(new ItemDto(ItemProtocol.item_task, "任务号", "DB600.D8")); return list; 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 f8a023e..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,14 +15,12 @@ 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_pick_start = "pick_start"; - public static String item_device_status = "device_status"; - public static String item_to_ready = "to_ready"; - public static String item_to_agv_status = "to_agv_status"; - public static String item_to_address = "to_address"; + public static String item_mode_switch = "mode_switch"; + public static String item_error = "error"; + public static String item_ioaction = "ioaction"; + public static String item_to_command = "to_command"; public static String item_to_mode_switch = "to_mode_switch"; - public static String item_to_pick_ready = "to_pick_ready"; - public static String item_to_pick_finish = "to_pick_finish"; + public static String item_weight = "weight"; private NdxySpecialTwoDeviceDriver driver; @@ -46,14 +44,25 @@ public class ItemProtocol { return this.getOpcIntegerValue(item_action); } - public int getPick_start() { - return this.getOpcIntegerValue(item_pick_start); + public int getMode_switch() { + return this.getOpcIntegerValue(item_mode_switch); } - public int getDevice_status() { - return this.getOpcIntegerValue(item_device_status); + public int getError() { + return this.getOpcIntegerValue(item_error); } + public int getIoaction() { + return this.getOpcIntegerValue(item_ioaction); + } + + public int getToCommand() { + return this.getOpcIntegerValue(item_to_command); + } + + public int getTo_mode_switch() { + return this.getOpcIntegerValue(item_to_mode_switch); + } //是否有货 public int hasGoods(int move) { @@ -77,23 +86,20 @@ public class ItemProtocol { public static List getReadableItemDtos() { ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB700.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB700.B1", Boolean.valueOf(true))); - list.add(new ItemDto(item_move, "光电开关信号", "DB700.B2")); - list.add(new ItemDto(item_action, "取放信号", "DB700.B3")); - list.add(new ItemDto(item_pick_start, "卸载开始", "DB700.B4")); - list.add(new ItemDto(item_device_status, "码垛机状态", "DB700.B5")); - + list.add(new ItemDto(item_heartbeat, "心跳", "DB600.B0")); + 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")); return list; } public static List getWriteableItemDtos() { ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_ready, "就绪", "DB701.W2", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_agv_status, "AGV状态", "DB701.W4")); - list.add(new ItemDto(item_to_address, "到位", "DB701.W6")); - list.add(new ItemDto(item_to_pick_ready, "允许卸货", "DB701.W8")); - list.add(new ItemDto(item_to_pick_finish, "卸货完成", "DB701.W10")); + list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2", Boolean.valueOf(true))); + 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 41f63e8..6b36221 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 @@ -52,9 +52,19 @@ public class NdxySpecialTwoDefination implements OpcDeviceDriverDefination { @Override public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); + return getReadableItemDtos2(); } + 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", 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_error, "报警信号", "DB600.B6")); + return list; + } @Override public List getWriteableItemDtos() { 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 d02cb1a..41d5ccb 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 @@ -138,13 +138,17 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen @Override - public void execute() throws Exception { + public void execute() { String message = null; try { device_code = this.getDeviceCode(); mode = this.itemProtocol.getMode(); + error = this.itemProtocol.getError(); move = this.itemProtocol.getMove(); action = this.itemProtocol.getAction(); + ioaction = this.itemProtocol.getIoaction(); + mode_switch = this.itemProtocol.getMode_switch(); + hasGoods = this.itemProtocol.getMove(); if (mode != last_mode) { this.execute_log.setResource(this.devicecode, this.device.getDevice_name()); @@ -157,11 +161,69 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen this.execute_log.setResource(this.devicecode, this.device.getDevice_name()); 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); + } if (action != last_action) { 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(); + DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + Device link_device = appService.findDeviceByCode(link_device_code); + NdxySpecialTwoDeviceDriver NdxySpecialTwoDevicedriver; + if (link_device.getDeviceDriver() instanceof NdxySpecialTwoDeviceDriver) { + NdxySpecialTwoDevicedriver = (NdxySpecialTwoDeviceDriver) link_device.getDeviceDriver(); + //如果目标设备申请叫料 则允许生成任务 + if (NdxySpecialTwoDevicedriver.getApply_material()) { + TaskDto dto = new TaskDto(); + String now = DateUtil.now(); + dto.setTask_id(IdUtil.simpleUUID()); + dto.setCreate_by(this.getDevice().getDevice_code()); + dto.setUpdate_by(this.getDevice().getDevice_code()); + dto.setStart_point_code(this.getDevice().getDevice_code()); + + String taskcode = CodeUtil.getNewCode("TASK_NO"); + dto.setTask_code("-" + taskcode); + dto.setTask_status("0"); + dto.setPriority("101"); +// RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); +// String next_device_codecode = jo.getNext_device_code(); +// if(StrUtil.isEmpty(next_device_codecode)){ +// throw new RuntimeException("该设备未找到对应路由"); +// } + dto.setNext_point_code(NdxySpecialTwoDevicedriver.getDevicecode()); + dto.setUpdate_time(now); + dto.setCreate_time(now); + + WQLObject wo = WQLObject.getWQLObject("acs_task"); + JSONObject json = JSONObject.fromObject(dto); + wo.insert(json); + NdxySpecialTwoDevicedriver.setApply_material(false); + } + } + this.setApply_handling(false); + } } catch (Exception var17) { return; @@ -190,10 +252,24 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen List toInstructions; switch (mode) { case 1: - if (!requireSucess && this.move != 0 && mode ==1 && action ==1) { + log.debug("设备运转模式:等待工作"); + return; + case 2: + if (!requireSucess && this.move != 0) { standby(); } } + } + + switch (flag) { + //取货完成 + case 2: + writing(2); + return; + //放货完成 + case 4: + writing(4); + return; } last_mode = mode; @@ -230,7 +306,7 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen * * @return */ - public synchronized boolean standby() throws Exception { + public synchronized boolean standby() { 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); @@ -293,10 +369,9 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen } } -// WQLObject wo = WQLObject.getWQLObject("acs_task"); -// JSONObject json = JSONObject.fromObject(dto); -// wo.insert(json); - taskserver.create(dto); + WQLObject wo = WQLObject.getWQLObject("acs_task"); + JSONObject json = JSONObject.fromObject(dto); + wo.insert(json); Device device = appService.findDeviceByCode(next_device_code); device.setIslock("true"); this.setRequireSucess(true); @@ -318,21 +393,36 @@ public class NdxySpecialTwoDeviceDriver extends AbstractOpcDeviceDriver implemen ReadUtil.write(itemMap, server); } - - public void writing(String type, int command) { - + public void writing(int command) { String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + type; + + "." + ItemProtocol.item_to_command; String opcservcerid = this.getDevice().getOpc_server_id(); Server server = ReadUtil.getServer(opcservcerid); Map itemMap = new HashMap(); - itemMap.put(to_command, command); ReadUtil.write(itemMap, server); } + 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_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_mode_switch, command); + } + ReadUtil.write(itemMap, server); + + } + public boolean instruction_require(String container_code) { return instruction_require(container_code, WcsConfig.task_container_type_default_desc); } diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index 33a1638..0831576 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -415,10 +415,10 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu } - if (startdevice.getDeviceDriver() instanceof NdxySpecialTwoDeviceDriver) { - ndxySpecialTwoDeviceDriver = (NdxySpecialTwoDeviceDriver) startdevice.getDeviceDriver(); - ndxySpecialTwoDeviceDriver.writing("to_ready",1); - } +// if (startdevice.getDeviceDriver() instanceof NdxySpecialTwoDeviceDriver) { +// ndxySpecialTwoDeviceDriver = (NdxySpecialTwoDeviceDriver) startdevice.getDeviceDriver(); +// ndxySpecialTwoDeviceDriver.writing("to_ready",1); +// } try { diff --git a/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryMagicAgvDeviceStatus.java b/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryMagicAgvDeviceStatus.java index 91df480..a1915d5 100644 --- a/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryMagicAgvDeviceStatus.java +++ b/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryMagicAgvDeviceStatus.java @@ -67,16 +67,22 @@ public class QueryMagicAgvDeviceStatus { // ndxySpecialTwoDeviceDriver.writing("to_agv_status",0); // } // } - if (deviceBycode.getDeviceDriver() instanceof LampThreecolorDeviceDriver){ + if (deviceBycode.getDeviceDriver() instanceof LampThreecolorDeviceDriver) { lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) deviceBycode.getDeviceDriver(); - if(jo.optString("state").equals("IDLE") || jo.optString("state").equals("EXECUTING")){ +// if(jo.optString("state").equals("IDLE") || jo.optString("state").equals("EXECUTING")){ +// lampThreecolorDeviceDriver.writing(0); +// flag = false; +// } else if (jo.optString("state").equals("ERROR")){ +// if (!flag){ +// lampThreecolorDeviceDriver.writing(3); +// flag = true; +// } +// } + String errorcode = jo.getString("warningCode"); + if (Integer.parseInt(errorcode) > 0) { + lampThreecolorDeviceDriver.writing(3); + } else { lampThreecolorDeviceDriver.writing(0); - flag = false; - } else if (jo.optString("state").equals("ERROR")){ - if (!flag){ - lampThreecolorDeviceDriver.writing(3); - flag = true; - } } } }