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 index f340a6c..b4e99b6 100644 --- 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 @@ -9,12 +9,14 @@ 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.DeviceService; 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.ext.wms.service.AcsToWmsService; import org.nl.acs.history.ErrorUtil; import org.nl.acs.history.service.DeviceErrorLogService; import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; @@ -44,19 +46,21 @@ import java.util.List; public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { protected StandardItemProtocol standardItemProtocol = new StandardItemProtocol(this); @Autowired - DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); + @Autowired + DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); + @Autowired + RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); @Autowired TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + @Autowired + AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl"); @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); + DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); //工作模式 int mode = 0; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandarManipulatorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandarManipulatorDeviceDriver.java deleted file mode 100644 index eb914f2..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandarManipulatorDeviceDriver.java +++ /dev/null @@ -1,392 +0,0 @@ -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 java.util.Date; -import java.util.List; -@Slf4j -@Data -@RequiredArgsConstructor -public class StandarManipulatorDeviceDriver 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/one_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_out_subvolumes_conveyor/BoxOutSubvolumesConveyorDefination.java similarity index 100% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDefination.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_out_subvolumes_conveyor/BoxOutSubvolumesConveyorDefination.java diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_out_subvolumes_conveyor/BoxOutSubvolumesConveyorDeviceDriver.java similarity index 100% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDeviceDriver.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_out_subvolumes_conveyor/BoxOutSubvolumesConveyorDeviceDriver.java diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_out_subvolumes_conveyor/ItemProtocol.java similarity index 100% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/ItemProtocol.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_out_subvolumes_conveyor/ItemProtocol.java diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_storage_out_conveyor/BoxStorageOutConveyorDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_storage_out_conveyor/BoxStorageOutConveyorDefination.java index 21bb812..7c0997e 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_storage_out_conveyor/BoxStorageOutConveyorDefination.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_storage_out_conveyor/BoxStorageOutConveyorDefination.java @@ -11,7 +11,7 @@ import java.util.LinkedList; import java.util.List; /** - * 一楼木箱出入库标准站点 + * 一楼木箱出入库站点 * */ @Service @@ -23,12 +23,12 @@ public class BoxStorageOutConveyorDefination implements OpcDeviceDriverDefinatio @Override public String getDriverName() { - return "一楼木箱出入库标准站点"; + return "一楼木箱入库站点"; } @Override public String getDriverDescription() { - return "一楼木箱出入库标准站点"; + return "一楼木箱入库站点"; } @Override diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_pick_site/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_pick_site/ItemProtocol.java new file mode 100644 index 0000000..680130d --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_pick_site/ItemProtocol.java @@ -0,0 +1,159 @@ +package org.nl.acs.device_driver.paper_tube_pick_site; + +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_qty = "qty"; + //报警 + public static String item_error = "error"; + //物料 + public static String item_material = "material"; + //物料直径 + public static String item_size = "size"; + //物料长度 + public static String item_len = "len"; + //明细数量 + public static String item_Itemized_qty = "Itemized_qty"; + + //下发命令 + public static String item_to_command = "to_command"; + //下发物料类型 + public static String item_to_material = "to_material"; + //下发命令 + public static String item_to_size = "to_size"; + //下发命令 + public static String item_to_len = "to_len"; + //下发命令 + public static String item_to_qty = "to_qty"; + + private PaperTubePickSiteDeviceDriver driver; + + public ItemProtocol(PaperTubePickSiteDeviceDriver 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 getQty() { + return this.getOpcIntegerValue(item_qty); + } + + public int getError() { + return this.getOpcIntegerValue(item_error); + } + + public String getMaterial() { + return this.getOpcStringValue(item_material); + } + + public int getSize() { + return this.getOpcIntegerValue(item_size); + } + + public int getLen() { + return this.getOpcIntegerValue(item_len); + } + + public int getItemized_qty() { + return this.getOpcIntegerValue(item_Itemized_qty); + } + + public int getTo_command() { + return this.getOpcIntegerValue(item_to_command); + } + + public String getTo_material() { + return this.getOpcStringValue(item_to_material); + } + + public int getTo_size() { + return this.getOpcIntegerValue(item_to_size); + } + + public int getTo_len() { + return this.getOpcIntegerValue(item_to_len); + } + + public int getTo_qty() { + return this.getOpcIntegerValue(item_to_qty); + } + + 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.isBlank(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_error, "报警", "DB1001.B4")); + list.add(new ItemDto(item_qty, "总数量", "DB1001.B5")); + list.add(new ItemDto(item_material, "物料类型", "DB1.B6")); + list.add(new ItemDto(item_size, "物料直径", "DB1.B7")); + list.add(new ItemDto(item_len, "物料长度", "DB1.B8")); + list.add(new ItemDto(item_Itemized_qty, "物料明细数量", "DB1.B9")); + 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_material, "下发物料类型", "DB2.W2")); + list.add(new ItemDto(item_to_size, "下发物料直径", "DB2.W4")); + list.add(new ItemDto(item_to_len, "下发物料长度", "DB2.W6")); + list.add(new ItemDto(item_to_qty, "下发物料数量", "DB2.W8")); + return list; + } +} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_pick_site/PaperTubePickSiteDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_pick_site/PaperTubePickSiteDefination.java new file mode 100644 index 0000000..7908f8c --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_pick_site/PaperTubePickSiteDefination.java @@ -0,0 +1,61 @@ +package org.nl.acs.device_driver.paper_tube_pick_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.nl.acs.device_driver.two_conveyor.pull_head_manipulator.ItemProtocol; +import org.springframework.stereotype.Service; + +import java.util.LinkedList; +import java.util.List; + +@Service +public class PaperTubePickSiteDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "paper_tube_pick_size"; + } + + @Override + public String getDriverName() { + return "纸管抓取位"; + } + + @Override + public String getDriverDescription() { + return "纸管抓取位"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new PaperTubePickSiteDeviceDriver()).setDevice(device).setDriverDefination(this); + + } + + @Override + public Class getDeviceDriverType() { + return PaperTubePickSiteDeviceDriver.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/paper_tube_pick_site/PaperTubePickSiteDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_pick_site/PaperTubePickSiteDeviceDriver.java new file mode 100644 index 0000000..cd0105a --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/paper_tube_pick_site/PaperTubePickSiteDeviceDriver.java @@ -0,0 +1,238 @@ +package org.nl.acs.device_driver.paper_tube_pick_site; + +import com.alibaba.fastjson.JSONObject; +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +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.RouteableDeviceDriver; +import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; +import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +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.HashMap; +import java.util.List; +import java.util.Map; + +/** + * + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class PaperTubePickSiteDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor { + 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); + + private Date instruction_require_time = new Date(); + private Date instruction_finished_time = new Date(); + private Date instruction_apply_time = new Date(); + private int instruction_require_time_out = 3000; + + //工作模式 + int mode = 0; + int last_mode = 0; + //光电信号 + int move = 0; + int last_move = 0; + //动作信号 + int action = 0; + int last_action = 0; + //总数量 + int qty = 0; + int last_qty = 0; + //物料类型 + String material = null; + String last_material = null; + //物料直径 + int size =0; + int last_size =0; + //物料长度 + int len = 0; + int last_len = 0; + //物料明细数量 + int Itemized_qty = 0; + int last_Itemized_qty = 0; + //报警信号 + int error = 0; + int last_error = 0; + int heartbeat = 0; + int last_heartbeat = 0; + + + int to_command = 0; + int last_to_command = 0; + //下发物料类型 + String to_material =null; + String last_to_material =null; + //下发物料直径 + int to_size = 0; + int last_to_size = 0; + //下发物料长度 + int to_len=0; + int last_to_len=0; + //下发物料数量 + int to_qty=0; + int last_to_qty=0; + + + Boolean isonline = true; + + Boolean iserror = false; + + /** + * 1-执行任务;2-取货完成;3-放货完成; + */ + int flag; + + String device_code; + + @Override + public Device getDevice() { + return this.device; + } + + /** + * 请求成功标记 + */ + Boolean requireSucess = false; + + @Override + public void execute() { + String message = null; + try { + device_code = this.getDeviceCode(); + mode = this.itemProtocol.getMode(); + error = this.itemProtocol.getError(); + move = this.itemProtocol.getMove(); + action = this.itemProtocol.getAction(); + if (mode != last_mode) { + this.setRequireSucess(false); + if (mode == 2) { + this.writing(0); + } + } + if (move != last_move) { + } + if (error != last_error) { + } + } catch (Exception var17) { + return; + } + + if (!this.itemProtocol.getIsonline()) { + this.setIsonline(false); + this.setIserror(true); + message = "信号量同步异常"; + //未联机 + } else if (mode == 0) { + this.setIsonline(false); + this.setIserror(true); + message = "未联机"; + //有报警 + } else if (error != 0) { + this.setIsonline(false); + this.setIserror(true); + message = "有报警"; + //无报警 + } else { + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + switch (mode) { + case 1: + log.debug("设备运转模式:等待工作"); + return; + case 2: + break; + case 3: + break; + default: + break; + } + + switch (flag) { + //取货完成 + case 1: + writing(3); + return; + //放货完成 + case 2: + writing(5); + return; + default: + break; + } + + } + + } + + protected void thingToNothing() { + this.setRequireSucess(false); + } + + public void writing(int command) { + String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + org.nl.acs.device_driver.two_conveyor.hongxiang_conveyor.ItemProtocol.item_to_command; + //String opcservcerid = this.getDevice().getOpc_server_id(); +//Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + itemMap.put(to_command, command); + this.control(itemMap); + } + + @Override + public JSONObject getDeviceStatusName() { + JSONObject jo = new JSONObject(); + String mode = ""; + String action = ""; + String move = ""; + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("mode", "联机"); + jo.put("action", action); + jo.put("isOnline", true); + jo.put("error", this.getError()); + jo.put("isError", this.getIserror()); + return jo; + } + + @Override + public void setDeviceStatus(JSONObject data) { + + } + + + +} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/blank_manipulator/BlankManipulatorDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/BlankManipulatorDefination.java similarity index 95% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/blank_manipulator/BlankManipulatorDefination.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/BlankManipulatorDefination.java index 99df9ae..d9e8e19 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/blank_manipulator/BlankManipulatorDefination.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/BlankManipulatorDefination.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.blank_manipulator; +package org.nl.acs.device_driver.two_conveyor.blank_manipulator; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; import org.nl.acs.device.domain.Device; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/blank_manipulator/BlankManipulatorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/BlankManipulatorDeviceDriver.java similarity index 99% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/blank_manipulator/BlankManipulatorDeviceDriver.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/BlankManipulatorDeviceDriver.java index 737a041..5e43e0b 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/blank_manipulator/BlankManipulatorDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/BlankManipulatorDeviceDriver.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.blank_manipulator; +package org.nl.acs.device_driver.two_conveyor.blank_manipulator; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/blank_manipulator/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/ItemProtocol.java similarity index 98% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/blank_manipulator/ItemProtocol.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/ItemProtocol.java index 95603b5..673a89c 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/blank_manipulator/ItemProtocol.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blank_manipulator/ItemProtocol.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.blank_manipulator; +package org.nl.acs.device_driver.two_conveyor.blank_manipulator; import cn.hutool.core.util.StrUtil; import lombok.Data; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/blanking_button/BlankingButtonDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blanking_button/BlankingButtonDefination.java similarity index 95% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/blanking_button/BlankingButtonDefination.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blanking_button/BlankingButtonDefination.java index 35bace5..71c6130 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/blanking_button/BlankingButtonDefination.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blanking_button/BlankingButtonDefination.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.blanking_button; +package org.nl.acs.device_driver.two_conveyor.blanking_button; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; import org.nl.acs.device.domain.Device; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blanking_button/BlankingButtonDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blanking_button/BlankingButtonDriver.java new file mode 100644 index 0000000..86e0438 --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blanking_button/BlankingButtonDriver.java @@ -0,0 +1,327 @@ +package org.nl.acs.device_driver.two_conveyor.blanking_button; + +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.AcsConfig; +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.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.ext.wms.data.BlankingButtonRequest; +import org.nl.acs.ext.wms.data.BlankingButtonResponse; +import org.nl.acs.ext.wms.service.AcsToWmsService; +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.route.service.RouteLineService; +import org.nl.acs.task.service.TaskService; +import org.nl.config.SpringContextHolder; +import org.nl.system.service.param.ISysParamService; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 下料按钮 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class BlankingButtonDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { + protected ItemProtocol itemProtocol = new ItemProtocol(this); + + + @Autowired + InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); + + @Autowired + DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class); + @Autowired + RouteLineService routelineserver = SpringContextHolder.getBean(RouteLineService.class); + @Autowired + TaskService taskserver = SpringContextHolder.getBean(TaskService.class); + + @Autowired + DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); + + @Autowired + RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); + + @Autowired + ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class); + @Autowired + AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class); + + DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); + + DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); + + private String error_type = "hx_error_type"; + + private Date instruction_require_time = new Date(); + private Date instruction_finished_time = new Date(); + private Date instruction_apply_time = new Date(); + private int instruction_require_time_out = 3000; + + public int heartbeat = 0; + public int mode = 0; + public int move = 0; + public int action = 0; + public int error = 0; + + public int last_heartbeat = 0; + public int last_mode = 0; + public int last_move = 0; + public int last_action = 0; + public int last_error = 0; + + Boolean isonline = true; + + Boolean iserror = false; + + + String device_code; + + String message = null; + + + @Override + public Device getDevice() { + return this.device; + } + + //请求成功标记 + Boolean requireSucess = false; + + @Override + public void execute() { + + device_code = this.getDeviceCode(); + heartbeat = this.itemProtocol.getItem_heartbeat(); + mode = this.itemProtocol.getItem_mode(); + move = this.itemProtocol.getItem_move(); + action = this.itemProtocol.getItem_action(); + error = this.itemProtocol.getItem_error(); + + 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 (mode == 0) { + this.setIsonline(false); + message = "未联机"; + // 有报警 + // } else if (error != 0) { + // this.setIsonline(false); + // this.setIserror(true); + // message = "有报警"; + // //无报警 + } else { + this.setIsonline(true); + this.setIserror(false); + if (error != 0) { + this.setIserror(true); + message = "有报警"; + } + message = ""; + Instruction instruction = null; + List toInstructions; + + switch (mode) { + case 2: + log.debug("设备运转模式:等待工作"); + break; + case 3: + log.debug("设备运转模式:等待工作"); + break; + case 9: + // 表处下满料请求 + if (move > 0 && !requireSucess) { + applyTakeFullVolume(); + } + break; + case 10: + //表处上空轴请求 + if (move > 0 && !requireSucess) { + applyTakeEmptyShaft(); + } + break; + case 11: + // 取消任务 + if (move > 0 && !requireSucess) { + cancelTask(); + } + break; + default: + break; + } + } + + + last_mode = mode; + last_move = move; + last_action = action; + last_error = error; + + } + + /** + * 表处下满料请求 + */ + public synchronized void applyTakeFullVolume() { + 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; + } else { + this.instruction_require_time = date; + if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), CommonFinalParam.ONE)) { + message = "申请下满料请求中..."; + BlankingButtonRequest blankingButtonRequest = new BlankingButtonRequest(); + blankingButtonRequest.setDevice_code(device_code); + blankingButtonRequest.setType("1"); + BlankingButtonResponse response = acsToWmsService.applyBlankButtonTask(blankingButtonRequest); + if (ObjectUtil.isEmpty(response)) { + message = "申请下满料任务接口不通"; + } else { + if (response.getCode()== 200) { + this.writing("to_command","9"); + message = "申请下满料任务成功"; + requireSucess = true; + } else { + requireSucess = false; + message = "申请下满料任务失败," + response.getMessage(); + this.writing("to_command","99"); + } + } + } + } + } + + /** + * 申请取消任务 + */ + public synchronized void applyTakeEmptyShaft() { + 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; + } else { + this.instruction_require_time = date; + if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), CommonFinalParam.ONE)) { + message = "申请取消任务中..."; + BlankingButtonRequest blankingButtonRequest = new BlankingButtonRequest(); + blankingButtonRequest.setDevice_code(device_code); + blankingButtonRequest.setType("2"); + BlankingButtonResponse response = acsToWmsService.applyBlankButtonTask(blankingButtonRequest); + if (ObjectUtil.isEmpty(response)) { + message = "申请取消任务接口不通"; + } else { + if (response.getCode()== 200) { + this.writing("to_command","10"); + message = "申请取消任务成功"; + requireSucess = true; + } else { + requireSucess = false; + message = "申请取消任务失败," + response.getMessage(); + this.writing("to_command","99"); + } + } + } + } + } + + /** + * 取消任务 + */ + public synchronized void cancelTask() { + 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; + } else { + this.instruction_require_time = date; + if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), CommonFinalParam.ONE)) { + message = "申请取消任务中..."; + BlankingButtonRequest blankingButtonRequest = new BlankingButtonRequest(); + blankingButtonRequest.setDevice_code(device_code); + blankingButtonRequest.setType("2"); + BlankingButtonResponse response = acsToWmsService.applyBlankButtonTask(blankingButtonRequest); + if (ObjectUtil.isEmpty(response)) { + message = "申请AGV搬运任务接口不通"; + } else { + if (response.getCode()== 200) { + this.writing("to_command","10"); + message = "申请AGV搬运任务成功"; + requireSucess = true; + } else { + requireSucess = false; + message = "申请AGV搬运任务失败," + response.getMessage(); + this.writing("to_command","99"); + } + } + } + } + } + + 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; + + Map itemMap = new HashMap(); + + itemMap.put(to_param, Integer.parseInt(value)); + this.control(itemMap); + logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value); + } + + + @Override + public JSONObject feedLmsRealFailedInfo() { + return null; + } + + @Override + public JSONObject getDeviceStatusName() throws Exception { + return null; + } + + @Override + public void setDeviceStatus(JSONObject data) { + + } +} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/blanking_button/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blanking_button/ItemProtocol.java similarity index 97% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/blanking_button/ItemProtocol.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blanking_button/ItemProtocol.java index 1511186..2bb83e2 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/blanking_button/ItemProtocol.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/blanking_button/ItemProtocol.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.blanking_button; +package org.nl.acs.device_driver.two_conveyor.blanking_button; import lombok.Data; import lombok.extern.slf4j.Slf4j; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/green_foil_machine_button/GreenFoilMachineButtonDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/green_foil_machine_button/GreenFoilMachineButtonDefination.java similarity index 95% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/green_foil_machine_button/GreenFoilMachineButtonDefination.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/green_foil_machine_button/GreenFoilMachineButtonDefination.java index 72a95ec..6503a8d 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/green_foil_machine_button/GreenFoilMachineButtonDefination.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/green_foil_machine_button/GreenFoilMachineButtonDefination.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.green_foil_machine_button; +package org.nl.acs.device_driver.two_conveyor.green_foil_machine_button; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; import org.nl.acs.device.domain.Device; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/green_foil_machine_button/GreenFoilMachineButtonDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/green_foil_machine_button/GreenFoilMachineButtonDriver.java similarity index 86% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/green_foil_machine_button/GreenFoilMachineButtonDriver.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/green_foil_machine_button/GreenFoilMachineButtonDriver.java index 8a8d1ce..fed8362 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/green_foil_machine_button/GreenFoilMachineButtonDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/green_foil_machine_button/GreenFoilMachineButtonDriver.java @@ -1,14 +1,12 @@ -package org.nl.acs.device_driver.green_foil_machine_button; +package org.nl.acs.device_driver.two_conveyor.green_foil_machine_button; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import lombok.Data; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.nl.acs.AcsConfig; -import org.nl.acs.agv.server.AgvService; import org.nl.acs.common.base.CommonFinalParam; import org.nl.acs.device.domain.Device; import org.nl.acs.device.service.DeviceService; @@ -17,13 +15,10 @@ 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.ext.wms.data.ApplyLabelingAndBindingRequest; -import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingResponse; +import org.nl.acs.ext.wms.data.ApplyGreenFoilButtonRequest; +import org.nl.acs.ext.wms.data.ApplyGreenFoilButtonResponse; import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; -import org.nl.acs.history.ErrorUtil; import org.nl.acs.history.service.DeviceErrorLogService; -import org.nl.acs.history.service.dto.DeviceErrorLogDto; import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; import org.nl.acs.instruction.domain.Instruction; import org.nl.acs.instruction.service.InstructionService; @@ -167,7 +162,7 @@ public class GreenFoilMachineButtonDriver extends AbstractOpcDeviceDriver implem case 4: // 申请AGV取空取满放空放满任务 if (move > 0 && !requireSucess) { -// applyFourPointAgvTask(); + applyAgvTask(mode); } break; case 5: @@ -175,31 +170,31 @@ public class GreenFoilMachineButtonDriver extends AbstractOpcDeviceDriver implem * 申请AGV取空放空的任务 */ if (move > 0 && !requireSucess) { - applyTakeEmptyAgvTask(); + applyAgvTask(mode); } break; case 6: // 申请取满放满任务 if (move > 0 && !requireSucess) { -// applyTakeFullAgvTask(); + applyAgvTask(mode); } break; case 7: // 允许AGV进入 if (move == 0 && !requireSucess) { -// allowAgvEntry(); + applyAgvTask(mode); } break; case 8: // 允许AGV离开 if (move == 0 && !requireSucess) { -// allowAgvLeave(); + applyAgvTask(mode); } break; case 9: // 取消任务 if (move == 0 && !requireSucess) { -// cancelTask(); + applyAgvTask(mode); } break; default: @@ -217,9 +212,9 @@ public class GreenFoilMachineButtonDriver extends AbstractOpcDeviceDriver implem } /** - * 申请AGV取空放空的任务 + * 申请AGV任务 */ - public synchronized void applyTakeEmptyAgvTask() { + public synchronized void applyAgvTask(int mode) { Date date = new Date(); if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { @@ -229,20 +224,27 @@ public class GreenFoilMachineButtonDriver extends AbstractOpcDeviceDriver implem this.instruction_require_time = date; if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), CommonFinalParam.ONE)) { message = "申请AGV搬运任务中..."; - JSONObject apply = new JSONObject(); - apply.put("device_code", device_code); - apply.put("type", CommonFinalParam.ONE); - String str = acsToWmsService.applyTaskToWms(apply); - JSONObject jo = JSON.parseObject(str); - if (ObjectUtil.isEmpty(jo)) { + ApplyGreenFoilButtonRequest applyGreenFoilButtonRequest = new ApplyGreenFoilButtonRequest(); + applyGreenFoilButtonRequest.setDevice_code(device_code); + applyGreenFoilButtonRequest.setType(String.valueOf(mode)); + ApplyGreenFoilButtonResponse response = acsToWmsService.applyGreenFoilButtonTask(applyGreenFoilButtonRequest); + if (ObjectUtil.isEmpty(response)) { message = "申请AGV搬运任务接口不通"; } else { - if (jo.getInteger("status") == 200) { + if (response.getCode()== 200) { + if (mode==4){ + this.writing("to_command","4"); + }else if (mode==5){ + this.writing("to_command","5"); + }else if (mode==9){ + this.writing("to_command","9"); + } message = "申请AGV搬运任务成功"; requireSucess = true; } else { requireSucess = false; - message = "申请AGV搬运任务失败," + jo.get("message").toString(); + message = "申请AGV搬运任务失败," + response.getMessage(); + this.writing("to_command","99"); } } } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/green_foil_machine_button/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/green_foil_machine_button/ItemProtocol.java similarity index 97% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/green_foil_machine_button/ItemProtocol.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/green_foil_machine_button/ItemProtocol.java index c7bbd41..4dfd566 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/green_foil_machine_button/ItemProtocol.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/green_foil_machine_button/ItemProtocol.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.green_foil_machine_button; +package org.nl.acs.device_driver.two_conveyor.green_foil_machine_button; import lombok.Data; import lombok.extern.slf4j.Slf4j; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/hongxiang_conveyor/HongXiangStationDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_conveyor/HongXiangStationDefination.java similarity index 95% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/hongxiang_conveyor/HongXiangStationDefination.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_conveyor/HongXiangStationDefination.java index 23e9b1e..96587d5 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/hongxiang_conveyor/HongXiangStationDefination.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_conveyor/HongXiangStationDefination.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.conveyor.hongxiang_conveyor; +package org.nl.acs.device_driver.two_conveyor.hongxiang_conveyor; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; import org.nl.acs.device.domain.Device; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/hongxiang_conveyor/HongXiangStationDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_conveyor/HongXiangStationDeviceDriver.java similarity index 99% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/hongxiang_conveyor/HongXiangStationDeviceDriver.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_conveyor/HongXiangStationDeviceDriver.java index c6b5541..c8c1536 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/hongxiang_conveyor/HongXiangStationDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_conveyor/HongXiangStationDeviceDriver.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.conveyor.hongxiang_conveyor; +package org.nl.acs.device_driver.two_conveyor.hongxiang_conveyor; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/hongxiang_conveyor/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_conveyor/ItemProtocol.java similarity index 95% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/hongxiang_conveyor/ItemProtocol.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_conveyor/ItemProtocol.java index 87955d8..72992cc 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/hongxiang_conveyor/ItemProtocol.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_conveyor/ItemProtocol.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.conveyor.hongxiang_conveyor; +package org.nl.acs.device_driver.two_conveyor.hongxiang_conveyor; import lombok.Data; import lombok.extern.slf4j.Slf4j; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/hongxiang_device/HongXiangConveyorDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_device/HongXiangConveyorDefination.java similarity index 95% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/hongxiang_device/HongXiangConveyorDefination.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_device/HongXiangConveyorDefination.java index 92af91a..0615adc 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/hongxiang_device/HongXiangConveyorDefination.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_device/HongXiangConveyorDefination.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.hongxiang_device; +package org.nl.acs.device_driver.two_conveyor.hongxiang_device; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; import org.nl.acs.device.domain.Device; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/hongxiang_device/HongXiangConveyorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_device/HongXiangConveyorDeviceDriver.java similarity index 98% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/hongxiang_device/HongXiangConveyorDeviceDriver.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_device/HongXiangConveyorDeviceDriver.java index 220591d..a65a8b9 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/hongxiang_device/HongXiangConveyorDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_device/HongXiangConveyorDeviceDriver.java @@ -1,8 +1,6 @@ -package org.nl.acs.device_driver.hongxiang_device; +package org.nl.acs.device_driver.two_conveyor.hongxiang_device; -import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import lombok.Data; import lombok.RequiredArgsConstructor; @@ -15,8 +13,6 @@ 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.ext.wms.data.ApplyLabelingAndBindingRequest; -import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingResponse; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; import org.nl.acs.history.ErrorUtil; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/hongxiang_device/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_device/ItemProtocol.java similarity index 99% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/hongxiang_device/ItemProtocol.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_device/ItemProtocol.java index ae87c5e..5db6a4c 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/hongxiang_device/ItemProtocol.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/hongxiang_device/ItemProtocol.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.hongxiang_device; +package org.nl.acs.device_driver.two_conveyor.hongxiang_device; import lombok.Data; import lombok.extern.slf4j.Slf4j; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/InflatableShaftLibraryDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/InflatableShaftLibraryDefination.java new file mode 100644 index 0000000..2b3997d --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/InflatableShaftLibraryDefination.java @@ -0,0 +1,59 @@ +package org.nl.acs.device_driver.two_conveyor.inflatable_shaft_library; + +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 InflatableShaftLibraryDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "inflatable_shaft_library"; + } + + @Override + public String getDriverName() { + return "气涨轴缓存库"; + } + + @Override + public String getDriverDescription() { + return "气涨轴缓存库"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new InflatableShaftLibraryDeviceDriver()).setDevice(device).setDriverDefination(this); + + } + + @Override + public Class getDeviceDriverType() { + return InflatableShaftLibraryDeviceDriver.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/blanking_button/BlankingButtonDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/InflatableShaftLibraryDeviceDriver.java similarity index 57% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/blanking_button/BlankingButtonDriver.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/InflatableShaftLibraryDeviceDriver.java index b01074b..655b06d 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/blanking_button/BlankingButtonDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/InflatableShaftLibraryDeviceDriver.java @@ -1,59 +1,80 @@ -package org.nl.acs.device_driver.blanking_button; +package org.nl.acs.device_driver.two_conveyor.inflatable_shaft_library; import com.alibaba.fastjson.JSONObject; import lombok.Data; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; 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.dto.DeviceErrorLogDto; import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; +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.HashMap; import java.util.Map; /** - * 下料按钮 + * 气涨轴缓存库 */ @Slf4j @Data @RequiredArgsConstructor -public class BlankingButtonDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { +public class InflatableShaftLibraryDeviceDriver 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); - - DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); - - DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); - - private String error_type = "hx_error_type"; - - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - private Date instruction_apply_time = new Date(); - private int instruction_require_time_out = 3000; - + //心跳 public int heartbeat = 0; - public int mode = 0; - public int move = 0; - public int action = 0; - public int error = 0; - public int last_heartbeat = 0; - public int last_mode = 0; - public int last_move = 0; - public int last_action = 0; - public int last_error = 0; + //工作模式 + 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 qty = 0; + int last_qty = 0; + //类型 + int type = 0; + int last_type = 0; + + int to_command = 0; + int last_to_command = 0; Boolean isonline = true; @@ -64,7 +85,6 @@ public class BlankingButtonDriver extends AbstractOpcDeviceDriver implements Dev String message = null; - @Override public Device getDevice() { return this.device; @@ -82,7 +102,8 @@ public class BlankingButtonDriver extends AbstractOpcDeviceDriver implements Dev move = this.itemProtocol.getItem_move(); action = this.itemProtocol.getItem_action(); error = this.itemProtocol.getItem_error(); - + qty = this.itemProtocol.getItem_qty(); + type = this.itemProtocol.getItem_type(); if (mode != last_mode) { requireSucess = false; logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); @@ -100,18 +121,29 @@ public class BlankingButtonDriver extends AbstractOpcDeviceDriver implements Dev logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); } + if (qty != last_qty) { + logServer.deviceItemValue(this.device_code, "weight", String.valueOf(qty)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号qty:" + last_qty + "->" + qty); + } + if (type != last_type) { + logServer.deviceItemValue(this.device_code, "weight", String.valueOf(type)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号type:" + last_type + "->" + type); + } + + if (move==1&&!requireSucess){ + this.writing("to_command","1"); + } last_mode = mode; last_move = move; last_action = action; last_error = error; - + last_qty = qty; + last_type = type; } - - public void writing(String param, String value) { String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/ItemProtocol.java new file mode 100644 index 0000000..30d6e19 --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/ItemProtocol.java @@ -0,0 +1,102 @@ +package org.nl.acs.device_driver.two_conveyor.inflatable_shaft_library; + +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; + +import java.util.ArrayList; +import java.util.List; + +@Slf4j +@Data +public class ItemProtocol { + public static String item_heartbeat = "heartbeat"; + public static String item_mode = "mode"; + public static String item_move = "move"; + public static String item_action = "action"; + public static String item_error = "error"; + public static String item_qty = "qty"; + public static String item_type = "type"; + + public static String item_to_command = "to_command"; + + private InflatableShaftLibraryDeviceDriver driver; + + public ItemProtocol(InflatableShaftLibraryDeviceDriver driver){ + this.driver=driver; + } + + + public int getItem_heartbeat(){ + return this.getOpcIntegerValue(item_heartbeat); + } ; + public int getItem_mode(){ + return this.getOpcIntegerValue(item_mode); + } ; + public int getItem_move(){ + return this.getOpcIntegerValue(item_move); + } ; + public int getItem_action(){ + return this.getOpcIntegerValue(item_action); + }; + public int getItem_error(){ + return this.getOpcIntegerValue(item_error); + } + public int getItem_qty(){ + return this.getOpcIntegerValue(item_qty); + } + public int getItem_type(){ + return this.getItem_type(); + } + + + Boolean isonline; + + public int getOpcIntegerValue(String protocol) { + Integer value = this.driver.getIntegeregerValue(protocol); + if (value == null) { + setIsonline(false); + } else { + setIsonline(true); + return value; + } + return 0; + + } + + public float getOpcFloatValue(String protocol) { + Float value = this.driver.getDoubleValue(protocol); + if (value == null) { + setIsonline(false); + } else { + setIsonline(true); + return value; + } + return 0L; + + } + + 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_qty, "数量", "DB1.B4")); + list.add(new ItemDto(item_error, "报警信号", "DB1.B5")); + list.add(new ItemDto(item_type, "类型", "DB1.B6")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList<>(); + list.add(new ItemDto(item_to_command, "下发命令", "DB2.W0")); + return list; + } + + @Override + public String toString() { + return ""; + } + +} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/three_color/lamp_three_color/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/lamp_three_color/ItemProtocol.java similarity index 94% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/three_color/lamp_three_color/ItemProtocol.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/lamp_three_color/ItemProtocol.java index fa4e1c8..cd262b0 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/three_color/lamp_three_color/ItemProtocol.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/lamp_three_color/ItemProtocol.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.three_color.lamp_three_color; +package org.nl.acs.device_driver.two_conveyor.lamp_three_color; import lombok.extern.slf4j.Slf4j; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/three_color/lamp_three_color/LampThreecolorDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/lamp_three_color/LampThreecolorDefination.java similarity index 95% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/three_color/lamp_three_color/LampThreecolorDefination.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/lamp_three_color/LampThreecolorDefination.java index b9ec9fb..97cf318 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/three_color/lamp_three_color/LampThreecolorDefination.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/lamp_three_color/LampThreecolorDefination.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.three_color.lamp_three_color; +package org.nl.acs.device_driver.two_conveyor.lamp_three_color; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; import org.nl.acs.device.domain.Device; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/three_color/lamp_three_color/LampThreecolorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/lamp_three_color/LampThreecolorDeviceDriver.java similarity index 98% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/three_color/lamp_three_color/LampThreecolorDeviceDriver.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/lamp_three_color/LampThreecolorDeviceDriver.java index f6d0b15..562eafb 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/three_color/lamp_three_color/LampThreecolorDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/lamp_three_color/LampThreecolorDeviceDriver.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.three_color.lamp_three_color; +package org.nl.acs.device_driver.two_conveyor.lamp_three_color; import lombok.Data; import lombok.RequiredArgsConstructor; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/ItemProtocol.java new file mode 100644 index 0000000..9c623ff --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/ItemProtocol.java @@ -0,0 +1,166 @@ +package org.nl.acs.device_driver.two_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_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"; + + 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); + } + + 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); + } + + public int getTo_onset() { + return this.getOpcIntegerValue(item_to_onset); + } + + public float getX_position() { + return this.getOpcFloatValue(item_x_position); + } + + public float getY_position() { + return this.getOpcFloatValue(item_y_position); + } + + + 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 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")); + 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_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<>(); + 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/manipulator/standard_manipulator/StandarManipulatorDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/OvenGantryManipulatorDefination.java similarity index 74% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandarManipulatorDefination.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/OvenGantryManipulatorDefination.java index 13c1134..51c5d15 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandarManipulatorDefination.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/OvenGantryManipulatorDefination.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.manipulator.standard_manipulator; +package org.nl.acs.device_driver.two_conveyor.oven_manipulator; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; import org.nl.acs.device.domain.Device; @@ -9,26 +9,32 @@ import org.springframework.stereotype.Service; import java.util.LinkedList; import java.util.List; + +/** + * 烘箱-行架机械手 + * + */ @Service -public class StandarManipulatorDefination implements OpcDeviceDriverDefination { +public class OvenGantryManipulatorDefination implements OpcDeviceDriverDefination { @Override public String getDriverCode() { - return "standar_manipulator"; + return "oven_manipulator"; } @Override public String getDriverName() { - return "标准机械手"; + return "烘箱-行架机械手"; } @Override public String getDriverDescription() { - return "标准机械手"; + return "烘箱-行架机械手"; } @Override public DeviceDriver getDriverInstance(Device device) { return (new OvenGantryManipulatorDeviceDriver()).setDevice(device).setDriverDefination(this); + } @Override @@ -45,13 +51,13 @@ public class StandarManipulatorDefination implements OpcDeviceDriverDefination { @Override public List getReadableItemDtos() { - return StandardItemProtocol.getReadableItemDtos(); + return ItemProtocol.getReadableItemDtos(); } @Override public List getWriteableItemDtos() { - return StandardItemProtocol.getWriteableItemDtos(); + return ItemProtocol.getWriteableItemDtos(); } } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/OvenGantryManipulatorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/OvenGantryManipulatorDeviceDriver.java new file mode 100644 index 0000000..954d26c --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/OvenGantryManipulatorDeviceDriver.java @@ -0,0 +1,1038 @@ +package org.nl.acs.device_driver.two_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.device.domain.Device; +import org.nl.acs.device.service.DeviceService; +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.conveyor.standard_inspect_site.StandardInspectSiteDeviceDriver; +import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; +import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.device_driver.two_conveyor.hongxiang_device.HongXiangConveyorDeviceDriver; +import org.nl.acs.device_driver.two_conveyor.lamp_three_color.LampThreecolorDeviceDriver; +import org.nl.acs.ext.wms.service.AcsToWmsService; +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.task.service.TaskService; +import org.nl.acs.task.service.dto.TaskDto; +import org.nl.common.exception.BadRequestException; +import org.nl.config.SpringContextHolder; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.*; + +/** + * 烘箱-行架机械手 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { + 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); + @Autowired + DeviceErrorLogService deviceErrorLogService = 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.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(); + + 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); + } + update_instruction_status(); + + } 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_x_position = x_position; + last_y_position = y_position; + } + + public List sortTask(List taskDtos) { + Collections.sort(taskDtos, new Comparator() { + @Override + public int compare(TaskDto t1, TaskDto t2) { + //优先级从大到小 + int i = t2.getPriority().compareTo(t1.getPriority()); + //如果优先级相等 + if (i == 0) { + //时间从早到晚 + i = t1.getCreate_time().compareTo(t2.getCreate_time()); + } + return i; + } + }); + return taskDtos; + } + + /** + * 申请任务 + * + * @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; + //抓取工位 + if (ObjectUtil.isEmpty(getDeviceCodeList)) { + getDeviceCodeList = this.getExtraDeviceCodes("get_device_code"); + } + //放货工位 + if (ObjectUtil.isEmpty(putDeviceCodeList)) { + 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); + + //存在行架->暂存的AGV任务 需要过滤 + // 6 行架任务 8烘箱任务 + if (!StrUtil.equals(taskDto.getTask_type(), "6") && !StrUtil.equals(taskDto.getTask_type(), "8")) { + taskDto = null; + continue; + } + + Instruction instruction = instructionService.findByTaskcodeAndStatus(taskDto.getTask_code()); + String start_device_code = instruction.getStart_device_code(); + String next_device_code = instruction.getNext_device_code(); + Device nextdevice = deviceAppService.findDeviceByCode(next_device_code); + Device startdevice = deviceAppService.findDeviceByCode(start_device_code); +// PhotoelectricInspectionSiteDeviceDriver photoelectricInspectionSiteDeviceDriver; + HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; + StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; +// if (startdevice.getDeviceDriver() instanceof PhotoelectricInspectionSiteDeviceDriver) { +// photoelectricInspectionSiteDeviceDriver = (PhotoelectricInspectionSiteDeviceDriver) startdevice.getDeviceDriver(); +// if (photoelectricInspectionSiteDeviceDriver.getMove() != 1) { +// notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位-烘箱对接位:" + photoelectricInspectionSiteDeviceDriver.getDevice_code() + "无货,无法下发指令!指令号:" + instruction.getInstruction_code(); +// return false; +// } +// } + if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver(); + if (standardInspectSiteDeviceDriver.getMove() != 1) { + notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位-烘箱对接位:" + standardInspectSiteDeviceDriver.getDevicecode() + "无货,无法下发指令!指令号:" + instruction.getInstruction_code(); + return false; + } + } + if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { + hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver(); + if (hongXiangConveyorDeviceDriver.getMode() == 0 || hongXiangConveyorDeviceDriver.getMove() == 0) { + notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位-烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code() + "未联机或无货,无法下发指令!指令号:" + instruction.getInstruction_code(); + return false; + } + } + + if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver(); + if (standardInspectSiteDeviceDriver.getMove() != 0) { + notCreateInstMessage = "手动创建指令未下发电气信号原因->放货位-烘箱对接位:" + standardInspectSiteDeviceDriver.getDevicecode() + "有货,无法下发指令!指令号:" + instruction.getInstruction_code(); + return false; + } + } + if (nextdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { + hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextdevice.getDeviceDriver(); + if (hongXiangConveyorDeviceDriver.getMode() == 0 || hongXiangConveyorDeviceDriver.getMove() == 1) { + notCreateInstMessage = "手动创建指令未下发电气信号原因->放货位-烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code() + "未联机或者有货,无法下发指令!指令号:" + instruction.getInstruction_code(); + return false; + } + } + //判断关联的同一列烘箱设备是否都关门 都关门返回false,有一个不关门就返回true + boolean isCloseDoor = this.judgeCloseDoor(start_device_code, next_device_code); + //未关门结束 + if (isCloseDoor) { + notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位:" + start_device_code + ",放货位:" + next_device_code + ",存在关联的同一列烘箱设备未关门!指令号:" + instruction.getInstruction_code(); + return false; + } + instruction.setInstruction_status("1"); + 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("设备:" + startDevice.getDevice_code() + "未设置电气调度号!"); + } + if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))) { + throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"); + } + String start_addr = startDevice.getExtraValue().get("address").toString(); + String next_addr = nextDevice.getExtraValue().get("address").toString(); + logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" + + instruction.getInstruction_code() + ",指令起点:" + instruction.getStart_device_code() + + ",指令终点:" + instruction.getNext_device_code()); + this.writing("to_onset", start_addr); + this.writing("to_target", next_addr); + this.writing("to_task", instruction.getInstruction_code()); + this.writing("to_command", "1"); + if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { + hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver(); + hongXiangConveyorDeviceDriver.writing("to_open_door", "1"); + } + if (nextdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { + hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextdevice.getDeviceDriver(); + hongXiangConveyorDeviceDriver.writing("to_open_door", "1"); + } + this.setNow_steps_type(2); + this.setRequireSucess(true); + return true; + } else { + List taskDtoList = taskserver.queryTaskByDeviceCode(startDeviceCode); + if (ObjectUtil.isNotEmpty(taskDtoList)) { + for (int j = 0; j < taskDtoList.size(); j++) { + //按照优先级排序 优先级相等按照创建时间排序 + taskDtoList = this.sortTask(taskDtoList); + task = taskDtoList.get(j); + // 6 行架任务 8烘箱任务 + if (!StrUtil.equals(task.getTask_type(), "6") && !StrUtil.equals(task.getTask_type(), "8")) { + task = null; + continue; + } + if (ObjectUtil.isNotEmpty(task)) { + break; + } + } + } + } + } + if (!ObjectUtil.isEmpty(task)) { + Device nextdevice = deviceAppService.findDeviceByCode(task.getNext_device_code()); + Device startdevice = deviceAppService.findDeviceByCode(task.getStart_device_code()); +// PhotoelectricInspectionSiteDeviceDriver photoelectricInspectionSiteDeviceDriver; + HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; + StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; +// if (startdevice.getDeviceDriver() instanceof PhotoelectricInspectionSiteDeviceDriver) { +// photoelectricInspectionSiteDeviceDriver = (PhotoelectricInspectionSiteDeviceDriver) startdevice.getDeviceDriver(); +// if (photoelectricInspectionSiteDeviceDriver.getMove() != 1) { +// notCreateInstMessage = "就绪任务未创建指令原因->取货位-烘箱对接位:" + photoelectricInspectionSiteDeviceDriver.getDevice_code() + "光电无货,无法生成指令!"; +// return false; +// } +// } + if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver(); + if (standardInspectSiteDeviceDriver.getMove() != 1) { + notCreateInstMessage = "就绪任务未创建指令原因->取货位-烘箱对接位:" + standardInspectSiteDeviceDriver.getDevicecode() + "光电无货,无法生成指令!"; + return false; + } + } + if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { + hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver(); + if (hongXiangConveyorDeviceDriver.getMode() == 0 || hongXiangConveyorDeviceDriver.getMove() == 0) { + notCreateInstMessage = "就绪任务未创建指令原因->取货位-烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code() + "光电无货,无法生成指令!"; + return false; + } + } + + if (nextdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { + hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextdevice.getDeviceDriver(); + if (hongXiangConveyorDeviceDriver.getMode() == 0 || hongXiangConveyorDeviceDriver.getMove() == 1) { + notCreateInstMessage = "就绪任务未创建指令原因->放货位-烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code() + "光电有货,无法生成指令!"; + return false; + } + } +// if (nextdevice.getDeviceDriver() instanceof PhotoelectricInspectionSiteDeviceDriver) { +// photoelectricInspectionSiteDeviceDriver = (PhotoelectricInspectionSiteDeviceDriver) nextdevice.getDeviceDriver(); +// if (photoelectricInspectionSiteDeviceDriver.getMove() != 0) { +// notCreateInstMessage = "就绪任务未创建指令原因->放货位-烘箱对接位:" + photoelectricInspectionSiteDeviceDriver.getDevice_code() + "光电有货,无法生成指令!"; +// return false; +// } +// } + if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver(); + if (standardInspectSiteDeviceDriver.getMove() != 0) { + notCreateInstMessage = "就绪任务未创建指令原因->放货位-烘箱对接位:" + standardInspectSiteDeviceDriver.getDevicecode() + "光电有货,无法生成指令!"; + return false; + } + } + 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("0"); + 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("1"); + 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("设备:" + 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("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"); + } + String start_addr = startDevice.getExtraValue().get("address").toString(); + String next_addr = nextDevice.getExtraValue().get("address").toString(); + logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" + + instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code() + + ",指令终点:" + instdto.getNext_device_code()); + this.writing("to_onset", start_addr); + this.writing("to_target", next_addr); + this.writing("to_task", instdto.getInstruction_code()); + this.writing("to_command", "1"); + //HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; + if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { + hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver(); + hongXiangConveyorDeviceDriver.writing("to_open_door", "1"); + hongXiangConveyorDeviceDriver.writing("to_open_door", "1"); + } + if (startDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { + hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startDevice.getDeviceDriver(); + hongXiangConveyorDeviceDriver.writing("to_open_door", "1"); + hongXiangConveyorDeviceDriver.writing("to_open_door", "1"); + } + this.setNow_steps_type(2); + this.setRequireSucess(true); + notCreateInstMessage = ""; + notCreateTaskMessage = ""; + } else { + notCreateInstMessage = "未找到关联设备的任务,指令无法创建"; + } + return true; + } + } + + //判断取货位或放货位为烘箱设备时关联的同一列烘箱设备是否有开门 + 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("设备号:" + 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("设备:" + start_device_code + "关联设备->" + deviceCode + "为空!"); + } + if (linkDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { + hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) linkDevice.getDeviceDriver(); + //判断关联设备是否开门 + if (hongXiangConveyorDeviceDriver.getDoor() == 1) { + isClose = true; + notCreateInstMessage = start_device_code + "关联设备->" + deviceCode + "烘箱门未关闭!"; + break; + } + } + } + return isClose; + } + } + if (ObjectUtil.isEmpty(nextDevice)) { + throw new BadRequestException("设备号:" + next_device_code + "不存在!"); + } + if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { + hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.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("设备:" + next_device_code + "关联设备->" + deviceCode + "为空!"); + } + if (linkDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { + hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) linkDevice.getDeviceDriver(); + //判断关联设备是否开门 + if (hongXiangConveyorDeviceDriver.getDoor() == 1) { + isClose = true; + notCreateInstMessage = next_device_code + "关联设备->" + deviceCode + "烘箱门未关闭!"; + break; + } + } + } + return isClose; + } + } + } catch (Exception e) { + isClose = true; + logServer.deviceExecuteLog(this.getDevice_code(), "", "", "检查烘箱是否关门时出现异常:" + e.getMessage()); + notCreateInstMessage = "检查烘箱是否关门时出现异常:" + e.getMessage(); + } + return isClose; + } + + + public synchronized void update_instruction_status() throws Exception { + 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) { + //inst_message + Instruction inst1 = checkInst(); + if (inst1 != null) { + if (StrUtil.equals(inst1.getInstruction_status(), "0")) { + inst1.setInstruction_status("1"); + inst1.setExecute_device_code(this.device_code); + instructionService.update(inst1); + } + } + } + + //申请取货 + if (mode == 3 && action == 1 && move == 0 && task > 0) { + Instruction inst2 = checkInst(); + 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", "1"); + int mode = hongXiangConveyorDeviceDriver.getMode(); + int door = hongXiangConveyorDeviceDriver.getDoor(); + int action = hongXiangConveyorDeviceDriver.getAction(); + int error1 = hongXiangConveyorDeviceDriver.getError1(); + int move = hongXiangConveyorDeviceDriver.getMove(); + if (mode == 1 && door == 1 && action == 1 && error1 == 0 && move == 1) { + 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 (move != 1) { + feedMessage = feedMessage + "取货位光电信号(move)不应该为无货状态,"; + } + if (error1 != 0) { + feedMessage = feedMessage + "故障(error1)信号出现故障,故障值:" + 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 = checkInst(); + 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", "1"); + } + 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 = checkInst(); + String next_device_code = instructionDto.getNext_device_code(); + Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); + HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; + StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; + if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { + hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver(); + //hongXiangConveyorDeviceDriver.writing("to_open_door", "1"); + int mode = hongXiangConveyorDeviceDriver.getMode(); + int door = hongXiangConveyorDeviceDriver.getDoor(); + int action = hongXiangConveyorDeviceDriver.getAction(); + int error1 = hongXiangConveyorDeviceDriver.getError1(); + int move = hongXiangConveyorDeviceDriver.getMove(); + if (mode == 1 && door == 1 && action == 1 && error1 == 0 && move == 0) { + if (this.getNow_steps_type() == 4) { + this.writing("to_command", "4"); + this.setNow_steps_type(5); + } else { + feedMessage = "未反馈电气信号原因:当前步骤不为允许放货(now_steps_type!=4)"; + //logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为允许放货(now_steps_type!=4)"); + } + } else { + if (this.getNow_steps_type() == 4) { + feedMessage = "烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code(); + if (mode != 1) { + feedMessage = feedMessage + "工作模式(mode)信号未联机,"; + } + if (door != 1) { + feedMessage = feedMessage + "门状态(door)信号未开门,"; + } + if (action != 1) { + feedMessage = feedMessage + "允许取放(action)信号未允许取放,"; + } + if (move != 0) { + feedMessage = feedMessage + "放货位光电信号不应该为有货状态"; + } + 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 = checkInst(); + if (inst2 != null) { + if (StrUtil.equals(inst2.getInstruction_status(), "1")) { + + TaskDto taskDto = taskserver.findByCode(inst2.getTask_code()); + + String next_device_code = inst2.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; + StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; + LampThreecolorDeviceDriver lampThreecolorDeviceDriver; +// if (startDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { +// hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startDevice.getDeviceDriver(); +// hongXiangConveyorDeviceDriver.writing("to_close_door", "1"); +// } + if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { + hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver(); + hongXiangConveyorDeviceDriver.writing("to_close_door", "1"); + 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 (nextDevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextDevice.getDeviceDriver(); +// hongXiangConveyorDeviceDriver.writing("to_close_door", "1"); + + if (!StrUtil.startWith(taskDto.getTask_code(), "-")) { + if (ObjectUtil.isNotEmpty(nextDevice.getExtraValue().get("link_three_lamp"))) { + String lamp = nextDevice.getExtraValue().get("link_three_lamp").toString(); + Device lampDevice = deviceAppService.findDeviceByCode(lamp); + if (ObjectUtil.isEmpty(lampDevice)) { + return; + } + if (lampDevice.getDeviceDriver() instanceof LampThreecolorDeviceDriver) { + lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) lampDevice.getDeviceDriver(); + logServer.deviceExecuteLog(lampDevice.getDeviceDriver().getDeviceCode(), "", "", "下发报警灯" + lamp + "报警信号"); + lampThreecolorDeviceDriver.writing("to_command", "1"); + } + } + } + + } + this.writing("to_command", "5"); + this.setNow_steps_type(6); + this.setNow_steps_type(0); + try { + finish_instruction(inst2); + } catch (Exception e) { + e.printStackTrace(); + } + feedMessage = ""; + } + } + } 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。"; + } + } + } + } + } + + public synchronized boolean finish_instruction(Instruction inst) throws Exception { + instructionService.finish(inst); + return true; + } + + @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; + } + } + + 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; + + Map itemMap = new HashMap(); + + itemMap.put(to_param, Integer.parseInt(value)); + this.control(itemMap); + logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value); + } + + @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/plug_pull_device_site/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/ItemProtocol.java similarity index 98% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/plug_pull_device_site/ItemProtocol.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/ItemProtocol.java index c7bb09f..09015c4 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/plug_pull_device_site/ItemProtocol.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/ItemProtocol.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.conveyor.plug_pull_device_site; +package org.nl.acs.device_driver.two_conveyor.plug_pull_device_site; import lombok.Data; import lombok.extern.slf4j.Slf4j; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/plug_pull_device_site/PlugPullDeviceSiteDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/PlugPullDeviceSiteDefination.java similarity index 95% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/plug_pull_device_site/PlugPullDeviceSiteDefination.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/PlugPullDeviceSiteDefination.java index f2dbcd4..d04b519 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/plug_pull_device_site/PlugPullDeviceSiteDefination.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/PlugPullDeviceSiteDefination.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.conveyor.plug_pull_device_site; +package org.nl.acs.device_driver.two_conveyor.plug_pull_device_site; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; import org.nl.acs.device.domain.Device; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/plug_pull_device_site/PlugPullDeviceSiteDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/PlugPullDeviceSiteDeviceDriver.java similarity index 99% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/plug_pull_device_site/PlugPullDeviceSiteDeviceDriver.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/PlugPullDeviceSiteDeviceDriver.java index 33659db..04ccab4 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/plug_pull_device_site/PlugPullDeviceSiteDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/PlugPullDeviceSiteDeviceDriver.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.conveyor.plug_pull_device_site; +package org.nl.acs.device_driver.two_conveyor.plug_pull_device_site; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; @@ -237,6 +237,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl } + if (mode == 0) { this.setIsonline(false); message = "未联机"; @@ -289,7 +290,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl break; case 8: if (!requireSucess && task > 0) { - //缓存线已满,生成行架任务 + //缓存线已满,申请行架任务 // applyTask(); } break; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/pull_head_manipulator/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/ItemProtocol.java similarity index 98% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/pull_head_manipulator/ItemProtocol.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/ItemProtocol.java index 1655c0b..207c653 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/pull_head_manipulator/ItemProtocol.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/ItemProtocol.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.pull_head_manipulator; +package org.nl.acs.device_driver.two_conveyor.pull_head_manipulator; import cn.hutool.core.util.StrUtil; import lombok.Data; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/pull_head_manipulator/PullHeadManipulatorDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/PullHeadManipulatorDefination.java similarity index 95% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/pull_head_manipulator/PullHeadManipulatorDefination.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/PullHeadManipulatorDefination.java index 2727537..aad3c1d 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/pull_head_manipulator/PullHeadManipulatorDefination.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/PullHeadManipulatorDefination.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.pull_head_manipulator; +package org.nl.acs.device_driver.two_conveyor.pull_head_manipulator; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; import org.nl.acs.device.domain.Device; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/pull_head_manipulator/PullHeadManipulatorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/PullHeadManipulatorDeviceDriver.java similarity index 99% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/pull_head_manipulator/PullHeadManipulatorDeviceDriver.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/PullHeadManipulatorDeviceDriver.java index 7a8210a..9a5f489 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/pull_head_manipulator/PullHeadManipulatorDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/PullHeadManipulatorDeviceDriver.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.pull_head_manipulator; +package org.nl.acs.device_driver.two_conveyor.pull_head_manipulator; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; @@ -17,6 +17,7 @@ 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.two_conveyor.pull_head_manipulator.ItemProtocol; import org.nl.acs.history.ErrorUtil; import org.nl.acs.history.service.DeviceErrorLogService; import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/pull_tail_manipulator/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_tail_manipulator/ItemProtocol.java similarity index 98% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/pull_tail_manipulator/ItemProtocol.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_tail_manipulator/ItemProtocol.java index 8dbb9b6..fcd35a5 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/pull_tail_manipulator/ItemProtocol.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_tail_manipulator/ItemProtocol.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.pull_tail_manipulator; +package org.nl.acs.device_driver.two_conveyor.pull_tail_manipulator; import cn.hutool.core.util.StrUtil; import lombok.Data; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/pull_tail_manipulator/PullTailManipulatorDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_tail_manipulator/PullTailManipulatorDefination.java similarity index 95% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/pull_tail_manipulator/PullTailManipulatorDefination.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_tail_manipulator/PullTailManipulatorDefination.java index bf39685..936d8a5 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/pull_tail_manipulator/PullTailManipulatorDefination.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_tail_manipulator/PullTailManipulatorDefination.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.pull_tail_manipulator; +package org.nl.acs.device_driver.two_conveyor.pull_tail_manipulator; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; import org.nl.acs.device.domain.Device; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/pull_tail_manipulator/PullTailManipulatorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_tail_manipulator/PullTailManipulatorDeviceDriver.java similarity index 95% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/pull_tail_manipulator/PullTailManipulatorDeviceDriver.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_tail_manipulator/PullTailManipulatorDeviceDriver.java index 04da92b..090099c 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/pull_tail_manipulator/PullTailManipulatorDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_tail_manipulator/PullTailManipulatorDeviceDriver.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.pull_tail_manipulator; +package org.nl.acs.device_driver.two_conveyor.pull_tail_manipulator; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; @@ -243,13 +243,14 @@ public class PullTailManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp } //反馈重量 - if (mode == 3 && action == 5 && move == 0 && task > 0) { + if (mode == 3 && action == 5 && move == 0 && task > 0 && !requireSucess) { Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task)); if (ObjectUtil.isNotEmpty(inst2)) { Map map = new LinkedHashMap<>(); //todo:反馈重量 map.put("to_command", "5"); this.writing(map); + this.requireSucess = true; } else { logServer.deviceExecuteLog(this.device_code, "", "", "未反馈电气信号原因:当前步骤不为允许取货(now_steps_type!=3)"); } @@ -270,7 +271,7 @@ public class PullTailManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp } //任务完成 - if (mode == 3 && action == 6 && move == 0 && task > 0) { + if (mode == 3 && action == 6 && move == 0 && task > 0 && !requireSucess) { Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task)); if (inst2 != null) { if (StrUtil.equals(inst2.getInstruction_status(), InstructionStatusEnum.BUSY.getIndex())) { @@ -279,6 +280,7 @@ public class PullTailManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp Map map = new LinkedHashMap<>(); map.put("to_command", "6"); this.writing(map); + this.requireSucess = true; } catch (Exception e) { e.printStackTrace(); } @@ -338,6 +340,32 @@ public class PullTailManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp this.setNotCreateTaskMessage(remark); //} } + + switch (action) { + case 1: + //取货中 + break; + case 2: + //取货完成 + /*if (move > 0 && !requireSucess) { + instruction_require(); + }*/ + break; + case 3: + //放货中 + break; + case 4: + //放货完成 + if (move == 1 && !requireSucess && task > 0) { + //申请套管校验 +// apply_for_casing_inspection(material1, material2); +// bushingSucess(); + } + break; + default: + log.info("未知模式"); + break; + } } } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/slit_two_manipulator/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/ItemProtocol.java similarity index 98% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/slit_two_manipulator/ItemProtocol.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/ItemProtocol.java index 466ac81..44a78f0 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/slit_two_manipulator/ItemProtocol.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/ItemProtocol.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.conveyor.slit_two_manipulator; +package org.nl.acs.device_driver.two_conveyor.slit_two_manipulator; import cn.hutool.core.util.StrUtil; import lombok.Data; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/slit_two_manipulator/SlitTwoManipulatorDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/SlitTwoManipulatorDefination.java similarity index 95% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/slit_two_manipulator/SlitTwoManipulatorDefination.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/SlitTwoManipulatorDefination.java index cea7504..e61a92d 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/slit_two_manipulator/SlitTwoManipulatorDefination.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/SlitTwoManipulatorDefination.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.conveyor.slit_two_manipulator; +package org.nl.acs.device_driver.two_conveyor.slit_two_manipulator; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; import org.nl.acs.device.domain.Device; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java similarity index 67% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java index 1a362bc..acc05e9 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java @@ -1,10 +1,9 @@ -package org.nl.acs.device_driver.conveyor.slit_two_manipulator; +package org.nl.acs.device_driver.two_conveyor.slit_two_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.JSONArray; import com.alibaba.fastjson.JSONObject; import lombok.Data; import lombok.RequiredArgsConstructor; @@ -14,7 +13,6 @@ 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.siemens_conveyor.SiemensConveyorDeviceDriver; import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; import org.nl.acs.ext.wms.service.AcsToWmsService; @@ -62,7 +60,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl //分切行架机械手是否禁用 0否 1是 private int is_disable = 0; - /** + /** * 工作模式 */ int mode = 0; @@ -80,7 +78,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl int last_action1 = 0; int action2 = 0; int last_action2 = 0; - /** + /** * 报警 */ int error = 0; @@ -107,6 +105,8 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl int hasGoods = 0; String message = null; Boolean iserror = false; + private Date instruction_update_time = new Date(); + private int instruction_update_time_out = 500; int branchProtocol = 0; @@ -213,467 +213,8 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl logServer.deviceExecuteLog(this.device_code, "", "", "信号task2:" + last_task2 + "->" + task2); } - //单任务 前工位任务更新指令状态 - if (task1 > 0 && type == 1) { - Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); - if (inst1 != null) { - if (StrUtil.equals(inst1.getInstruction_status(), InstructionStatusEnum.READY.getIndex())) { - //当前执行步骤为更新任务状态 - inst1.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); - inst1.setExecute_device_code(this.getDevice_code()); - instructionService.update(inst1); -// TaskDto taskDto = taskserver.findByCodeFromCache(inst1.getTask_code()); -// if (!ObjectUtil.isEmpty(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); -// } -// } - ; - //this.setNow_steps_type1(1); - } - } - } - - //单任务 后工位任务更新指令状态 - if (task2 > 0 && type == 2) { - //inst_message - Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task2)); - if (inst2 != null) { - if (StrUtil.equals(inst2.getInstruction_status(), InstructionStatusEnum.READY.getIndex())) { - //指令更新状态 - now_steps_type2 = 1; - inst2.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); - inst2.setExecute_device_code(this.device_code); - instructionService.update(inst2); -// TaskDto taskDto = taskserver.findByCodeFromCache(inst2.getTask_code()); -// if (!ObjectUtil.isEmpty(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); -// } -// } - ; - // this.setNow_steps_type2(1); - } - } - } - - //双任务更新指令状态 - if (task2 > 0 && task1 > 0 && type == 3) { - //inst_message - Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task1)); - if (inst2 != null) { - if (StrUtil.equals(inst2.getInstruction_status(), InstructionStatusEnum.READY.getIndex())) { - //指令更新状态 - inst2.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); - inst2.setExecute_device_code(this.device_code); - instructionService.update(inst2); -// TaskDto taskDto = taskserver.findByCodeFromCache(inst2.getTask_code()); -// if (!ObjectUtil.isEmpty(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 && action2 == 1 && move2 == 0 && task2 > 0) { - Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task2)); - String start_device_code = inst1.getStart_device_code(); - Device startDevice = deviceAppservice.findDeviceByCode(start_device_code); - if (ObjectUtil.isEmpty(startDevice)) { - feedMessage = "后工位取货位:" + start_device_code + "为空!"; - logServer.deviceExecuteLog(this.getDeviceCode(), "", "", "后工位取货位:" + start_device_code + "为空!"); - throw new BadRequestException("后工位取货位:" + start_device_code + "为空!"); - } - SiemensConveyorDeviceDriver siemensConveyorDeviceDriver; - if (startDevice.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { - siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) startDevice.getDeviceDriver(); - int move = siemensConveyorDeviceDriver.getMove(); - int mode = siemensConveyorDeviceDriver.getMode(); - if (mode == 2 && move == 1) { - this.writing("to_command2", "2"); - if (type == 2) { - this.setNow_steps_type2(3); - } else if (type == 3) { - this.setNow_steps_type3(3); - } - } else { - log.warn("后工位取货位无货,取货位:{},mode:{},move:{}", start_device_code, mode, move); - if (this.getNow_steps_type2() == 2 || this.getNow_steps_type3() == 2) { - feedMessage = "后工位未取货原因-->"; - if (mode != 2) { - feedMessage += "后工位取货位工作模式不为待机(mode != 2),"; - } else if (move != 1) { - feedMessage += "后工位取货位无货(move != 1)"; - } - } - } - } - } else { - if (this.getNow_steps_type2() == 2 || this.getNow_steps_type3() == 2) { - feedMessage = "后工位未取货原因-->"; - if (mode != 3) { - feedMessage += "行架工作模式不为运行中(mode != 3),"; - } - if (action2 != 1) { - feedMessage += "后工位动作信号不为取货中(action2 != 1),"; - } - if (move2 != 0) { - feedMessage += "后工位光电信号不为空(move2 != 0),"; - } - if (task2 == 0) { - feedMessage += "后工位没有任务(task2 == 0)"; - } - } - } - - //单任务/或双任务 后工位收到取货完成信号并反馈 - if (mode == 3 && action2 == 2 && move2 == 1 && task2 > 0) { - this.writing("to_command2", "3"); - if (type == 2) { - this.setNow_steps_type2(4); - } - if (type == 3) { - this.setNow_steps_type3(4); - } - } else { - if (this.getNow_steps_type2() == 3 || this.getNow_steps_type3() == 3) { - feedMessage = "后工位取货完成后未反馈原因-->"; - if (mode != 3) { - feedMessage += "行架工作模式不为运行中(mode != 3),"; - } - if (action2 != 2) { - feedMessage += "后工位未取货完成(action2 != 2),"; - } - if (move2 == 0) { - feedMessage += "后工位光电信号为空(move2 == 0),"; - } - if (task2 == 0) { - feedMessage += "后工位没有任务(task2 == 0)"; - } - } - } - - //单任务/双任务 前工位取货时判断动作信号并反馈 - if (mode == 3 && action1 == 1 && move1 == 0 && task1 > 0) { - this.writing("to_command1", "2"); - if (type == 1) { - this.setNow_steps_type1(3); - } else if (type == 3) { - this.setNow_steps_type3(5); - } - } else { - if (this.getNow_steps_type1() == 2 || this.getNow_steps_type3() == 4) { - feedMessage = "前工位未取货原因"; - if (mode != 3) { - feedMessage += "行架工作模式不为运行中(mode != 3),"; - } - if (action1 != 1) { - feedMessage += "前工位动作信号不为取货中(action2 != 1),"; - } - if (move1 != 0) { - feedMessage += "前工位光电信号不为空(move2 != 0),"; - } - if (task1 == 0) { - feedMessage += "前工位没有任务(task2 == 0)"; - } - } - } - - //单任务/双任务 前工位取货完成并反馈 - if (mode == 3 && action1 == 2 && move1 == 1 && task1 > 0) { - this.writing("to_command1", "3"); - if (type == 1) { - this.setNow_steps_type1(4); - } - if (type == 3) { - this.setNow_steps_type3(6); - } - } else { - if (this.getNow_steps_type1() == 3 || this.getNow_steps_type3() == 5) { - feedMessage = "前工位取货完成后未反馈原因"; - if (mode != 3) { - feedMessage += "行架工作模式不为运行中(mode != 3),"; - } - if (action1 != 2) { - feedMessage += "前工位未取货完成(action2 != 2),"; - } - if (move1 == 0) { - feedMessage += "前工位光电信号为空(move2 == 0),"; - } - if (task1 == 0) { - feedMessage += "前工位没有任务(task2 == 0)"; - } - } - } - - - //单任务/双任务 后工位放货时判断信号并反馈 - if (mode == 3 && action2 == 3 && move2 == 1 && task2 > 0) { - this.writing("to_command2", "4"); - if (type == 2) { - this.setNow_steps_type2(5); - } else if (type == 3) { - this.setNow_steps_type3(7); - } - } else { - if (this.getNow_steps_type2() == 4 || this.getNow_steps_type3() == 6) { - feedMessage = "后工位未放货原因-->"; - if (mode != 3) { - feedMessage += "行架工作模式不为运行中(mode != 3),"; - } - if (action2 != 3) { - feedMessage += "后工位动作信号不为放货中(action2 != 3),"; - } - if (move2 == 0) { - feedMessage += "后工位光电信号为空(move2 == 0),"; - } - if (task2 == 0) { - feedMessage += "后工位没有任务(task2 == 0)"; - } - } - } - - //单任务 后工位放货完成 任务完成 - if (mode == 3 && action2 == 4 && move2 == 0 && task2 > 0 && type == 2) { - //inst_message - Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task2)); - if (inst2 != null) { - if (StrUtil.equals(inst2.getInstruction_status(), InstructionStatusEnum.BUSY.getIndex())) { - finish_instruction(inst2); - TaskDto taskDto = taskserver.findByCodeFromCache(inst2.getTask_code()); - if (!ObjectUtil.isEmpty(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", "2"); - array.add(map); - acsToWmsService.feedbackTaskStatusToWms(array); - } - } - ; - this.writing("to_command2", "5"); - this.setNow_steps_type2(6); - this.setNow_steps_type2(0); - } - } - } else { - if (this.getNow_steps_type2() == 5) { - feedMessage = "单任务后工位放货完成后未反馈原因-->"; - if (mode != 3) { - feedMessage += "行架工作模式不为运行中(mode != 3),"; - } - if (action2 != 4) { - feedMessage += "后工位未放货完成(action2 != 4),"; - } - if (move2 != 0) { - feedMessage += "后工位光电信号为有货(move2 != 0),"; - } - if (task2 == 0) { - feedMessage += "后工位没有任务(task2 == 0),"; - } - if (type != 2) { - feedMessage += "不是后工位单任务(type != 2)"; - } - } - } - - //双任务 后工位反馈任务完成 并反馈 - if (mode == 3 && action2 == 4 && move2 == 0 && task1 > 0 && task2 > 0 && type == 3) { - this.writing("to_command2", "5"); - this.setNow_steps_type3(8); - } else { - if (this.getNow_steps_type3() == 7) { - feedMessage = "双任务后工位放货完成后未反馈原因-->"; - if (mode != 3) { - feedMessage += "行架工作模式不为运行中(mode != 3),"; - } - if (action2 != 4) { - feedMessage += "后工位未放货完成(action2 != 4),"; - } - if (move2 != 0) { - feedMessage += "后工位光电信号为有货(move2 != 0),"; - } - if (task1 == 0) { - feedMessage += "前工位没有任务(task1 == 0),"; - } - if (task2 == 0) { - feedMessage += "后工位没有任务(task2 == 0),"; - } - if (type != 3) { - feedMessage += "不是双任务(type != 3)"; - } - } - } - - //单任务/双任务 前工位放货时判断放货位光电信号 - if (mode == 3 && action1 == 3 && move1 == 1 && task1 > 0) { - Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); - String next_device_code = ""; - if (type == 1) { - next_device_code = inst1.getNext_device_code(); - } else if (type == 3) { - next_device_code = inst1.getNext_device_code2(); - } - Device nextDevice = deviceAppservice.findDeviceByCode(next_device_code); - if (ObjectUtil.isEmpty(nextDevice)) { - feedMessage = "前工位放货位:" + next_device_code + "为空!"; - throw new BadRequestException("前工位放货位:" + next_device_code + "为空!"); - } - SiemensConveyorDeviceDriver siemensConveyorDeviceDriver; - if (nextDevice.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { - siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) nextDevice.getDeviceDriver(); - int move = siemensConveyorDeviceDriver.getMove(); - int mode = siemensConveyorDeviceDriver.getMode(); - if (move == 1 && mode == 2) { - this.writing("to_command1", "4"); - if (type == 1) { - this.setNow_steps_type1(5); - } else if (type == 3) { - this.setNow_steps_type3(9); - } - } else { - log.warn("后工位放货位有货,放货位:{},mode:{},move:{}", next_device_code, mode, move); - if (this.getNow_steps_type1() == 4 || this.getNow_steps_type3() == 8) { - feedMessage = "前工位未放货原因-->"; - if (mode != 2) { - feedMessage += "前工位放货位工作模式不为待机(mode != 2),"; - } else if (move == 0) { - feedMessage += "前工位放货位无货(move == 0)"; - } - } - } - } - } else { - if (this.getNow_steps_type1() == 4 || this.getNow_steps_type3() == 8) { - feedMessage = "前工位未放货原因-->"; - if (mode != 3) { - feedMessage += "行架工作模式不为运行中(mode != 3),"; - } - if (action1 != 3) { - feedMessage += "前工位动作信号不为放货中(action1 != 3),"; - } - if (move1 == 0) { - feedMessage += "前工位光电信号为空(move1 == 0),"; - } - if (task1 == 0) { - feedMessage += "前工位没有任务(task1 == 0),"; - } - } - } - - - //单任务前工位放货完成 任务完成 - if (mode == 3 && action1 == 4 && move1 == 0 && task1 > 0 && type == 1) { - //inst_message - Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); - if (inst1 != null) { - if (StrUtil.equals(inst1.getInstruction_status(), InstructionStatusEnum.BUSY.getIndex())) { - this.finish_instruction(inst1); - TaskDto taskDto = taskserver.findByCodeFromCache(inst1.getTask_code()); - if (!ObjectUtil.isEmpty(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", "2"); - array.add(map); - acsToWmsService.feedbackTaskStatusToWms(array); - } - } - ; - this.writing("to_command1", "5"); - this.setNow_steps_type1(6); - this.setNow_steps_type1(0); - } - } - } else { - if (this.getNow_steps_type1() == 5) { - feedMessage = "单任务前工位放货完成后未反馈原因-->"; - if (mode != 3) { - feedMessage += "行架工作模式不为运行中(mode != 3),"; - } - if (action1 != 4) { - feedMessage += "前工位未放货完成(action1 != 4),"; - } - if (move1 != 0) { - feedMessage += "前工位光电信号为有货(move1 != 0),"; - } - if (task1 == 0) { - feedMessage += "前工位没有任务(task1 == 0),"; - } - if (type != 1) { - feedMessage += "不为前工位单任务(type != 1)"; - } - } - } - - - //双工位 任务完成 前工位反馈4 - if (mode == 3 && action1 == 4 && move1 == 0 && task1 > 0 && task2 > 0 && type == 3) { - //inst_message - Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); - if (inst1 != null) { - if (StrUtil.equals(inst1.getInstruction_status(), InstructionStatusEnum.BUSY.getIndex())) { - this.finish_instruction(inst1); - TaskDto taskDto = taskserver.findByCodeFromCache(inst1.getTask_code()); - if (!ObjectUtil.isEmpty(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", "2"); - array.add(map); - acsToWmsService.feedbackTaskStatusToWms(array); - } - } - ; - this.writing("to_command1", "5"); - this.setNow_steps_type3(10); - this.setNow_steps_type3(0); - } - } - } else { - if (this.getNow_steps_type3() == 9) { - feedMessage = "双任务前工位放货完成后未反馈原因-->"; - if (mode != 3) { - feedMessage += "行架工作模式不为运行中(mode != 3),"; - } - if (action1 != 4) { - feedMessage += "前工位未放货完成(action1 != 4),"; - } - if (move1 != 0) { - feedMessage += "前工位光电信号为有货(move1 != 0),"; - } - if (task1 == 0) { - feedMessage += "前工位没有任务(task1 == 0),"; - } - if (task2 == 0) { - feedMessage += "后工位没有任务(task2 == 0),"; - } - if (type != 3) { - feedMessage += "不是双任务(type != 3)"; - } - } + if (task1 > 0 && task2 > 0 && !requireSucess) { + update_instruction_status1(); } @@ -706,7 +247,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl return; case 2: //申请任务 - if (mode == 2 && move1 == 0 && move2 == 0 && action1 == 0 && action2 == 0 && task1 == 0 && task2 == 0 && !requireSucess) { + if (move1 == 0 && move2 == 0 && action1 == 0 && action2 == 0 && task1 == 0 && task2 == 0 && !requireSucess) { //获取关联设备驱动信息 判断关联设备是否禁用 String link_device_code = String.valueOf(this.getDevice().getExtraValue().get("link_device_code")); Device device = deviceAppservice.findDeviceByCode(link_device_code); @@ -728,11 +269,13 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl } } //没有生成异常取放货工位的任务 就生成正常关联取放货工位的任务 - instruction_require(); - feedMessage = ""; - notCreateInstMessage = ""; - notCreateTaskMessage = ""; - logServer.deviceExecuteLog(device_code, "", String.valueOf(task1), "move2:" + move2 + ",action2:" + action2 + ",move1:" + move1 + ",action1:" + action1 + ",requireSucess:" + requireSucess); + boolean res = applyTask(); + if (res) { + feedMessage = ""; + notCreateInstMessage = ""; + notCreateTaskMessage = ""; + logServer.deviceExecuteLog(device_code, "", String.valueOf(task1), "move2:" + move2 + ",action2:" + action2 + ",move1:" + move1 + ",action1:" + action1 + ",requireSucess:" + requireSucess); + } } else { // if (!requireSucess) { // remark = remark + "请求标记为true,请检查mode是否由其他值变为2!"; @@ -784,6 +327,36 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl last_task2 = task2; } + + /** + * 更新分切机下双卷指令状态 + */ + public synchronized void update_instruction_status1() throws Exception { + 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 (task1 > 0 && type == 1) { + Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); + if (inst1 != null) { + if (StrUtil.equals(inst1.getInstruction_status(), "0")) { + //当前执行步骤为更新任务状态 + inst1.setInstruction_status("1"); + inst1.setExecute_device_code(this.getDevice_code()); + instructionService.update(inst1); + } + } + } + +// if (mode = 3 && move1 = 0 && move2 = 0 && action1 = 5 && action2 = 5) { +// +// } + } + } + //关联设备异常申请任务 public synchronized boolean instruction_require2() { Boolean flag = false; @@ -858,7 +431,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl } //正常申请任务 - public synchronized boolean instruction_require() { + public synchronized boolean applyTask() { boolean flag = false; Date date = new Date(); if (date.getTime() - this.instruction_head_time.getTime() < (long) this.instruction_require_time_out) { @@ -880,6 +453,18 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl //按照优先级排序 优先级相等按照创建时间排序 taskDtos = this.sortTask(taskDtos); taskDto = taskDtos.get(0); + //分切机出双卷任务 + if (StrUtil.equals(taskDto.getTruss_type(), "1")) { + inst_require1(taskDto, getDeviceCodeList, backGetDeviceCodeList); + } + //分切机出上卷-行架取单轴 + else if (StrUtil.equals(taskDto.getTruss_type(), "2")) { +// inst_require2(taskDto, getDeviceCodeList, backGetDeviceCodeList); + } + //分切机出下卷-行架取单轴 + else if (StrUtil.equals(taskDto.getTruss_type(), "3")) { +// inst_require3(taskDto, getDeviceCodeList, backGetDeviceCodeList); + } flag = this.executeBusiness(taskDto, getDeviceCodeList, backGetDeviceCodeList); return flag; } else { @@ -932,6 +517,75 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl return flag; } + //执行重新生成分切机出双卷的任务 + public synchronized boolean inst_require1(TaskDto taskDto, List getDeviceCodeList, List backGetDeviceCodeList) { + boolean flag = false; + //获取指令信息 + Instruction instructionDto = instructionService.findByTaskcodeAndStatus(taskDto.getTask_code()); + //获取指令表中的取货点1 + String start_device_code = instructionDto.getStart_device_code(); + //获取指令表中的取货点2 + String start_device_code2 = instructionDto.getStart_device_code2(); + //获取指令表中的放货点1 + String next_device_code = instructionDto.getNext_device_code(); + //获取指令表中的放货点2 + String next_device_code2 = instructionDto.getNext_device_code2(); + //判断任务点位是否配置电气信号 + Device startDevice = deviceAppservice.findDeviceByCode(start_device_code); + Device startDevice2 = deviceAppservice.findDeviceByCode(start_device_code2); + Device nextDevice = deviceAppservice.findDeviceByCode(next_device_code); + Device nextDevice2 = deviceAppservice.findDeviceByCode(next_device_code2); + this.isSetAddress(startDevice); + this.isSetAddress(nextDevice); + this.isSetAddress(startDevice2); + this.isSetAddress(nextDevice2); + + //修改指令状态 + instructionDto.setInstruction_status(InstructionStatusEnum.BUSY.getIndex()); + instructionDto.setUpdate_time(DateUtil.now()); + instructionService.update(instructionDto); + flag = true; + //下发电气信号 + this.sendSignal(instructionDto, taskDto); + //请求任务成功 + requireSucess = true; + return flag; + } + + //下发电气信号 + public synchronized void sendSignal(Instruction dto, TaskDto taskDto) { + logServer.deviceExecuteLog(this.getDeviceCode(), "", "", "开始下发电气信号,即下发电气指令信息为:" + + dto.toString()); + String start_device_code = dto.getStart_device_code(); + String next_device_code = dto.getNext_device_code(); + Device startDevice = deviceAppservice.findDeviceByCode(start_device_code); + Device nextDevice = deviceAppservice.findDeviceByCode(next_device_code); + String start_addr = startDevice.getExtraValue().get("address").toString(); + String next_addr = nextDevice.getExtraValue().get("address").toString(); + + String start_device_code2 = dto.getStart_device_code2(); + String next_device_code2 = dto.getNext_device_code2(); + Device startDevice2 = deviceAppservice.findDeviceByCode(start_device_code2); + Device nextDevice2 = deviceAppservice.findDeviceByCode(next_device_code2); + String start_addr2 = startDevice2.getExtraValue().get("address").toString(); + String next_addr2 = nextDevice2.getExtraValue().get("address").toString(); + + Map map = new LinkedHashMap<>(); + map.put("to_onset1", start_addr2); + map.put("to_target1", next_addr2); + map.put("to_task1", dto.getInstruction_code()); + map.put("to_onset2", start_addr); + map.put("to_target2", next_addr); + map.put("to_task2", dto.getInstruction_code()); + map.put("to_type", taskDto.getTruss_type()); + map.put("to_command1", CommonFinalParam.ONE); + map.put("to_command2", CommonFinalParam.ONE); + this.writing(map); + logServer.deviceExecuteLog(device_code, "", "", dto.getInstruction_code() + "下发分切机出双卷任务"); + this.setNow_steps_type3(2); + } + + //执行重新生成指令的任务 public synchronized boolean executeBusiness(TaskDto taskDto, List getDeviceCodeList, List backGetDeviceCodeList) { boolean flag = false; @@ -1563,4 +1217,32 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl this.requireSucess = true; } } + + /** + * 抽取统一下发电气信号前缀 + * + * @return + */ + public String getToParam() { + return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "."; + } + + /** + * 多个信号一起下发电气 + * + * @param map + */ + public void writing(Map map) { + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + Map itemMap = new LinkedHashMap<>(); + map.forEach((key, value) -> { + if (ObjectUtil.isNotEmpty(value)) { + itemMap.put(getToParam() + key, value); + } + }); + if (ObjectUtil.isNotEmpty(itemMap)) { + this.control(itemMap); + logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap); + } + } } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/subvolume_weighing_station/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/subvolume_weighing_station/ItemProtocol.java similarity index 97% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/subvolume_weighing_station/ItemProtocol.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/subvolume_weighing_station/ItemProtocol.java index 3ecdcf1..b276ae9 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/subvolume_weighing_station/ItemProtocol.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/subvolume_weighing_station/ItemProtocol.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.subvolume_weighing_station; +package org.nl.acs.device_driver.two_conveyor.subvolume_weighing_station; import lombok.Data; import lombok.extern.slf4j.Slf4j; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/subvolume_weighing_station/SubvolumeWeighingStationDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/subvolume_weighing_station/SubvolumeWeighingStationDefination.java similarity index 95% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/subvolume_weighing_station/SubvolumeWeighingStationDefination.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/subvolume_weighing_station/SubvolumeWeighingStationDefination.java index 07d0117..4eb38d2 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/subvolume_weighing_station/SubvolumeWeighingStationDefination.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/subvolume_weighing_station/SubvolumeWeighingStationDefination.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.subvolume_weighing_station; +package org.nl.acs.device_driver.two_conveyor.subvolume_weighing_station; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; import org.nl.acs.device.domain.Device; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/subvolume_weighing_station/SubvolumeWeighingStationDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/subvolume_weighing_station/SubvolumeWeighingStationDriver.java similarity index 98% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/subvolume_weighing_station/SubvolumeWeighingStationDriver.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/subvolume_weighing_station/SubvolumeWeighingStationDriver.java index e88ff41..1ae9182 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/subvolume_weighing_station/SubvolumeWeighingStationDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/subvolume_weighing_station/SubvolumeWeighingStationDriver.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.subvolume_weighing_station; +package org.nl.acs.device_driver.two_conveyor.subvolume_weighing_station; import com.alibaba.fastjson.JSONObject; import lombok.Data; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/waste_foil_weighing_station/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/waste_foil_weighing_station/ItemProtocol.java similarity index 97% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/waste_foil_weighing_station/ItemProtocol.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/waste_foil_weighing_station/ItemProtocol.java index 8f0dda6..3a3d254 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/waste_foil_weighing_station/ItemProtocol.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/waste_foil_weighing_station/ItemProtocol.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.waste_foil_weighing_station; +package org.nl.acs.device_driver.two_conveyor.waste_foil_weighing_station; import lombok.Data; import lombok.extern.slf4j.Slf4j; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/waste_foil_weighing_station/WasteFoilWeighingStationDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/waste_foil_weighing_station/WasteFoilWeighingStationDefination.java similarity index 95% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/waste_foil_weighing_station/WasteFoilWeighingStationDefination.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/waste_foil_weighing_station/WasteFoilWeighingStationDefination.java index f77d5be..7a15d6c 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/waste_foil_weighing_station/WasteFoilWeighingStationDefination.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/waste_foil_weighing_station/WasteFoilWeighingStationDefination.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.waste_foil_weighing_station; +package org.nl.acs.device_driver.two_conveyor.waste_foil_weighing_station; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; import org.nl.acs.device.domain.Device; diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/waste_foil_weighing_station/WasteFoilWeighingStationDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/waste_foil_weighing_station/WasteFoilWeighingStationDriver.java similarity index 99% rename from acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/waste_foil_weighing_station/WasteFoilWeighingStationDriver.java rename to acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/waste_foil_weighing_station/WasteFoilWeighingStationDriver.java index eece88c..beaac4f 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/waste_foil_weighing_station/WasteFoilWeighingStationDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/waste_foil_weighing_station/WasteFoilWeighingStationDriver.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.waste_foil_weighing_station; +package org.nl.acs.device_driver.two_conveyor.waste_foil_weighing_station; import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSONObject;