From 2aef51749390e01b8312aa80177b0d02af1094f5 Mon Sep 17 00:00:00 2001 From: loujf Date: Mon, 21 Nov 2022 14:57:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=89=E6=97=B6=E7=BA=AAsmart200=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E9=97=A8=E9=A9=B1=E5=8A=A8=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../acs/agv/server/impl/AgvServiceImpl.java | 36 ++ .../device/device_driver/DriverTypeEnum.java | 4 +- .../ItemProtocol.java | 72 ++++ .../StandardAutodoorSmartDefination.java | 71 ++++ .../StandardAutodoorSmartDeviceDriver.java | 164 ++++++++ qd/src/views/acs/device/config.vue | 4 +- .../device/driver/standard_autodoor_smart.vue | 352 ++++++++++++++++++ 7 files changed, 701 insertions(+), 2 deletions(-) create mode 100644 hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor_smart200/ItemProtocol.java create mode 100644 hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor_smart200/StandardAutodoorSmartDefination.java create mode 100644 hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor_smart200/StandardAutodoorSmartDeviceDriver.java create mode 100644 qd/src/views/acs/device/driver/standard_autodoor_smart.vue 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 4e15f7c..f7a668f 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 @@ -21,7 +21,9 @@ import org.nl.acs.device_driver.magic3.Magic3DeviceDriver; import org.nl.acs.device_driver.ndxy_special_two.NdxySpecialTwoDeviceDriver; import org.nl.acs.device_driver.special_ordinary_site.SpecialOrdinarySiteDeviceDriver; import org.nl.acs.device_driver.standard_autodoor.StandardAutodoorDeviceDriver; +import org.nl.acs.device_driver.standard_autodoor_smart200.StandardAutodoorSmartDeviceDriver; import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver; +import org.nl.acs.device_driver.standard_inspect_site_smart200.StandardInspectSiteSmartDeviceDriver; import org.nl.acs.device_driver.standard_manipulator_inspect_site.StandardManipulatorInspectSiteDeviceDriver; import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; import org.nl.acs.device_driver.standard_storage.StandardStorageDeviceDriver; @@ -828,6 +830,7 @@ public class AgvServiceImpl implements AgvService { StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; SpecialOrdinarySiteDeviceDriver specialOrdinarySiteDeviceDriver; YzjaSpecialDeviceDriver yzjaSpecialDeviceDriver; + StandardInspectSiteSmartDeviceDriver standardInspectSiteSmartDeviceDriver; //请求进入 if ("onEntry".equals(type)) { @@ -954,6 +957,27 @@ public class AgvServiceImpl implements AgvService { } } + } + if (addressdevice.getDeviceDriver() instanceof StandardInspectSiteSmartDeviceDriver) { + standardInspectSiteSmartDeviceDriver = (StandardInspectSiteSmartDeviceDriver) addressdevice.getDeviceDriver(); + //取货完成 + if ("Load".equals(action)) { + if (standardInspectSiteSmartDeviceDriver.getMode() != 0 && standardInspectSiteSmartDeviceDriver.getMove() == 0) { + inst.setExecute_device_code(processingVehicle); + inst.setExecute_status("2"); + standardInspectSiteSmartDeviceDriver.writing(2); + is_feedback = true; + } + //放货完成 + } else if ("Unload".equals(action)) { + if (standardInspectSiteSmartDeviceDriver.getMode() != 0 && standardInspectSiteSmartDeviceDriver.getMove() > 0) { + inst.setExecute_device_code(address); + inst.setExecute_status("4"); + standardInspectSiteSmartDeviceDriver.writing(3); + is_feedback = true; + } + } + } if (addressdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver(); @@ -1365,6 +1389,7 @@ public class AgvServiceImpl implements AgvService { break; default: StandardAutodoorDeviceDriver autodoor; + StandardAutodoorSmartDeviceDriver standardAutodoorSmartDeviceDriver; LampThreecolorDeviceDriver lampThreecolorDeviceDriver; Device doordevice = deviceAppService.findDeviceByCode(device); if (ObjectUtil.isEmpty(doordevice)) { @@ -1381,6 +1406,17 @@ public class AgvServiceImpl implements AgvService { log.info("下发关门请求"); } } + if (doordevice.getDeviceDriver() instanceof StandardAutodoorSmartDeviceDriver) { + standardAutodoorSmartDeviceDriver = (StandardAutodoorSmartDeviceDriver) doordevice.getDeviceDriver(); + if (StrUtil.equals("open", param)) { + standardAutodoorSmartDeviceDriver.OpenOrClose("1"); + log.info("下发开门请求"); + + } else if (StrUtil.equals("close", param)) { + standardAutodoorSmartDeviceDriver.OpenOrClose("2"); + log.info("下发关门请求"); + } + } if (doordevice.getDeviceDriver() instanceof LampThreecolorDeviceDriver) { lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) doordevice.getDeviceDriver(); if (StrUtil.equals("open", param)) { diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java b/hd/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java index d80a5ae..75cbe56 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java @@ -90,7 +90,9 @@ public enum DriverTypeEnum { YZJA_SPECIAL(40, "yzja_special", "扬州晶澳专用", "conveyor"), - INSPECT_SITE_SMART(41, "standard_inspect_site_smart", "检测站点_smaet200", "conveyor"); + INSPECT_SITE_SMART(41, "standard_inspect_site_smart", "检测站点_smart200", "conveyor"), + + AUTODOORSMART(42, "standard_autodoor_smart", "标准版-自动门-samrt200", "autodoor"); //驱动索引 private int index; diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor_smart200/ItemProtocol.java b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor_smart200/ItemProtocol.java new file mode 100644 index 0000000..32b3247 --- /dev/null +++ b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor_smart200/ItemProtocol.java @@ -0,0 +1,72 @@ +package org.nl.acs.device_driver.standard_autodoor_smart200; + +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; + +import java.util.ArrayList; +import java.util.List; + +@Slf4j +public class ItemProtocol { + public static String item_heartbeat = "heartbeat"; + public static String item_mode = "mode"; + public static String item_action = "action"; + public static String item_error = "error"; + public static String item_to_command = "to_command"; + + + private StandardAutodoorSmartDeviceDriver driver; + + public ItemProtocol(StandardAutodoorSmartDeviceDriver driver) { + this.driver = driver; + } + + public int getHeartbeat() { + return this.getOpcIntegerValue(item_heartbeat); + } + + public int getMode() { + return this.getOpcIntegerValue(item_mode); + } + + public int getAction() { + return this.getOpcIntegerValue(item_action); + } + + public int getError() { + return this.getOpcIntegerValue(item_error); + } + + public int getToCommand() { + return this.getOpcIntegerValue(item_to_command); + } + + + public int getOpcIntegerValue(String protocol) { + Integer value = this.driver.getIntegerValue(protocol); + if (value == null) { + log.error("读取错误!"); + } else { + 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_action, "动作信号", "VW4")); + list.add(new ItemDto(item_error, "报警信号", "VW6")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_to_command, "作业命令", "VW52", Boolean.valueOf(true))); + return list; + } + +} + diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor_smart200/StandardAutodoorSmartDefination.java b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor_smart200/StandardAutodoorSmartDefination.java new file mode 100644 index 0000000..8950474 --- /dev/null +++ b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor_smart200/StandardAutodoorSmartDefination.java @@ -0,0 +1,71 @@ +package org.nl.acs.device_driver.standard_autodoor_smart200; + +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; + +/** + * 自动门samrt200驱动定义 + */ +@Service +public class StandardAutodoorSmartDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "standard_autodoor_smart"; + } + + @Override + public String getDriverName() { + return "标准版-自动门-smart"; + } + + @Override + public String getDriverDescription() { + return "标准版-自动门-smart"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new StandardAutodoorSmartDeviceDriver()).setDevice(device).setDriverDefination(this); + + } + + @Override + public Class getDeviceDriverType() { + return StandardAutodoorSmartDeviceDriver.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", true)); + list.add(new ItemDto(ItemProtocol.item_action, "动作信号", "VW4")); + list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "VW6")); + return list; + } + + @Override + public List getWriteableItemDtos() { + return ItemProtocol.getWriteableItemDtos(); + } + +} diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor_smart200/StandardAutodoorSmartDeviceDriver.java b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor_smart200/StandardAutodoorSmartDeviceDriver.java new file mode 100644 index 0000000..f24f882 --- /dev/null +++ b/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor_smart200/StandardAutodoorSmartDeviceDriver.java @@ -0,0 +1,164 @@ +package org.nl.acs.device_driver.standard_autodoor_smart200; + +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import net.sf.json.JSONObject; +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.driver.AbstractOpcDeviceDriver; +import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.instruction.service.InstructionService; +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.Map; + +/** + * 自动门驱动smart200 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class StandardAutodoorSmartDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver { + 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"); + String container; + String container_type_desc; + String last_container_type_desc; + String last_container; + //放货准备锁 + String putReadyLock = null; + //有货标记 + protected boolean has_goods_tag = false; + String devicecode; + int mode = 0; + int action = 0; + int error = 0; + Boolean iserror = false; + + int move = 0; + int task = 0; + int last_action = 0; + int last_mode = 0; + int last_error = 0; + int last_move = 0; + int last_task = 0; + + boolean hasVehicle = false; + boolean isReady = false; + protected int instruction_num = 0; + protected int instruction_num_truth = 0; + protected boolean hasGoods = false; + boolean isFold = false; + private String assemble_check_tag; + private Boolean sampleMode0; + private Boolean sampleMode3; + private Integer sampleError; + private Boolean sampleOnline; + protected String displayMessage = null; + public int display_message_time_out = 30000; + public Date display_message_time; + 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; + + @Override + public Device getDevice() { + return this.device; + } + + + @Override + public void execute() { + String message = null; + + String device_code = this.getDevice().getDevice_code(); + mode = this.itemProtocol.getMode(); + action = this.itemProtocol.getAction(); + error = this.itemProtocol.getError(); + if (mode != last_mode) { + this.execute_log.log("设备:" + device_code + ",last_mode -> mode:" + last_mode + "->" + mode); + } + if (action != last_action) { + this.execute_log.log("设备:" + device_code + ",last_action -> action:" + last_action + "->" + action); + } + if (error != last_error) { + //this.execute_log.setContainer(""); + this.execute_log.log("设备:" + device_code + ",last_error -> error:" + last_error + "->" + error); + } + last_action = action; + last_mode = mode; + last_error = error; + //message = StringFormatUtl.format("设备报警:{}", new Object[]{}); + +// String manual_create_task = this.getDevice().getExtraValue().get("manual_create_task").toString(); + + } + + public synchronized String getStatus() { + JSONObject jo = new JSONObject(); + + if (action == 1 && mode == 2) { + jo.put("name", this.getDevice().getDevice_code()); + jo.put("status", "OPEN"); + } else if (action == 2 && mode == 2) { + jo.put("name", this.getDevice().getDevice_code()); + jo.put("status", "CLOSE"); + } else { + jo.put("name", this.getDevice().getDevice_code()); + jo.put("status", "ERROR"); + } + return jo.toString(); + } + + + public void writeing(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); + log.info("下发PLC信号:{},{}", to_command, command); + System.out.println("设备:" + devicecode + ",下发PLC信号:" + to_command + ",value:" + command); + + } + + public synchronized void OpenOrClose(String type) { + + //开门 + if ("1".equals(type)) { + writeing(1); + } else { + writeing(2); + } + + } + +} diff --git a/qd/src/views/acs/device/config.vue b/qd/src/views/acs/device/config.vue index 601b0d9..de30417 100644 --- a/qd/src/views/acs/device/config.vue +++ b/qd/src/views/acs/device/config.vue @@ -114,6 +114,7 @@ import xg_agv from '@/views/acs/device/driver/xg_agv' import agv_site from '@/views/acs/device/driver/agv_site' import whxr_weighing from '@/views/acs/device/driver/whxr/whxr_weighing' import jmagv from '@/views/acs/device/driver/jmagv' +import standard_autodoor_smart from '@/views/acs/device/driver/standard_autodoor_smart' export default { name: 'DeviceConfig', @@ -123,7 +124,8 @@ export default { standard_conveyor_control_with_plcscanner, standard_conveyor_control, standard_conveyor_monitor, weighing_site, machines_site, non_line_manipulator_inspect_site, non_line_inspect_site, manipulator_inspect_site_NDC, feedback_agv_status_site, standard_manipulator_stacking_site, standard_photoelectric_inspect_site, ndxy_special, hailiang_labeling, ndxy_special_two, whxr_storage_conveyor, whxr_ball_mill, whxr_spary_tower, whxr_weight, - electric_fence, oumulong_plc, traffic_light, standard_rgv, ykbk_special, ssj_cache_site, magic3, xg_agv, agv_site, whxr_weighing, jmagv, standard_inspect_site_smart }, + electric_fence, oumulong_plc, traffic_light, standard_rgv, ykbk_special, ssj_cache_site, magic3, xg_agv, agv_site, whxr_weighing, jmagv, standard_inspect_site_smart, + standard_autodoor_smart }, dicts: ['device_type'], mixins: [crud], data() { diff --git a/qd/src/views/acs/device/driver/standard_autodoor_smart.vue b/qd/src/views/acs/device/driver/standard_autodoor_smart.vue new file mode 100644 index 0000000..ca9f417 --- /dev/null +++ b/qd/src/views/acs/device/driver/standard_autodoor_smart.vue @@ -0,0 +1,352 @@ + + + + +