| | |
| | | import com.zy.asrs.wcs.rcs.model.enums.SlaveType; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol; |
| | | import com.zy.asrs.wcs.rcs.thread.ShuttleThread; |
| | | import org.aspectj.apache.bcel.generic.RET; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | ShuttleRedisCommand redisCommand = new ShuttleRedisCommand(); |
| | | |
| | | redisCommand.setShuttleNo(assignCommand.getShuttleNo());//四向穿梭车号 |
| | | redisCommand.setWrkNo(assignCommand.getTaskNo());//工作号 |
| | | redisCommand.setTaskNo(assignCommand.getTaskNo());//工作号 |
| | | redisCommand.setCommandStep(0);//命令执行步序 |
| | | redisCommand.setAssignCommand(assignCommand);//命令 |
| | | //任务数据保存到redis |
| | |
| | | || assignCommand.getTaskMode() == ShuttleTaskModeType.MOVE_LOC_NO.id |
| | | || assignCommand.getTaskMode() == ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO.id) { |
| | | //下发行驶路径 |
| | | boolean result = shuttleThread.movePath(assignCommand.getNodes(), assignCommand.getTaskNo()); |
| | | boolean result = shuttleThread.movePath(assignCommand.getNodes(), assignCommand.getDeviceTaskNo()); |
| | | if (!result) { |
| | | return false; |
| | | } |
| | | } |
| | | shuttleProtocol.setTaskNo(assignCommand.getTaskNo()); |
| | | shuttleProtocol.setSyncTaskNo(assignCommand.getTaskNo()); |
| | | return true; |
| | | } |
| | | return false; |
| | |
| | | } |
| | | |
| | | //判断设备是否空闲 |
| | | if (!shuttleThread.isIdle(() -> { |
| | | return shuttleProtocol.getTaskNo().equals(taskNo); |
| | | })) { |
| | | if (!shuttleThread.isDeviceIdle()) { |
| | | return false; |
| | | } |
| | | // if (!shuttleThread.isIdle(() -> { |
| | | // return shuttleProtocol.getTaskNo().equals(taskNo); |
| | | // })) { |
| | | // return false; |
| | | // } |
| | | |
| | | //判断工作号是否相同 |
| | | if (!shuttleProtocol.getTaskNo().equals(taskNo)) { |
| | | return false; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | // 更新redis数据 |
| | | redisUtil.set(DeviceRedisConstant.SHUTTLE_WORK_FLAG + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand)); |
| | | redisUtil.set(DeviceRedisConstant.SHUTTLE_WORK_FLAG + redisCommand.getTaskNo(), JSON.toJSONString(redisCommand)); |
| | | |
| | | if (!command.getComplete()) { |
| | | return false; |
| | |
| | | if (assignCommand.getAuto()) { |
| | | if (!assignCommand.getCharge()) { |
| | | //对主线程抛出等待确认状态waiting |
| | | shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.WAITING); |
| | | shuttleThread.setProtocolStatus(ShuttleProtocolStatusType.WAITING); |
| | | }else { |
| | | shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.CHARGING_WAITING); |
| | | shuttleThread.setProtocolStatus(ShuttleProtocolStatusType.CHARGING_WAITING); |
| | | } |
| | | News.info("四向穿梭车任务执行下发完成等待执行结束,穿梭车号={},任务数据={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(command)); |
| | | |
| | | // 手动任务 |
| | | } else { |
| | | //手动模式不抛出等待状态,直接复位空闲状态 |
| | | shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE); |
| | | shuttleThread.setProtocolStatus(ShuttleProtocolStatusType.IDLE); |
| | | //任务号清零 |
| | | shuttleProtocol.setTaskNo(0); |
| | | shuttleThread.setSyncTaskNo(0); |
| | | //标记复位 |
| | | shuttleProtocol.setPakMk(true); |
| | | shuttleThread.setPakMk(true); |
| | | News.info("四向穿梭车手动任务执行完成,穿梭车号={},任务数据={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(command)); |
| | | } |
| | | |
| | | //删除redis |
| | | redisUtil.del(DeviceRedisConstant.SHUTTLE_WORK_FLAG + redisCommand.getWrkNo()); |
| | | redisUtil.del(DeviceRedisConstant.SHUTTLE_WORK_FLAG + redisCommand.getTaskNo()); |
| | | return false;//禁止再下发命令 |
| | | } |
| | | } |
| | |
| | | return false; |
| | | } |
| | | |
| | | shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.WORKING); |
| | | shuttleThread.setProtocolStatus(ShuttleProtocolStatusType.WORKING); |
| | | commandStep++; |
| | | //更新redis数据 |
| | | redisCommand.setCommandStep(commandStep); |
| | | //任务数据保存到redis |
| | | redisUtil.set(DeviceRedisConstant.SHUTTLE_WORK_FLAG + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand)); |
| | | redisUtil.set(DeviceRedisConstant.SHUTTLE_WORK_FLAG + redisCommand.getTaskNo(), JSON.toJSONString(redisCommand)); |
| | | return true; |
| | | } |
| | | |
| | |
| | | if (shuttleThread == null) { |
| | | return; |
| | | } |
| | | |
| | | ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); |
| | | if (shuttleProtocol == null) { |
| | | return; |