zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/LiftAction.java
@@ -8,7 +8,7 @@ import com.zy.asrs.wcs.rcs.cache.SlaveConnection; import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant; import com.zy.asrs.wcs.rcs.entity.Device; import com.zy.asrs.wcs.rcs.model.enums.ShuttleProtocolStatusType; import com.zy.asrs.wcs.rcs.model.enums.LiftProtocolStatusType; import com.zy.asrs.wcs.rcs.model.enums.SlaveType; import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol; import com.zy.asrs.wcs.rcs.thread.LiftThread; @@ -69,7 +69,7 @@ } //判断提升机是否空闲 if (!liftThread.isIdle()) { if (!liftThread.isDeviceIdle()) { return false; } @@ -83,22 +83,39 @@ if (commandStep != 0) { LiftCommand command = commands.get(commandStep - 1); //目前没有判断,直接判定上一条指令完成 command.setComplete(true); if (command.getMode() == LiftCommandModeType.MOVE.id) { //提升机升降 if (liftProtocol.getLev() == command.getTargetLev()) { command.setComplete(true); } } else if (command.getMode() == LiftCommandModeType.MOVE_CAR.id) { //提升机升降小车 if (liftProtocol.getLev() == command.getTargetLev()) { command.setComplete(true); } } else if (command.getMode() == LiftCommandModeType.PALLET_INOUT.id) { //托盘出入 if (liftProtocol.getLev() == command.getTargetLev()) { command.setComplete(true); } } // 更新redis数据 redisUtil.set(DeviceRedisConstant.LIFT_WORK_FLAG + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand)); redisUtil.set(DeviceRedisConstant.LIFT_WORK_FLAG + taskNo, JSON.toJSONString(redisCommand)); if (!command.getComplete()) { return false; } //判断是否为最后一条命令且命令执行完成,抛出等待确认状态 LiftCommand endCommand = commands.get(commands.size() - 1); if (endCommand.getComplete()) { News.info("提升机任务执行下发完成等待执行结束,提升机号={},任务数据={}", liftProtocol.getLiftNo(), JSON.toJSON(commands)); //对主线程抛出等待确认状态waiting liftThread.setProtocolStatus(LiftProtocolStatusType.WAITING); liftThread.commandFinished(taskNo);//调用完成后续指令(部分提升机有后续指令,实际情况看是否有真正实现方法) redisUtil.del(DeviceRedisConstant.LIFT_WORK_FLAG + taskNo); return false;//禁止再下发命令 } } @@ -114,7 +131,12 @@ News.info("提升机命令下发成功,提升机号={},任务数据={}", command.getLiftNo(), JSON.toJSON(command)); } redisUtil.del(DeviceRedisConstant.LIFT_WORK_FLAG + command.getTaskNo()); liftThread.setProtocolStatus(LiftProtocolStatusType.WORKING); commandStep++; //更新redis数据 redisCommand.setCommandStep(commandStep); // 更新redis数据 redisUtil.set(DeviceRedisConstant.LIFT_WORK_FLAG + taskNo, JSON.toJSONString(redisCommand)); return true; } zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/LiftCommandService.java
@@ -12,6 +12,7 @@ import com.zy.asrs.wcs.core.service.MotionService; import com.zy.asrs.wcs.core.service.TaskService; import com.zy.asrs.wcs.rcs.cache.SlaveConnection; import com.zy.asrs.wcs.rcs.model.enums.LiftProtocolStatusType; import com.zy.asrs.wcs.rcs.model.enums.SlaveType; import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol; import com.zy.asrs.wcs.rcs.thread.LiftThread; @@ -194,9 +195,8 @@ } liftThread.setSyncTaskNo(0);//清零工作号 liftThread.commandFinished(motion.getTaskNo());//调用完成后续指令(部分提升机有后续指令,实际情况看是否有真正实现方法) liftThread.setProtocolStatus(LiftProtocolStatusType.IDLE); return true; } } zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/LiftProtocol.java
@@ -125,7 +125,7 @@ /** * 作业标记 */ private Boolean pakMk = false; private Boolean pakMk = true; /** * 指令下发时间 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/LiftThread.java
@@ -28,6 +28,10 @@ boolean isIdle(ExecuteSupport support);//是否空闲 boolean isDeviceIdle();//设备是否空闲 boolean isDeviceIdle(ExecuteSupport support);//设备是否空闲 boolean setProtocolStatus(LiftProtocolStatusType status);//设置工作状态 boolean setSyncTaskNo(Integer taskNo);//设置工作号 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyLiftThread.java
@@ -81,9 +81,9 @@ try { readStatus(); //提升机处于运行状态,将标记置为false //提升机处于运行状态,将标记置为true if (liftProtocol.getRun()) { liftProtocol.setPakMk(false); liftProtocol.setPakMk(true); } } catch (Exception e) { OutputQueue.LIFT.offer(MessageFormat.format("【{0}】读取提升机状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), device.getId(), device.getIp(), device.getPort())); @@ -308,17 +308,45 @@ @Override public boolean isIdle(ExecuteSupport support) { if (null != support) { if (!support.judgement()) { return false; Boolean judgement = support.judgement(); if (judgement != null && !judgement) { return true; } } // 判断提升机是否自动、就绪、空闲 if (this.liftProtocol.getModel() && !this.liftProtocol.getRun() && this.liftProtocol.getReady() && this.liftProtocol.getPakMk() && this.liftProtocol.getErrorCode().equals("0") && this.liftProtocol.getProtocolStatus().equals(LiftProtocolStatusType.IDLE) && (this.liftProtocol.getProtocolStatusType().equals(LiftProtocolStatusType.IDLE) || this.liftProtocol.getProtocolStatusType().equals(LiftProtocolStatusType.WAITING)) ) { return true; } return false; } @Override public boolean isDeviceIdle() { return isDeviceIdle(null); } @Override public boolean isDeviceIdle(ExecuteSupport support) { if (null != support) { Boolean judgement = support.judgement(); if (judgement != null && !judgement) { return true; } } // 判断提升机是否自动、就绪、空闲 if (this.liftProtocol.getModel() && !this.liftProtocol.getRun() && this.liftProtocol.getReady() && this.liftProtocol.getErrorCode().equals("0") ) { return true; } zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayLiftThread.java
@@ -63,9 +63,9 @@ try { readStatus(); //提升机处于运行状态,将标记置为false //提升机处于运行状态,将标记置为true if (liftProtocol.getRun()) { liftProtocol.setPakMk(false); liftProtocol.setPakMk(true); } } catch (Exception e) { OutputQueue.LIFT.offer(MessageFormat.format("【{0}】读取提升机状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), device.getId(), device.getIp(), device.getPort())); @@ -345,10 +345,11 @@ // 判断提升机是否自动、就绪、空闲、未锁定 if (this.liftProtocol.getModel() && !this.liftProtocol.getRun() && this.liftProtocol.getPakMk() && this.liftProtocol.getReady() // && this.liftProtocol.getPakMk() && this.liftProtocol.getErrorCode().equals("0") && this.liftProtocol.getProtocolStatusType().equals(LiftProtocolStatusType.IDLE) && (this.liftProtocol.getProtocolStatusType().equals(LiftProtocolStatusType.IDLE) || this.liftProtocol.getProtocolStatusType().equals(LiftProtocolStatusType.WAITING)) && !extend.getLock() ) { return true; @@ -357,6 +358,36 @@ } @Override public boolean isDeviceIdle() { return isDeviceIdle(null); } @Override public boolean isDeviceIdle(ExecuteSupport support) { if (null != support) { Boolean judgement = support.judgement(); if (judgement != null && !judgement) { return true; } } // 判断提升机是否自动、就绪、空闲 if (this.liftProtocol.getModel() && !this.liftProtocol.getRun() && this.liftProtocol.getErrorCode().equals("0") ) { if (this.liftProtocol.getTaskNo() == 0) { //无任务情况下检测是否就绪 if (!this.liftProtocol.getReady()) { return false; } } return true; } return false; } @Override public boolean setProtocolStatus(LiftProtocolStatusType status) { this.liftProtocol.setProtocolStatus(status); return true;