From 7f27dbd120865c34c58a334d8fea3dc53be353b8 Mon Sep 17 00:00:00 2001 From: loujf Date: Tue, 2 Aug 2022 19:34:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=B7=E9=87=8F=E4=B8=89=E4=B8=AA=E6=96=B0?= =?UTF-8?q?=E9=A9=B1=E5=8A=A8=E5=88=9B=E5=BB=BA=EF=BC=8C=E5=AF=BC=E5=87=BA?= =?UTF-8?q?smartCSV=E6=96=87=E4=BB=B6=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/HailiangElevatorWiringDevice.java | 52 ++ .../HailiangFoldingDiscSmartDevice.java | 42 ++ .../HailiangThreestationSmartDevice.java | 51 ++ .../device/device_driver/DriverTypeEnum.java | 6 +- .../nl/acs/device/rest/DeviceController.java | 8 +- .../nl/acs/device/service/DeviceService.java | 2 +- .../service/impl/DeviceServiceImpl.java | 11 +- .../HailiangElevatorWiringDefination.java | 73 +++ .../HailiangElevatorWiringDeviceDriver.java | 252 +++++++++ .../ItemProtocol.java | 107 ++++ .../HailiangFoldingDiscSmartDefination.java | 73 +++ .../HailiangFoldingDiscSmartDeviceDriver.java | 252 +++++++++ .../ItemProtocol.java | 107 ++++ .../HailiangThreestationSmartDefination.java | 73 +++ ...HailiangThreestationSmartDeviceDriver.java | 263 ++++++++++ .../ItemProtocol.java | 107 ++++ .../service/impl/StageActorServiceImpl.java | 74 +++ wcs/qd/src/views/acs/device/config.vue | 5 +- .../hailiang_one/hailiang_elevator_wiring.vue | 487 ++++++++++++++++++ .../hailiang_foldingDisc_smart.vue | 487 ++++++++++++++++++ .../hailiang_threestation_smart.vue | 487 ++++++++++++++++++ .../src/views/acs/device/protocol/index.vue | 21 + 22 files changed, 3030 insertions(+), 10 deletions(-) create mode 100644 wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangElevatorWiringDevice.java create mode 100644 wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangFoldingDiscSmartDevice.java create mode 100644 wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangThreestationSmartDevice.java create mode 100644 wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_elevator_wiring/HailiangElevatorWiringDefination.java create mode 100644 wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_elevator_wiring/HailiangElevatorWiringDeviceDriver.java create mode 100644 wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_elevator_wiring/ItemProtocol.java create mode 100644 wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_foldingDisc_smart/HailiangFoldingDiscSmartDefination.java create mode 100644 wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_foldingDisc_smart/HailiangFoldingDiscSmartDeviceDriver.java create mode 100644 wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_foldingDisc_smart/ItemProtocol.java create mode 100644 wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_threeStation_smart/HailiangThreestationSmartDefination.java create mode 100644 wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_threeStation_smart/HailiangThreestationSmartDeviceDriver.java create mode 100644 wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_threeStation_smart/ItemProtocol.java create mode 100644 wcs/qd/src/views/acs/device/driver/hailiang_one/hailiang_elevator_wiring.vue create mode 100644 wcs/qd/src/views/acs/device/driver/hailiang_one/hailiang_foldingDisc_smart.vue create mode 100644 wcs/qd/src/views/acs/device/driver/hailiang_one/hailiang_threestation_smart.vue diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangElevatorWiringDevice.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangElevatorWiringDevice.java new file mode 100644 index 00000000..e41fce37 --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangElevatorWiringDevice.java @@ -0,0 +1,52 @@ +package org.nl.acs.common; + +import com.alibaba.fastjson.JSONObject; +import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_elevator_wiring.HailiangElevatorWiringDeviceDriver; +import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_engraving_cache.HailiangEngravingCacheDeviceDriver; +import org.nl.acs.opc.Device; +import org.nl.acs.stage.service.utils.StageActorUtil; +import org.springframework.stereotype.Service; + +@Service("hailiang_elevator_wiring") +public class HailiangElevatorWiringDevice extends AbstractDriverService { + + @Override + public JSONObject getDeviceInfo(Device device) { + HailiangElevatorWiringDeviceDriver hailiangElevatorWiringDeviceDriver = (HailiangElevatorWiringDeviceDriver) device.getDeviceDriver(); + JSONObject jo = super.getCommonDeviceInfo(hailiangElevatorWiringDeviceDriver); + + String mode = ""; + String move = ""; + String action = ""; + if (hailiangElevatorWiringDeviceDriver.getMode() == 0) { + mode = "脱机"; + } else if (hailiangElevatorWiringDeviceDriver.getMode() == 2) { + mode = "待机"; + } else if (hailiangElevatorWiringDeviceDriver.getMode() == 3) { + mode = "运行中"; + } + if (hailiangElevatorWiringDeviceDriver.getMove() == 0) { + move = "无货"; + } else if (hailiangElevatorWiringDeviceDriver.getMove() == 1) { + move = "有货"; + } + if (hailiangElevatorWiringDeviceDriver.getAction() == 0) { + action = "禁止取放"; + } else if (hailiangElevatorWiringDeviceDriver.getAction() == 1) { + action = "允许取货"; + } else if (hailiangElevatorWiringDeviceDriver.getAction() == 2) { + action = "允许放货"; + } else if (hailiangElevatorWiringDeviceDriver.getAction() == 3) { + action = "允许取放"; + } + jo.put("mode", mode); + jo.put("move", move); + jo.put("action", action); + jo.put("hasGoods", hailiangElevatorWiringDeviceDriver.getHasGoods()); + jo.put("isOnline", hailiangElevatorWiringDeviceDriver.getIsonline()); + jo.put("error", hailiangElevatorWiringDeviceDriver.getError()); + jo.put("isError", hailiangElevatorWiringDeviceDriver.getIserror()); + jo.put("message", hailiangElevatorWiringDeviceDriver.getMessage()); + return jo; + } +} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangFoldingDiscSmartDevice.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangFoldingDiscSmartDevice.java new file mode 100644 index 00000000..ff1383f4 --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangFoldingDiscSmartDevice.java @@ -0,0 +1,42 @@ +package org.nl.acs.common; + +import com.alibaba.fastjson.JSONObject; +import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_elevator_wiring.HailiangElevatorWiringDeviceDriver; +import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_foldingDisc_smart.HailiangFoldingDiscSmartDeviceDriver; +import org.nl.acs.opc.Device; +import org.springframework.stereotype.Service; + +@Service("hailiang_foldingDisc_smart") +public class HailiangFoldingDiscSmartDevice extends AbstractDriverService { + + @Override + public JSONObject getDeviceInfo(Device device) { + HailiangFoldingDiscSmartDeviceDriver hailiangFoldingDiscSmartDeviceDriver = (HailiangFoldingDiscSmartDeviceDriver) device.getDeviceDriver(); + JSONObject jo = super.getCommonDeviceInfo(hailiangFoldingDiscSmartDeviceDriver); + + String mode = ""; + String move = ""; + + if (hailiangFoldingDiscSmartDeviceDriver.getMode() == 0) { + mode = "脱机"; + } else if (hailiangFoldingDiscSmartDeviceDriver.getMode() == 2) { + mode = "待机"; + } else if (hailiangFoldingDiscSmartDeviceDriver.getMode() == 3) { + mode = "运行中"; + } + if (hailiangFoldingDiscSmartDeviceDriver.getMove() == 0) { + move = "无货"; + } else if (hailiangFoldingDiscSmartDeviceDriver.getMove() == 1) { + move = "有货"; + } + jo.put("mode", mode); + jo.put("move", move); + jo.put("number", hailiangFoldingDiscSmartDeviceDriver.getNumber()); + jo.put("hasGoods", hailiangFoldingDiscSmartDeviceDriver.getHasGoods()); + jo.put("isOnline", hailiangFoldingDiscSmartDeviceDriver.getIsonline()); + jo.put("error", hailiangFoldingDiscSmartDeviceDriver.getError()); + jo.put("isError", hailiangFoldingDiscSmartDeviceDriver.getIserror()); + jo.put("message", hailiangFoldingDiscSmartDeviceDriver.getMessage()); + return jo; + } +} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangThreestationSmartDevice.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangThreestationSmartDevice.java new file mode 100644 index 00000000..884b896d --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/common/HailiangThreestationSmartDevice.java @@ -0,0 +1,51 @@ +package org.nl.acs.common; + +import com.alibaba.fastjson.JSONObject; +import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_elevator_wiring.HailiangElevatorWiringDeviceDriver; +import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_threeStation_smart.HailiangThreestationSmartDeviceDriver; +import org.nl.acs.opc.Device; +import org.springframework.stereotype.Service; + +@Service("hailiang_threestation_smart") +public class HailiangThreestationSmartDevice extends AbstractDriverService { + + @Override + public JSONObject getDeviceInfo(Device device) { + HailiangThreestationSmartDeviceDriver threestationSmartDeviceDriver = (HailiangThreestationSmartDeviceDriver) device.getDeviceDriver(); + JSONObject jo = super.getCommonDeviceInfo(threestationSmartDeviceDriver); + + String mode = ""; + String move = ""; + String action = ""; + if (threestationSmartDeviceDriver.getMode() == 0) { + mode = "脱机"; + } else if (threestationSmartDeviceDriver.getMode() == 2) { + mode = "待机"; + } else if (threestationSmartDeviceDriver.getMode() == 3) { + mode = "运行中"; + } + if (threestationSmartDeviceDriver.getMove() == 0) { + move = "无货"; + } else if (threestationSmartDeviceDriver.getMove() == 1) { + move = "有货"; + } + if (threestationSmartDeviceDriver.getAction() == 0) { + action = "禁止取放"; + } else if (threestationSmartDeviceDriver.getAction() == 1) { + action = "允许取货"; + } else if (threestationSmartDeviceDriver.getAction() == 2) { + action = "允许放货"; + } else if (threestationSmartDeviceDriver.getAction() == 3) { + action = "允许取放"; + } + jo.put("mode", mode); + jo.put("move", move); + jo.put("action", action); + jo.put("hasGoods", threestationSmartDeviceDriver.getHasGoods()); + jo.put("isOnline", threestationSmartDeviceDriver.getIsonline()); + jo.put("error", threestationSmartDeviceDriver.getError()); + jo.put("isError", threestationSmartDeviceDriver.getIserror()); + jo.put("message", threestationSmartDeviceDriver.getMessage()); + return jo; + } +} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java index 81925b28..330e7d61 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java @@ -63,9 +63,13 @@ public enum DriverTypeEnum { HAILIANG_XJ_PLC_TEST(27, "hailiang_xj_plc_test", "海亮-信捷PLC", "conveyor"), - HAILIANG_SMART_PLC_TEST(28, "hailiang_smart_plc_test", "海亮-西门子SMART200PLC", "conveyor"); + HAILIANG_SMART_PLC_TEST(28, "hailiang_smart_plc_test", "海亮-西门子SMART200PLC", "conveyor"), + HAILIANG_THREESTATION_SMART(29, "hailiang_threestation_smart", "海亮-三工位Smart200", "conveyor"), + HAILIANG_FOLDINGDISC_SMART(30, "hailiang_foldingDisc_smart", "海亮-叠盘位Smart200", "conveyor"), + + HAILIANG_ELEVATOR_WIRING(31, "hailiang_elevator_wiring", "海亮-货梯对接线", "conveyor"); //驱动索引 private int index; diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/rest/DeviceController.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/rest/DeviceController.java index c973d9cb..857a9d8a 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/rest/DeviceController.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/rest/DeviceController.java @@ -73,12 +73,12 @@ public class DeviceController { deviceService.downDeviceDBloadCSV(deviceService.queryDeviceProtocol(whereJson), response); } - @Log("导出欧姆龙设备协议CSV") - @ApiOperation("导出欧姆龙设备协议CSV") - @GetMapping(value = "/protocol/downloadoumulongCSV") + @Log("导出Smart设备协议CSV") + @ApiOperation("导出Smart设备协议CSV") + @GetMapping(value = "/protocol/downloadSmartCSV") //@PreAuthorize("@el.check('device:list')") public void downDeviceDBloadOumulongCSV(HttpServletResponse response, @RequestParam Map whereJson) throws IOException { - deviceService.downDeviceDBloadOumulongCSV(deviceService.queryDeviceProtocol(whereJson), response); + deviceService.downDeviceDBloadSmartCSV(deviceService.queryDeviceProtocol(whereJson), response); } @PostMapping diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/service/DeviceService.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/service/DeviceService.java index ac201f58..8f37a03f 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/service/DeviceService.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/service/DeviceService.java @@ -240,7 +240,7 @@ public interface DeviceService { void downDeviceDBloadCSV(JSONArray queryDeviceProtocol, HttpServletResponse response); - void downDeviceDBloadOumulongCSV(JSONArray queryDeviceProtocol, HttpServletResponse response); + void downDeviceDBloadSmartCSV(JSONArray queryDeviceProtocol, HttpServletResponse response); JSONArray selectDeviceListByType(String type); diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java index 79402867..45f1fb56 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java @@ -1455,7 +1455,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial } @Override - public void downDeviceDBloadOumulongCSV(JSONArray jsonarr, HttpServletResponse response) { + public void downDeviceDBloadSmartCSV(JSONArray jsonarr, HttpServletResponse response) { List cellList = new ArrayList<>(); for (int i = 0; i < jsonarr.size(); i++) { List item = new ArrayList(); @@ -1473,8 +1473,13 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial item.add(jo.get("extra_name")); String datatype = jo.getString("extra_name"); //西门子200 - if (datatype.indexOf(".") == -1) { - datatype = "Word"; + if (!datatype.contains(".")) { + String[] split = datatype.split(""); + if (split[1].equals("W")) { + datatype = "Word"; + } else if (split[1].equals("D")) { + datatype = "DWord"; + } } else { datatype = "Boolean"; } diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_elevator_wiring/HailiangElevatorWiringDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_elevator_wiring/HailiangElevatorWiringDefination.java new file mode 100644 index 00000000..0c3534c7 --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_elevator_wiring/HailiangElevatorWiringDefination.java @@ -0,0 +1,73 @@ +package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_elevator_wiring; + +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; +import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceType; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +/** + * 海亮-货梯对接线 + */ +@Service +public class HailiangElevatorWiringDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "hailiang_elevator_wiring"; + } + + @Override + public String getDriverName() { + return "海亮-货梯对接线"; + } + + @Override + public String getDriverDescription() { + return "海亮-货梯对接线"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new HailiangElevatorWiringDeviceDriver()).setDevice(device).setDriverDefination(this); + + } + + @Override + public Class getDeviceDriverType() { + return HailiangElevatorWiringDeviceDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList(); + types.add(DeviceType.conveyor); + return types; + } + + @Override + public List getReadableItemDtos() { + return getReadableItemDtos2(); + } + + public static List getReadableItemDtos2() { + List list = new ArrayList(); + list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "VW0")); + list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "VW2", Boolean.valueOf(true))); + list.add(new ItemDto(ItemProtocol.item_move, "光电信号", "VW4")); + list.add(new ItemDto(ItemProtocol.item_action, "取放信号", "VW6")); + list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "VW8")); + list.add(new ItemDto(ItemProtocol.item_task, "任务号", "VD10")); + return list; + } + + @Override + public List getWriteableItemDtos() { + return ItemProtocol.getWriteableItemDtos(); + } + +} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_elevator_wiring/HailiangElevatorWiringDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_elevator_wiring/HailiangElevatorWiringDeviceDriver.java new file mode 100644 index 00000000..aea7c06b --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_elevator_wiring/HailiangElevatorWiringDeviceDriver.java @@ -0,0 +1,252 @@ +package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_elevator_wiring; + +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; +import org.nl.acs.device.service.DeviceService; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.RouteableDeviceDriver; +import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; +import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.instruction.service.InstructionService; +import org.nl.acs.instruction.service.dto.Instruction; +import org.nl.acs.log.service.LogServer; +import org.nl.acs.opc.Device; +import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.task.service.TaskService; +import org.nl.utils.SpringContextHolder; +import org.openscada.opc.lib.da.Server; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 海亮-货梯对接线 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class HailiangElevatorWiringDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { + protected ItemProtocol itemProtocol = new ItemProtocol(this); + @Autowired + InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); + @Autowired + DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); + @Autowired + RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); + @Autowired + TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); + @Autowired + LogServer logServer = SpringContextHolder.getBean(LogServer.class); + String container; + String container_type_desc; + String last_container_type_desc; + String last_container; + //放货准备锁 + String putReadyLock = null; + //有货标记 + protected boolean has_goods_tag = false; + + int mode = 0; + int error = 0; + int move = 0; + int task = 0; + int action = 0; + int last_mode = 0; + int last_error = 0; + int last_move = 0; + int last_task = 0; + int last_action = 0; + Boolean isonline = true; + int hasGoods = 0; + String message = null; + Boolean iserror = false; + + + boolean hasVehicle = false; + boolean isReady = false; + protected int instruction_num = 0; + protected int instruction_num_truth = 0; + boolean isFold = false; + private String assemble_check_tag; + + protected String current_stage_instruction_message; + protected String last_stage_instruction_message; + Integer heartbeat_tag; + private Date instruction_require_time = new Date(); + private Date instruction_finished_time = new Date(); + + private int instruction_require_time_out; + boolean requireSucess = false; + + private int instruction_finished_time_out; + + int branchProtocol = 0; + //备注 + String remark; + //物料 + String material; + //当前指令 + Instruction inst = null; + //上次指令 + Instruction last_inst = null; + + //触摸屏手动触发任务 + private Boolean is_has_task = false; + + //申请搬运任务 + private Boolean apply_handling = false; + //申请物料 + private Boolean apply_material = false; + + //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 + int flag; + + String device_code; + + @Override + public Device getDevice() { + return this.device; + } + + + @Override + public void execute() { + String message = null; + try { + device_code = this.getDeviceCode(); + mode = this.itemProtocol.getMode(); + error = this.itemProtocol.getError(); + action = this.itemProtocol.getAction(); + move = this.itemProtocol.getMove(); + task = this.itemProtocol.getTask(); + hasGoods = this.itemProtocol.getMove(); + + if (mode != last_mode) { + this.setRequireSucess(false); + logServer.deviceLog(this.device_code,"mode" ,String.valueOf(mode)); + logServer.deviceLogToacs(this.device_code,"","","信号mode:" + last_mode + "->" + mode); + } + if (move != last_move) { + logServer.deviceLog(this.device_code,"move" ,String.valueOf(move)); + logServer.deviceLogToacs(this.device_code,"","","信号move:" + last_move + "->" + move); + } + if (error != last_error) { + logServer.deviceLog(this.device_code,"error" ,String.valueOf(error)); + logServer.deviceLogToacs(this.device_code,"","","信号error:" + last_error + "->" + error); + } + if (action != last_action) { + logServer.deviceLog(this.device_code,"action" ,String.valueOf(action)); + logServer.deviceLogToacs(this.device_code,"","","信号action:" + last_action + "->" + action); + } + + } catch (Exception var17) { + return; + } + + if (!this.itemProtocol.getIsonline()) { + this.setIsonline(false); + this.setIserror(true); + message = "信号量同步异常"; + //未联机 + } else if (mode == 0) { + this.setIsonline(false); + this.setIserror(true); + message = "未联机"; + //有报警 + } else if (error != 0) { + this.setIsonline(false); + this.setIserror(true); + message = "有报警"; + //无报警 + } else { + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + switch (mode) { + case 1: + log.debug("设备运转模式:等待工作"); + return; + case 2: + break; + } + + switch (flag) { + //取货完成 + case 1: + writing(2); + return; + //放货完成 + case 2: + writing(3); + return; + + } + + } + last_mode = mode; + last_error = error; + last_move = move; + last_task = task; + last_action = action; + } + + + public boolean exe_error() { + if (this.error == 0) { + return true; + } else { + log.debug("设备报警"); + return false; + } + } + + + public boolean exe_business() { + return true; + } + + public void executing(Server server, Map itemMap) { + ReadUtil.write(itemMap, server); + } + + public void writing(int command) { + String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + 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_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 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); + } + ReadUtil.write(itemMap, server); + + } +} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_elevator_wiring/ItemProtocol.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_elevator_wiring/ItemProtocol.java new file mode 100644 index 00000000..1c7e841b --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_elevator_wiring/ItemProtocol.java @@ -0,0 +1,107 @@ +package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_elevator_wiring; + +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; + +import java.util.ArrayList; +import java.util.List; + +@Slf4j +@Data +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_error = "error"; + public static String item_task = "task"; + 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_weight = "weight"; + + private HailiangElevatorWiringDeviceDriver driver; + + public ItemProtocol(HailiangElevatorWiringDeviceDriver driver) { + this.driver = driver; + } + + public int getHeartbeat() { + return this.getOpcIntegerValue(item_heartbeat); + } + + public int getMode() { + return this.getOpcIntegerValue(item_mode); + } + + public int getMove() { + return this.getOpcIntegerValue(item_move); + } + + public int getAction() { + return this.getOpcIntegerValue(item_action); + } + + public int getError() { + return this.getOpcIntegerValue(item_error); + } + + public int getTask() { + return this.getOpcIntegerValue(item_task); + } + + 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 hasGoods(int move) { + return move; + } + + Boolean isonline; + + public int getOpcIntegerValue(String protocol) { + Integer value = this.driver.getIntegeregerValue(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, "心跳", "VW0")); + list.add(new ItemDto(item_mode, "工作状态", "VW2", Boolean.valueOf(true))); + list.add(new ItemDto(item_move, "光电信号", "VW4")); + list.add(new ItemDto(item_action, "取放信号", "VW6")); + list.add(new ItemDto(item_error, "报警信号", "VW8")); + list.add(new ItemDto(item_task, "任务号", "VD10")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_to_command, "作业命令", "VW102", Boolean.valueOf(true))); + list.add(new ItemDto(item_to_target, "目标站", "VW104")); + list.add(new ItemDto(item_to_task, "任务号", "VD108")); + return list; + } + +} + diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_foldingDisc_smart/HailiangFoldingDiscSmartDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_foldingDisc_smart/HailiangFoldingDiscSmartDefination.java new file mode 100644 index 00000000..688a669d --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_foldingDisc_smart/HailiangFoldingDiscSmartDefination.java @@ -0,0 +1,73 @@ +package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_foldingDisc_smart; + +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; +import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceType; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +/** + * 海亮-叠盘位Smart200 + */ +@Service +public class HailiangFoldingDiscSmartDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "hailiang_foldingDisc_smart"; + } + + @Override + public String getDriverName() { + return "海亮-叠盘位Smart200"; + } + + @Override + public String getDriverDescription() { + return "海亮-叠盘位Smart200"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new HailiangFoldingDiscSmartDeviceDriver()).setDevice(device).setDriverDefination(this); + + } + + @Override + public Class getDeviceDriverType() { + return HailiangFoldingDiscSmartDeviceDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList(); + types.add(DeviceType.conveyor); + return types; + } + + @Override + public List getReadableItemDtos() { + return getReadableItemDtos2(); + } + + public static List getReadableItemDtos2() { + List list = new ArrayList(); + list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "VW0")); + list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "VW2", Boolean.valueOf(true))); + list.add(new ItemDto(ItemProtocol.item_move, "光电信号", "VW4")); + list.add(new ItemDto(ItemProtocol.item_number, "数量", "VW6")); + list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "VW10")); + list.add(new ItemDto(ItemProtocol.item_task, "任务号", "VD12")); + return list; + } + + @Override + public List getWriteableItemDtos() { + return ItemProtocol.getWriteableItemDtos(); + } + +} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_foldingDisc_smart/HailiangFoldingDiscSmartDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_foldingDisc_smart/HailiangFoldingDiscSmartDeviceDriver.java new file mode 100644 index 00000000..7ee22c14 --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_foldingDisc_smart/HailiangFoldingDiscSmartDeviceDriver.java @@ -0,0 +1,252 @@ +package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_foldingDisc_smart; + +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; +import org.nl.acs.device.service.DeviceService; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.RouteableDeviceDriver; +import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; +import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.instruction.service.InstructionService; +import org.nl.acs.instruction.service.dto.Instruction; +import org.nl.acs.log.service.LogServer; +import org.nl.acs.opc.Device; +import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.task.service.TaskService; +import org.nl.utils.SpringContextHolder; +import org.openscada.opc.lib.da.Server; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 海亮-叠盘位Smart200 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class HailiangFoldingDiscSmartDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { + protected ItemProtocol itemProtocol = new ItemProtocol(this); + @Autowired + InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); + @Autowired + DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); + @Autowired + RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); + @Autowired + TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); + @Autowired + LogServer logServer = SpringContextHolder.getBean(LogServer.class); + String container; + String container_type_desc; + String last_container_type_desc; + String last_container; + //放货准备锁 + String putReadyLock = null; + //有货标记 + protected boolean has_goods_tag = false; + + int mode = 0; + int error = 0; + int move = 0; + int task = 0; + int number = 0; + int last_mode = 0; + int last_error = 0; + int last_move = 0; + int last_task = 0; + int last_number = 0; + Boolean isonline = true; + int hasGoods = 0; + String message = null; + Boolean iserror = false; + + + boolean hasVehicle = false; + boolean isReady = false; + protected int instruction_num = 0; + protected int instruction_num_truth = 0; + boolean isFold = false; + private String assemble_check_tag; + + protected String current_stage_instruction_message; + protected String last_stage_instruction_message; + Integer heartbeat_tag; + private Date instruction_require_time = new Date(); + private Date instruction_finished_time = new Date(); + + private int instruction_require_time_out; + boolean requireSucess = false; + + private int instruction_finished_time_out; + + int branchProtocol = 0; + //备注 + String remark; + //物料 + String material; + //当前指令 + Instruction inst = null; + //上次指令 + Instruction last_inst = null; + + //触摸屏手动触发任务 + private Boolean is_has_task = false; + + //申请搬运任务 + private Boolean apply_handling = false; + //申请物料 + private Boolean apply_material = false; + + //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 + int flag; + + String device_code; + + @Override + public Device getDevice() { + return this.device; + } + + + @Override + public void execute() { + String message = null; + try { + device_code = this.getDeviceCode(); + mode = this.itemProtocol.getMode(); + error = this.itemProtocol.getError(); + number = this.itemProtocol.getNumber(); + move = this.itemProtocol.getMove(); + task = this.itemProtocol.getTask(); + hasGoods = this.itemProtocol.getMove(); + + if (mode != last_mode) { + this.setRequireSucess(false); + logServer.deviceLog(this.device_code,"mode" ,String.valueOf(mode)); + logServer.deviceLogToacs(this.device_code,"","","信号mode:" + last_mode + "->" + mode); + } + if (move != last_move) { + logServer.deviceLog(this.device_code,"move" ,String.valueOf(move)); + logServer.deviceLogToacs(this.device_code,"","","信号move:" + last_move + "->" + move); + } + if (error != last_error) { + logServer.deviceLog(this.device_code,"error" ,String.valueOf(error)); + logServer.deviceLogToacs(this.device_code,"","","信号error:" + last_error + "->" + error); + } + if (number != last_number) { + logServer.deviceLog(this.device_code,"action" ,String.valueOf(number)); + logServer.deviceLogToacs(this.device_code,"","","信号number:" + last_number + "->" + number); + } + + } catch (Exception var17) { + return; + } + + if (!this.itemProtocol.getIsonline()) { + this.setIsonline(false); + this.setIserror(true); + message = "信号量同步异常"; + //未联机 + } else if (mode == 0) { + this.setIsonline(false); + this.setIserror(true); + message = "未联机"; + //有报警 + } else if (error != 0) { + this.setIsonline(false); + this.setIserror(true); + message = "有报警"; + //无报警 + } else { + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + switch (mode) { + case 1: + log.debug("设备运转模式:等待工作"); + return; + case 2: + break; + } + + switch (flag) { + //取货完成 + case 1: + writing(2); + return; + //放货完成 + case 2: + writing(3); + return; + + } + + } + last_mode = mode; + last_error = error; + last_move = move; + last_task = task; + last_number = number; + } + + + public boolean exe_error() { + if (this.error == 0) { + return true; + } else { + log.debug("设备报警"); + return false; + } + } + + + public boolean exe_business() { + return true; + } + + public void executing(Server server, Map itemMap) { + ReadUtil.write(itemMap, server); + } + + public void writing(int command) { + String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + 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_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 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); + } + ReadUtil.write(itemMap, server); + + } +} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_foldingDisc_smart/ItemProtocol.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_foldingDisc_smart/ItemProtocol.java new file mode 100644 index 00000000..d03c2c87 --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_foldingDisc_smart/ItemProtocol.java @@ -0,0 +1,107 @@ +package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_foldingDisc_smart; + +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; + +import java.util.ArrayList; +import java.util.List; + +@Slf4j +@Data +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_number = "number"; + public static String item_error = "error"; + public static String item_task = "task"; + 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_weight = "weight"; + + private HailiangFoldingDiscSmartDeviceDriver driver; + + public ItemProtocol(HailiangFoldingDiscSmartDeviceDriver driver) { + this.driver = driver; + } + + public int getHeartbeat() { + return this.getOpcIntegerValue(item_heartbeat); + } + + public int getMode() { + return this.getOpcIntegerValue(item_mode); + } + + public int getMove() { + return this.getOpcIntegerValue(item_move); + } + + public int getNumber() { + return this.getOpcIntegerValue(item_number); + } + + public int getError() { + return this.getOpcIntegerValue(item_error); + } + + public int getTask() { + return this.getOpcIntegerValue(item_task); + } + + 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 hasGoods(int move) { + return move; + } + + Boolean isonline; + + public int getOpcIntegerValue(String protocol) { + Integer value = this.driver.getIntegeregerValue(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, "心跳", "VW0")); + list.add(new ItemDto(item_mode, "工作状态", "VW2", Boolean.valueOf(true))); + list.add(new ItemDto(item_move, "光电信号", "VW4")); + list.add(new ItemDto(item_number, "数量", "VW6")); + list.add(new ItemDto(item_error, "报警信号", "VW10")); + list.add(new ItemDto(item_task, "任务号", "VD12")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_to_command, "作业命令", "VW102", Boolean.valueOf(true))); + list.add(new ItemDto(item_to_target, "目标站", "VW104")); + list.add(new ItemDto(item_to_task, "任务号", "VD108")); + return list; + } + +} + diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_threeStation_smart/HailiangThreestationSmartDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_threeStation_smart/HailiangThreestationSmartDefination.java new file mode 100644 index 00000000..1d297608 --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_threeStation_smart/HailiangThreestationSmartDefination.java @@ -0,0 +1,73 @@ +package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_threeStation_smart; + +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; +import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceType; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +/** + * 海亮-三工位Smart200 + */ +@Service +public class HailiangThreestationSmartDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "hailiang_threestation_smart"; + } + + @Override + public String getDriverName() { + return "海亮-三工位Smart200"; + } + + @Override + public String getDriverDescription() { + return "海亮-三工位Smart200"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new HailiangThreestationSmartDeviceDriver()).setDevice(device).setDriverDefination(this); + + } + + @Override + public Class getDeviceDriverType() { + return HailiangThreestationSmartDeviceDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList(); + types.add(DeviceType.conveyor); + return types; + } + + @Override + public List getReadableItemDtos() { + return getReadableItemDtos2(); + } + + public static List getReadableItemDtos2() { + List list = new ArrayList(); + list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "VW0")); + list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "VW2", Boolean.valueOf(true))); + list.add(new ItemDto(ItemProtocol.item_move, "光电信号", "VW4")); + list.add(new ItemDto(ItemProtocol.item_action, "取放信号", "VW6")); + list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "VW8")); + list.add(new ItemDto(ItemProtocol.item_task, "任务号", "VD10")); + return list; + } + + @Override + public List getWriteableItemDtos() { + return ItemProtocol.getWriteableItemDtos(); + } + +} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_threeStation_smart/HailiangThreestationSmartDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_threeStation_smart/HailiangThreestationSmartDeviceDriver.java new file mode 100644 index 00000000..e140032c --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_threeStation_smart/HailiangThreestationSmartDeviceDriver.java @@ -0,0 +1,263 @@ +package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_threeStation_smart; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONObject; +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; +import org.nl.acs.device.service.DeviceService; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.RouteableDeviceDriver; +import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; +import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.instruction.service.InstructionService; +import org.nl.acs.instruction.service.dto.Instruction; +import org.nl.acs.log.service.LogServer; +import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceAppService; +import org.nl.acs.opc.DeviceAppServiceImpl; +import org.nl.acs.opc.WcsConfig; +import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.route.service.dto.RouteLineDto; +import org.nl.acs.task.service.TaskService; +import org.nl.acs.task.service.dto.TaskDto; +import org.nl.modules.system.util.CodeUtil; +import org.nl.utils.SpringContextHolder; +import org.nl.wql.core.bean.WQLObject; +import org.openscada.opc.lib.da.Server; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 海亮-三工位Smart200 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class HailiangThreestationSmartDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { + protected ItemProtocol itemProtocol = new ItemProtocol(this); + @Autowired + InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); + @Autowired + DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); + @Autowired + RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); + @Autowired + TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); + @Autowired + LogServer logServer = SpringContextHolder.getBean(LogServer.class); + String container; + String container_type_desc; + String last_container_type_desc; + String last_container; + //放货准备锁 + String putReadyLock = null; + //有货标记 + protected boolean has_goods_tag = false; + + int mode = 0; + int error = 0; + int move = 0; + int task = 0; + int action = 0; + int last_mode = 0; + int last_error = 0; + int last_move = 0; + int last_task = 0; + int last_action = 0; + Boolean isonline = true; + int hasGoods = 0; + String message = null; + Boolean iserror = false; + + + boolean hasVehicle = false; + boolean isReady = false; + protected int instruction_num = 0; + protected int instruction_num_truth = 0; + boolean isFold = false; + private String assemble_check_tag; + + protected String current_stage_instruction_message; + protected String last_stage_instruction_message; + Integer heartbeat_tag; + private Date instruction_require_time = new Date(); + private Date instruction_finished_time = new Date(); + + private int instruction_require_time_out; + boolean requireSucess = false; + + private int instruction_finished_time_out; + + int branchProtocol = 0; + //备注 + String remark; + //物料 + String material; + //当前指令 + Instruction inst = null; + //上次指令 + Instruction last_inst = null; + + //触摸屏手动触发任务 + private Boolean is_has_task = false; + + //申请搬运任务 + private Boolean apply_handling = false; + //申请物料 + private Boolean apply_material = false; + + //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 + int flag; + + String device_code; + + @Override + public Device getDevice() { + return this.device; + } + + + @Override + public void execute() { + String message = null; + try { + device_code = this.getDeviceCode(); + mode = this.itemProtocol.getMode(); + error = this.itemProtocol.getError(); + action = this.itemProtocol.getAction(); + move = this.itemProtocol.getMove(); + task = this.itemProtocol.getTask(); + hasGoods = this.itemProtocol.getMove(); + + if (mode != last_mode) { + this.setRequireSucess(false); + logServer.deviceLog(this.device_code,"mode" ,String.valueOf(mode)); + logServer.deviceLogToacs(this.device_code,"","","信号mode:" + last_mode + "->" + mode); + } + if (move != last_move) { + logServer.deviceLog(this.device_code,"move" ,String.valueOf(move)); + logServer.deviceLogToacs(this.device_code,"","","信号move:" + last_move + "->" + move); + } + if (error != last_error) { + logServer.deviceLog(this.device_code,"error" ,String.valueOf(error)); + logServer.deviceLogToacs(this.device_code,"","","信号error:" + last_error + "->" + error); + } + if (action != last_action) { + logServer.deviceLog(this.device_code,"action" ,String.valueOf(action)); + logServer.deviceLogToacs(this.device_code,"","","信号action:" + last_action + "->" + action); + } + + } catch (Exception var17) { + return; + } + + if (!this.itemProtocol.getIsonline()) { + this.setIsonline(false); + this.setIserror(true); + message = "信号量同步异常"; + //未联机 + } else if (mode == 0) { + this.setIsonline(false); + this.setIserror(true); + message = "未联机"; + //有报警 + } else if (error != 0) { + this.setIsonline(false); + this.setIserror(true); + message = "有报警"; + //无报警 + } else { + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + switch (mode) { + case 1: + log.debug("设备运转模式:等待工作"); + return; + case 2: + break; + } + + switch (flag) { + //取货完成 + case 1: + writing(2); + return; + //放货完成 + case 2: + writing(3); + return; + + } + + } + last_mode = mode; + last_error = error; + last_move = move; + last_task = task; + last_action = action; + } + + + public boolean exe_error() { + if (this.error == 0) { + return true; + } else { + log.debug("设备报警"); + return false; + } + } + + + public boolean exe_business() { + return true; + } + + public void executing(Server server, Map itemMap) { + ReadUtil.write(itemMap, server); + } + + public void writing(int command) { + String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + 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_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 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); + } + ReadUtil.write(itemMap, server); + + } +} diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_threeStation_smart/ItemProtocol.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_threeStation_smart/ItemProtocol.java new file mode 100644 index 00000000..6c094f81 --- /dev/null +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_one/hailiang_threeStation_smart/ItemProtocol.java @@ -0,0 +1,107 @@ +package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_threeStation_smart; + +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; + +import java.util.ArrayList; +import java.util.List; + +@Slf4j +@Data +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_error = "error"; + public static String item_task = "task"; + 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_weight = "weight"; + + private HailiangThreestationSmartDeviceDriver driver; + + public ItemProtocol(HailiangThreestationSmartDeviceDriver driver) { + this.driver = driver; + } + + public int getHeartbeat() { + return this.getOpcIntegerValue(item_heartbeat); + } + + public int getMode() { + return this.getOpcIntegerValue(item_mode); + } + + public int getMove() { + return this.getOpcIntegerValue(item_move); + } + + public int getAction() { + return this.getOpcIntegerValue(item_action); + } + + public int getError() { + return this.getOpcIntegerValue(item_error); + } + + public int getTask() { + return this.getOpcIntegerValue(item_task); + } + + 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 hasGoods(int move) { + return move; + } + + Boolean isonline; + + public int getOpcIntegerValue(String protocol) { + Integer value = this.driver.getIntegeregerValue(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, "心跳", "VW0")); + list.add(new ItemDto(item_mode, "工作状态", "VW2", Boolean.valueOf(true))); + list.add(new ItemDto(item_move, "光电信号", "VW4")); + list.add(new ItemDto(item_action, "取放信号", "VW6")); + list.add(new ItemDto(item_error, "报警信号", "VW8")); + list.add(new ItemDto(item_task, "任务号", "VD10")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_to_command, "作业命令", "VW102", Boolean.valueOf(true))); + list.add(new ItemDto(item_to_target, "目标站", "VW104")); + list.add(new ItemDto(item_to_task, "任务号", "VD108")); + return list; + } + +} + diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/stage/service/impl/StageActorServiceImpl.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/stage/service/impl/StageActorServiceImpl.java index 26422b5d..d03b0d43 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/stage/service/impl/StageActorServiceImpl.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/stage/service/impl/StageActorServiceImpl.java @@ -22,14 +22,17 @@ import org.nl.acs.device_driver.basedriver.agv.utils.IAgv; import org.nl.acs.device_driver.basedriver.agv.utils.OneAgvPhase; import org.nl.acs.device_driver.basedriver.agv.utils.TwoAgvPhase; import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_cleaning_machine_storage_station.HailiangCleaningMachineStorageStationDeviceDriver; +import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_elevator_wiring.HailiangElevatorWiringDeviceDriver; import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_engraving_cache.HailiangEngravingCacheDeviceDriver; import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_engraving_machine.HailiangEngravingMachineDeviceDriver; +import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_foldingDisc_smart.HailiangFoldingDiscSmartDeviceDriver; import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_packer_station.HailiangPackerStationDeviceDriver; import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_device.HailiangSpecialDeviceDriver; import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_empty_station.HailiangSpecialEmptyStationDeviceDriver; import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_full_station.HailiangSpecialFullStationDeviceDriver; import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_pick_station.HailiangSpecialPickStationDeviceDriver; import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_pour_station.HailiangSpecialPourStationDeviceDriver; +import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_threeStation_smart.HailiangThreestationSmartDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_autodoor.StandardAutodoorDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_conveyor_control.StandardCoveyorControlDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_plcscanner.StandardCoveyorControlWithPlcScannerDeviceDriver; @@ -271,6 +274,77 @@ public class StageActorServiceImpl implements StageActorService { if (ObjectUtil.isNull(device)) { continue; } + + String move = ""; + String mode = ""; + String action = ""; + + //海亮-三工位Smart200 + HailiangThreestationSmartDeviceDriver hailiangThreestationSmartDeviceDriver; + //海亮-叠盘位Smart200 + HailiangFoldingDiscSmartDeviceDriver hailiangFoldingDiscSmartDeviceDriver; + //海亮-货梯对接线 + HailiangElevatorWiringDeviceDriver hailiangElevatorWiringDeviceDriver; + + if (device.getDeviceDriver() instanceof HailiangThreestationSmartDeviceDriver) { + hailiangThreestationSmartDeviceDriver = (HailiangThreestationSmartDeviceDriver) device.getDeviceDriver(); + if (hailiangThreestationSmartDeviceDriver.getMode() == 0) { + mode = "脱机"; + } else if (hailiangThreestationSmartDeviceDriver.getMode() == 2) { + mode = "待机"; + } else if (hailiangThreestationSmartDeviceDriver.getMode() == 3) { + mode = "运行中"; + } + if (hailiangThreestationSmartDeviceDriver.getMove() == 0) { + move = "无货"; + } else if (hailiangThreestationSmartDeviceDriver.getMove() == 1) { + move = "有货"; + } + if (hailiangThreestationSmartDeviceDriver.getAction() == 0) { + action = "禁止取放"; + } else if (hailiangThreestationSmartDeviceDriver.getAction() == 1) { + action = "允许取货"; + } else if (hailiangThreestationSmartDeviceDriver.getAction() == 2) { + action = "允许放货"; + } else if (hailiangThreestationSmartDeviceDriver.getAction() == 3) { + action = "允许取放"; + } + obj.put("device_name", hailiangThreestationSmartDeviceDriver.getDevice().getDevice_name()); + jo.put("mode", mode); + jo.put("move", move); + jo.put("action", action); + jo.put("hasGoods", hailiangThreestationSmartDeviceDriver.getHasGoods()); + jo.put("isOnline", hailiangThreestationSmartDeviceDriver.getIsonline()); + jo.put("error", hailiangThreestationSmartDeviceDriver.getError()); + jo.put("isError", hailiangThreestationSmartDeviceDriver.getIserror()); + jo.put("container", hailiangThreestationSmartDeviceDriver.getContainer()); + jo.put("message", hailiangThreestationSmartDeviceDriver.getMessage()); + } else if (device.getDeviceDriver() instanceof HailiangFoldingDiscSmartDeviceDriver) { + hailiangFoldingDiscSmartDeviceDriver = (HailiangFoldingDiscSmartDeviceDriver) device.getDeviceDriver(); + if (hailiangFoldingDiscSmartDeviceDriver.getMode() == 0) { + mode = "脱机"; + } else if (hailiangFoldingDiscSmartDeviceDriver.getMode() == 2) { + mode = "待机"; + } else if (hailiangFoldingDiscSmartDeviceDriver.getMode() == 3) { + mode = "运行中"; + } + if (hailiangFoldingDiscSmartDeviceDriver.getMove() == 0) { + move = "无货"; + } else if (hailiangFoldingDiscSmartDeviceDriver.getMove() == 1) { + move = "有货"; + } + + obj.put("device_name", hailiangFoldingDiscSmartDeviceDriver.getDevice().getDevice_name()); + jo.put("mode", mode); + jo.put("move", move); + jo.put("number", hailiangFoldingDiscSmartDeviceDriver.getNumber()); + jo.put("hasGoods", hailiangFoldingDiscSmartDeviceDriver.getHasGoods()); + jo.put("isOnline", hailiangFoldingDiscSmartDeviceDriver.getIsonline()); + jo.put("error", hailiangFoldingDiscSmartDeviceDriver.getError()); + jo.put("isError", hailiangFoldingDiscSmartDeviceDriver.getIserror()); + jo.put("container", hailiangFoldingDiscSmartDeviceDriver.getContainer()); + jo.put("message", hailiangFoldingDiscSmartDeviceDriver.getMessage()); + } if (ObjectUtil.isNotEmpty(device.getDeviceDriver())) { IDriverService driverService = applicationContext.getBean(device.getDeviceDriverDefination().getDriverCode(), IDriverService.class); obj.put("device_name", device.getDevice_name()); diff --git a/wcs/qd/src/views/acs/device/config.vue b/wcs/qd/src/views/acs/device/config.vue index 4480f3e2..059f7dfb 100644 --- a/wcs/qd/src/views/acs/device/config.vue +++ b/wcs/qd/src/views/acs/device/config.vue @@ -111,6 +111,9 @@ import agv_ndc_one from '@/views/acs/device/driver/agv/agv_ndc_one' import agv_ndc_two from '@/views/acs/device/driver/agv/agv_ndc_two' import hailiang_xj_plc_test from '@/views/acs/device/driver/hailiang_one/hailiang_xj_plc_test' import hailiang_smart_plc_test from '@/views/acs/device/driver/hailiang_one/hailiang_smart_plc_test' +import hailiang_threestation_smart from '@/views/acs/device/driver/hailiang_one/hailiang_threestation_smart' +import hailiang_foldingDisc_smart from '@/views/acs/device/driver/hailiang_one/hailiang_foldingDisc_smart' +import hailiang_elevator_wiring from '@/views/acs/device/driver/hailiang_one/hailiang_elevator_wiring' export default { name: 'DeviceConfig', @@ -122,7 +125,7 @@ export default { standard_photoelectric_inspect_site, agv_ndc_two, agv_ndc_one, hailiang_packer_station, hailiang_engraving_cache, hailiang_special_pick_station, hailiang_special_empty_station, hailiang_special_full_station, hailiang_special_pour_station, hailiang_special_device, hailiang_engraving_machine, hailiang_auto_cache_line, hailiang_cleaning_feeding_line, hailiang_cleaning_machine, hailiang_cleaning_machine_storage_station, - hailiang_xj_plc_test, hailiang_smart_plc_test }, + hailiang_xj_plc_test, hailiang_smart_plc_test, hailiang_threestation_smart, hailiang_foldingDisc_smart,hailiang_elevator_wiring }, dicts: ['device_type'], mixins: [crud], data() { diff --git a/wcs/qd/src/views/acs/device/driver/hailiang_one/hailiang_elevator_wiring.vue b/wcs/qd/src/views/acs/device/driver/hailiang_one/hailiang_elevator_wiring.vue new file mode 100644 index 00000000..9f1191a2 --- /dev/null +++ b/wcs/qd/src/views/acs/device/driver/hailiang_one/hailiang_elevator_wiring.vue @@ -0,0 +1,487 @@ + + + + + diff --git a/wcs/qd/src/views/acs/device/driver/hailiang_one/hailiang_foldingDisc_smart.vue b/wcs/qd/src/views/acs/device/driver/hailiang_one/hailiang_foldingDisc_smart.vue new file mode 100644 index 00000000..884c08fe --- /dev/null +++ b/wcs/qd/src/views/acs/device/driver/hailiang_one/hailiang_foldingDisc_smart.vue @@ -0,0 +1,487 @@ + + + + + diff --git a/wcs/qd/src/views/acs/device/driver/hailiang_one/hailiang_threestation_smart.vue b/wcs/qd/src/views/acs/device/driver/hailiang_one/hailiang_threestation_smart.vue new file mode 100644 index 00000000..41d2800d --- /dev/null +++ b/wcs/qd/src/views/acs/device/driver/hailiang_one/hailiang_threestation_smart.vue @@ -0,0 +1,487 @@ + + + + + diff --git a/wcs/qd/src/views/acs/device/protocol/index.vue b/wcs/qd/src/views/acs/device/protocol/index.vue index b6e1ad0e..11f035cc 100644 --- a/wcs/qd/src/views/acs/device/protocol/index.vue +++ b/wcs/qd/src/views/acs/device/protocol/index.vue @@ -58,6 +58,17 @@ > 导出CSV + + 导出SMARTCSV + { + downloadFile(result, crud.title + '数据', 'csv') + this.downLoadcsvLoadingSmart = false + }).catch(() => { + this.downLoadcsvLoadingSmart = false + }) + }, // 钩子:在获取表格数据之前执行,false 则代表不获取数据 [CRUD.HOOK.beforeRefresh]() { return true