diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java index 22581b3..94e9b39 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java @@ -25,6 +25,7 @@ import org.nl.acs.device.enums.DeviceType; import org.nl.acs.device.service.mapper.DeviceExtraMapper; import org.nl.acs.device.domain.DeviceRunpoint; import org.nl.acs.device.service.mapper.DeviceRunpointMapper; +import org.nl.acs.device_driver.manipulator.standard_manipulator.OvenGantryManipulatorDeviceDriver; import org.nl.acs.route.domain.RouteLine; import org.nl.acs.route.service.mapper.RouteLineMapper; //import org.nl.acs.stage.domain.Stage; @@ -40,7 +41,6 @@ import org.nl.acs.device.service.DeviceDriverDefinationAppService; import org.nl.acs.device.service.DeviceExtraService; import org.nl.acs.device_driver.DeviceDriverDefination; import org.nl.acs.device_driver.ScannerDeviceDriver; -import org.nl.acs.device_driver.conveyor.oven_manipulator.OvenGantryManipulatorDeviceDriver; import org.nl.acs.device_driver.conveyor.siemens_conveyor.SiemensConveyorDeviceDriver; import org.nl.acs.device_driver.conveyor.siemens_conveyor_ckk.SiemensConveyorCkkDeviceDriver; import org.nl.acs.device_driver.conveyor.siemens_conveyor_labeling.SiemensConveyorLabelingDeviceDriver; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator/BoxManipulatorDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator/BoxManipulatorDefination.java index 065a0c7..cfc28c7 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator/BoxManipulatorDefination.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator/BoxManipulatorDefination.java @@ -1,60 +1,59 @@ -//package org.nl.acs.device_driver.box_manipulator; -// -//import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -//import org.nl.acs.device.domain.Device; -//import org.nl.acs.device.enums.DeviceType; -//import org.nl.acs.device_driver.DeviceDriver; -//import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -//import org.nl.acs.device_driver.manipulator.standard_manipulator.StandardItemProtocol; -//import org.springframework.stereotype.Service; -// -//import java.util.LinkedList; -//import java.util.List; -// -//@Service -//public class BoxManipulatorDefination implements OpcDeviceDriverDefination { -// @Override -// public String getDriverCode() { -// return "box_manipulator"; -// } -// -// @Override -// public String getDriverName() { -// return "装箱行架机械手"; -// } -// -// @Override -// public String getDriverDescription() { -// return "装箱行架机械手"; -// } -// -// @Override -// public DeviceDriver getDriverInstance(Device device) { -// return (new BoxManipulatorDeviceDriver()).setDevice(device).setDriverDefination(this); -// -// } -// -// @Override -// public Class getDeviceDriverType() { -// return BoxManipulatorDeviceDriver.class; -// } -// -// @Override -// public List getFitDeviceTypes() { -// List types = new LinkedList(); -// types.add(DeviceType.station); -// return types; -// } -// -// @Override -// public List getReadableItemDtos() { -// return StandardItemProtocol.getReadableItemDtos(); -// } -// -// -// -// @Override -// public List getWriteableItemDtos() { -// return StandardItemProtocol.getWriteableItemDtos(); -// } -//} +package org.nl.acs.device_driver.box_manipulator; + +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device.enums.DeviceType; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; +import org.springframework.stereotype.Service; + +import java.util.LinkedList; +import java.util.List; + +@Service +public class BoxManipulatorDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "box_manipulator"; + } + + @Override + public String getDriverName() { + return "装箱行架机械手"; + } + + @Override + public String getDriverDescription() { + return "装箱行架机械手"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new BoxManipulatorDeviceDriver()).setDevice(device).setDriverDefination(this); + + } + + @Override + public Class getDeviceDriverType() { + return BoxManipulatorDeviceDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList(); + types.add(DeviceType.station); + return types; + } + + @Override + public List getReadableItemDtos() { + return ItemProtocol.getReadableItemDtos(); + } + + + + @Override + public List getWriteableItemDtos() { + return ItemProtocol.getWriteableItemDtos(); + } +} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator/BoxManipulatorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator/BoxManipulatorDeviceDriver.java index 8aad399..8a64c2a 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator/BoxManipulatorDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator/BoxManipulatorDeviceDriver.java @@ -1,396 +1,411 @@ -//package org.nl.acs.device_driver.box_manipulator; -// -//import cn.hutool.core.util.ObjectUtil; -//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.common.base.CommonFinalParam; -//import org.nl.acs.device.domain.Device; -//import org.nl.acs.device.service.DeviceExtraService; -//import org.nl.acs.device.service.impl.DeviceExtraServiceImpl; -//import org.nl.acs.device_driver.DeviceDriver; -//import org.nl.acs.device_driver.FeedLmsRealFailed; -//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.device_driver.manipulator.standard_manipulator.StandardItemProtocol; -//import org.nl.acs.history.ErrorUtil; -//import org.nl.acs.history.service.DeviceErrorLogService; -//import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; -//import org.nl.acs.instruction.domain.Instruction; -//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.DeviceAppService; -//import org.nl.acs.opc.DeviceAppServiceImpl; -//import org.nl.acs.route.service.RouteLineService; -//import org.nl.acs.route.service.impl.RouteLineServiceImpl; -//import org.nl.acs.task.service.TaskService; -//import org.nl.config.SpringContextHolder; -//import org.springframework.beans.factory.annotation.Autowired; -// -//import java.util.Date; -//import java.util.List; -// -///** -// * 装箱行架机械手 -// */ -//@Slf4j -//@Data -//@RequiredArgsConstructor -//public class BoxManipulatorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { -// -// protected StandardItemProtocol standardItemProtocol = new StandardItemProtocol("2"); -// @Autowired -// DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); -// @Autowired -// TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); -// @Autowired -// InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); -// @Autowired -// DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); -// @Autowired -// RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class); -// @Autowired -// DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class); -// @Autowired -// DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); -// -// //工作模式 -// int mode = 0; -// int last_mode = 0; -// //光电信号 -// int move = 0; -// int last_move = 0; -// //动作信号 -// int action = 0; -// int last_action = 0; -// //行走列 -// int walk_y = 0; -// int last_walk_y = 0; -// //报警信号 -// int error = 0; -// int last_error = 0; -// //任务号 -// int task = 0; -// int last_task = 0; -// // x坐标 -// float x_position = 0; -// float last_x_position = 0; -// // y坐标 -// float y_position = 0; -// float last_y_position = 0; -// -// int heartbeat = 0; -// int last_heartbeat = 0; -// int to_command = 0; -// int last_to_command = 0; -// -// int to_target = 0; -// int last_to_target = 0; -// -// int to_task = 0; -// int last_to_task = 0; -// -// int to_onset = 0; -// int last_to_onset = 0; -// -// Boolean isonline = true; -// int hasGoods = 0; -// String message = null; -// Boolean iserror = false; -// private Date instruction_update_time = new Date(); -// private int instruction_update_time_out = 1000; -// Integer heartbeat_tag; -// private Date instruction_require_time = new Date(); -// -// private int instruction_require_time_out = 3000; -// //行架机械手申请任务成功标识 -// boolean requireSucess = false; -// -// private int instruction_finished_time_out; -// -// int branchProtocol = 0; -// private String error_type = "hxhj_error_type"; -// -// //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 -// int flag; -// -// String device_code; -// -// //当前指令 -// Instruction inst = null; -// -// //0 无任务执行 1更新指令状态 2下发电气信号 3允许取货 允许放货 5放货完成 -// int now_steps_type = 0; -// String notCreateTaskMessage = ""; -// String notCreateInstMessage = ""; -// String feedMessage = ""; -// -// -// List getDeviceCodeList = null; -// -// List putDeviceCodeList = null; -// -// -// @Override -// public Device getDevice() { -// return this.device; -// } -// -// @Override -// public void execute() { -// String message = null; -// try { -// device_code = this.getDeviceCode(); -// mode = this.standardItemProtocol.getMode(); -// move = this.standardItemProtocol.getMove(); -// action = this.standardItemProtocol.getAction(); -// walk_y = this.standardItemProtocol.getWalk_y(); -// error = this.standardItemProtocol.getError(); -// task = this.standardItemProtocol.getTask(); -// heartbeat = this.standardItemProtocol.getHeartbeat(); -// to_command = this.standardItemProtocol.getTo_command(); -// to_target = this.standardItemProtocol.getTo_target(); -// to_task = this.standardItemProtocol.getTo_task(); -// to_onset = this.standardItemProtocol.getTo_onset(); -// x_position = this.standardItemProtocol.getX_position(); -// y_position = this.standardItemProtocol.getY_position(); -// -// if (to_onset != last_to_onset) { -// logServer.deviceExecuteLog(this.device_code, "", "", "信号to_onset:" + last_to_onset + "->" + to_onset); -// } -// if (to_command != last_to_command) { -// logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command:" + last_to_command + "->" + to_command); -// } -// if (to_target != last_to_target) { -// logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target:" + last_to_target + "->" + to_target); -// } -// if (to_task != last_to_task) { -// logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task:" + last_to_task + "->" + to_task); -// } -// if (mode != last_mode) { -// requireSucess = false; -// logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); -// logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); -// } -// if (move != last_move) { -// logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); -// logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); -// } -// if (action != last_action) { -// logServer.deviceItemValue(this.device_code, "action", String.valueOf(action)); -// logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action); -// } -// if (error != last_error) { -// logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); -// logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); -// } -// if (walk_y != last_walk_y) { -// logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(walk_y)); -// logServer.deviceExecuteLog(this.device_code, "", "", "信号walk_y:" + last_walk_y + "->" + walk_y); -// } -// if (task != last_task) { -// logServer.deviceItemValue(this.device_code, "task", String.valueOf(task)); -// logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); -// } -// if (x_position != last_x_position) { -// logServer.deviceItemValue(this.device_code, "x_position", String.valueOf(x_position)); -// logServer.deviceExecuteLog(this.device_code, "", "", "信号x_position:" + last_x_position + "->" + x_position); -// } -// if (y_position != last_y_position) { -// logServer.deviceItemValue(this.device_code, "y_position", String.valueOf(y_position)); -// logServer.deviceExecuteLog(this.device_code, "", "", "信号y_position:" + last_y_position + "->" + y_position); -// } -// -// // 更新指令状态 -// if (mode == 3 && task > 0) { -// Date date = new Date(); -// if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) { -// log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out); -// -// } else { -// this.instruction_update_time = date; -// //更改指令状态 -// if (task > 0) { -// Instruction inst = checkInst(); -// if (inst != null) { -// if (StrUtil.equals(inst.getInstruction_status(), "0")) { -// inst.setInstruction_status(CommonFinalParam.ONE); -// inst.setExecute_device_code(this.device_code); -// instructionService.update(inst); -// } -// } -// } +package org.nl.acs.device_driver.box_manipulator; + +import cn.hutool.core.util.ObjectUtil; +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.common.base.CommonFinalParam; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device.service.DeviceExtraService; +import org.nl.acs.device.service.impl.DeviceExtraServiceImpl; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.FeedLmsRealFailed; +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.history.ErrorUtil; +import org.nl.acs.history.service.DeviceErrorLogService; +import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; +import org.nl.acs.instruction.domain.Instruction; +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.DeviceAppService; +import org.nl.acs.opc.DeviceAppServiceImpl; +import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.route.service.impl.RouteLineServiceImpl; +import org.nl.acs.task.service.TaskService; +import org.nl.config.SpringContextHolder; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.List; + +/** + * 装箱行架机械手 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class BoxManipulatorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { + + protected ItemProtocol itemProtocol = new ItemProtocol(this); + @Autowired + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + @Autowired + TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); + @Autowired + InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); + @Autowired + DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + @Autowired + RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class); + @Autowired + DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class); + @Autowired + DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); + + //工作模式 + int mode = 0; + int last_mode = 0; + //光电信号 + int move = 0; + int last_move = 0; + //动作信号 + int action = 0; + int last_action = 0; + //行走列 + int walk_y = 0; + int last_walk_y = 0; + //报警信号 + int error = 0; + int last_error = 0; + //任务号 + int task = 0; + int last_task = 0; + // x坐标 + float x_position = 0; + float last_x_position = 0; + // y坐标 + float y_position = 0; + float last_y_position = 0; + + int heartbeat = 0; + int last_heartbeat = 0; + int to_command = 0; + int last_to_command = 0; + + int to_target = 0; + int last_to_target = 0; + + int to_task = 0; + int last_to_task = 0; + + int to_onset = 0; + int last_to_onset = 0; + + int to_seq = 0; + int last_to_seq = 0; + + int to_last = 0; + int last_to_last = 0; + + Boolean isonline = true; + int hasGoods = 0; + String message = null; + Boolean iserror = false; + private Date instruction_update_time = new Date(); + private int instruction_update_time_out = 1000; + Integer heartbeat_tag; + private Date instruction_require_time = new Date(); + + private int instruction_require_time_out = 3000; + //行架机械手申请任务成功标识 + boolean requireSucess = false; + + private int instruction_finished_time_out; + + int branchProtocol = 0; + private String error_type = "hxhj_error_type"; + + //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 + int flag; + + String device_code; + + //当前指令 + Instruction inst = null; + + //0 无任务执行 1更新指令状态 2下发电气信号 3允许取货 允许放货 5放货完成 + int now_steps_type = 0; + String notCreateTaskMessage = ""; + String notCreateInstMessage = ""; + String feedMessage = ""; + + + List getDeviceCodeList = null; + + List putDeviceCodeList = null; + + + @Override + public Device getDevice() { + return this.device; + } + + @Override + public void execute() { + String message = null; + try { + device_code = this.getDeviceCode(); + mode = this.itemProtocol.getMode(); + move = this.itemProtocol.getMove(); + action = this.itemProtocol.getAction(); + walk_y = this.itemProtocol.getWalk_y(); + error = this.itemProtocol.getError(); + task = this.itemProtocol.getTask(); + heartbeat = this.itemProtocol.getHeartbeat(); + to_command = this.itemProtocol.getTo_command(); + to_target = this.itemProtocol.getTo_target(); + to_task = this.itemProtocol.getTo_task(); + to_onset = this.itemProtocol.getTo_onset(); + x_position = this.itemProtocol.getX_position(); + y_position = this.itemProtocol.getY_position(); + to_seq = this.itemProtocol.getTo_seq(); + to_last = this.itemProtocol.getTo_last(); + + if (to_last != last_to_last) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_last:" + last_to_last + "->" + to_last); + } + if (to_seq != last_to_seq) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_seq:" + last_to_seq + "->" + to_seq); + } + if (to_onset != last_to_onset) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_onset:" + last_to_onset + "->" + to_onset); + } + if (to_command != last_to_command) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command:" + last_to_command + "->" + to_command); + } + if (to_target != last_to_target) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target:" + last_to_target + "->" + to_target); + } + if (to_task != last_to_task) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task:" + last_to_task + "->" + to_task); + } + if (mode != last_mode) { + requireSucess = false; + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); + } + if (move != last_move) { + logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); + } + if (action != last_action) { + logServer.deviceItemValue(this.device_code, "action", String.valueOf(action)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action); + } + if (error != last_error) { + logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); + } + if (walk_y != last_walk_y) { + logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(walk_y)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号walk_y:" + last_walk_y + "->" + walk_y); + } + if (task != last_task) { + logServer.deviceItemValue(this.device_code, "task", String.valueOf(task)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); + } + if (x_position != last_x_position) { + logServer.deviceItemValue(this.device_code, "x_position", String.valueOf(x_position)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号x_position:" + last_x_position + "->" + x_position); + } + if (y_position != last_y_position) { + logServer.deviceItemValue(this.device_code, "y_position", String.valueOf(y_position)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号y_position:" + last_y_position + "->" + y_position); + } + + // 更新指令状态 + if (mode == 3 && task > 0) { + Date date = new Date(); + if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out); + + } else { + this.instruction_update_time = date; + //更改指令状态 + if (task > 0) { + Instruction inst = checkInst(); + if (inst != null) { + if (StrUtil.equals(inst.getInstruction_status(), "0")) { + inst.setInstruction_status(CommonFinalParam.ONE); + inst.setExecute_device_code(this.device_code); + instructionService.update(inst); + } + } + } + } + } + + } catch (Exception var17) { + var17.printStackTrace(); + feedMessage = var17.getMessage(); + logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol)); + + } + + if (mode == 0) { + this.setIsonline(false); + message = "未联机"; + //有报警 + } else if (error != 0) { + this.setIserror(true); + message = "有报警"; + //无报警 + } else { + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + + //行架机械手申请任务 + if (mode == 2 && move == 0 && task == 0 && !requireSucess) { +// boolean res = applyTask(); +// if (res) { +// notCreateInstMessage = ""; +// notCreateTaskMessage = ""; +// feedMessage = ""; // } -// } -// -// } catch (Exception var17) { -// var17.printStackTrace(); -// feedMessage = var17.getMessage(); -// logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.standardItemProtocol)); -// -// } -// -// if (mode == 0) { -// this.setIsonline(false); -// message = "未联机"; -// //有报警 -// } else if (error != 0) { -// this.setIserror(true); -// message = "有报警"; -// //无报警 -// } else { -// this.setIsonline(true); -// this.setIserror(false); -// message = ""; -// Instruction instruction = null; -// List toInstructions; -// -// //行架机械手申请任务 -// if (mode == 2 && move == 0 && task == 0 && !requireSucess) { -//// boolean res = applyTask(); -//// if (res) { -//// notCreateInstMessage = ""; -//// notCreateTaskMessage = ""; -//// feedMessage = ""; -//// } -// } else { -// if (mode == 2) { -// //if (!requireSucess) { -// String remark = "未查找任务原因为:"; -// if (mode != 2) { -// remark = remark + "工作模式(mode)不是待机状态,"; -// } -// if (move != 0) { -// remark = remark + "光电信号(move)为有货状态,"; -// } -// if (task != 0) { -// remark = remark + "当前上报任务号(task)应该为0,"; -// if (ObjectUtil.isNotEmpty(this.inst)) { -// this.inst = null; -// } -// } -// if (requireSucess) { -// remark = remark + "请右击该图标,将请求任务复位标记(requireSucess)改为否。"; -// } -// this.setNotCreateTaskMessage(remark); -// //} -// } -// } -// -// } -// last_mode = mode; -// last_move = move; -// last_action = action; -// last_walk_y = walk_y; -// last_error = error; -// last_task = task; -// last_heartbeat = heartbeat; -// last_to_task = to_task; -// last_to_command = to_command; -// last_to_target = to_target; -// last_to_onset = to_onset; -// last_x_position = x_position; -// last_y_position = y_position; -// } -// -// @Override -// public JSONObject getDeviceStatusName() { -// JSONObject jo = new JSONObject(); -// String mode = ""; -// String move = ""; -// String action = ""; -// String walk_y = ""; -// if (this.getMode() == 0) { -// mode = "脱机"; -// } else if (this.getMode() == 1) { -// mode = "单机"; -// } else if (this.getMode() == 2) { -// mode = "待机"; -// } else if (this.getMode() == 3) { -// mode = "运行中"; -// } -// -// if (this.getMove() == 0) { -// move = "无货"; -// } else if (this.getMove() == 1) { -// move = "有货"; -// } -// -// String requireSucess = "0"; -// if (this.requireSucess) { -// requireSucess = "1"; -// } -// jo.put("requireSucess", requireSucess); -// if (this.getAction() == 1) { -// action = "取货中"; -// } else if (this.getAction() == 2) { -// action = "取货完成"; -// } else if (this.getAction() == 3) { -// action = "放货中"; -// } else if (this.getAction() == 4) { -// action = "放货完成"; -// } -// -// jo.put("device_name", this.getDevice().getDevice_name()); -// jo.put("mode", mode); -// jo.put("move", move); -// jo.put("action", action); -// jo.put("task", task); -// jo.put("walk_y", walk_y); -// jo.put("isOnline", this.getIsonline()); -// jo.put("error", ErrorUtil.getDictDetail("hxhj_error_type", String.valueOf(this.getError()))); -// jo.put("isError", this.getIserror()); -// jo.put("message", this.getMessage()); -// jo.put("notCreateTaskMessage", notCreateTaskMessage); -// jo.put("notCreateInstMessage", notCreateInstMessage); -// jo.put("feedMessage", feedMessage); -// jo.put("driver_type", "siemens_conveyor"); -// jo.put("is_click", true); -// jo.put("x", x_position); -// jo.put("y", y_position); -// return jo; -// } -// -// @Override -// public void setDeviceStatus(JSONObject data) { -// String requestSucess = data.getString("requireSucess"); -// if (StrUtil.equals(requestSucess, "0")) { -// this.requireSucess = false; -// } else if (StrUtil.equals(requestSucess, "1")) { -// this.requireSucess = true; -// } -// } -// -// @Override -// public JSONObject feedLmsRealFailedInfo() { -// JSONObject jo = new JSONObject(); -// jo.put("device_code", this.getDevice().getDevice_code()); -// jo.put("device_name", this.getDevice().getDevice_name()); -// jo.put("fault_code", String.valueOf(error)); -// jo.put("fault_info", ErrorUtil.getDictDetail(error_type, String.valueOf(this.getError()))); -// jo.put("fault_type", error_type); -// return jo; -// } -// -// -// public Instruction checkInst() { -// if (ObjectUtil.isNotEmpty(this.inst)) { -// if (this.task > 0) { -// if (this.inst.getInstruction_code().equals(String.valueOf(this.task))) { -// return this.inst; -// } else { -// inst = instructionService.findByCodeFromCache(String.valueOf(task)); -// return inst; -// } -// } -// } else { -// inst = instructionService.findByCodeFromCache(String.valueOf(task)); -// return inst; -// } -// return null; -// } -//} + } else { + if (mode == 2) { + //if (!requireSucess) { + String remark = "未查找任务原因为:"; + if (mode != 2) { + remark = remark + "工作模式(mode)不是待机状态,"; + } + if (move != 0) { + remark = remark + "光电信号(move)为有货状态,"; + } + if (task != 0) { + remark = remark + "当前上报任务号(task)应该为0,"; + if (ObjectUtil.isNotEmpty(this.inst)) { + this.inst = null; + } + } + if (requireSucess) { + remark = remark + "请右击该图标,将请求任务复位标记(requireSucess)改为否。"; + } + this.setNotCreateTaskMessage(remark); + //} + } + } + + } + last_mode = mode; + last_move = move; + last_action = action; + last_walk_y = walk_y; + last_error = error; + last_task = task; + last_heartbeat = heartbeat; + last_to_task = to_task; + last_to_command = to_command; + last_to_target = to_target; + last_to_onset = to_onset; + last_x_position = x_position; + last_y_position = y_position; + last_to_seq = to_seq; + last_to_last = to_last; + } + + @Override + public JSONObject getDeviceStatusName() { + JSONObject jo = new JSONObject(); + String mode = ""; + String move = ""; + String action = ""; + String walk_y = ""; + if (this.getMode() == 0) { + mode = "脱机"; + } else if (this.getMode() == 1) { + mode = "单机"; + } else if (this.getMode() == 2) { + mode = "待机"; + } else if (this.getMode() == 3) { + mode = "运行中"; + } + + if (this.getMove() == 0) { + move = "无货"; + } else if (this.getMove() == 1) { + move = "有货"; + } + + String requireSucess = "0"; + if (this.requireSucess) { + requireSucess = "1"; + } + jo.put("requireSucess", requireSucess); + if (this.getAction() == 1) { + action = "取货中"; + } else if (this.getAction() == 2) { + action = "取货完成"; + } else if (this.getAction() == 3) { + action = "放货中"; + } else if (this.getAction() == 4) { + action = "放货完成"; + } + + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("mode", mode); + jo.put("move", move); + jo.put("action", action); + jo.put("task", task); + jo.put("walk_y", walk_y); + jo.put("isOnline", this.getIsonline()); + jo.put("error", this.getError()); + jo.put("isError", this.getIserror()); + jo.put("message", this.getMessage()); + jo.put("notCreateTaskMessage", notCreateTaskMessage); + jo.put("notCreateInstMessage", notCreateInstMessage); + jo.put("feedMessage", feedMessage); + jo.put("driver_type", "siemens_conveyor"); + jo.put("is_click", true); + jo.put("x", x_position); + jo.put("y", y_position); + return jo; + } + + @Override + public void setDeviceStatus(JSONObject data) { + String requestSucess = data.getString("requireSucess"); + if (StrUtil.equals(requestSucess, "0")) { + this.requireSucess = false; + } else if (StrUtil.equals(requestSucess, "1")) { + this.requireSucess = true; + } + } + + @Override + public JSONObject feedLmsRealFailedInfo() { + JSONObject jo = new JSONObject(); + jo.put("device_code", this.getDevice().getDevice_code()); + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("fault_code", String.valueOf(error)); + jo.put("fault_info", ErrorUtil.getDictDetail(error_type, String.valueOf(this.getError()))); + jo.put("fault_type", error_type); + return jo; + } + + + public Instruction checkInst() { + if (ObjectUtil.isNotEmpty(this.inst)) { + if (this.task > 0) { + if (this.inst.getInstruction_code().equals(String.valueOf(this.task))) { + return this.inst; + } else { + inst = instructionService.findByCodeFromCache(String.valueOf(task)); + return inst; + } + } + } else { + inst = instructionService.findByCodeFromCache(String.valueOf(task)); + return inst; + } + return null; + } +} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator/ItemProtocol.java similarity index 83% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/ItemProtocol.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator/ItemProtocol.java index 4e87380..57f71ed 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/ItemProtocol.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator/ItemProtocol.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.manipulator.standard_manipulator; +package org.nl.acs.device_driver.box_manipulator; import cn.hutool.core.util.StrUtil; import lombok.Data; @@ -38,11 +38,15 @@ public class ItemProtocol { public static String item_to_target = "to_target"; //下发任务号 public static String item_to_task = "to_task"; + //下发木箱工位顺序 + public static String item_to_seq = "to_seq"; + //下发是否最后子卷 + public static String item_to_last = "to_last"; - private StandardManipulatorDeviceDriver driver; + private BoxManipulatorDeviceDriver driver; - public ItemProtocol(StandardManipulatorDeviceDriver driver) { + public ItemProtocol(BoxManipulatorDeviceDriver driver) { this.driver = driver; } @@ -74,14 +78,6 @@ public class ItemProtocol { return this.getOpcIntegerValue(item_task); } - public int getTo_command() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getTo_target() { - return this.getOpcIntegerValue(item_to_target); - } - public int getTo_task() { return this.getOpcIntegerValue(item_to_task); } @@ -90,12 +86,28 @@ public class ItemProtocol { return this.getOpcIntegerValue(item_to_onset); } - public float getX_position() { - return this.getOpcFloatValue(item_x_position); + public int getTo_command() { + return this.getOpcIntegerValue(item_to_command); } - public float getY_position() { - return this.getOpcFloatValue(item_y_position); + public int getTo_target() { + return this.getOpcIntegerValue(item_to_target); + } + + public int getX_position() { + return this.getOpcIntegerValue(item_x_position); + } + + public int getY_position() { + return this.getOpcIntegerValue(item_y_position); + } + + public int getTo_seq(){ + return this.getOpcIntegerValue(item_to_seq); + } + + public int getTo_last(){ + return this.getOpcIntegerValue(item_to_last); } @@ -124,19 +136,6 @@ public class ItemProtocol { return "0"; } - public float getOpcFloatValue(String protocol) { - Float value = this.driver.getDoubleValue(protocol); - if (value == null) { - // log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0; - - } - public static List getReadableItemDtos() { ArrayList list = new ArrayList<>(); list.add(new ItemDto(item_heartbeat, "心跳", "DB1.B0")); @@ -157,11 +156,8 @@ public class ItemProtocol { list.add(new ItemDto(item_to_onset, "下发起始站", "DB2.W2")); list.add(new ItemDto(item_to_target, "下发目标站", "DB2.W4")); list.add(new ItemDto(item_to_task, "下发任务号", "DB2.D6")); + list.add(new ItemDto(item_to_seq, "下发木箱工位顺序", "DB2.W8")); + list.add(new ItemDto(item_to_last, "下发是否最后子卷", "DB2.W10")); return list; } - - @Override - public String toString() { - return ""; - } } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator_site/BoxManipulatorSiteDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator_site/BoxManipulatorSiteDefination.java new file mode 100644 index 0000000..4e272a6 --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator_site/BoxManipulatorSiteDefination.java @@ -0,0 +1,56 @@ +package org.nl.acs.device_driver.box_manipulator_site; + +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device.enums.DeviceType; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; +import org.springframework.stereotype.Service; + +import java.util.LinkedList; +import java.util.List; + +@Service +public class BoxManipulatorSiteDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "box_manipulator_site"; + } + + @Override + public String getDriverName() { + return "木箱机械手对接位"; + } + + @Override + public String getDriverDescription() { + return "木箱机械手对接位"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new BoxManipulatorSiteDeviceDriver()).setDevice(device).setDriverDefination(this); + } + + @Override + public Class getDeviceDriverType() { + return BoxManipulatorSiteDeviceDriver.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/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator_site/BoxManipulatorSiteDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator_site/BoxManipulatorSiteDeviceDriver.java new file mode 100644 index 0000000..f8a2ae7 --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator_site/BoxManipulatorSiteDeviceDriver.java @@ -0,0 +1,403 @@ +package org.nl.acs.device_driver.box_manipulator_site; + +import cn.hutool.core.util.ObjectUtil; +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.common.base.CommonFinalParam; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device.service.DeviceExtraService; +import org.nl.acs.device.service.impl.DeviceExtraServiceImpl; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.FeedLmsRealFailed; +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.history.ErrorUtil; +import org.nl.acs.history.service.DeviceErrorLogService; +import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; +import org.nl.acs.instruction.domain.Instruction; +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.DeviceAppService; +import org.nl.acs.opc.DeviceAppServiceImpl; +import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.route.service.impl.RouteLineServiceImpl; +import org.nl.acs.task.service.TaskService; +import org.nl.config.SpringContextHolder; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.List; + +/** + * 木箱机械手对接位 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class BoxManipulatorSiteDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { + + protected ItemProtocol itemProtocol = new ItemProtocol(this); + @Autowired + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + @Autowired + TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); + @Autowired + InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); + @Autowired + DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + @Autowired + RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class); + @Autowired + DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class); + @Autowired + DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); + + //工作模式 + int mode = 0; + int last_mode = 0; + //光电信号 + int move = 0; + int last_move = 0; + //动作信号 + int action = 0; + int last_action = 0; + //报警信号 + int error = 0; + int last_error = 0; + //任务号 + int task = 0; + int last_task = 0; + + + int heartbeat = 0; + int last_heartbeat = 0; + int to_command = 0; + int last_to_command = 0; + + int to_target = 0; + int last_to_target = 0; + + int to_task = 0; + int last_to_task = 0; + + int to_container_type = 0; + int last_to_container_type = 0; + + //托盘类型 + int container_type = 0; + int last_container_type = 0; + + + //行架任务号 + int hj_task = 0; + int last_hj_task = 0; + + //数量 + int qty = 0; + int last_qty = 0; + + + //托盘方向 + int carrier_direction = 0; + int last_carrier_direction = 0; + + Boolean isonline = true; + int hasGoods = 0; + String message = null; + Boolean iserror = false; + private Date instruction_update_time = new Date(); + private int instruction_update_time_out = 1000; + Integer heartbeat_tag; + private Date instruction_require_time = new Date(); + + private int instruction_require_time_out = 3000; + //行架机械手申请任务成功标识 + boolean requireSucess = false; + + private int instruction_finished_time_out; + + int branchProtocol = 0; + private String error_type = "hxhj_error_type"; + + //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 + int flag; + + String device_code; + + //当前指令 + Instruction inst = null; + + //0 无任务执行 1更新指令状态 2下发电气信号 3允许取货 允许放货 5放货完成 + int now_steps_type = 0; + String notCreateTaskMessage = ""; + String notCreateInstMessage = ""; + String feedMessage = ""; + + + List getDeviceCodeList = null; + + List putDeviceCodeList = null; + + + @Override + public Device getDevice() { + return this.device; + } + + @Override + public void execute() { + String message = null; + try { + device_code = this.getDeviceCode(); + mode = this.itemProtocol.getMode(); + move = this.itemProtocol.getMove(); + action = this.itemProtocol.getAction(); + error = this.itemProtocol.getError(); + task = this.itemProtocol.getTask(); + heartbeat = this.itemProtocol.getHeartbeat(); + to_command = this.itemProtocol.getTo_command(); + to_target = this.itemProtocol.getTo_target(); + to_task = this.itemProtocol.getTo_task(); + to_container_type = this.itemProtocol.getTo_container_type(); + container_type = this.itemProtocol.getContainer_type(); + carrier_direction = this.itemProtocol.getCarrier_direction(); + hj_task = this.itemProtocol.getHj_task(); + qty = this.itemProtocol.getQty(); + + if (to_container_type != last_to_container_type) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_container_type:" + last_to_container_type + "->" + to_container_type); + } + if (container_type != last_container_type) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号container_type:" + last_container_type + "->" + container_type); + } + if (hj_task != last_hj_task) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号hj_task:" + last_hj_task + "->" + hj_task); + } + if (qty != last_qty) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号qty:" + last_qty + "->" + qty); + } + if (carrier_direction != last_carrier_direction) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号carrier_direction:" + last_carrier_direction + "->" + carrier_direction); + } + if (to_command != last_to_command) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command:" + last_to_command + "->" + to_command); + } + if (to_target != last_to_target) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target:" + last_to_target + "->" + to_target); + } + if (to_task != last_to_task) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task:" + last_to_task + "->" + to_task); + } + if (mode != last_mode) { + requireSucess = false; + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); + } + if (move != last_move) { + logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); + } + if (action != last_action) { + logServer.deviceItemValue(this.device_code, "action", String.valueOf(action)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action); + } + if (error != last_error) { + logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); + } + if (task != last_task) { + logServer.deviceItemValue(this.device_code, "task", String.valueOf(task)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); + } + + // 更新指令状态 + if (mode == 3 && task > 0) { + Date date = new Date(); + if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out); + + } else { + this.instruction_update_time = date; + //更改指令状态 + if (task > 0) { + Instruction inst = checkInst(); + if (inst != null) { + if (StrUtil.equals(inst.getInstruction_status(), "0")) { + inst.setInstruction_status(CommonFinalParam.ONE); + inst.setExecute_device_code(this.device_code); + instructionService.update(inst); + } + } + } + } + } + + } catch (Exception var17) { + var17.printStackTrace(); + feedMessage = var17.getMessage(); + logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol)); + + } + + if (mode == 0) { + this.setIsonline(false); + message = "未联机"; + //有报警 + } else if (error != 0) { + this.setIserror(true); + message = "有报警"; + //无报警 + } else { + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + + //行架机械手申请任务 + if (mode == 2 && move == 0 && task == 0 && !requireSucess) { +// boolean res = applyTask(); +// if (res) { +// notCreateInstMessage = ""; +// notCreateTaskMessage = ""; +// feedMessage = ""; +// } + } else { + if (mode == 2) { + //if (!requireSucess) { + String remark = "未查找任务原因为:"; + if (mode != 2) { + remark = remark + "工作模式(mode)不是待机状态,"; + } + if (move != 0) { + remark = remark + "光电信号(move)为有货状态,"; + } + if (task != 0) { + remark = remark + "当前上报任务号(task)应该为0,"; + if (ObjectUtil.isNotEmpty(this.inst)) { + this.inst = null; + } + } + if (requireSucess) { + remark = remark + "请右击该图标,将请求任务复位标记(requireSucess)改为否。"; + } + this.setNotCreateTaskMessage(remark); + //} + } + } + + } + last_mode = mode; + last_move = move; + last_action = action; + last_error = error; + last_task = task; + last_heartbeat = heartbeat; + last_to_task = to_task; + last_to_command = to_command; + last_to_target = to_target; + last_hj_task = hj_task; + last_container_type = container_type; + last_carrier_direction = carrier_direction; + last_qty = qty; + } + + @Override + public JSONObject getDeviceStatusName() { + JSONObject jo = new JSONObject(); + String mode = ""; + String move = ""; + String action = ""; + String walk_y = ""; + if (this.getMode() == 0) { + mode = "脱机"; + } else if (this.getMode() == 1) { + mode = "单机"; + } else if (this.getMode() == 2) { + mode = "待机"; + } else if (this.getMode() == 3) { + mode = "运行中"; + } + + if (this.getMove() == 0) { + move = "无货"; + } else if (this.getMove() == 1) { + move = "有货"; + } + + String requireSucess = "0"; + if (this.requireSucess) { + requireSucess = "1"; + } + jo.put("requireSucess", requireSucess); + if (this.getAction() == 1) { + action = "取货中"; + } else if (this.getAction() == 2) { + action = "取货完成"; + } else if (this.getAction() == 3) { + action = "放货中"; + } else if (this.getAction() == 4) { + action = "放货完成"; + } + + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("mode", mode); + jo.put("move", move); + jo.put("action", action); + jo.put("task", task); + jo.put("isOnline", this.getIsonline()); + jo.put("error", this.getError()); + jo.put("isError", this.getIserror()); + jo.put("message", this.getMessage()); + jo.put("notCreateTaskMessage", notCreateTaskMessage); + jo.put("notCreateInstMessage", notCreateInstMessage); + jo.put("feedMessage", feedMessage); + jo.put("driver_type", "siemens_conveyor"); + jo.put("is_click", true); + return jo; + } + + @Override + public void setDeviceStatus(JSONObject data) { + String requestSucess = data.getString("requireSucess"); + if (StrUtil.equals(requestSucess, "0")) { + this.requireSucess = false; + } else if (StrUtil.equals(requestSucess, "1")) { + this.requireSucess = true; + } + } + + @Override + public JSONObject feedLmsRealFailedInfo() { + JSONObject jo = new JSONObject(); + jo.put("device_code", this.getDevice().getDevice_code()); + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("fault_code", String.valueOf(error)); + jo.put("fault_info", ErrorUtil.getDictDetail(error_type, String.valueOf(this.getError()))); + jo.put("fault_type", error_type); + return jo; + } + + + public Instruction checkInst() { + if (ObjectUtil.isNotEmpty(this.inst)) { + if (this.task > 0) { + if (this.inst.getInstruction_code().equals(String.valueOf(this.task))) { + return this.inst; + } else { + inst = instructionService.findByCodeFromCache(String.valueOf(task)); + return inst; + } + } + } else { + inst = instructionService.findByCodeFromCache(String.valueOf(task)); + return inst; + } + return null; + } +} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator_site/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator_site/ItemProtocol.java new file mode 100644 index 0000000..ee0de43 --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/box_manipulator_site/ItemProtocol.java @@ -0,0 +1,142 @@ +package org.nl.acs.device_driver.box_manipulator_site; + +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_qty = "qty"; + //任务号 + public static String item_task = "task"; + //报警 + public static String item_error = "error"; + //托盘类型 + public static String item_container_type="container_type"; + //托盘方向 + public static String item_carrier_direction="carrier_direction"; + //行架任务号 + public static String item_hj_task = "hj_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_to_container_type = "to_container_type"; + + private BoxManipulatorSiteDeviceDriver driver; + + public ItemProtocol(BoxManipulatorSiteDeviceDriver 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 getQty(){ + return this.getOpcIntegerValue(item_qty); + } + + public int getCarrier_direction(){ + return this.getOpcIntegerValue(item_carrier_direction); + } + + public int getHj_task(){ + return this.getOpcIntegerValue(item_hj_task); + } + + public int getTo_task() { + return this.getOpcIntegerValue(item_to_task); + } + + public int getTo_command() { + return this.getOpcIntegerValue(item_to_command); + } + + public int getTo_target() { + return this.getOpcIntegerValue(item_to_target); + } + + public int getContainer_type(){ + return this.getOpcIntegerValue(item_container_type); + } + + public int getTo_container_type(){ + return this.getOpcIntegerValue(item_to_container_type); + } + + + 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, "心跳", "DB1.B0")); + list.add(new ItemDto(item_mode, "工作模式", "DB1.B1")); + list.add(new ItemDto(item_move, "光电信号", "DB1.B2")); + list.add(new ItemDto(item_action, "动作信号", "DB1.B3")); + list.add(new ItemDto(item_error, "报警信号", "DB1.B5")); + list.add(new ItemDto(item_task, "任务号", "DB1.D6")); + list.add(new ItemDto(item_container_type, "托盘类型", "DB1.B7")); + list.add(new ItemDto(item_qty, "数量", "DB1.B8")); + list.add(new ItemDto(item_hj_task, "行架任务号", "DB1.D9")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList<>(); + list.add(new ItemDto(item_to_command, "下发命令", "DB2.W0")); + list.add(new ItemDto(item_to_target, "下发目标站", "DB2.W4")); + list.add(new ItemDto(item_to_task, "下发任务号", "DB2.D6")); + list.add(new ItemDto(item_to_container_type, "下发托盘类型", "DB2.W8")); + return list; + } +} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/box_palletizing_manipulator/BoxPalletizingManipulatorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/box_palletizing_manipulator/BoxPalletizingManipulatorDeviceDriver.java index 29b0ea2..247f98a 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/box_palletizing_manipulator/BoxPalletizingManipulatorDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/box_palletizing_manipulator/BoxPalletizingManipulatorDeviceDriver.java @@ -49,64 +49,94 @@ public class BoxPalletizingManipulatorDeviceDriver extends AbstractOpcDeviceDriv @Autowired DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - /** - * 工作模式 - */ + //工作模式 int mode = 0; int last_mode = 0; - /** - * 光电信号 - */ + //光电信号 int move = 0; int last_move = 0; - /** - * 动作信号 - */ + //动作信号 int action = 0; int last_action = 0; - /** - * 行走列 - */ + //行走列 int walk_y = 0; int last_walk_y = 0; - /** - * 报警 - */ + //报警信号 int error = 0; int last_error = 0; - /** - * 任务号 - */ + //任务号 int task = 0; int last_task = 0; + // x坐标 + float x_position = 0; + float last_x_position = 0; + // y坐标 + float y_position = 0; + float last_y_position = 0; + int heartbeat = 0; + int last_heartbeat = 0; + int to_command = 0; + int last_to_command = 0; + + int to_target = 0; + int last_to_target = 0; + + int to_task = 0; + int last_to_task = 0; + + int to_onset = 0; + int last_to_onset = 0; + + int to_size = 0; + int last_to_size = 0; + + int to_barcode = 0; + int last_to_barcode = 0; + + int to_layer = 0; + int last_to_layer = 0; + + int to_last = 0; + int last_to_last = 0; Boolean isonline = true; int hasGoods = 0; String message = null; Boolean iserror = false; - + private Date instruction_update_time = new Date(); + private int instruction_update_time_out = 1000; Integer heartbeat_tag; private Date instruction_require_time = new Date(); - private int instruction_require_time_out; - /** - * 行架机械手申请任务成功标识 - */ + private int instruction_require_time_out = 3000; + //行架机械手申请任务成功标识 boolean requireSucess = false; private int instruction_finished_time_out; int branchProtocol = 0; + private String error_type = "hxhj_error_type"; - - /** - * 暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - */ + //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 int flag; String device_code; + //当前指令 + Instruction inst = null; + + //0 无任务执行 1更新指令状态 2下发电气信号 3允许取货 允许放货 5放货完成 + int now_steps_type = 0; + String notCreateTaskMessage = ""; + String notCreateInstMessage = ""; + String feedMessage = ""; + + + List getDeviceCodeList = null; + + List putDeviceCodeList = null; + @Override public Device getDevice() { @@ -125,7 +155,43 @@ public class BoxPalletizingManipulatorDeviceDriver extends AbstractOpcDeviceDriv walk_y = this.itemProtocol.getWalk_y(); error = this.itemProtocol.getError(); task = this.itemProtocol.getTask(); + heartbeat = this.itemProtocol.getHeartbeat(); + to_command = this.itemProtocol.getTo_command(); + to_target = this.itemProtocol.getTo_target(); + to_task = this.itemProtocol.getTo_task(); + to_onset = this.itemProtocol.getTo_onset(); + x_position = this.itemProtocol.getX_position(); + y_position = this.itemProtocol.getY_position(); + to_barcode = this.itemProtocol.getTo_barcode(); + to_size = this.itemProtocol.getTo_size(); + to_layer = this.itemProtocol.getTo_layer(); + to_last = this.itemProtocol.getTo_last(); + if (to_onset != last_to_onset) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_onset:" + last_to_onset + "->" + to_onset); + } + if (to_command != last_to_command) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command:" + last_to_command + "->" + to_command); + } + if (to_target != last_to_target) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target:" + last_to_target + "->" + to_target); + } + if (to_task != last_to_task) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task:" + last_to_task + "->" + to_task); + } + if (to_last != last_to_last) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_last:" + last_to_last + "->" + to_last); + } + if (to_size != last_to_size) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_size:" + last_to_size + "->" + to_size); + } + if (to_barcode != last_to_barcode) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_barcode:" + last_to_barcode + "->" + to_barcode); + } + if (to_layer != last_to_layer) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_layer:" + last_to_layer + "->" + to_layer); + } if (mode != last_mode) { + requireSucess = false; logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); } @@ -149,6 +215,14 @@ public class BoxPalletizingManipulatorDeviceDriver extends AbstractOpcDeviceDriv logServer.deviceItemValue(this.device_code, "task", String.valueOf(task)); logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); } + if (x_position != last_x_position) { + logServer.deviceItemValue(this.device_code, "x_position", String.valueOf(x_position)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号x_position:" + last_x_position + "->" + x_position); + } + if (y_position != last_y_position) { + logServer.deviceItemValue(this.device_code, "y_position", String.valueOf(y_position)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号y_position:" + last_y_position + "->" + y_position); + } } catch (Exception var17) { return; @@ -183,6 +257,17 @@ public class BoxPalletizingManipulatorDeviceDriver extends AbstractOpcDeviceDriv last_walk_y = walk_y; last_error = error; last_task = task; + last_heartbeat = heartbeat; + last_to_task = to_task; + last_to_command = to_command; + last_to_target = to_target; + last_to_onset = to_onset; + last_x_position = x_position; + last_y_position = y_position; + last_to_layer = to_layer; + last_to_barcode = to_barcode; + last_to_size = to_size; + last_to_last = to_last; } @@ -232,6 +317,7 @@ public class BoxPalletizingManipulatorDeviceDriver extends AbstractOpcDeviceDriv /** * 将扩展表中的字符串数据转换成集合 + * * @param extraName * @return */ diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/box_palletizing_manipulator/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/box_palletizing_manipulator/ItemProtocol.java index 083b8f3..4f5ce43 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/box_palletizing_manipulator/ItemProtocol.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/box_palletizing_manipulator/ItemProtocol.java @@ -12,35 +12,41 @@ import java.util.List; @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_walk_y = "walk_y"; - /** - * 报警 - */ - public static String item_error = "error"; - /** - * 任务号 - */ + //任务号 public static String item_task = "task"; + //报警 + public static String item_error = "error"; + //x轴坐标 + public static String item_x_position = "x_position"; + //y轴坐标 + public static String item_y_position = "y_position"; + //下发命令 + public static String item_to_command = "to_command"; + //下发起始站 + public static String item_to_onset = "to_onset"; + //下发目标站 + public static String item_to_target = "to_target"; + //下发任务号 + public static String item_to_task = "to_task"; + //下发是否最后子卷 + public static String item_to_last = "to_last"; + //下发物料规格 + public static String item_to_size = "to_size"; + //下发木箱条码 + public static String item_to_barcode = "to_barcode"; + //下发木箱层数 + public static String item_to_layer = "to_layer"; private BoxPalletizingManipulatorDeviceDriver driver; @@ -76,6 +82,46 @@ public class ItemProtocol { return this.getOpcIntegerValue(item_task); } + public int getTo_task() { + return this.getOpcIntegerValue(item_to_task); + } + + public int getTo_onset() { + return this.getOpcIntegerValue(item_to_onset); + } + + public int getTo_command() { + return this.getOpcIntegerValue(item_to_command); + } + + public int getTo_target() { + return this.getOpcIntegerValue(item_to_target); + } + + public int getX_position() { + return this.getOpcIntegerValue(item_x_position); + } + + public int getY_position() { + return this.getOpcIntegerValue(item_y_position); + } + + public int getTo_size(){ + return this.getOpcIntegerValue(item_to_size); + } + + public int getTo_last(){ + return this.getOpcIntegerValue(item_to_last); + } + + public int getTo_barcode(){ + return this.getOpcIntegerValue(item_to_barcode); + } + + public int getTo_layer(){ + return this.getOpcIntegerValue(item_to_layer); + } + Boolean isonline; @@ -111,11 +157,21 @@ public class ItemProtocol { list.add(new ItemDto(item_walk_y, "行走列", "DB1.B4")); list.add(new ItemDto(item_error, "报警信号", "DB1.B5")); list.add(new ItemDto(item_task, "任务号", "DB1.D6")); + list.add(new ItemDto(item_x_position, "x坐标", "DB1.REAL10")); + list.add(new ItemDto(item_y_position, "y坐标", "DB1.REAL14")); return list; } public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); + list.add(new ItemDto(item_to_command, "下发命令", "DB2.W0")); + list.add(new ItemDto(item_to_onset, "下发起始站", "DB2.W2")); + list.add(new ItemDto(item_to_target, "下发目标站", "DB2.W4")); + list.add(new ItemDto(item_to_task, "下发任务号", "DB2.D6")); + list.add(new ItemDto(item_to_last, "下发是否最后子卷", "DB2.W10")); + list.add(new ItemDto(item_to_size, "下发物料规格", "DB2.String.50")); + list.add(new ItemDto(item_to_barcode, "下发木箱条码", "DB2.String.50")); + list.add(new ItemDto(item_to_layer, "下发木箱层数", "DB2.W12")); return list; } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/oven_manipulator/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/oven_manipulator/ItemProtocol.java index 9bead50..b2396e6 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/oven_manipulator/ItemProtocol.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/oven_manipulator/ItemProtocol.java @@ -1,148 +1,150 @@ -package org.nl.acs.device_driver.conveyor.oven_manipulator; - -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_action = "action"; - /** - * 行走列 - */ - public static String item_walk_y = "walk_y"; - /** - * 报警 - */ - 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_onset = "to_onset"; - /** - * 下发目标站 - */ - public static String item_to_target = "to_target"; - /** - * 下发任务号 - */ - public static String item_to_task = "to_task"; - - - private OvenGantryManipulatorDeviceDriver driver; - - public ItemProtocol(OvenGantryManipulatorDeviceDriver 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 getWalk_y() { - return this.getOpcIntegerValue(item_walk_y); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - - 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 String getOpcStringValue(String protocol) { - String value = this.driver.getStringValue(protocol); - if (StrUtil.isEmpty(value)) { - - } else { - return value; - } - return "0"; - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB1.B0")); - list.add(new ItemDto(item_mode, "工作模式", "DB1.B1")); - list.add(new ItemDto(item_move, "光电信号", "DB1.B2")); - list.add(new ItemDto(item_action, "动作信号", "DB1.B3")); - list.add(new ItemDto(item_walk_y, "行走列", "DB1.B4")); - list.add(new ItemDto(item_error, "报警信号", "DB1.B5")); - list.add(new ItemDto(item_task, "任务号", "DB1.D6")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "下发命令", "DB2.W0")); - list.add(new ItemDto(item_to_onset, "下发起始站", "DB2.W2")); - list.add(new ItemDto(item_to_target, "下发目标站", "DB2.W4")); - list.add(new ItemDto(item_to_task, "下发任务号", "DB2.D6")); - return list; - } - - @Override - public String toString() { - return ""; - } -} - +//package org.nl.acs.device_driver.conveyor.oven_manipulator; +// +//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_action = "action"; +// /** +// * 行走列 +// */ +// public static String item_walk_y = "walk_y"; +// /** +// * 报警 +// */ +// 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_onset = "to_onset"; +// /** +// * 下发目标站 +// */ +// public static String item_to_target = "to_target"; +// /** +// * 下发任务号 +// */ +// public static String item_to_task = "to_task"; +// +// +// private OvenGantryManipulatorDeviceDriver driver; +// +// public ItemProtocol(OvenGantryManipulatorDeviceDriver 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 getWalk_y() { +// return this.getOpcIntegerValue(item_walk_y); +// } +// +// public int getError() { +// return this.getOpcIntegerValue(item_error); +// } +// +// public int getTask() { +// return this.getOpcIntegerValue(item_task); +// } +// +// +// +// +// 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 String getOpcStringValue(String protocol) { +// String value = this.driver.getStringValue(protocol); +// if (StrUtil.isEmpty(value)) { +// +// } else { +// return value; +// } +// return "0"; +// } +// +// public static List getReadableItemDtos() { +// ArrayList list = new ArrayList(); +// list.add(new ItemDto(item_heartbeat, "心跳", "DB1.B0")); +// list.add(new ItemDto(item_mode, "工作模式", "DB1.B1")); +// list.add(new ItemDto(item_move, "光电信号", "DB1.B2")); +// list.add(new ItemDto(item_action, "动作信号", "DB1.B3")); +// list.add(new ItemDto(item_walk_y, "行走列", "DB1.B4")); +// list.add(new ItemDto(item_error, "报警信号", "DB1.B5")); +// list.add(new ItemDto(item_task, "任务号", "DB1.D6")); +// return list; +// } +// +// public static List getWriteableItemDtos() { +// ArrayList list = new ArrayList(); +// list.add(new ItemDto(item_to_command, "下发命令", "DB2.W0")); +// list.add(new ItemDto(item_to_onset, "下发起始站", "DB2.W2")); +// list.add(new ItemDto(item_to_target, "下发目标站", "DB2.W4")); +// list.add(new ItemDto(item_to_task, "下发任务号", "DB2.D6")); +// return list; +// } +// +// @Override +// public String toString() { +// return ""; +// } +//} +// diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/oven_manipulator/OvenGantryManipulatorDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/oven_manipulator/OvenGantryManipulatorDefination.java index 8449377..c77d28e 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/oven_manipulator/OvenGantryManipulatorDefination.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/oven_manipulator/OvenGantryManipulatorDefination.java @@ -1,62 +1,62 @@ -package org.nl.acs.device_driver.conveyor.oven_manipulator; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device.domain.Device; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.device.enums.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.LinkedList; -import java.util.List; - -/** - * 烘箱-行架机械手 - */ -@Service -public class OvenGantryManipulatorDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "oven_manipulator"; - } - - @Override - public String getDriverName() { - return "烘箱-行架机械手"; - } - - @Override - public String getDriverDescription() { - return "烘箱-行架机械手"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new OvenGantryManipulatorDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return OvenGantryManipulatorDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.station); - return types; - } - - @Override - public List getReadableItemDtos() { - return ItemProtocol.getReadableItemDtos(); - } - - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} +//package org.nl.acs.device_driver.conveyor.oven_manipulator; +// +//import org.nl.acs.device.device_driver.standard_inspect.ItemDto; +//import org.nl.acs.device.domain.Device; +//import org.nl.acs.device_driver.DeviceDriver; +//import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; +//import org.nl.acs.device.enums.DeviceType; +//import org.springframework.stereotype.Service; +// +//import java.util.LinkedList; +//import java.util.List; +// +///** +// * 烘箱-行架机械手 +// */ +//@Service +//public class OvenGantryManipulatorDefination implements OpcDeviceDriverDefination { +// @Override +// public String getDriverCode() { +// return "oven_manipulator"; +// } +// +// @Override +// public String getDriverName() { +// return "烘箱-行架机械手"; +// } +// +// @Override +// public String getDriverDescription() { +// return "烘箱-行架机械手"; +// } +// +// @Override +// public DeviceDriver getDriverInstance(Device device) { +// return (new OvenGantryManipulatorDeviceDriver()).setDevice(device).setDriverDefination(this); +// +// } +// +// @Override +// public Class getDeviceDriverType() { +// return OvenGantryManipulatorDeviceDriver.class; +// } +// +// @Override +// public List getFitDeviceTypes() { +// List types = new LinkedList(); +// types.add(DeviceType.station); +// return types; +// } +// +// @Override +// public List getReadableItemDtos() { +// return ItemProtocol.getReadableItemDtos(); +// } +// +// +// @Override +// public List getWriteableItemDtos() { +// return ItemProtocol.getWriteableItemDtos(); +// } +// +//} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/oven_manipulator/OvenGantryManipulatorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/oven_manipulator/OvenGantryManipulatorDeviceDriver.java index 2d4fcd6..1e14dcf 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/oven_manipulator/OvenGantryManipulatorDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/oven_manipulator/OvenGantryManipulatorDeviceDriver.java @@ -1,385 +1,710 @@ -package org.nl.acs.device_driver.conveyor.oven_manipulator; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -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.common.base.CommonFinalParam; -import org.nl.acs.device.domain.Device; -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.device_driver.hongxiang_device.HongXiangConveyorDeviceDriver; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.instruction.domain.Instruction; -import org.nl.acs.instruction.enums.InstructionStatusEnum; -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.DeviceAppService; -import org.nl.acs.opc.DeviceAppServiceImpl; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.task.enums.TaskStatusEnum; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.common.exception.BadRequestException; -import org.nl.config.SpringContextHolder; -import org.nl.config.language.LangProcess; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.*; - -/** - * 烘箱-行架机械手 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor { - 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 - DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl"); - @Autowired - DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - - /** - * 工作模式 - */ - int mode = 0; - int last_mode = 0; - /** - * 光电信号 - */ - int move = 0; - int last_move = 0; - /** - * 动作信号 - */ - int action = 0; - int last_action = 0; - /** - * 行走列 - */ - int walk_y = 0; - int last_walk_y = 0; - /** - * 报警 - */ - int error = 0; - int last_error = 0; - /** - * 任务号 - */ - int task = 0; - int last_task = 0; - - - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - - private int instruction_require_time_out; - /** - * 行架机械手申请任务成功标识 - */ - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - - - /** - * 暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - */ - int flag; - - String device_code; - - /** - * 0 无任务执行 1更新指令状态 2下发电气信号 3允许取货 允许放货 5放货完成 - */ - int now_steps_type = 0; - String notCreateTaskMessage = ""; - String notCreateInstMessage = ""; - String feedMessage = ""; - - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - try { - device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - move = this.itemProtocol.getMove(); - action = this.itemProtocol.getAction(); - walk_y = this.itemProtocol.getWalk_y(); - error = this.itemProtocol.getError(); - task = this.itemProtocol.getTask(); - if (mode != last_mode) { - if (mode == 2) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号复位前requireSuccess:" + requireSucess); - this.setRequireSucess(false); - message = null; - logServer.deviceExecuteLog(this.device_code, "", "", "信号复位后requireSuccess:" + requireSucess); - } - logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); - } - if (move != last_move) { - logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); - } - if (action != last_action) { - logServer.deviceItemValue(this.device_code, "action", String.valueOf(action)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action); - } - if (error != last_error) { - logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); - } - if (walk_y != last_walk_y) { - logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(walk_y)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号walk_y:" + last_walk_y + "->" + walk_y); - } - if (task != last_task) { - logServer.deviceItemValue(this.device_code, "task", String.valueOf(task)); - logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); - } - - //更改任务状态 - if (task > 0) { - //inst_message - Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task)); - if (inst1 != null) { - if (StrUtil.equals(inst1.getInstruction_status(), InstructionStatusEnum.READY.getIndex())) { - inst1.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); - inst1.setExecute_device_code(this.device_code); - instructionService.update(inst1); -// TaskDto tas未反馈电气信号原因kDto = taskserver.findByCodeFromCache(inst1.getTask_code()); -// if (ObjectUtil.isNotEmpty(taskDto)) { -// if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) { -// JSONArray array = new JSONArray(); -// JSONObject map = new JSONObject(); -// map.put("task_id", taskDto.getExt_task_id()); -// map.put("task_status", CommonFinalParam.ONE); -// array.add(map); -// acsToWmsService.feedbackTaskStatusToWms(array); +//package org.nl.acs.device_driver.conveyor.oven_manipulator; +// +//import cn.hutool.core.date.DateUtil; +//import cn.hutool.core.util.IdUtil; +//import cn.hutool.core.util.ObjectUtil; +//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.common.base.CommonFinalParam; +//import org.nl.acs.device.domain.Device; +//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.conveyor.hongxiang_device.HongXiangConveyorDeviceDriver; +//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.instruction.domain.Instruction; +//import org.nl.acs.instruction.enums.InstructionStatusEnum; +//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.DeviceAppService; +//import org.nl.acs.opc.DeviceAppServiceImpl; +//import org.nl.acs.route.service.RouteLineService; +//import org.nl.acs.task.enums.TaskStatusEnum; +//import org.nl.acs.task.service.TaskService; +//import org.nl.acs.task.service.dto.TaskDto; +//import org.nl.common.exception.BadRequestException; +//import org.nl.config.SpringContextHolder; +//import org.nl.config.language.LangProcess; +//import org.openscada.opc.lib.da.Server; +//import org.springframework.beans.factory.annotation.Autowired; +// +//import java.util.*; +// +///** +// * 烘箱-行架机械手 +// */ +//@Slf4j +//@Data +//@RequiredArgsConstructor +//public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor { +// 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 +// DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); +// @Autowired +// AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl"); +// @Autowired +// DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); +// +// /** +// * 工作模式 +// */ +// int mode = 0; +// int last_mode = 0; +// /** +// * 光电信号 +// */ +// int move = 0; +// int last_move = 0; +// /** +// * 动作信号 +// */ +// int action = 0; +// int last_action = 0; +// /** +// * 行走列 +// */ +// int walk_y = 0; +// int last_walk_y = 0; +// /** +// * 报警 +// */ +// int error = 0; +// int last_error = 0; +// /** +// * 任务号 +// */ +// int task = 0; +// int last_task = 0; +// +// +// Boolean isonline = true; +// int hasGoods = 0; +// String message = null; +// Boolean iserror = false; +// +// Integer heartbeat_tag; +// private Date instruction_require_time = new Date(); +// +// private int instruction_require_time_out; +// /** +// * 行架机械手申请任务成功标识 +// */ +// boolean requireSucess = false; +// +// private int instruction_finished_time_out; +// +// int branchProtocol = 0; +// +// +// /** +// * 暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 +// */ +// int flag; +// +// String device_code; +// +// /** +// * 0 无任务执行 1更新指令状态 2下发电气信号 3允许取货 允许放货 5放货完成 +// */ +// int now_steps_type = 0; +// String notCreateTaskMessage = ""; +// String notCreateInstMessage = ""; +// String feedMessage = ""; +// +// +// @Override +// public Device getDevice() { +// return this.device; +// } +// +// +// @Override +// public void execute() { +// String message = null; +// try { +// device_code = this.getDeviceCode(); +// mode = this.itemProtocol.getMode(); +// move = this.itemProtocol.getMove(); +// action = this.itemProtocol.getAction(); +// walk_y = this.itemProtocol.getWalk_y(); +// error = this.itemProtocol.getError(); +// task = this.itemProtocol.getTask(); +// if (mode != last_mode) { +// if (mode == 2) { +// logServer.deviceExecuteLog(this.device_code, "", "", "信号复位前requireSuccess:" + requireSucess); +// this.setRequireSucess(false); +// message = null; +// logServer.deviceExecuteLog(this.device_code, "", "", "信号复位后requireSuccess:" + requireSucess); +// } +// logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); +// logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); +// } +// if (move != last_move) { +// logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); +// logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); +// } +// if (action != last_action) { +// logServer.deviceItemValue(this.device_code, "action", String.valueOf(action)); +// logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action); +// } +// if (error != last_error) { +// logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); +// logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); +// } +// if (walk_y != last_walk_y) { +// logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(walk_y)); +// logServer.deviceExecuteLog(this.device_code, "", "", "信号walk_y:" + last_walk_y + "->" + walk_y); +// } +// if (task != last_task) { +// logServer.deviceItemValue(this.device_code, "task", String.valueOf(task)); +// logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); +// } +// +// //更改任务状态 +// if (task > 0) { +// //inst_message +// Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task)); +// if (inst1 != null) { +// if (StrUtil.equals(inst1.getInstruction_status(), InstructionStatusEnum.READY.getIndex())) { +// inst1.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); +// inst1.setExecute_device_code(this.device_code); +// instructionService.update(inst1); +//// TaskDto tas未反馈电气信号原因kDto = taskserver.findByCodeFromCache(inst1.getTask_code()); +//// if (ObjectUtil.isNotEmpty(taskDto)) { +//// if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) { +//// JSONArray array = new JSONArray(); +//// JSONObject map = new JSONObject(); +//// map.put("task_id", taskDto.getExt_task_id()); +//// map.put("task_status", CommonFinalParam.ONE); +//// array.add(map); +//// acsToWmsService.feedbackTaskStatusToWms(array); +//// } +//// } +// } +// } +// } +// +// //申请取货 +// if (mode == 3 && action == 1 && move == 0 && task > 0) { +// Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task)); +// if (ObjectUtil.isNotEmpty(inst2)) { +// String start_device_code = inst2.getStart_device_code(); +// Device device = deviceAppService.findDeviceByCode(start_device_code); +// HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; +// if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { +// hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver(); +// //hongXiangConveyorDeviceDriver.writing("to_open_door", CommonFinalParam.ONE); +// int mode = hongXiangConveyorDeviceDriver.getMode(); +// int door = hongXiangConveyorDeviceDriver.getDoor(); +// int action = hongXiangConveyorDeviceDriver.getAction(); +// int error1 = hongXiangConveyorDeviceDriver.getError1(); +// if (mode == 1 && door == 1 && action == 1 && error1 == 0) { +// if (this.getNow_steps_type() == 2) { +// this.writing("to_command", "2"); +// this.setNow_steps_type(3); +// } else { +// logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为下发电气信号(now_steps_type!=2)"); +// } +// } else { +// if (this.getNow_steps_type() == 2) { +// feedMessage = "烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code(); +// if (mode != 1) { +// feedMessage = feedMessage + "mode未联机,"; +// } +// if (door != 1) { +// feedMessage = feedMessage + "door未开门,"; +// } +// if (action != 1) { +// feedMessage = feedMessage + "action未允许取放,"; +// } +// if (error1 != 0) { +// feedMessage = feedMessage + "error1出现故障。"; +// } // } // } - } - } - } - - //申请取货 - if (mode == 3 && action == 1 && move == 0 && task > 0) { - Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task)); - if (ObjectUtil.isNotEmpty(inst2)) { - String start_device_code = inst2.getStart_device_code(); - Device device = deviceAppService.findDeviceByCode(start_device_code); - HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; - if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver(); - //hongXiangConveyorDeviceDriver.writing("to_open_door", CommonFinalParam.ONE); - int mode = hongXiangConveyorDeviceDriver.getMode(); - int door = hongXiangConveyorDeviceDriver.getDoor(); - int action = hongXiangConveyorDeviceDriver.getAction(); - int error1 = hongXiangConveyorDeviceDriver.getError1(); - if (mode == 1 && door == 1 && action == 1 && error1 == 0) { - if (this.getNow_steps_type() == 2) { - this.writing("to_command", "2"); - this.setNow_steps_type(3); - } else { - logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为下发电气信号(now_steps_type!=2)"); - } - } else { - if (this.getNow_steps_type() == 2) { - feedMessage = "烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code(); - if (mode != 1) { - feedMessage = feedMessage + "mode未联机,"; - } - if (door != 1) { - feedMessage = feedMessage + "door未开门,"; - } - if (action != 1) { - feedMessage = feedMessage + "action未允许取放,"; - } - if (error1 != 0) { - feedMessage = feedMessage + "error1出现故障。"; - } - } - } - } else { - if (this.getNow_steps_type() == 2) { - this.writing("to_command", "2"); - this.setNow_steps_type(3); - } else { - logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为下发电气信号(now_steps_type!=2)\")"); - } - } - } - } else { - if (this.getNow_steps_type() == 2) { - feedMessage = "行架机械手:"; - if (mode != 3) { - feedMessage = feedMessage + "mode不为运行中状态,"; - } - if (action != 1) { - feedMessage = feedMessage + "action不为取货中状态,"; - } - if (move != 0) { - feedMessage = feedMessage + "move不为无货状态,"; - } - if (task == 0) { - feedMessage = feedMessage + "task为0。"; - } - } - } - - //取货完成关闭烘箱门 - if (mode == 3 && action == 2 && move == 1 && task > 0) { - Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task)); - if (ObjectUtil.isNotEmpty(inst2)) { - String start_device_code = inst2.getStart_device_code(); - Device device = deviceAppService.findDeviceByCode(start_device_code); - HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; - if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver(); - hongXiangConveyorDeviceDriver.writing("to_close_door", CommonFinalParam.ONE); - } - if (this.getNow_steps_type() == 3) { - this.writing("to_command", "3"); - this.setNow_steps_type(4); - } else { - logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为允许取货(now_steps_type!=3)"); - } - } - } else { - if (this.getNow_steps_type() == 3) { - feedMessage = "行架机械手:"; - if (mode != 3) { - feedMessage = feedMessage + "mode不为运行中状态,"; - } - if (action != 2) { - feedMessage = feedMessage + "action不为取货完成状态,"; - } - if (move != 1) { - feedMessage = feedMessage + "move不为有货状态,"; - } - if (task == 0) { - feedMessage = feedMessage + "task为0。"; - } - } - } - - //申请放货 - if (mode == 3 && action == 3 && move == 1 && task > 0) { - Instruction instructionDto = instructionService.findByCode(String.valueOf(task)); - String next_device_code = instructionDto.getNext_device_code(); - Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); - HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; - if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver(); - //hongXiangConveyorDeviceDriver.writing("to_open_door", CommonFinalParam.ONE); - int mode = hongXiangConveyorDeviceDriver.getMode(); - int door = hongXiangConveyorDeviceDriver.getDoor(); - int action = hongXiangConveyorDeviceDriver.getAction(); - int error1 = hongXiangConveyorDeviceDriver.getError1(); - if (mode == 1 && door == 1 && action == 1 && error1 == 0) { - if (this.getNow_steps_type() == 4) { - this.writing("to_command", "4"); - this.setNow_steps_type(5); - } else { - logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为允许放货(now_steps_type!=4)"); - } - } else { - feedMessage = "烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code(); - if (mode != 1) { - feedMessage = feedMessage + "mode未联机,"; - } - if (door != 1) { - feedMessage = feedMessage + "door未开门,"; - } - if (action != 1) { - feedMessage = feedMessage + "action未允许取放,"; - } - if (error1 != 0) { - feedMessage = feedMessage + "error1出现故障。"; - } - } - } else { - if (this.getNow_steps_type() == 4) { - this.writing("to_command", "4"); - this.setNow_steps_type(5); - } else { - logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为允许放货(now_steps_type!=4)"); - } - } - } else { - if (this.getNow_steps_type() == 4) { - feedMessage = "行架机械手:"; - if (mode != 3) { - feedMessage = feedMessage + "mode不为运行中状态,"; - } - if (action != 3) { - feedMessage = feedMessage + "action不为放货中状态,"; - } - if (move != 1) { - feedMessage = feedMessage + "move不为有货状态,"; - } - if (task == 0) { - feedMessage = feedMessage + "task为0。"; - } - } - } - - //放货完成 - if (mode == 3 && action == 4 && move == 0 && task > 0) { - Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task)); - if (inst2 != null) { - if (StrUtil.equals(inst2.getInstruction_status(), InstructionStatusEnum.BUSY.getIndex())) { - try { - finish_instruction(inst2); - } catch (Exception e) { - e.printStackTrace(); - } - TaskDto taskDto = taskserver.findByCode(inst2.getTask_code()); - - String next_device_code = taskDto.getNext_device_code(); - //String start_device_code = taskDto.getStart_device_code(); - //Device startDevice = deviceAppService.findDeviceByCode(start_device_code); - Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); - HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; -// if (startDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { -// hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startDevice.getDeviceDriver(); +// } else { +// if (this.getNow_steps_type() == 2) { +// this.writing("to_command", "2"); +// this.setNow_steps_type(3); +// } else { +// logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为下发电气信号(now_steps_type!=2)\")"); +// } +// } +// } +// } else { +// if (this.getNow_steps_type() == 2) { +// feedMessage = "行架机械手:"; +// if (mode != 3) { +// feedMessage = feedMessage + "mode不为运行中状态,"; +// } +// if (action != 1) { +// feedMessage = feedMessage + "action不为取货中状态,"; +// } +// if (move != 0) { +// feedMessage = feedMessage + "move不为无货状态,"; +// } +// if (task == 0) { +// feedMessage = feedMessage + "task为0。"; +// } +// } +// } +// +// //取货完成关闭烘箱门 +// if (mode == 3 && action == 2 && move == 1 && task > 0) { +// Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task)); +// if (ObjectUtil.isNotEmpty(inst2)) { +// String start_device_code = inst2.getStart_device_code(); +// Device device = deviceAppService.findDeviceByCode(start_device_code); +// HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; +// if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { +// hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver(); +// hongXiangConveyorDeviceDriver.writing("to_close_door", CommonFinalParam.ONE); +// } +// if (this.getNow_steps_type() == 3) { +// this.writing("to_command", "3"); +// this.setNow_steps_type(4); +// } else { +// logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为允许取货(now_steps_type!=3)"); +// } +// } +// } else { +// if (this.getNow_steps_type() == 3) { +// feedMessage = "行架机械手:"; +// if (mode != 3) { +// feedMessage = feedMessage + "mode不为运行中状态,"; +// } +// if (action != 2) { +// feedMessage = feedMessage + "action不为取货完成状态,"; +// } +// if (move != 1) { +// feedMessage = feedMessage + "move不为有货状态,"; +// } +// if (task == 0) { +// feedMessage = feedMessage + "task为0。"; +// } +// } +// } +// +// //申请放货 +// if (mode == 3 && action == 3 && move == 1 && task > 0) { +// Instruction instructionDto = instructionService.findByCode(String.valueOf(task)); +// String next_device_code = instructionDto.getNext_device_code(); +// Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); +// HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; +// if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { +// hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver(); +// //hongXiangConveyorDeviceDriver.writing("to_open_door", CommonFinalParam.ONE); +// int mode = hongXiangConveyorDeviceDriver.getMode(); +// int door = hongXiangConveyorDeviceDriver.getDoor(); +// int action = hongXiangConveyorDeviceDriver.getAction(); +// int error1 = hongXiangConveyorDeviceDriver.getError1(); +// if (mode == 1 && door == 1 && action == 1 && error1 == 0) { +// if (this.getNow_steps_type() == 4) { +// this.writing("to_command", "4"); +// this.setNow_steps_type(5); +// } else { +// logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为允许放货(now_steps_type!=4)"); +// } +// } else { +// feedMessage = "烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code(); +// if (mode != 1) { +// feedMessage = feedMessage + "mode未联机,"; +// } +// if (door != 1) { +// feedMessage = feedMessage + "door未开门,"; +// } +// if (action != 1) { +// feedMessage = feedMessage + "action未允许取放,"; +// } +// if (error1 != 0) { +// feedMessage = feedMessage + "error1出现故障。"; +// } +// } +// } else { +// if (this.getNow_steps_type() == 4) { +// this.writing("to_command", "4"); +// this.setNow_steps_type(5); +// } else { +// logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为允许放货(now_steps_type!=4)"); +// } +// } +// } else { +// if (this.getNow_steps_type() == 4) { +// feedMessage = "行架机械手:"; +// if (mode != 3) { +// feedMessage = feedMessage + "mode不为运行中状态,"; +// } +// if (action != 3) { +// feedMessage = feedMessage + "action不为放货中状态,"; +// } +// if (move != 1) { +// feedMessage = feedMessage + "move不为有货状态,"; +// } +// if (task == 0) { +// feedMessage = feedMessage + "task为0。"; +// } +// } +// } +// +// //放货完成 +// if (mode == 3 && action == 4 && move == 0 && task > 0) { +// Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task)); +// if (inst2 != null) { +// if (StrUtil.equals(inst2.getInstruction_status(), InstructionStatusEnum.BUSY.getIndex())) { +// try { +// finish_instruction(inst2); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// TaskDto taskDto = taskserver.findByCode(inst2.getTask_code()); +// +// String next_device_code = taskDto.getNext_device_code(); +// //String start_device_code = taskDto.getStart_device_code(); +// //Device startDevice = deviceAppService.findDeviceByCode(start_device_code); +// Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); +// HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; +//// if (startDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { +//// hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startDevice.getDeviceDriver(); +//// hongXiangConveyorDeviceDriver.writing("to_close_door", CommonFinalParam.ONE); +//// } +// if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { +// hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver(); // hongXiangConveyorDeviceDriver.writing("to_close_door", CommonFinalParam.ONE); +// if (StrUtil.isNotEmpty(taskDto.getOven_time())) { +// //下发烘箱时间 +// int time = Integer.parseInt(taskDto.getOven_time()); +// int hours = (time % (60 * 60 * 24)) / (60 * 60); +// int minutes = (time % (60 * 60)) / 60; +// hongXiangConveyorDeviceDriver.writing("to_time_house", String.valueOf(hours)); +// hongXiangConveyorDeviceDriver.writing("to_time_min", String.valueOf(minutes)); +// } +// } +// if (this.getNow_steps_type() == 5) { +// this.writing("to_command", "5"); +// this.setNow_steps_type(6); +// this.setNow_steps_type(0); +// feedMessage = ""; +// } else { +// logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为放货完成(now_steps_type!=5)"); +// } +//// this.writing("to_onset", "0"); +//// this.writing("to_target", "0"); +//// this.writing("to_task", "0"); +// } +// } +// } else { +// if (this.getNow_steps_type() == 5) { +// feedMessage = "行架机械手:"; +// if (mode != 3) { +// feedMessage = feedMessage + "mode不为运行中状态,"; +// } +// if (action != 4) { +// feedMessage = feedMessage + "action不为放货完成状态,"; +// } +// if (move != 0) { +// feedMessage = feedMessage + "move不为无货状态,"; +// } +// if (task == 0) { +// feedMessage = feedMessage + "task为0。"; +// } +// } +// } +// +// } catch (Exception var17) { +// feedMessage = var17.getMessage(); +// logServer.deviceExecuteLog(this.getDevice_code(), "", "", "读取信号值时出现异常:" + var17.getMessage()); +// } +// +//// if (!this.itemProtocol.getIsonline()) { +//// this.setIsonline(false); +//// this.setIserror(true); +//// message = "信号量同步异常"; +//// //未联机 +//// } else +// if (mode == 0) { +// this.setIsonline(false); +// message = "未联机"; +// //有报警 +// } else if (error != 0) { +// this.setIserror(true); +// message = "有报警"; +// //无报警 +// } else { +// this.setIsonline(true); +// this.setIserror(false); +// message = ""; +// Instruction instruction = null; +// List toInstructions; +// +// //行架机械手申请任务 +// if (mode == 2 && move == 0 && task == 0 && !requireSucess) { +// applyTask(); +// notCreateInstMessage = ""; +// notCreateTaskMessage = ""; +// feedMessage = ""; +// } else { +// if (mode == 2) { +// //if (!requireSucess) { +// String remark = "未查找任务原因为:"; +// if (mode != 2) { +// remark = remark + "mode不是待机状态,"; +// } +// if (move != 0) { +// remark = remark + "move为有货状态,"; +// } +// if (task != 0) { +// remark = remark + "task任务号不为0,"; +// } +// if (requireSucess) { +// remark = remark + "请求标记requireSucess为true。"; +// } +// this.setNotCreateTaskMessage(remark); +// //} +// } +// } +// +// } +// last_mode = mode; +// last_move = move; +// last_action = action; +// last_walk_y = walk_y; +// last_error = error; +// last_task = task; +// } +// +// +// public boolean exe_error() { +// if (this.error == 0) { +// return true; +// } else { +// log.debug("设备报警"); +// return false; +// } +// } +// +// +// /** +// * 申请任务 +// * +// * @param +// */ +// public synchronized boolean applyTask() { +// Date date = new Date(); +// if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { +// log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); +// return false; +// } else { +// this.instruction_require_time = date; +// //抓取工位 +// List getDeviceCodeList = this.getExtraDeviceCodes("get_device_code"); +// //放货工位 +// List putDeviceCodeList = this.getExtraDeviceCodes("put_device_code"); +// TaskDto task = null; +// for (int i = 0; i < getDeviceCodeList.size(); i++) { +// String startDeviceCode = getDeviceCodeList.get(i); +// List taskDtos = taskserver.queryTaskByDeviceCodeAndStatus(startDeviceCode); +// if (ObjectUtil.isNotEmpty(taskDtos)) { +// //按照优先级排序 优先级相等按照创建时间排序 +// taskDtos = this.sortTask(taskDtos); +// TaskDto taskDto = taskDtos.get(0); +// Instruction instruction = instructionService.findByTaskcode(taskDto.getTask_code()); +// String start_device_code = instruction.getStart_device_code(); +// String next_device_code = instruction.getNext_device_code(); +// //判断关联的同一列烘箱设备是否都关门 都关门返回false,有一个不关门就返回true +// boolean isCloseDoor = this.judgeCloseDoor(start_device_code, next_device_code); +// //未关门结束 +// if (isCloseDoor) { +// return false; +// } +// instruction.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); +// instruction.setUpdate_time(DateUtil.now()); +// instructionService.update(instruction); +// Device startDevice = deviceAppService.findDeviceByCode(start_device_code); +// Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); +// if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) { +// throw new BadRequestException(LangProcess.msg("device_checkAdd", startDevice.getDevice_code())); +// } +// if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))) { +// throw new BadRequestException(LangProcess.msg("device_checkAdd", nextDevice.getDevice_code())); +// } +// String start_addr = startDevice.getExtraValue().get("address").toString(); +// String next_addr = nextDevice.getExtraValue().get("address").toString(); +// this.writing("to_onset", start_addr); +// this.writing("to_target", next_addr); +// this.writing("to_task", instruction.getInstruction_code()); +// this.writing("to_command", CommonFinalParam.ONE); +// +// this.setNow_steps_type(2); +// this.setRequireSucess(true); +// return true; +// } else { +// List taskDtoList = taskserver.queryTaskByDeviceCode(startDeviceCode); +// if (ObjectUtil.isNotEmpty(taskDtoList)) { +// //按照优先级排序 优先级相等按照创建时间排序 +// taskDtoList = this.sortTask(taskDtoList); +// task = taskDtoList.get(0); +// } +// if (ObjectUtil.isNotEmpty(task)) { +// break; +// } +// } +// } +// if (!ObjectUtil.isEmpty(task)) { +// String taskid = task.getTask_id(); +// String taskcode = task.getTask_code(); +// String vehiclecode = task.getVehicle_code(); +// String priority = task.getPriority(); +// String start_point_code = task.getStart_point_code(); +// String start_device_code = task.getStart_device_code(); +// String route_plan_code = task.getRoute_plan_code(); +// String next_point_code = task.getNext_point_code(); +// String next_device_code = task.getNext_device_code(); +// +// Instruction instdto = new Instruction(); +// instdto.setInstruction_id(IdUtil.simpleUUID()); +// instdto.setRoute_plan_code(route_plan_code); +// instdto.setRemark(task.getRemark()); +// instdto.setMaterial(task.getMaterial()); +// instdto.setQuantity(task.getQuantity()); +// instdto.setTask_id(taskid); +// instdto.setTask_code(taskcode); +// instdto.setVehicle_code(vehiclecode); +// String now = DateUtil.now(); +// instdto.setCreate_time(now); +// instdto.setCreate_by("auto"); +// instdto.setStart_device_code(start_device_code); +// instdto.setNext_device_code(next_device_code); +// instdto.setStart_point_code(start_point_code); +// instdto.setNext_point_code(next_point_code); +// instdto.setPriority(priority); +// instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex()); +// instdto.setExecute_device_code(start_point_code); +// +// //判断关联的同一列烘箱设备是否都关门 都关门返回false,有一个不关门就返回true +// boolean isCloseDoor = this.judgeCloseDoor(instdto.getStart_device_code(), instdto.getNext_device_code()); +// //如果未关门结束 +// if (isCloseDoor) { +// return false; +// } +// +// try { +// instructionService.create(instdto); +// } catch (Exception e) { +// notCreateInstMessage = e.getMessage(); +// logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage()); +// return false; +// } +// //创建指令后修改任务状态 +// task.setTask_status(TaskStatusEnum.BUSY.getIndex()); +// task.setUpdate_time(DateUtil.now()); +// taskserver.update(task); +// +// Device startDevice = deviceAppService.findDeviceByCode(instdto.getStart_device_code()); +// Device nextDevice = deviceAppService.findDeviceByCode(instdto.getNext_device_code()); +// if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) { +// notCreateInstMessage = "设备:" + startDevice.getDevice_code() + "未设置电气调度号!"; +// logServer.deviceExecuteLog(this.getDevice_code(), "", "", "设备:" + startDevice.getDevice_code() + "未设置电气调度号!"); +// throw new BadRequestException(LangProcess.msg("device_checkAdd", startDevice.getDevice_code())); +// } +// if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))) { +// notCreateInstMessage = "设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"; +// logServer.deviceExecuteLog(this.getDevice_code(), "", "", "设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"); +// throw new BadRequestException(LangProcess.msg("device_checkAdd", nextDevice.getDevice_code())); +// +// } +// String start_addr = startDevice.getExtraValue().get("address").toString(); +// String next_addr = nextDevice.getExtraValue().get("address").toString(); +// this.writing("to_onset", start_addr); +// this.writing("to_target", next_addr); +// this.writing("to_task", instdto.getInstruction_code()); +// this.writing("to_command", CommonFinalParam.ONE); +// HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; +// if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { +// hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver(); +// hongXiangConveyorDeviceDriver.writing("to_open_door", CommonFinalParam.ONE); +// hongXiangConveyorDeviceDriver.writing("to_open_door", CommonFinalParam.ONE); +// } +// if (startDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { +// hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startDevice.getDeviceDriver(); +// hongXiangConveyorDeviceDriver.writing("to_open_door", CommonFinalParam.ONE); +// hongXiangConveyorDeviceDriver.writing("to_open_door", CommonFinalParam.ONE); +// } +// this.setNow_steps_type(2); +// this.setRequireSucess(true); +// notCreateInstMessage = ""; +// notCreateTaskMessage = ""; +// } else { +// notCreateInstMessage = "未找到关联设备的任务,指令无法创建"; +// } +// return true; +// } +// } +// +// public boolean exe_business() { +// return true; +// } +// +// public synchronized boolean finish_instruction(Instruction inst) throws Exception { +// instructionService.finish(inst); +// return true; +// } +// +// public void writing(String param, String value) { +// +// 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(value)); +//// itemMap.put(to_param, Integer.parseInt(value)); +// this.control(itemMap); +// logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value); +// } +// +// public void executing(Server server, Map itemMap) { +// this.control(itemMap); +// } +// +// /** +// * 判断取货位或放货位为烘箱设备时关联的同一列烘箱设备是否有开门 +// * @param start_device_code +// * @param next_device_code +// * @return +// */ +// public boolean judgeCloseDoor(String start_device_code, String next_device_code) { +// Boolean isClose = false; +// +// try { +// Device startDevice = deviceAppService.findDeviceByCode(start_device_code); +// Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); +// HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; +// if (ObjectUtil.isEmpty(startDevice)) { +// throw new BadRequestException(LangProcess.msg("error_isNull", start_device_code)); +// } +// if (startDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { +// hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startDevice.getDeviceDriver(); +// List deviceCodes = hongXiangConveyorDeviceDriver.getExtraDeviceCodes("link_device_code"); +// if (ObjectUtil.isNotEmpty(deviceCodes)) { +// for (String deviceCode : deviceCodes) { +// Device linkDevice = deviceAppService.findDeviceByCode(deviceCode); +// if (ObjectUtil.isEmpty(linkDevice)) { +// throw new BadRequestException(LangProcess.msg("device_checkrelate", start_device_code, deviceCode, "is null")); // } if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver(); diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor_with_scanner_weight/ConveyorWithScannerWeightDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor_with_scanner_weight/ConveyorWithScannerWeightDefination.java new file mode 100644 index 0000000..2395978 --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor_with_scanner_weight/ConveyorWithScannerWeightDefination.java @@ -0,0 +1,57 @@ +package org.nl.acs.device_driver.conveyor_with_scanner_weight; + +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device.enums.DeviceType; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; +import org.springframework.stereotype.Service; + +import java.util.LinkedList; +import java.util.List; + +@Service +public class ConveyorWithScannerWeightDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "conveyor_with_scanner_weight"; + } + + @Override + public String getDriverName() { + return "输送线工位-带扫码称重"; + } + + @Override + public String getDriverDescription() { + return "输送线工位-带扫码称重"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new ConveyorWithScannerWeightDeviceDriver()).setDevice(device).setDriverDefination(this); + } + + @Override + public Class getDeviceDriverType() { + return ConveyorWithScannerWeightDeviceDriver.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/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor_with_scanner_weight/ConveyorWithScannerWeightDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor_with_scanner_weight/ConveyorWithScannerWeightDeviceDriver.java new file mode 100644 index 0000000..9b90f64 --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor_with_scanner_weight/ConveyorWithScannerWeightDeviceDriver.java @@ -0,0 +1,413 @@ +package org.nl.acs.device_driver.conveyor_with_scanner_weight; + +import cn.hutool.core.util.ObjectUtil; +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.common.base.CommonFinalParam; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device.service.DeviceExtraService; +import org.nl.acs.device.service.impl.DeviceExtraServiceImpl; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.FeedLmsRealFailed; +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.history.ErrorUtil; +import org.nl.acs.history.service.DeviceErrorLogService; +import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; +import org.nl.acs.instruction.domain.Instruction; +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.DeviceAppService; +import org.nl.acs.opc.DeviceAppServiceImpl; +import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.route.service.impl.RouteLineServiceImpl; +import org.nl.acs.task.service.TaskService; +import org.nl.config.SpringContextHolder; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.List; + +/** + * 木箱机械手对接位 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { + protected ItemProtocol itemProtocol = new ItemProtocol(this); + @Autowired + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + @Autowired + TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); + @Autowired + InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); + @Autowired + DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + @Autowired + RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class); + @Autowired + DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class); + @Autowired + DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); + + //工作模式 + int mode = 0; + int last_mode = 0; + //光电信号 + int move = 0; + int last_move = 0; + //动作信号 + int action = 0; + int last_action = 0; + //报警信号 + int error = 0; + int last_error = 0; + //任务号 + int task = 0; + int last_task = 0; + + + int heartbeat = 0; + int last_heartbeat = 0; + int to_command = 0; + int last_to_command = 0; + + int to_target = 0; + int last_to_target = 0; + + int to_task = 0; + int last_to_task = 0; + + int to_container_type = 0; + int last_to_container_type = 0; + + //托盘类型 + int container_type = 0; + int last_container_type = 0; + + //行架任务号 + int hj_task = 0; + int last_hj_task = 0; + + //重量 + int weight = 0; + int last_weight = 0; + + //条码 + int barcode = 0; + int last_barcode = 0; + + //数量 + int qty = 0; + int last_qty = 0; + + //托盘方向 + int carrier_direction = 0; + int last_carrier_direction = 0; + + Boolean isonline = true; + int hasGoods = 0; + String message = null; + Boolean iserror = false; + private Date instruction_update_time = new Date(); + private int instruction_update_time_out = 1000; + Integer heartbeat_tag; + private Date instruction_require_time = new Date(); + + private int instruction_require_time_out = 3000; + //行架机械手申请任务成功标识 + boolean requireSucess = false; + + private int instruction_finished_time_out; + + int branchProtocol = 0; + private String error_type = "hxhj_error_type"; + + //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 + int flag; + + String device_code; + + //当前指令 + Instruction inst = null; + + //0 无任务执行 1更新指令状态 2下发电气信号 3允许取货 允许放货 5放货完成 + int now_steps_type = 0; + String notCreateTaskMessage = ""; + String notCreateInstMessage = ""; + String feedMessage = ""; + + + List getDeviceCodeList = null; + + List putDeviceCodeList = null; + + + @Override + public Device getDevice() { + return this.device; + } + + @Override + public void execute() { + String message = null; + try { + device_code = this.getDeviceCode(); + mode = this.itemProtocol.getMode(); + move = this.itemProtocol.getMove(); + action = this.itemProtocol.getAction(); + error = this.itemProtocol.getError(); + task = this.itemProtocol.getTask(); + heartbeat = this.itemProtocol.getHeartbeat(); + to_command = this.itemProtocol.getTo_command(); + to_target = this.itemProtocol.getTo_target(); + to_task = this.itemProtocol.getTo_task(); + to_container_type = this.itemProtocol.getTo_container_type(); + container_type = this.itemProtocol.getContainer_type(); + carrier_direction = this.itemProtocol.getCarrier_direction(); + hj_task = this.itemProtocol.getHj_task(); + qty = this.itemProtocol.getQty(); + weight = this.itemProtocol.getWeight(); + + if (to_container_type != last_to_container_type) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_container_type:" + last_to_container_type + "->" + to_container_type); + } + if (container_type != last_container_type) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号container_type:" + last_container_type + "->" + container_type); + } + if (hj_task != last_hj_task) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号hj_task:" + last_hj_task + "->" + hj_task); + } + if (qty != last_qty) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号qty:" + last_qty + "->" + qty); + } + if (weight != last_weight) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号weight:" + last_weight + "->" + weight); + } + if (carrier_direction != last_carrier_direction) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号carrier_direction:" + last_carrier_direction + "->" + carrier_direction); + } + if (to_command != last_to_command) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command:" + last_to_command + "->" + to_command); + } + if (to_target != last_to_target) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target:" + last_to_target + "->" + to_target); + } + if (to_task != last_to_task) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task:" + last_to_task + "->" + to_task); + } + if (mode != last_mode) { + requireSucess = false; + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); + } + if (move != last_move) { + logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); + } + if (action != last_action) { + logServer.deviceItemValue(this.device_code, "action", String.valueOf(action)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action); + } + if (error != last_error) { + logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); + } + if (task != last_task) { + logServer.deviceItemValue(this.device_code, "task", String.valueOf(task)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); + } + + // 更新指令状态 + if (mode == 3 && task > 0) { + Date date = new Date(); + if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out); + + } else { + this.instruction_update_time = date; + //更改指令状态 + if (task > 0) { + Instruction inst = checkInst(); + if (inst != null) { + if (StrUtil.equals(inst.getInstruction_status(), "0")) { + inst.setInstruction_status(CommonFinalParam.ONE); + inst.setExecute_device_code(this.device_code); + instructionService.update(inst); + } + } + } + } + } + + } catch (Exception var17) { + var17.printStackTrace(); + feedMessage = var17.getMessage(); + logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol)); + + } + + if (mode == 0) { + this.setIsonline(false); + message = "未联机"; + //有报警 + } else if (error != 0) { + this.setIserror(true); + message = "有报警"; + //无报警 + } else { + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + + //行架机械手申请任务 + if (mode == 2 && move == 0 && task == 0 && !requireSucess) { +// boolean res = applyTask(); +// if (res) { +// notCreateInstMessage = ""; +// notCreateTaskMessage = ""; +// feedMessage = ""; +// } + } else { + if (mode == 2) { + //if (!requireSucess) { + String remark = "未查找任务原因为:"; + if (mode != 2) { + remark = remark + "工作模式(mode)不是待机状态,"; + } + if (move != 0) { + remark = remark + "光电信号(move)为有货状态,"; + } + if (task != 0) { + remark = remark + "当前上报任务号(task)应该为0,"; + if (ObjectUtil.isNotEmpty(this.inst)) { + this.inst = null; + } + } + if (requireSucess) { + remark = remark + "请右击该图标,将请求任务复位标记(requireSucess)改为否。"; + } + this.setNotCreateTaskMessage(remark); + //} + } + } + + } + last_mode = mode; + last_move = move; + last_action = action; + last_error = error; + last_task = task; + last_heartbeat = heartbeat; + last_to_task = to_task; + last_to_command = to_command; + last_to_target = to_target; + last_hj_task = hj_task; + last_container_type = container_type; + last_carrier_direction = carrier_direction; + last_qty = qty; + last_weight = weight; + } + + @Override + public JSONObject getDeviceStatusName() { + JSONObject jo = new JSONObject(); + String mode = ""; + String move = ""; + String action = ""; + String walk_y = ""; + if (this.getMode() == 0) { + mode = "脱机"; + } else if (this.getMode() == 1) { + mode = "单机"; + } else if (this.getMode() == 2) { + mode = "待机"; + } else if (this.getMode() == 3) { + mode = "运行中"; + } + + if (this.getMove() == 0) { + move = "无货"; + } else if (this.getMove() == 1) { + move = "有货"; + } + + String requireSucess = "0"; + if (this.requireSucess) { + requireSucess = "1"; + } + jo.put("requireSucess", requireSucess); + if (this.getAction() == 1) { + action = "取货中"; + } else if (this.getAction() == 2) { + action = "取货完成"; + } else if (this.getAction() == 3) { + action = "放货中"; + } else if (this.getAction() == 4) { + action = "放货完成"; + } + + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("mode", mode); + jo.put("move", move); + jo.put("action", action); + jo.put("task", task); + jo.put("isOnline", this.getIsonline()); + jo.put("error", this.getError()); + jo.put("isError", this.getIserror()); + jo.put("message", this.getMessage()); + jo.put("notCreateTaskMessage", notCreateTaskMessage); + jo.put("notCreateInstMessage", notCreateInstMessage); + jo.put("feedMessage", feedMessage); + jo.put("driver_type", "siemens_conveyor"); + jo.put("is_click", true); + return jo; + } + + @Override + public void setDeviceStatus(JSONObject data) { + String requestSucess = data.getString("requireSucess"); + if (StrUtil.equals(requestSucess, "0")) { + this.requireSucess = false; + } else if (StrUtil.equals(requestSucess, "1")) { + this.requireSucess = true; + } + } + + @Override + public JSONObject feedLmsRealFailedInfo() { + JSONObject jo = new JSONObject(); + jo.put("device_code", this.getDevice().getDevice_code()); + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("fault_code", String.valueOf(error)); + jo.put("fault_info", ErrorUtil.getDictDetail(error_type, String.valueOf(this.getError()))); + jo.put("fault_type", error_type); + return jo; + } + + + public Instruction checkInst() { + if (ObjectUtil.isNotEmpty(this.inst)) { + if (this.task > 0) { + if (this.inst.getInstruction_code().equals(String.valueOf(this.task))) { + return this.inst; + } else { + inst = instructionService.findByCodeFromCache(String.valueOf(task)); + return inst; + } + } + } else { + inst = instructionService.findByCodeFromCache(String.valueOf(task)); + return inst; + } + return null; + } +} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor_with_scanner_weight/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor_with_scanner_weight/ItemProtocol.java new file mode 100644 index 0000000..8fafad1 --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor_with_scanner_weight/ItemProtocol.java @@ -0,0 +1,156 @@ +package org.nl.acs.device_driver.conveyor_with_scanner_weight; + +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_qty = "qty"; + //任务号 + public static String item_task = "task"; + //报警 + public static String item_error = "error"; + //托盘类型 + public static String item_container_type="container_type"; + //托盘方向 + public static String item_carrier_direction="carrier_direction"; + //行架任务号 + public static String item_hj_task = "hj_task"; + //条码 + public static String item_barcode = "barcode"; + //重量 + public static String item_weight = "weight"; + + + //下发命令 + 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_container_type = "to_container_type"; + + private ConveyorWithScannerWeightDeviceDriver driver; + + public ItemProtocol(ConveyorWithScannerWeightDeviceDriver 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 getQty(){ + return this.getOpcIntegerValue(item_qty); + } + + public int getCarrier_direction(){ + return this.getOpcIntegerValue(item_carrier_direction); + } + + public int getHj_task(){ + return this.getOpcIntegerValue(item_hj_task); + } + + public int getBarcode(){ + return this.getOpcIntegerValue(item_barcode); + } + + public int getWeight(){ + return this.getOpcIntegerValue(item_weight); + } + public int getTo_task() { + return this.getOpcIntegerValue(item_to_task); + } + + public int getTo_command() { + return this.getOpcIntegerValue(item_to_command); + } + + public int getTo_target() { + return this.getOpcIntegerValue(item_to_target); + } + + public int getContainer_type(){ + return this.getOpcIntegerValue(item_container_type); + } + + public int getTo_container_type(){ + return this.getOpcIntegerValue(item_to_container_type); + } + + + 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, "心跳", "DB1.B0")); + list.add(new ItemDto(item_mode, "工作模式", "DB1.B1")); + list.add(new ItemDto(item_move, "光电信号", "DB1.B2")); + list.add(new ItemDto(item_action, "动作信号", "DB1.B3")); + list.add(new ItemDto(item_error, "报警信号", "DB1.B5")); + list.add(new ItemDto(item_task, "任务号", "DB1.D6")); + list.add(new ItemDto(item_container_type, "托盘类型", "DB1.B7")); + list.add(new ItemDto(item_qty, "数量", "DB1.B8")); + list.add(new ItemDto(item_hj_task, "行架任务号", "DB1.D9")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList<>(); + list.add(new ItemDto(item_to_command, "下发命令", "DB2.W0")); + list.add(new ItemDto(item_to_target, "下发目标站", "DB2.W4")); + list.add(new ItemDto(item_to_task, "下发任务号", "DB2.D6")); + list.add(new ItemDto(item_to_container_type, "下发托盘类型", "DB2.W8")); + return list; + } + + +} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/fold_disc_site/FoldDiscSiteDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/fold_disc_site/FoldDiscSiteDefination.java new file mode 100644 index 0000000..8f53017 --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/fold_disc_site/FoldDiscSiteDefination.java @@ -0,0 +1,56 @@ +package org.nl.acs.device_driver.fold_disc_site; + +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device.enums.DeviceType; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; +import org.springframework.stereotype.Service; + +import java.util.LinkedList; +import java.util.List; + +@Service +public class FoldDiscSiteDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "fold_disc_site"; + } + + @Override + public String getDriverName() { + return "叠盘机"; + } + + @Override + public String getDriverDescription() { + return "叠盘机"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new FoldDiscSiteDeviceDriver()).setDevice(device).setDriverDefination(this); + } + + @Override + public Class getDeviceDriverType() { + return FoldDiscSiteDeviceDriver.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/nlsso-server/src/main/java/org/nl/acs/device_driver/fold_disc_site/FoldDiscSiteDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/fold_disc_site/FoldDiscSiteDeviceDriver.java new file mode 100644 index 0000000..d0226d5 --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/fold_disc_site/FoldDiscSiteDeviceDriver.java @@ -0,0 +1,391 @@ +package org.nl.acs.device_driver.fold_disc_site; + +import cn.hutool.core.util.ObjectUtil; +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.common.base.CommonFinalParam; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device.service.DeviceExtraService; +import org.nl.acs.device.service.impl.DeviceExtraServiceImpl; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.FeedLmsRealFailed; +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.history.ErrorUtil; +import org.nl.acs.history.service.DeviceErrorLogService; +import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; +import org.nl.acs.instruction.domain.Instruction; +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.DeviceAppService; +import org.nl.acs.opc.DeviceAppServiceImpl; +import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.route.service.impl.RouteLineServiceImpl; +import org.nl.acs.task.service.TaskService; +import org.nl.config.SpringContextHolder; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.List; + +/** + * 叠盘机 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { + protected ItemProtocol itemProtocol = new ItemProtocol(this); + @Autowired + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + @Autowired + TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); + @Autowired + InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); + @Autowired + DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + @Autowired + RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class); + @Autowired + DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class); + @Autowired + DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); + + //工作模式 + int mode = 0; + int last_mode = 0; + //光电信号 + int move = 0; + int last_move = 0; + //动作信号 + int action = 0; + int last_action = 0; + //报警信号 + int error = 0; + int last_error = 0; + //任务号 + int task = 0; + int last_task = 0; + + + int heartbeat = 0; + int last_heartbeat = 0; + int to_command = 0; + int last_to_command = 0; + + int to_target = 0; + int last_to_target = 0; + + int to_task = 0; + int last_to_task = 0; + + int to_container_type = 0; + int last_to_container_type = 0; + + //托盘类型 + int container_type = 0; + int last_container_type = 0; + + //数量 + int qty = 0; + int last_qty = 0; + + //托盘方向 + int carrier_direction = 0; + int last_carrier_direction = 0; + + Boolean isonline = true; + int hasGoods = 0; + String message = null; + Boolean iserror = false; + private Date instruction_update_time = new Date(); + private int instruction_update_time_out = 1000; + Integer heartbeat_tag; + private Date instruction_require_time = new Date(); + + private int instruction_require_time_out = 3000; + //行架机械手申请任务成功标识 + boolean requireSucess = false; + + private int instruction_finished_time_out; + + int branchProtocol = 0; + private String error_type = "hxhj_error_type"; + + //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 + int flag; + + String device_code; + + //当前指令 + Instruction inst = null; + + //0 无任务执行 1更新指令状态 2下发电气信号 3允许取货 允许放货 5放货完成 + int now_steps_type = 0; + String notCreateTaskMessage = ""; + String notCreateInstMessage = ""; + String feedMessage = ""; + + + List getDeviceCodeList = null; + + List putDeviceCodeList = null; + + + @Override + public Device getDevice() { + return this.device; + } + + @Override + public void execute() { + String message = null; + try { + device_code = this.getDeviceCode(); + mode = this.itemProtocol.getMode(); + move = this.itemProtocol.getMove(); + action = this.itemProtocol.getAction(); + error = this.itemProtocol.getError(); + task = this.itemProtocol.getTask(); + heartbeat = this.itemProtocol.getHeartbeat(); + to_command = this.itemProtocol.getTo_command(); + to_target = this.itemProtocol.getTo_target(); + to_task = this.itemProtocol.getTo_task(); + qty = this.itemProtocol.getQty(); + to_container_type = this.itemProtocol.getTo_container_type(); + container_type = this.itemProtocol.getContainer_type(); + carrier_direction = this.itemProtocol.getCarrier_direction(); + + if (to_container_type != last_to_container_type) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_container_type:" + last_to_container_type + "->" + to_container_type); + } + if (container_type != last_container_type) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号container_type:" + last_container_type + "->" + container_type); + } + if (qty != last_qty) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号qty:" + last_qty + "->" + qty); + } + if (carrier_direction != last_carrier_direction) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号carrier_direction:" + last_carrier_direction + "->" + carrier_direction); + } + if (to_command != last_to_command) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command:" + last_to_command + "->" + to_command); + } + if (to_target != last_to_target) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target:" + last_to_target + "->" + to_target); + } + if (to_task != last_to_task) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task:" + last_to_task + "->" + to_task); + } + if (mode != last_mode) { + requireSucess = false; + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); + } + if (move != last_move) { + logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); + } + if (action != last_action) { + logServer.deviceItemValue(this.device_code, "action", String.valueOf(action)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action); + } + if (error != last_error) { + logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); + } + if (task != last_task) { + logServer.deviceItemValue(this.device_code, "task", String.valueOf(task)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); + } + + // 更新指令状态 + if (mode == 3 && task > 0) { + Date date = new Date(); + if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out); + + } else { + this.instruction_update_time = date; + //更改指令状态 + if (task > 0) { + Instruction inst = checkInst(); + if (inst != null) { + if (StrUtil.equals(inst.getInstruction_status(), "0")) { + inst.setInstruction_status(CommonFinalParam.ONE); + inst.setExecute_device_code(this.device_code); + instructionService.update(inst); + } + } + } + } + } + + } catch (Exception var17) { + var17.printStackTrace(); + feedMessage = var17.getMessage(); + logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol)); + + } + + if (mode == 0) { + this.setIsonline(false); + message = "未联机"; + //有报警 + } else if (error != 0) { + this.setIserror(true); + message = "有报警"; + //无报警 + } else { + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + + //行架机械手申请任务 + if (mode == 2 && move == 0 && task == 0 && !requireSucess) { +// boolean res = applyTask(); +// if (res) { +// notCreateInstMessage = ""; +// notCreateTaskMessage = ""; +// feedMessage = ""; +// } + } else { + if (mode == 2) { + //if (!requireSucess) { + String remark = "未查找任务原因为:"; + if (mode != 2) { + remark = remark + "工作模式(mode)不是待机状态,"; + } + if (move != 0) { + remark = remark + "光电信号(move)为有货状态,"; + } + if (task != 0) { + remark = remark + "当前上报任务号(task)应该为0,"; + if (ObjectUtil.isNotEmpty(this.inst)) { + this.inst = null; + } + } + if (requireSucess) { + remark = remark + "请右击该图标,将请求任务复位标记(requireSucess)改为否。"; + } + this.setNotCreateTaskMessage(remark); + //} + } + } + + } + last_mode = mode; + last_move = move; + last_action = action; + last_error = error; + last_task = task; + last_heartbeat = heartbeat; + last_to_task = to_task; + last_to_command = to_command; + last_to_target = to_target; + last_qty = qty; + last_container_type = container_type; + last_carrier_direction = carrier_direction; + } + + @Override + public JSONObject getDeviceStatusName() { + JSONObject jo = new JSONObject(); + String mode = ""; + String move = ""; + String action = ""; + String walk_y = ""; + if (this.getMode() == 0) { + mode = "脱机"; + } else if (this.getMode() == 1) { + mode = "单机"; + } else if (this.getMode() == 2) { + mode = "待机"; + } else if (this.getMode() == 3) { + mode = "运行中"; + } + + if (this.getMove() == 0) { + move = "无货"; + } else if (this.getMove() == 1) { + move = "有货"; + } + + String requireSucess = "0"; + if (this.requireSucess) { + requireSucess = "1"; + } + jo.put("requireSucess", requireSucess); + if (this.getAction() == 1) { + action = "取货中"; + } else if (this.getAction() == 2) { + action = "取货完成"; + } else if (this.getAction() == 3) { + action = "放货中"; + } else if (this.getAction() == 4) { + action = "放货完成"; + } + + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("mode", mode); + jo.put("move", move); + jo.put("action", action); + jo.put("task", task); + jo.put("isOnline", this.getIsonline()); + jo.put("error", this.getError()); + jo.put("isError", this.getIserror()); + jo.put("message", this.getMessage()); + jo.put("notCreateTaskMessage", notCreateTaskMessage); + jo.put("notCreateInstMessage", notCreateInstMessage); + jo.put("feedMessage", feedMessage); + jo.put("driver_type", "siemens_conveyor"); + jo.put("is_click", true); + return jo; + } + + @Override + public void setDeviceStatus(JSONObject data) { + String requestSucess = data.getString("requireSucess"); + if (StrUtil.equals(requestSucess, "0")) { + this.requireSucess = false; + } else if (StrUtil.equals(requestSucess, "1")) { + this.requireSucess = true; + } + } + + @Override + public JSONObject feedLmsRealFailedInfo() { + JSONObject jo = new JSONObject(); + jo.put("device_code", this.getDevice().getDevice_code()); + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("fault_code", String.valueOf(error)); + jo.put("fault_info", ErrorUtil.getDictDetail(error_type, String.valueOf(this.getError()))); + jo.put("fault_type", error_type); + return jo; + } + + + public Instruction checkInst() { + if (ObjectUtil.isNotEmpty(this.inst)) { + if (this.task > 0) { + if (this.inst.getInstruction_code().equals(String.valueOf(this.task))) { + return this.inst; + } else { + inst = instructionService.findByCodeFromCache(String.valueOf(task)); + return inst; + } + } + } else { + inst = instructionService.findByCodeFromCache(String.valueOf(task)); + return inst; + } + return null; + } +} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/fold_disc_site/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/fold_disc_site/ItemProtocol.java new file mode 100644 index 0000000..06129de --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/fold_disc_site/ItemProtocol.java @@ -0,0 +1,135 @@ +package org.nl.acs.device_driver.fold_disc_site; + +import com.baomidou.mybatisplus.extension.api.R; +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_qty = "qty"; + //任务号 + public static String item_task = "task"; + //报警 + public static String item_error = "error"; + //托盘类型 + public static String item_container_type="container_type"; + //托盘方向 + public static String item_carrier_direction="carrier_direction"; + + //下发命令 + 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_container_type = "to_container_type"; + + private FoldDiscSiteDeviceDriver driver; + + public ItemProtocol(FoldDiscSiteDeviceDriver 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 getQty(){ + return this.getOpcIntegerValue(item_qty); + } + + public int getCarrier_direction(){ + return this.getOpcIntegerValue(item_carrier_direction); + } + + public int getTo_task() { + return this.getOpcIntegerValue(item_to_task); + } + + public int getTo_command() { + return this.getOpcIntegerValue(item_to_command); + } + + public int getTo_target() { + return this.getOpcIntegerValue(item_to_target); + } + + public int getContainer_type(){ + return this.getOpcIntegerValue(item_container_type); + } + + public int getTo_container_type(){ + return this.getOpcIntegerValue(item_to_container_type); + } + + 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, "心跳", "DB1.B0")); + list.add(new ItemDto(item_mode, "工作模式", "DB1.B1")); + list.add(new ItemDto(item_move, "光电信号", "DB1.B2")); + list.add(new ItemDto(item_action, "动作信号", "DB1.B3")); + list.add(new ItemDto(item_error, "报警信号", "DB1.B5")); + list.add(new ItemDto(item_task, "任务号", "DB1.D6")); + list.add(new ItemDto(item_container_type, "托盘类型", "DB1.B7")); + list.add(new ItemDto(item_qty, "数量", "DB1.B8")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList<>(); + list.add(new ItemDto(item_to_command, "下发命令", "DB2.W0")); + list.add(new ItemDto(item_to_target, "下发目标站", "DB2.W4")); + list.add(new ItemDto(item_to_task, "下发任务号", "DB2.D6")); + list.add(new ItemDto(item_to_container_type, "下发托盘类型", "DB2.W8")); + return list; + } +} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardManipulatorDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/BlankManipulatorDefination.java similarity index 77% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardManipulatorDefination.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/BlankManipulatorDefination.java index 5639b1a..f6765fc 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardManipulatorDefination.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/BlankManipulatorDefination.java @@ -11,31 +11,31 @@ import java.util.LinkedList; import java.util.List; @Service -public class StandardManipulatorDefination implements OpcDeviceDriverDefination { +public class BlankManipulatorDefination implements OpcDeviceDriverDefination { @Override public String getDriverCode() { - return "standard_manipulator"; + return "blank_manipulator"; } @Override public String getDriverName() { - return "标准版-行架机械手"; + return "表处下料-行架机械手"; } @Override public String getDriverDescription() { - return "标准版-行架机械手"; + return "表处下料-行架机械手"; } @Override public DeviceDriver getDriverInstance(Device device) { - return (new StandardManipulatorDeviceDriver()).setDevice(device).setDriverDefination(this); + return (new BlankManipulatorDeviceDriver()).setDevice(device).setDriverDefination(this); } @Override public Class getDeviceDriverType() { - return StandardManipulatorDeviceDriver.class; + return BlankManipulatorDeviceDriver.class; } @Override diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardManipulatorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/BlankManipulatorDeviceDriver.java similarity index 98% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardManipulatorDeviceDriver.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/BlankManipulatorDeviceDriver.java index 590fb6f..ca51861 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardManipulatorDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/BlankManipulatorDeviceDriver.java @@ -41,7 +41,7 @@ import java.util.List; @Slf4j @Data @RequiredArgsConstructor -public class StandardManipulatorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { +public class BlankManipulatorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { protected StandardItemProtocol standardItemProtocol = new StandardItemProtocol(this); @Autowired DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/BoxManipulatorDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/DryManipulatorDefination.java similarity index 81% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/BoxManipulatorDefination.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/DryManipulatorDefination.java index 63929b3..eb7713b 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/BoxManipulatorDefination.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/DryManipulatorDefination.java @@ -11,31 +11,31 @@ import java.util.LinkedList; import java.util.List; @Service -public class BoxManipulatorDefination implements OpcDeviceDriverDefination { +public class DryManipulatorDefination implements OpcDeviceDriverDefination { @Override public String getDriverCode() { - return "box_manipulator"; + return "dry_manipulator"; } @Override public String getDriverName() { - return "装箱行架机械手"; + return "干燥剂机械手"; } @Override public String getDriverDescription() { - return "装箱行架机械手"; + return "干燥剂机械手"; } @Override public DeviceDriver getDriverInstance(Device device) { - return (new BoxManipulatorDeviceDriver()).setDevice(device).setDriverDefination(this); + return (new DryManipulatorDeviceDriver()).setDevice(device).setDriverDefination(this); } @Override public Class getDeviceDriverType() { - return BoxManipulatorDeviceDriver.class; + return DryManipulatorDeviceDriver.class; } @Override @@ -56,4 +56,5 @@ public class BoxManipulatorDefination implements OpcDeviceDriverDefination { public List getWriteableItemDtos() { return StandardItemProtocol.getWriteableItemDtos(); } + } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/BoxManipulatorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/DryManipulatorDeviceDriver.java similarity index 98% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/BoxManipulatorDeviceDriver.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/DryManipulatorDeviceDriver.java index daccfe2..1d272af 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/BoxManipulatorDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/DryManipulatorDeviceDriver.java @@ -29,19 +29,17 @@ import org.nl.acs.route.service.impl.RouteLineServiceImpl; import org.nl.acs.task.service.TaskService; import org.nl.config.SpringContextHolder; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Service; import java.util.Date; import java.util.List; /** - * 装箱行架机械手 + * 干燥剂机械手 */ @Slf4j @Data @RequiredArgsConstructor -public class BoxManipulatorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { +public class DryManipulatorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { protected StandardItemProtocol standardItemProtocol = new StandardItemProtocol(this); @Autowired DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/OvenGantryManipulatorDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/OvenGantryManipulatorDefination.java new file mode 100644 index 0000000..febf2d3 --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/OvenGantryManipulatorDefination.java @@ -0,0 +1,58 @@ +package org.nl.acs.device_driver.manipulator.standard_manipulator; + +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device.enums.DeviceType; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; +import org.springframework.stereotype.Service; + +import java.util.LinkedList; +import java.util.List; + +@Service +public class OvenGantryManipulatorDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "oven_manipulator"; + } + + @Override + public String getDriverName() { + return "烘箱-行架机械手"; + } + + @Override + public String getDriverDescription() { + return "烘箱-行架机械手"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new OvenGantryManipulatorDeviceDriver()).setDevice(device).setDriverDefination(this); + } + + @Override + public Class getDeviceDriverType() { + return OvenGantryManipulatorDeviceDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList(); + types.add(DeviceType.station); + return types; + } + + @Override + public List getReadableItemDtos() { + return StandardItemProtocol.getReadableItemDtos(); + } + + + + @Override + public List getWriteableItemDtos() { + return StandardItemProtocol.getWriteableItemDtos(); + } +} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/OvenGantryManipulatorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/OvenGantryManipulatorDeviceDriver.java new file mode 100644 index 0000000..f340a6c --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/OvenGantryManipulatorDeviceDriver.java @@ -0,0 +1,397 @@ +package org.nl.acs.device_driver.manipulator.standard_manipulator; + +import cn.hutool.core.util.ObjectUtil; +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.common.base.CommonFinalParam; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device.service.DeviceExtraService; +import org.nl.acs.device.service.impl.DeviceExtraServiceImpl; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.FeedLmsRealFailed; +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.history.ErrorUtil; +import org.nl.acs.history.service.DeviceErrorLogService; +import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; +import org.nl.acs.instruction.domain.Instruction; +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.DeviceAppService; +import org.nl.acs.opc.DeviceAppServiceImpl; +import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.route.service.impl.RouteLineServiceImpl; +import org.nl.acs.task.service.TaskService; +import org.nl.config.SpringContextHolder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.List; + +/** + * 装箱行架机械手 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { + protected StandardItemProtocol standardItemProtocol = new StandardItemProtocol(this); + @Autowired + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + @Autowired + TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); + @Autowired + InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); + @Autowired + DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + @Autowired + RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class); + @Autowired + DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class); + @Autowired + DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); + + //工作模式 + int mode = 0; + int last_mode = 0; + //光电信号 + int move = 0; + int last_move = 0; + //动作信号 + int action = 0; + int last_action = 0; + //行走列 + int walk_y = 0; + int last_walk_y = 0; + //报警信号 + int error = 0; + int last_error = 0; + //任务号 + int task = 0; + int last_task = 0; + // x坐标 + float x_position = 0; + float last_x_position = 0; + // y坐标 + float y_position = 0; + float last_y_position = 0; + + int heartbeat = 0; + int last_heartbeat = 0; + int to_command = 0; + int last_to_command = 0; + + int to_target = 0; + int last_to_target = 0; + + int to_task = 0; + int last_to_task = 0; + + int to_onset = 0; + int last_to_onset = 0; + + Boolean isonline = true; + int hasGoods = 0; + String message = null; + Boolean iserror = false; + private Date instruction_update_time = new Date(); + private int instruction_update_time_out = 1000; + Integer heartbeat_tag; + private Date instruction_require_time = new Date(); + + private int instruction_require_time_out = 3000; + //行架机械手申请任务成功标识 + boolean requireSucess = false; + + private int instruction_finished_time_out; + + int branchProtocol = 0; + private String error_type = "hxhj_error_type"; + + //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 + int flag; + + String device_code; + + //当前指令 + Instruction inst = null; + + + //0 无任务执行 1更新指令状态 2下发电气信号 3允许取货 允许放货 5放货完成 + int now_steps_type = 0; + String notCreateTaskMessage = ""; + String notCreateInstMessage = ""; + String feedMessage = ""; + + + List getDeviceCodeList = null; + + List putDeviceCodeList = null; + + + @Override + public Device getDevice() { + return this.device; + } + + @Override + public void execute() { + String message = null; + try { + device_code = this.getDeviceCode(); + mode = this.standardItemProtocol.getMode(device_code); + move = this.standardItemProtocol.getMove(device_code); + action = this.standardItemProtocol.getAction(device_code); + walk_y = this.standardItemProtocol.getWalk_y(device_code); + error = this.standardItemProtocol.getError(device_code); + task = this.standardItemProtocol.getTask(device_code); + heartbeat = this.standardItemProtocol.getHeartbeat(device_code); + to_command = this.standardItemProtocol.getTo_command(device_code); + to_target = this.standardItemProtocol.getTo_target(device_code); + to_task = this.standardItemProtocol.getTo_task(device_code); + to_onset = this.standardItemProtocol.getTo_onset(device_code); + x_position = this.standardItemProtocol.getX_position(device_code); + y_position = this.standardItemProtocol.getY_position(device_code); + + if (to_onset != last_to_onset) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_onset:" + last_to_onset + "->" + to_onset); + } + if (to_command != last_to_command) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command:" + last_to_command + "->" + to_command); + } + if (to_target != last_to_target) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target:" + last_to_target + "->" + to_target); + } + if (to_task != last_to_task) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task:" + last_to_task + "->" + to_task); + } + if (mode != last_mode) { + requireSucess = false; + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); + } + if (move != last_move) { + logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); + } + if (action != last_action) { + logServer.deviceItemValue(this.device_code, "action", String.valueOf(action)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action); + } + if (error != last_error) { + logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); + } + if (walk_y != last_walk_y) { + logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(walk_y)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号walk_y:" + last_walk_y + "->" + walk_y); + } + if (task != last_task) { + logServer.deviceItemValue(this.device_code, "task", String.valueOf(task)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); + } + if (x_position != last_x_position) { + logServer.deviceItemValue(this.device_code, "x_position", String.valueOf(x_position)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号x_position:" + last_x_position + "->" + x_position); + } + if (y_position != last_y_position) { + logServer.deviceItemValue(this.device_code, "y_position", String.valueOf(y_position)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号y_position:" + last_y_position + "->" + y_position); + } + + // 更新指令状态 + if (mode == 3 && task > 0) { + Date date = new Date(); + if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out); + + } else { + this.instruction_update_time = date; + //更改指令状态 + if (task > 0) { + Instruction inst = checkInst(); + if (inst != null) { + if (StrUtil.equals(inst.getInstruction_status(), "0")) { + inst.setInstruction_status(CommonFinalParam.ONE); + inst.setExecute_device_code(this.device_code); + instructionService.update(inst); + } + } + } + } + } + + } catch (Exception var17) { + var17.printStackTrace(); + feedMessage = var17.getMessage(); + logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.standardItemProtocol)); + + } + + if (mode == 0) { + this.setIsonline(false); + message = "未联机"; + //有报警 + } else if (error != 0) { + this.setIserror(true); + message = "有报警"; + //无报警 + } else { + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + + //行架机械手申请任务 + if (mode == 2 && move == 0 && task == 0 && !requireSucess) { +// boolean res = applyTask(); +// if (res) { +// notCreateInstMessage = ""; +// notCreateTaskMessage = ""; +// feedMessage = ""; +// } + } else { + if (mode == 2) { + //if (!requireSucess) { + String remark = "未查找任务原因为:"; + if (mode != 2) { + remark = remark + "工作模式(mode)不是待机状态,"; + } + if (move != 0) { + remark = remark + "光电信号(move)为有货状态,"; + } + if (task != 0) { + remark = remark + "当前上报任务号(task)应该为0,"; + if (ObjectUtil.isNotEmpty(this.inst)) { + this.inst = null; + } + } + if (requireSucess) { + remark = remark + "请右击该图标,将请求任务复位标记(requireSucess)改为否。"; + } + this.setNotCreateTaskMessage(remark); + //} + } + } + + } + last_mode = mode; + last_move = move; + last_action = action; + last_walk_y = walk_y; + last_error = error; + last_task = task; + last_heartbeat = heartbeat; + last_to_task = to_task; + last_to_command = to_command; + last_to_target = to_target; + last_to_onset = to_onset; + last_x_position = x_position; + last_y_position = y_position; + } + + @Override + public JSONObject getDeviceStatusName() { + JSONObject jo = new JSONObject(); + String mode = ""; + String move = ""; + String action = ""; + String walk_y = ""; + if (this.getMode() == 0) { + mode = "脱机"; + } else if (this.getMode() == 1) { + mode = "单机"; + } else if (this.getMode() == 2) { + mode = "待机"; + } else if (this.getMode() == 3) { + mode = "运行中"; + } + + if (this.getMove() == 0) { + move = "无货"; + } else if (this.getMove() == 1) { + move = "有货"; + } + + String requireSucess = "0"; + if (this.requireSucess) { + requireSucess = "1"; + } + jo.put("requireSucess", requireSucess); + if (this.getAction() == 1) { + action = "取货中"; + } else if (this.getAction() == 2) { + action = "取货完成"; + } else if (this.getAction() == 3) { + action = "放货中"; + } else if (this.getAction() == 4) { + action = "放货完成"; + } + + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("mode", mode); + jo.put("move", move); + jo.put("action", action); + jo.put("task", task); + jo.put("walk_y", walk_y); + jo.put("isOnline", this.getIsonline()); + jo.put("error", ErrorUtil.getDictDetail("hxhj_error_type", String.valueOf(this.getError()))); + jo.put("isError", this.getIserror()); + jo.put("message", this.getMessage()); + jo.put("notCreateTaskMessage", notCreateTaskMessage); + jo.put("notCreateInstMessage", notCreateInstMessage); + jo.put("feedMessage", feedMessage); + jo.put("driver_type", "siemens_conveyor"); + jo.put("is_click", true); + jo.put("x", x_position); + jo.put("y", y_position); + return jo; + } + + @Override + public void setDeviceStatus(JSONObject data) { + String requestSucess = data.getString("requireSucess"); + if (StrUtil.equals(requestSucess, "0")) { + this.requireSucess = false; + } else if (StrUtil.equals(requestSucess, "1")) { + this.requireSucess = true; + } + } + + @Override + public JSONObject feedLmsRealFailedInfo() { + JSONObject jo = new JSONObject(); + jo.put("device_code", this.getDevice().getDevice_code()); + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("fault_code", String.valueOf(error)); + jo.put("fault_info", ErrorUtil.getDictDetail(error_type, String.valueOf(this.getError()))); + jo.put("fault_type", error_type); + return jo; + } + + + public Instruction checkInst() { + if (ObjectUtil.isNotEmpty(this.inst)) { + if (this.task > 0) { + if (this.inst.getInstruction_code().equals(String.valueOf(this.task))) { + return this.inst; + } else { + inst = instructionService.findByCodeFromCache(String.valueOf(task)); + return inst; + } + } + } else { + inst = instructionService.findByCodeFromCache(String.valueOf(task)); + return inst; + } + return null; + } +} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardItemProtocol.java index 33f93c0..2e26fa7 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardItemProtocol.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardItemProtocol.java @@ -113,14 +113,18 @@ public class StandardItemProtocol { public int getOpcIntegerValue(String protocol,String device_code) { Integer value = null; Device device = deviceAppService.findDeviceByCode(device_code); - if (device.getDeviceDriver() instanceof StandardManipulatorDeviceDriver) { - StandardManipulatorDeviceDriver standardManipulatorDeviceDriver; - standardManipulatorDeviceDriver = (StandardManipulatorDeviceDriver) device.getDeviceDriver(); - value = standardManipulatorDeviceDriver.getIntegeregerValue(protocol); - }else if (device.getDeviceDriver() instanceof BoxManipulatorDeviceDriver){ - BoxManipulatorDeviceDriver boxManipulatorDeviceDriver; - boxManipulatorDeviceDriver = (BoxManipulatorDeviceDriver) device.getDeviceDriver(); - value = boxManipulatorDeviceDriver.getIntegeregerValue(protocol); + if (device.getDeviceDriver() instanceof BlankManipulatorDeviceDriver) { + BlankManipulatorDeviceDriver blankManipulatorDeviceDriver; + blankManipulatorDeviceDriver = (BlankManipulatorDeviceDriver) device.getDeviceDriver(); + value = blankManipulatorDeviceDriver.getIntegeregerValue(protocol); + }else if (device.getDeviceDriver() instanceof OvenGantryManipulatorDeviceDriver){ + OvenGantryManipulatorDeviceDriver ovenGantryManipulatorDeviceDriver; + ovenGantryManipulatorDeviceDriver = (OvenGantryManipulatorDeviceDriver) device.getDeviceDriver(); + value = ovenGantryManipulatorDeviceDriver.getIntegeregerValue(protocol); + }else if (device.getDeviceDriver() instanceof DryManipulatorDeviceDriver){ + DryManipulatorDeviceDriver dryManipulatorDeviceDriver; + dryManipulatorDeviceDriver = (DryManipulatorDeviceDriver) device.getDeviceDriver(); + value = dryManipulatorDeviceDriver.getIntegeregerValue(protocol); } if (value == null) { // log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/rgv/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/rgv/ItemProtocol.java new file mode 100644 index 0000000..f2e9b51 --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/rgv/ItemProtocol.java @@ -0,0 +1,136 @@ +package org.nl.acs.device_driver.rgv; + +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_walk_y = "walk_y"; + //任务号 + public static String item_task = "task"; + //报警 + public static String item_error = "error"; + //托盘类型 + public static String item_container_type="container_type"; + + //下发命令 + public static String item_to_command = "to_command"; + //下发起始站 + public static String item_to_onset = "to_onset"; + //下发目标站 + public static String item_to_target = "to_target"; + //下发任务号 + public static String item_to_task = "to_task"; + //下发托盘类型 + public static String item_to_container_type = "to_container_type"; + + private RgvDeviceDriver driver; + + public ItemProtocol(RgvDeviceDriver 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 getWalk_y() { + return this.getOpcIntegerValue(item_walk_y); + } + + public int getError() { + return this.getOpcIntegerValue(item_error); + } + + public int getTask() { + return this.getOpcIntegerValue(item_task); + } + + public int getTo_task() { + return this.getOpcIntegerValue(item_to_task); + } + + public int getTo_onset() { + return this.getOpcIntegerValue(item_to_onset); + } + + public int getTo_command() { + return this.getOpcIntegerValue(item_to_command); + } + + public int getTo_target() { + return this.getOpcIntegerValue(item_to_target); + } + + public int getContainer_type(){ + return this.getOpcIntegerValue(item_container_type); + } + + public int getTo_container_type(){ + return this.getOpcIntegerValue(item_to_container_type); + } + + 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, "心跳", "DB1.B0")); + list.add(new ItemDto(item_mode, "工作模式", "DB1.B1")); + list.add(new ItemDto(item_move, "光电信号", "DB1.B2")); + list.add(new ItemDto(item_action, "动作信号", "DB1.B3")); + list.add(new ItemDto(item_walk_y, "行走列", "DB1.B4")); + list.add(new ItemDto(item_error, "报警信号", "DB1.B5")); + list.add(new ItemDto(item_task, "任务号", "DB1.D6")); + list.add(new ItemDto(item_container_type, "托盘类型", "DB1.D6")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList<>(); + list.add(new ItemDto(item_to_command, "下发命令", "DB2.W0")); + list.add(new ItemDto(item_to_onset, "下发起始站", "DB2.W2")); + list.add(new ItemDto(item_to_target, "下发目标站", "DB2.W4")); + list.add(new ItemDto(item_to_task, "下发任务号", "DB2.D6")); + list.add(new ItemDto(item_to_container_type, "下发托盘类型", "DB2.W8")); + return list; + } +} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/rgv/RgvDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/rgv/RgvDefination.java new file mode 100644 index 0000000..c11d039 --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/rgv/RgvDefination.java @@ -0,0 +1,56 @@ +package org.nl.acs.device_driver.rgv; + +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device.enums.DeviceType; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; +import org.springframework.stereotype.Service; + +import java.util.LinkedList; +import java.util.List; + +@Service +public class RgvDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "rgv"; + } + + @Override + public String getDriverName() { + return "rgv"; + } + + @Override + public String getDriverDescription() { + return "rgv"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new RgvDeviceDriver()).setDevice(device).setDriverDefination(this); + } + + @Override + public Class getDeviceDriverType() { + return RgvDeviceDriver.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/nlsso-server/src/main/java/org/nl/acs/device_driver/rgv/RgvDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/rgv/RgvDeviceDriver.java new file mode 100644 index 0000000..62ccb34 --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/rgv/RgvDeviceDriver.java @@ -0,0 +1,394 @@ +package org.nl.acs.device_driver.rgv; + +import cn.hutool.core.util.ObjectUtil; +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.common.base.CommonFinalParam; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device.service.DeviceExtraService; +import org.nl.acs.device.service.impl.DeviceExtraServiceImpl; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.FeedLmsRealFailed; +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.history.ErrorUtil; +import org.nl.acs.history.service.DeviceErrorLogService; +import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; +import org.nl.acs.instruction.domain.Instruction; +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.DeviceAppService; +import org.nl.acs.opc.DeviceAppServiceImpl; +import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.route.service.impl.RouteLineServiceImpl; +import org.nl.acs.task.service.TaskService; +import org.nl.config.SpringContextHolder; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.List; + +/** + * RGV + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class RgvDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { + + protected ItemProtocol itemProtocol = new ItemProtocol(this); + @Autowired + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + @Autowired + TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); + @Autowired + InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); + @Autowired + DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + @Autowired + RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class); + @Autowired + DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class); + @Autowired + DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); + + //工作模式 + int mode = 0; + int last_mode = 0; + //光电信号 + int move = 0; + int last_move = 0; + //动作信号 + int action = 0; + int last_action = 0; + //行走列 + int walk_y = 0; + int last_walk_y = 0; + //报警信号 + int error = 0; + int last_error = 0; + //任务号 + int task = 0; + int last_task = 0; + + + int heartbeat = 0; + int last_heartbeat = 0; + int to_command = 0; + int last_to_command = 0; + + int to_target = 0; + int last_to_target = 0; + + int to_task = 0; + int last_to_task = 0; + + int to_onset = 0; + int last_to_onset = 0; + + //托盘类型 + int container_type = 0; + int last_container_type = 0; + + int to_container_type = 0; + int last_to_container_type = 0; + + Boolean isonline = true; + int hasGoods = 0; + String message = null; + Boolean iserror = false; + private Date instruction_update_time = new Date(); + private int instruction_update_time_out = 1000; + Integer heartbeat_tag; + private Date instruction_require_time = new Date(); + + private int instruction_require_time_out = 3000; + //行架机械手申请任务成功标识 + boolean requireSucess = false; + + private int instruction_finished_time_out; + + int branchProtocol = 0; + private String error_type = "hxhj_error_type"; + + //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 + int flag; + + String device_code; + + //当前指令 + Instruction inst = null; + + //0 无任务执行 1更新指令状态 2下发电气信号 3允许取货 允许放货 5放货完成 + int now_steps_type = 0; + String notCreateTaskMessage = ""; + String notCreateInstMessage = ""; + String feedMessage = ""; + + + List getDeviceCodeList = null; + + List putDeviceCodeList = null; + + + @Override + public Device getDevice() { + return this.device; + } + + @Override + public void execute() { + String message = null; + try { + device_code = this.getDeviceCode(); + mode = this.itemProtocol.getMode(); + move = this.itemProtocol.getMove(); + action = this.itemProtocol.getAction(); + walk_y = this.itemProtocol.getWalk_y(); + error = this.itemProtocol.getError(); + task = this.itemProtocol.getTask(); + heartbeat = this.itemProtocol.getHeartbeat(); + to_command = this.itemProtocol.getTo_command(); + to_target = this.itemProtocol.getTo_target(); + to_task = this.itemProtocol.getTo_task(); + to_onset = this.itemProtocol.getTo_onset(); + to_container_type = this.itemProtocol.getTo_container_type(); + container_type = this.itemProtocol.getContainer_type(); + + if (to_container_type != last_to_container_type) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_container_type:" + last_to_container_type + "->" + to_container_type); + } + if (container_type != last_container_type) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号container_type:" + last_container_type + "->" + container_type); + } + if (to_onset != last_to_onset) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_onset:" + last_to_onset + "->" + to_onset); + } + if (to_command != last_to_command) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command:" + last_to_command + "->" + to_command); + } + if (to_target != last_to_target) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target:" + last_to_target + "->" + to_target); + } + if (to_task != last_to_task) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task:" + last_to_task + "->" + to_task); + } + if (mode != last_mode) { + requireSucess = false; + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); + } + if (move != last_move) { + logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); + } + if (action != last_action) { + logServer.deviceItemValue(this.device_code, "action", String.valueOf(action)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action); + } + if (error != last_error) { + logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); + } + if (walk_y != last_walk_y) { + logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(walk_y)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号walk_y:" + last_walk_y + "->" + walk_y); + } + if (task != last_task) { + logServer.deviceItemValue(this.device_code, "task", String.valueOf(task)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); + } + + // 更新指令状态 + if (mode == 3 && task > 0) { + Date date = new Date(); + if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out); + + } else { + this.instruction_update_time = date; + //更改指令状态 + if (task > 0) { + Instruction inst = checkInst(); + if (inst != null) { + if (StrUtil.equals(inst.getInstruction_status(), "0")) { + inst.setInstruction_status(CommonFinalParam.ONE); + inst.setExecute_device_code(this.device_code); + instructionService.update(inst); + } + } + } + } + } + + } catch (Exception var17) { + var17.printStackTrace(); + feedMessage = var17.getMessage(); + logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol)); + + } + + if (mode == 0) { + this.setIsonline(false); + message = "未联机"; + //有报警 + } else if (error != 0) { + this.setIserror(true); + message = "有报警"; + //无报警 + } else { + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + + //行架机械手申请任务 + if (mode == 2 && move == 0 && task == 0 && !requireSucess) { +// boolean res = applyTask(); +// if (res) { +// notCreateInstMessage = ""; +// notCreateTaskMessage = ""; +// feedMessage = ""; +// } + } else { + if (mode == 2) { + //if (!requireSucess) { + String remark = "未查找任务原因为:"; + if (mode != 2) { + remark = remark + "工作模式(mode)不是待机状态,"; + } + if (move != 0) { + remark = remark + "光电信号(move)为有货状态,"; + } + if (task != 0) { + remark = remark + "当前上报任务号(task)应该为0,"; + if (ObjectUtil.isNotEmpty(this.inst)) { + this.inst = null; + } + } + if (requireSucess) { + remark = remark + "请右击该图标,将请求任务复位标记(requireSucess)改为否。"; + } + this.setNotCreateTaskMessage(remark); + //} + } + } + + } + last_mode = mode; + last_move = move; + last_action = action; + last_walk_y = walk_y; + last_error = error; + last_task = task; + last_heartbeat = heartbeat; + last_to_task = to_task; + last_to_command = to_command; + last_to_target = to_target; + last_to_onset = to_onset; + last_to_container_type = to_container_type; + last_container_type = container_type; + } + + @Override + public JSONObject getDeviceStatusName() { + JSONObject jo = new JSONObject(); + String mode = ""; + String move = ""; + String action = ""; + String walk_y = ""; + if (this.getMode() == 0) { + mode = "脱机"; + } else if (this.getMode() == 1) { + mode = "单机"; + } else if (this.getMode() == 2) { + mode = "待机"; + } else if (this.getMode() == 3) { + mode = "运行中"; + } + + if (this.getMove() == 0) { + move = "无货"; + } else if (this.getMove() == 1) { + move = "有货"; + } + + String requireSucess = "0"; + if (this.requireSucess) { + requireSucess = "1"; + } + jo.put("requireSucess", requireSucess); + if (this.getAction() == 1) { + action = "取货中"; + } else if (this.getAction() == 2) { + action = "取货完成"; + } else if (this.getAction() == 3) { + action = "放货中"; + } else if (this.getAction() == 4) { + action = "放货完成"; + } + + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("mode", mode); + jo.put("move", move); + jo.put("action", action); + jo.put("task", task); + jo.put("walk_y", walk_y); + jo.put("isOnline", this.getIsonline()); + jo.put("error", this.getError()); + jo.put("isError", this.getIserror()); + jo.put("message", this.getMessage()); + jo.put("notCreateTaskMessage", notCreateTaskMessage); + jo.put("notCreateInstMessage", notCreateInstMessage); + jo.put("feedMessage", feedMessage); + jo.put("driver_type", "siemens_conveyor"); + jo.put("is_click", true); + return jo; + } + + @Override + public void setDeviceStatus(JSONObject data) { + String requestSucess = data.getString("requireSucess"); + if (StrUtil.equals(requestSucess, "0")) { + this.requireSucess = false; + } else if (StrUtil.equals(requestSucess, "1")) { + this.requireSucess = true; + } + } + + @Override + public JSONObject feedLmsRealFailedInfo() { + JSONObject jo = new JSONObject(); + jo.put("device_code", this.getDevice().getDevice_code()); + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("fault_code", String.valueOf(error)); + jo.put("fault_info", ErrorUtil.getDictDetail(error_type, String.valueOf(this.getError()))); + jo.put("fault_type", error_type); + return jo; + } + + + public Instruction checkInst() { + if (ObjectUtil.isNotEmpty(this.inst)) { + if (this.task > 0) { + if (this.inst.getInstruction_code().equals(String.valueOf(this.task))) { + return this.inst; + } else { + inst = instructionService.findByCodeFromCache(String.valueOf(task)); + return inst; + } + } + } else { + inst = instructionService.findByCodeFromCache(String.valueOf(task)); + return inst; + } + return null; + } + +} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java index 2fac209..c347a4b 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java @@ -1,9 +1,6 @@ package org.nl.acs.ext.wms.service.impl; -import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; @@ -11,11 +8,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.nl.acs.AcsConfig; -import org.nl.acs.agv.server.NDCAgvService; -import org.nl.acs.agv.server.impl.NDCAgvServiceImpl; -import org.nl.acs.common.IDriverService; import org.nl.acs.device.domain.Device; +import org.nl.acs.device_driver.box_manipulator.BoxManipulatorDeviceDriver; +import org.nl.acs.device_driver.conveyor.box_palletizing_manipulator.BoxPalletizingManipulatorDeviceDriver; +import org.nl.acs.device_driver.manipulator.standard_manipulator.OvenGantryManipulatorDeviceDriver; +import org.nl.acs.device_driver.manipulator.standard_manipulator.BlankManipulatorDeviceDriver; import org.nl.acs.device.service.DeviceService; import org.nl.acs.device_driver.FeedLmsRealFailed; import org.nl.acs.device_driver.agv.ndcone.AgvNdcOneDeviceDriver; @@ -38,32 +35,19 @@ import org.nl.acs.device_driver.conveyor.standard_ordinary_site.StandardOrdinary import org.nl.acs.device_driver.waste_foil_weighing_station.WasteFoilWeighingStationDriver; import org.nl.acs.ext.wms.data.*; -import org.nl.acs.ext.wms.liKuData.Resp; -import org.nl.acs.ext.wms.service.AcsToLiKuService; import org.nl.acs.ext.wms.service.WmsToAcsService; -import org.nl.acs.history.ErrorUtil; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.monitor.DeviceStageMonitor; import org.nl.acs.opc.DeviceAppService; -import org.nl.acs.opc.DeviceExtraManageDto; -import org.nl.acs.route.service.RouteLineService; import org.nl.acs.storage_cell.domain.StorageCell; import org.nl.acs.storage_cell.service.mapper.StorageCellMapper; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; import org.nl.common.exception.BadRequestException; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; @Service @RequiredArgsConstructor @@ -115,10 +99,14 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { MDC.put(log_file_type, log_type); JSONArray backja = new JSONArray(); JSONArray datas = JSONArray.parseArray(jsonObject); - //标准版行架机械手 - StandardManipulatorDeviceDriver standardManipulatorDeviceDriver; + //表处下料行架机械手 + BlankManipulatorDeviceDriver blankManipulatorDeviceDriver; + //烘箱行架机械手 + OvenGantryManipulatorDeviceDriver ovenGantryManipulatorDeviceDriver; //装箱行架机械手 BoxManipulatorDeviceDriver boxManipulatorDeviceDriver; + //木箱码垛机械手 + BoxPalletizingManipulatorDeviceDriver boxPalletizingManipulatorDeviceDriver; //纸管库2 PaperTubeConveyor2DeviceDriver paperTubeConveyor2DeviceDriver; //废箔称重位 @@ -148,22 +136,54 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { if (ObjectUtil.isEmpty(device)) { throw new Exception("未找到对应设备:" + parent_device_code); } - if (device.getDeviceDriver() instanceof StandardManipulatorDeviceDriver) { - standardManipulatorDeviceDriver = (StandardManipulatorDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", standardManipulatorDeviceDriver.getDevice().getDevice_code()); - jo.put("device_name", standardManipulatorDeviceDriver.getDevice().getDevice_name()); - jo.put("status", Math.min(3, standardManipulatorDeviceDriver.getMode())); - jo.put("x", standardManipulatorDeviceDriver.getX_position()); - jo.put("y", standardManipulatorDeviceDriver.getY_position()); - jo.put("error", standardManipulatorDeviceDriver.getError()); - } else if (device.getDeviceDriver() instanceof BoxManipulatorDeviceDriver){ + if (device.getDeviceDriver() instanceof BlankManipulatorDeviceDriver) { + blankManipulatorDeviceDriver = (BlankManipulatorDeviceDriver) device.getDeviceDriver(); + jo.put("device_code", blankManipulatorDeviceDriver.getDevice().getDevice_code()); + jo.put("device_name", blankManipulatorDeviceDriver.getDevice().getDevice_name()); + jo.put("status", Math.min(3, blankManipulatorDeviceDriver.getMode())); + jo.put("x", blankManipulatorDeviceDriver.getX_position()); + jo.put("y", blankManipulatorDeviceDriver.getY_position()); + jo.put("error", blankManipulatorDeviceDriver.getError()); + } else if (device.getDeviceDriver() instanceof OvenGantryManipulatorDeviceDriver){ + ovenGantryManipulatorDeviceDriver = (OvenGantryManipulatorDeviceDriver) device.getDeviceDriver(); + jo.put("device_code", ovenGantryManipulatorDeviceDriver.getDevice().getDevice_code()); + jo.put("device_name", ovenGantryManipulatorDeviceDriver.getDevice().getDevice_name()); + jo.put("status", Math.min(3, ovenGantryManipulatorDeviceDriver.getMode())); + jo.put("x", ovenGantryManipulatorDeviceDriver.getX_position()); + jo.put("y", ovenGantryManipulatorDeviceDriver.getY_position()); + jo.put("mode", ovenGantryManipulatorDeviceDriver.getMode()); + jo.put("move", ovenGantryManipulatorDeviceDriver.getMove()); + jo.put("action", ovenGantryManipulatorDeviceDriver.getAction()); + jo.put("walk_y", ovenGantryManipulatorDeviceDriver.getWalk_y()); + jo.put("task", ovenGantryManipulatorDeviceDriver.getTask()); + jo.put("error", ovenGantryManipulatorDeviceDriver.getError()); + } else if (device.getDeviceDriver() instanceof BoxManipulatorDeviceDriver) { boxManipulatorDeviceDriver = (BoxManipulatorDeviceDriver) device.getDeviceDriver(); jo.put("device_code", boxManipulatorDeviceDriver.getDevice().getDevice_code()); jo.put("device_name", boxManipulatorDeviceDriver.getDevice().getDevice_name()); jo.put("status", Math.min(3, boxManipulatorDeviceDriver.getMode())); jo.put("x", boxManipulatorDeviceDriver.getX_position()); jo.put("y", boxManipulatorDeviceDriver.getY_position()); + jo.put("mode", boxManipulatorDeviceDriver.getMode()); + jo.put("move", boxManipulatorDeviceDriver.getMove()); + jo.put("action", boxManipulatorDeviceDriver.getAction()); + jo.put("walk_y", boxManipulatorDeviceDriver.getWalk_y()); + jo.put("task", boxManipulatorDeviceDriver.getTask()); jo.put("error", boxManipulatorDeviceDriver.getError()); + } else if (device.getDeviceDriver() instanceof BoxPalletizingManipulatorDeviceDriver) { + boxPalletizingManipulatorDeviceDriver = (BoxPalletizingManipulatorDeviceDriver) device.getDeviceDriver(); + jo.put("device_code", boxPalletizingManipulatorDeviceDriver.getDevice().getDevice_code()); + jo.put("device_name", boxPalletizingManipulatorDeviceDriver.getDevice().getDevice_name()); + jo.put("status", Math.min(3, boxPalletizingManipulatorDeviceDriver.getMode())); + jo.put("x", boxPalletizingManipulatorDeviceDriver.getX_position()); + jo.put("y", boxPalletizingManipulatorDeviceDriver.getY_position()); + jo.put("mode", boxPalletizingManipulatorDeviceDriver.getMode()); + jo.put("move", boxPalletizingManipulatorDeviceDriver.getMove()); + jo.put("action", boxPalletizingManipulatorDeviceDriver.getAction()); + jo.put("walk_y", boxPalletizingManipulatorDeviceDriver.getWalk_y()); + jo.put("task", boxPalletizingManipulatorDeviceDriver.getTask()); + jo.put("error", boxPalletizingManipulatorDeviceDriver.getError()); + } else { }else if (device.getDeviceDriver() instanceof PaperTubeConveyor2DeviceDriver) { paperTubeConveyor2DeviceDriver = (PaperTubeConveyor2DeviceDriver) device.getDeviceDriver(); jo.put("device_code", parent_device_code); diff --git a/acs/nladmin-ui/src/views/acs/device/config.vue b/acs/nladmin-ui/src/views/acs/device/config.vue index 2a9fd2a..79e99a5 100644 --- a/acs/nladmin-ui/src/views/acs/device/config.vue +++ b/acs/nladmin-ui/src/views/acs/device/config.vue @@ -105,6 +105,12 @@ import double_belt_conveyor from '@/views/acs/device/driver/double_belt_conveyor import with_station_device from '@/views/acs/device/driver/with_station_device.vue' import standard_manipulator from '@/views/acs/device/driver/standard_manipulator.vue' import box_manipulator from '@/views/acs/device/driver/box_manipulator.vue' +import conveyor_with_scanner_weight from '@/views/acs/device/driver/conveyor_with_scanner_weight.vue' +import box_manipulator_site from '@/views/acs/device/driver/box_manipulator_site.vue' +import fold_disc_site from '@/views/acs/device/driver/fold_disc_site.vue' +import rgv from '@/views/acs/device/driver/rgv.vue' +import dry_manipulator from '@/views/acs/device/driver/dry_manipulator.vue' +import blank_manipulator from '@/views/acs/device/driver/blank_manipulator.vue' export default { name: 'DeviceConfig', components: { @@ -139,7 +145,13 @@ export default { double_belt_conveyor, with_station_device, standard_manipulator, - box_manipulator + box_manipulator, + conveyor_with_scanner_weight, + box_manipulator_site, + fold_disc_site, + rgv, + dry_manipulator, + blank_manipulator }, dicts: ['device_type'], mixins: [crud], diff --git a/acs/nladmin-ui/src/views/acs/device/driver/blank_manipulator.vue b/acs/nladmin-ui/src/views/acs/device/driver/blank_manipulator.vue new file mode 100644 index 0000000..121bc7c --- /dev/null +++ b/acs/nladmin-ui/src/views/acs/device/driver/blank_manipulator.vue @@ -0,0 +1,546 @@ + + + + + diff --git a/acs/nladmin-ui/src/views/acs/device/driver/box_manipulator_site.vue b/acs/nladmin-ui/src/views/acs/device/driver/box_manipulator_site.vue new file mode 100644 index 0000000..ff36045 --- /dev/null +++ b/acs/nladmin-ui/src/views/acs/device/driver/box_manipulator_site.vue @@ -0,0 +1,564 @@ + + + + + diff --git a/acs/nladmin-ui/src/views/acs/device/driver/conveyor_with_scanner_weight.vue b/acs/nladmin-ui/src/views/acs/device/driver/conveyor_with_scanner_weight.vue new file mode 100644 index 0000000..6079e15 --- /dev/null +++ b/acs/nladmin-ui/src/views/acs/device/driver/conveyor_with_scanner_weight.vue @@ -0,0 +1,564 @@ + + + + + diff --git a/acs/nladmin-ui/src/views/acs/device/driver/dry_manipulator.vue b/acs/nladmin-ui/src/views/acs/device/driver/dry_manipulator.vue new file mode 100644 index 0000000..237eb18 --- /dev/null +++ b/acs/nladmin-ui/src/views/acs/device/driver/dry_manipulator.vue @@ -0,0 +1,546 @@ + + + + + diff --git a/acs/nladmin-ui/src/views/acs/device/driver/fold_disc_site.vue b/acs/nladmin-ui/src/views/acs/device/driver/fold_disc_site.vue new file mode 100644 index 0000000..95bbb02 --- /dev/null +++ b/acs/nladmin-ui/src/views/acs/device/driver/fold_disc_site.vue @@ -0,0 +1,564 @@ + + + + + diff --git a/acs/nladmin-ui/src/views/acs/device/driver/rgv.vue b/acs/nladmin-ui/src/views/acs/device/driver/rgv.vue new file mode 100644 index 0000000..5b8e3a1 --- /dev/null +++ b/acs/nladmin-ui/src/views/acs/device/driver/rgv.vue @@ -0,0 +1,564 @@ + + + + +