diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java b/acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java index 998f6f584..d0db77776 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java @@ -55,7 +55,11 @@ public enum DriverTypeEnum { PAPER_TUBE_DEVICE(22, "paper_tube_conveyor", "纸管库设备", "conveyor"), - DEVICE_STATUS(23,"device_status","立库设备状态","conveyor"); + DEVICE_STATUS(23,"device_status","立库设备状态","conveyor"), + + PACKAGE_MANIPULATOR(24,"package_manipulator","内包间行架机械手","station"), + + PAPER_TUBE_DEVICE2(22, "paper_tube_conveyor2", "纸管库设备2", "conveyor"); //驱动索引 private int index; diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/ItemProtocol.java new file mode 100644 index 000000000..9e975fe10 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/ItemProtocol.java @@ -0,0 +1,226 @@ +package org.nl.acs.device_driver.basedriver.paper_tube_device2; + +import cn.hutool.core.util.StrUtil; +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_carrier_direction = "carrier_direction"; + //报警 + public static String item_error = "error"; + //任务号 + public static String item_task = "task"; + //出库顺序数组 + public static String item_out_seq_arr = "out_seq_arr"; + //出库数量数组 + public static String item_out_qty_arr = "out_qty_arr"; + //物料1 + public static String item_material1 = "material1"; + //物料2 + public static String item_material2 = "material2"; + //物料3 + public static String item_material3 = "material3"; + //物料4 + public static String item_material4 = "material4"; + //物料5 + public static String item_material5 = "material5"; + //物料6 + public static String item_material6 = "material6"; + //物料7 + public static String item_material7 = "material7"; + //物料8 + public static String item_material8 = "material8"; + //物料9 + public static String item_material9 = "material9"; + //物料10 + public static String item_material10 = "material10"; + //物料11 + public static String item_material11 = "material11"; + //物料12 + public static String item_material12 = "material12"; + //数量1 + public static String item_qty1 = "qty1"; + //数量2 + public static String item_qty2 = "qty2"; + //数量3 + public static String item_qty3 = "qty3"; + //数量4 + public static String item_qty4 = "qty4"; + //数量5 + public static String item_qty5 = "qty5"; + //数量6 + public static String item_qty6 = "qty6"; + //数量7 + public static String item_qty7 = "qty7"; + //数量8 + public static String item_qty8 = "qty8"; + //数量9 + public static String item_qty9 = "qty9"; + //数量10 + public static String item_qty10 = "qty10"; + //数量11 + public static String item_qty11 = "qty11"; + //数量12 + public static String item_qty12 = "qty12"; + + + //下发命令 + public static String item_to_command = "to_command"; + //下发目标站 + public static String item_to_target = "to_target"; + + public static String item_to_task = "to_task"; + public static String item_to_material1 = "to_material1"; + public static String item_to_out_qty1 = "to_out_qty1"; + public static String item_to_seq1 = "to_seq1"; + public static String item_to_position1 = "to_position1"; + + public static String item_to_material2 = "to_material2"; + public static String item_to_out_qty2 = "to_out_qty2"; + public static String item_to_seq2 = "to_seq2"; + public static String item_to_position2 = "to_position2"; + + public static String item_to_material3 = "to_material3"; + public static String item_to_out_qty3 = "to_out_qty3"; + public static String item_to_seq3 = "to_seq3"; + public static String item_to_position3 = "to_position3"; + + + private PaperTubeConveyor2DeviceDriver driver; + + public ItemProtocol(PaperTubeConveyor2DeviceDriver driver) { + this.driver = driver; + } + + public int getHeartbeat() { + return this.getOpcIntegerValue(item_heartbeat); + } + + public int getMode() { + return this.getOpcIntegerValue(item_mode); + } + + public int getError() { + return this.getOpcIntegerValue(item_error); + } + + public String getMaterial1() { + return this.getOpcStringValue(item_material1); + } + + public String getMaterial2() { + return this.getOpcStringValue(item_material2); + } + + public String getMaterial3() { + return this.getOpcStringValue(item_material3); + } + + public String getMaterial4() { + return this.getOpcStringValue(item_material4); + } + + public String getMaterial5() { + return this.getOpcStringValue(item_material5); + } + + public String getMaterial6() { + return this.getOpcStringValue(item_material6); + } + + public String getMaterial7() { + return this.getOpcStringValue(item_material7); + } + + public String getMaterial8() { + return this.getOpcStringValue(item_material8); + } + + public String getMaterial9() { + return this.getOpcStringValue(item_material9); + } + + public String getMaterial10() { + return this.getOpcStringValue(item_material10); + } + + public String getMaterial11() { + return this.getOpcStringValue(item_material11); + } + + public String getMaterial12() { + return this.getOpcStringValue(item_material12); + } + + + public int getTotarget() { + return this.getOpcIntegerValue(item_to_target); + } + + public int getTo_command() { + return this.getOpcIntegerValue(item_to_command); + } + + Boolean isonline; + + public int getOpcIntegerValue(String protocol) { + Integer value = this.driver.getIntegeregerValue(protocol); + if (value == null) { + setIsonline(false); + } else { + setIsonline(true); + return value; + } + return 0; + + } + + + public String getOpcStringValue(String protocol) { + String value = this.driver.getStringValue(protocol); + if (StrUtil.isBlank(value)) { + + } else { + return value; + } + return "0"; + } + + public static List getReadableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_heartbeat, "心跳", "DB101.W0")); + list.add(new ItemDto(item_mode, "模式", "DB101.W2")); + + list.add(new ItemDto(item_error, "error", "DB101.W58")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_to_target , "下发仓位号", "DB102.W2")); + list.add(new ItemDto(item_to_command, "下发命令", "DB102.W4")); + + return list; + } + + @Override + public String toString() { + return ""; + } + +} + diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/PaperTubeConveyor2Defination.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/PaperTubeConveyor2Defination.java new file mode 100644 index 000000000..5ae32d885 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/PaperTubeConveyor2Defination.java @@ -0,0 +1,61 @@ +package org.nl.acs.device_driver.basedriver.paper_tube_device2; + +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.LinkedList; +import java.util.List; + +/** + * 油漆线 + */ +@Service +public class PaperTubeConveyor2Defination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "paper_tube_conveyor2"; + } + + @Override + public String getDriverName() { + return "纸管库2"; + } + + @Override + public String getDriverDescription() { + return "纸管库2"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new PaperTubeConveyor2DeviceDriver()).setDevice(device).setDriverDefination(this); + + } + + @Override + public Class getDeviceDriverType() { + return PaperTubeConveyor2DeviceDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList(); + types.add(DeviceType.conveyor); + return types; + } + + @Override + public List getReadableItemDtos() { + return ItemProtocol.getReadableItemDtos(); + } + + @Override + public List getWriteableItemDtos() { + return ItemProtocol.getWriteableItemDtos(); + } + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/PaperTubeConveyor2DeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/PaperTubeConveyor2DeviceDriver.java new file mode 100644 index 000000000..276a66c8f --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/PaperTubeConveyor2DeviceDriver.java @@ -0,0 +1,232 @@ +package org.nl.acs.device_driver.basedriver.paper_tube_device2; + +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.agv.server.AgvService; +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.ext.wms.service.AcsToWmsService; +import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; +import org.nl.acs.history.ErrorUtil; +import org.nl.acs.instruction.service.InstructionService; +import org.nl.acs.log.service.DeviceExecuteLogService; +import org.nl.acs.monitor.DeviceStageMonitor; +import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceAppService; +import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.task.service.TaskService; +import org.nl.modules.system.service.ParamService; +import org.nl.modules.wql.util.SpringContextHolder; +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 PaperTubeConveyor2DeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor { + protected ItemProtocol itemProtocol = new ItemProtocol(this); + @Autowired + DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); + @Autowired + InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); + @Autowired + DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class); + @Autowired + TaskService taskserver = SpringContextHolder.getBean(TaskService.class); + @Autowired + RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); + @Autowired + AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); + @Autowired + ParamService paramService = SpringContextHolder.getBean(ParamService.class); + @Autowired + DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); + @Autowired + AgvService agvService = SpringContextHolder.getBean(AgvService.class); + + private Date instruction_require_time = new Date(); + private Date instruction_finished_time = new Date(); + private Date instruction_apply_time = new Date(); + private int instruction_require_time_out = 3000; + + int heartbeat = 0; + int mode = 0; + int inventory_qty =0; + int out_finish =0; + int error =0; + int to_command =0; + int to_target =0; + String material = null; + + Boolean isonline = true; + + Boolean iserror = false; + + //1-执行任务;2-取货完成;3-放货完成; + int flag; + + int last_mode = 0; + int last_inventory_qty =0; + int last_out_finish =0; + int last_error = 0; + String last_material = null; + + String device_code; + + @Override + public Device getDevice() { + return this.device; + } + + //请求成功标记 + Boolean requireSucess = false; + + @Override + public void execute() { + String message = null; + + device_code = this.getDeviceCode(); + heartbeat = this.itemProtocol.getHeartbeat(); + mode = this.itemProtocol.getMode(); + error = this.itemProtocol.getError(); + to_command = this.itemProtocol.getTo_command(); + to_target = this.itemProtocol.getTotarget(); + + if (mode != last_mode) { + this.setRequireSucess(false); + if (mode == 0) { + this.setIsonline(false); + message = "未联机"; + } else { + this.setIsonline(true); + } + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); + } + if (inventory_qty != last_inventory_qty) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号inventory_qty:" + last_inventory_qty + "->" + inventory_qty); + } + if (out_finish != last_out_finish) { + if(out_finish == 1){ + this.writing(0); + this.writing("to_target","0"); + this.writing("to_out_qty","0"); + + } + logServer.deviceExecuteLog(this.device_code, "", "", "信号out_finish:" + last_out_finish + "->" + out_finish); + } + if (!StrUtil.equals(material,last_material)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号material:" + last_material + "->" + material); + } + if (error != last_error) { + if(error > 0){ + this.setIserror(true); + } else { + if(error > 0){ + this.setIserror(false); + } + } + logServer.deviceExecuteLog(this.device_code, "", "", "信号out_finish:" + last_out_finish + "->" + out_finish); + } + + + last_mode = mode; + last_inventory_qty = inventory_qty; + last_out_finish = out_finish; + last_error = error; + last_material = material; + } + + + public void writing(int command) { + String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_command; + + Map itemMap = new HashMap(); + this.control(itemMap); + } + + + public void writing(List list) { + + Map itemMap = new HashMap(); + for (int i = 0; i < list.size(); i++) { + Object ob = list.get(i); + JSONObject json = (JSONObject) JSONObject.toJSON(ob); + if (!StrUtil.isEmpty(json.getString("value"))) { + String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + json.getString("code"); + itemMap.put(to_param, json.getString("value")); + } + } + logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); + try { + this.checkcontrol(itemMap); + } catch (Exception e) { + e.printStackTrace(); + try{ + this.checkcontrol(itemMap); + } catch (Exception e1){ + e1.printStackTrace(); + } + } + + } + public void writing(String key, String param) { + + String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + param; + //String opcservcerid = this.getDevice().getOpc_server_id(); +//Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + + itemMap.put(to_param, Integer.parseInt(param)); +// itemMap.put(to_param, Integer.parseInt(value)); + this.control(itemMap); + logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + param); + } + + @Override + public JSONObject getDeviceStatusName() { + JSONObject jo = new JSONObject(); + String mode = ""; + + if (this.getMode() == 0) { + mode = "未联机"; + } else if (this.getMode() == 1) { + mode = "单机"; + } else if (this.getMode() == 2) { + mode = "联机"; + } else if (this.getMode() == 3) { + mode = "入库中"; + } else if (this.getMode() == 4) { + mode = "出库中"; + } + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("mode", mode); + jo.put("error", ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(this.getError()))); + jo.put("inventory_qty", inventory_qty); + jo.put("out_finish", out_finish); + jo.put("material", material); + jo.put("isOnline", this.getIsonline()); + + return jo; + } + + @Override + public void setDeviceStatus(JSONObject data) { + + } +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java index 591b2e6b0..23a9448d5 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java @@ -393,6 +393,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe last_error = error; last_move = move; last_task = task; + last_height = height; last_plcbarcode_length = plcbarcode_length; last_plcbarcode = plcbarcode; last_weight = weight; diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java index bfedc6cb0..4ac9b6396 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java @@ -1255,6 +1255,13 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { e.printStackTrace(); } + } else if(StrUtil.equals(type, "3")){ + List list = new ArrayList(); + Map map = new HashMap(); + map.put("code", "to_command"); + map.put("value", 3); + list.add(map); + paperTubeConveyorDeviceDriver.writing(list); } }