From 6dcf9c843bf1d3ca5fe66d111e0f5b4ae1ef5abf Mon Sep 17 00:00:00 2001 From: yanps Date: Tue, 30 Apr 2024 13:35:59 +0800 Subject: [PATCH] =?UTF-8?q?opt:=20=E8=BE=93=E9=80=81=E7=BA=BF=E8=81=94?= =?UTF-8?q?=E8=B0=83=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../agv/ndctwo/AgvNdcTwoDeviceDriver.java | 7 +- .../BeltConveyorDeviceDriver.java | 20 ++- ...ConveyorWithScannerWeightDeviceDriver.java | 7 +- .../scanner_weight_conveyor/ItemProtocol.java | 18 ++- .../BoxStorageManipulatorDeviceDriver.java | 10 +- .../InflatableShaftLibraryDeviceDriver.java | 1 + .../ItemProtocol.java | 6 +- .../PullHeadManipulatorDeviceDriver.java | 139 ++++++++++-------- 8 files changed, 123 insertions(+), 85 deletions(-) diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDeviceDriver.java index 47afce62e..1993d4627 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDeviceDriver.java @@ -484,8 +484,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); standardOrdinarySiteDeviceDriver.setAgvphase(phase); if (ObjectUtil.isNotEmpty(standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait")) - && StrUtil.equals("true", standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait").toString()) - && StrUtil.equals(task.getTask_type(), "1")) { + && StrUtil.equals("true", standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait").toString())) { if (standardOrdinarySiteDeviceDriver.getOption() == 1) { standardOrdinarySiteDeviceDriver.setAgvphase(0); String task_code = standardOrdinarySiteDeviceDriver.getTask_code(); @@ -501,7 +500,6 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic log.info("等待LMS系统进行确认允许取货,设备号{},指令号{}", device_code, ikey); message = "等待LMS系统进行确认允许取货,设备号:" + device_code + ",指令号:" + ikey; logServer.deviceExecuteLog(this.device_code, "", "", "等待LMS系统进行确认允许取货,设备号" + device.getDevice_code()); - } }else { data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); @@ -616,8 +614,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); if (ObjectUtil.isNotEmpty(standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait")) - && StrUtil.equals("true", standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait").toString()) - && StrUtil.equals(task.getTask_type(), "1")) { + && StrUtil.equals("true", standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait").toString())) { standardOrdinarySiteDeviceDriver.setOption(0); }else { data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java index 4cb4aae0b..dbf493d14 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java @@ -511,8 +511,14 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements if (ObjectUtil.isEmpty(inst)) { return false; } + String interactionJson = taskDto.getInteraction_json(); + InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); + String containerType = ""; + if (ObjectUtil.isNotEmpty(interactionJsonDTO)) { + containerType = interactionJsonDTO.getContainerType(); + } List list = new ArrayList(); - writeData(next_addr, list, inst); + writeData(next_addr, list, inst,containerType); // led_message = getLedMessage(inst); requireSucess = true; return true; @@ -675,14 +681,20 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements taskserver.update(taskdto); requireSucess = true; String next_addr = nextdevice.getExtraValue().get("address").toString(); + String interactionJson = taskdto.getInteraction_json(); + InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); + String containerType = ""; + if (ObjectUtil.isNotEmpty(interactionJsonDTO)) { + containerType = interactionJsonDTO.getContainerType(); + } List list = new ArrayList(); - writeData(next_addr, list, instdto); + writeData(next_addr, list, instdto, containerType); // led_message = getLedMessage(instdto); requireSucess = true; return true; } - private void writeData(String next_addr, List list, Instruction inst) { + private void writeData(String next_addr, List list, Instruction inst,String containerType) { List list1 = new ArrayList(); Map map = new HashMap(); map.put("code", "to_target"); @@ -698,7 +710,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements List list4 = new ArrayList(); Map map3 = new HashMap(); map3.put("code", "to_container_type"); - map3.put("value", inst.getVehicle_type()); + map3.put("value", containerType); list4.add(map3); this.writing(list4); List list3 = new ArrayList(); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java index 2a9e7bc89..fbd4ba383 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java @@ -130,8 +130,8 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv int last_hj_task = 0; //重量 - int weight = 0; - int last_weight = 0; + Float weight = 0.0F; + Float last_weight = 0.0F; //托盘条码 String barcode = null; @@ -533,7 +533,6 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv packageInstrcutData(instdto, taskdto, taskid, taskcode, vehiclecode, priority,start_device_code,next_device_code,containerType); }else { - packageInstrcutData(instdto, taskdto, taskid, taskcode, vehiclecode, priority, taskdto.getStart_device_code(), taskdto.getNext_device_code(),containerType); } try { @@ -561,7 +560,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv list.add(map2); Map map3 = new HashMap(); map3.put("code", "to_container_type"); - map3.put("value", instdto.getVehicle_type()); + map3.put("value", containerType); list.add(map3); Map map4 = new HashMap(); map3.put("code", "to_command"); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ItemProtocol.java index 092dfa643..9295ff0e3 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ItemProtocol.java @@ -129,8 +129,8 @@ public class ItemProtocol { return this.getOpcStringValue(item_material_barcode); } - public int getWeight(){ - return this.getOpcIntegerValue(item_weight); + public Float getWeight(){ + return this.getOpcFloatValue(item_weight); } public int getTo_task() { return this.getOpcIntegerValue(item_to_task); @@ -179,6 +179,20 @@ public class ItemProtocol { return 0; } + + public float getOpcFloatValue(String protocol) { + Float value = this.driver.getDoubleValue(protocol); + if (value == null) { + // log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + setIsonline(false); + } else { + setIsonline(true); + return value; + } + return 0; + + } + public static List getReadableItemDtos() { ArrayList list = new ArrayList<>(); list.add(new ItemDto(item_heartbeat, "心跳", "DB1.B0")); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_storage_manipulator/BoxStorageManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_storage_manipulator/BoxStorageManipulatorDeviceDriver.java index 856fa85f2..0e176481a 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_storage_manipulator/BoxStorageManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_storage_manipulator/BoxStorageManipulatorDeviceDriver.java @@ -76,6 +76,7 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i int last_mode = 0; int move = 0; int action = 0; + int last_action = 0; int error = 0; int task = 0; int heartbeat = 0; @@ -99,6 +100,7 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i private int instruction_require_time_out = 3000; //行架机械手申请任务成功标识 boolean requireSucess = false; + boolean requireActionSucess = false; private int instruction_finished_time_out; @@ -149,11 +151,13 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i to_barcode = this.itemProtocol.getTo_barcode(); if (mode != last_mode) { - requireSucess = false; } + if(action == last_action){ + requireActionSucess = false; + } // 更新指令状态 - if (mode == 3 && task > 0) { + if (mode == 3 && task > 0 && !requireActionSucess) { updateInstructionStatus(); } @@ -214,6 +218,7 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i } last_mode =mode; + last_action = action; } @@ -247,6 +252,7 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i map1.put("value", 5); list.add(map1); this.writing(list); + requireActionSucess = true; message = "universal_message1"; } catch (Exception e) { message = "universal_message2"; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/InflatableShaftLibraryDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/InflatableShaftLibraryDeviceDriver.java index 978abdc7a..75d8cbe0f 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/InflatableShaftLibraryDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/InflatableShaftLibraryDeviceDriver.java @@ -113,6 +113,7 @@ public class InflatableShaftLibraryDeviceDriver extends AbstractOpcDeviceDriver requireSucess = false; } + lastMode = mode; lastMove = move; lastAction = action; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/ItemProtocol.java index d628151a1..0f4496203 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/ItemProtocol.java @@ -13,11 +13,11 @@ import java.util.List; public class ItemProtocol { public static String item_heartbeat = "heartbeat"; public static String item_mode = "mode"; - public static String item_move = "move"; - public static String item_action = "action"; + public static String item_move = "move1"; + public static String item_action = "action1"; public static String item_error = "error"; public static String item_qty = "qty"; - public static String item_type = "type"; + public static String item_type = "type1"; public static String item_to_command = "to_command"; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/PullHeadManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/PullHeadManipulatorDeviceDriver.java index 383ee61f7..8771de923 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/PullHeadManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/PullHeadManipulatorDeviceDriver.java @@ -454,73 +454,82 @@ public class PullHeadManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp @NotNull private Map toStringObjectMap(Instruction instdto, String startAddr, String nextAddr, String interaction_json) { - JSONObject jsonObject = JSONObject.parseObject(interaction_json); - //套管1物料 - Object to_material1 = jsonObject.get("left"); - //套管2物料 - Object to_material2 = jsonObject.get("right"); - //套管1规格 - Object to_spec1 = jsonObject.get("leftSpec"); - //套管2规格 - Object to_spec2 = jsonObject.get("rightSpec"); - //套管1尺寸 - Object to_size1 = jsonObject.get("leftSize"); - //套管2尺寸 - Object to_size2 = jsonObject.get("rightSize"); - //拔管1物料 - Object to_material3 = jsonObject.get("currentLeft"); - //拔管2物料 - Object to_material4 = jsonObject.get("currentRight"); - //拔管1尺寸 - Object to_size3 = jsonObject.get("currentLeftSize"); - //拔管2尺寸 - Object to_size4 = jsonObject.get("currentRightSize"); - //拔管1规格 - Object to_spec3 = jsonObject.get("currentLeftSpec"); - //拔管2规格 - Object to_spec4 = jsonObject.get("currentRightSpec"); - - //套管数量 - Object to_qty1 = jsonObject.get("casingCount"); - //拔管数量 - Object to_qty2 = jsonObject.get("pullCount"); Map map = new LinkedHashMap<>(); - map.put("to_pull", jsonObject.getString("is_pulling")); - map.put("is_bushing", jsonObject.getString("is_bushing")); - map.put("to_size", jsonObject.getString("qzz_size")); - map.put("to_barcode", jsonObject.getString("qzz_no")); - map.put("to_command", CommonFinalParam.ONE); - map.put("to_onset", startAddr); - map.put("to_task", instdto.getInstruction_code()); - map.put("to_target", nextAddr); - //toTranscription(taskDto,map); - map.put("to_material1", to_material1); - if (ObjectUtil.isNotEmpty(to_material2)) { - map.put("to_material2", to_material2); + if(StrUtil.isNotEmpty(interaction_json) && !"".equals(interaction_json)){ + JSONObject jsonObject = JSONObject.parseObject(interaction_json); + //套管1物料 + Object to_material1 = jsonObject.get("left"); + //套管2物料 + Object to_material2 = jsonObject.get("right"); + //套管1规格 + Object to_spec1 = jsonObject.get("leftSpec"); + //套管2规格 + Object to_spec2 = jsonObject.get("rightSpec"); + //套管1尺寸 + Object to_size1 = jsonObject.get("leftSize"); + //套管2尺寸 + Object to_size2 = jsonObject.get("rightSize"); + //拔管1物料 + Object to_material3 = jsonObject.get("currentLeft"); + //拔管2物料 + Object to_material4 = jsonObject.get("currentRight"); + //拔管1尺寸 + Object to_size3 = jsonObject.get("currentLeftSize"); + //拔管2尺寸 + Object to_size4 = jsonObject.get("currentRightSize"); + //拔管1规格 + Object to_spec3 = jsonObject.get("currentLeftSpec"); + //拔管2规格 + Object to_spec4 = jsonObject.get("currentRightSpec"); + + //套管数量 + Object to_qty1 = jsonObject.get("casingCount"); + //拔管数量 + Object to_qty2 = jsonObject.get("pullCount"); + + map.put("to_pull", jsonObject.getString("is_pulling")); + map.put("is_bushing", jsonObject.getString("is_bushing")); + map.put("to_size", jsonObject.getString("qzz_size")); + map.put("to_barcode", jsonObject.getString("qzz_no")); + map.put("to_command", CommonFinalParam.ONE); + map.put("to_onset", startAddr); + map.put("to_task", instdto.getInstruction_code()); + map.put("to_target", nextAddr); + //toTranscription(taskDto,map); + map.put("to_material1", to_material1); + if (ObjectUtil.isNotEmpty(to_material2)) { + map.put("to_material2", to_material2); + } + map.put("to_spec1", to_spec1); + if (ObjectUtil.isNotEmpty(to_spec2)) { + map.put("to_spec2", to_spec2); + } + map.put("to_size1", to_size1); + if (ObjectUtil.isNotEmpty(to_size2)) { + map.put("to_size2", to_size2); + } + map.put("to_material3", to_material3); + if (ObjectUtil.isNotEmpty(to_material4)) { + map.put("to_material4", to_material4); + } + map.put("to_size3", to_size3); + if (ObjectUtil.isNotEmpty(to_size4)) { + map.put("to_size4", to_size4); + } + map.put("to_spec3", to_spec3); + if (ObjectUtil.isNotEmpty(to_spec4)) { + map.put("to_spec4", to_spec4); + } + map.put("to_qty1", to_qty1); + map.put("to_qty2", to_qty2); + return map; + }else{ + map.put("to_command", CommonFinalParam.ONE); + map.put("to_onset", startAddr); + map.put("to_task", instdto.getInstruction_code()); + map.put("to_target", nextAddr); + return map; } - map.put("to_spec1", to_spec1); - if (ObjectUtil.isNotEmpty(to_spec2)) { - map.put("to_spec2", to_spec2); - } - map.put("to_size1", to_size1); - if (ObjectUtil.isNotEmpty(to_size2)) { - map.put("to_size2", to_size2); - } - map.put("to_material3", to_material3); - if (ObjectUtil.isNotEmpty(to_material4)) { - map.put("to_material4", to_material4); - } - map.put("to_size3", to_size3); - if (ObjectUtil.isNotEmpty(to_size4)) { - map.put("to_size4", to_size4); - } - map.put("to_spec3", to_spec3); - if (ObjectUtil.isNotEmpty(to_spec4)) { - map.put("to_spec4", to_spec4); - } - map.put("to_qty1", to_qty1); - map.put("to_qty2", to_qty2); - return map; } private void toTranscription(TaskDto taskDto,Map map){