| | |
| | | |
| | | News.info("[RCS Debug] Execute check command {},{}", shuttleNo, taskNo); |
| | | //检测命令 |
| | | int checked = checkCommand(redisCommand, shuttleNo); |
| | | ShuttleCheckCommandResultType checked = checkCommand(redisCommand, shuttleNo); |
| | | News.info("[RCS Debug] Execute check command complete {},{}", shuttleNo, taskNo); |
| | | if (checked == 0) { |
| | | if (checked.equals(ShuttleCheckCommandResultType.FAIL)) { |
| | | return false; |
| | | } |
| | | |
| | |
| | | |
| | | //取出命令 |
| | | ShuttleCommand command = null; |
| | | if (checked == 1) { |
| | | if (checked.equals(ShuttleCheckCommandResultType.SUCCESS)) { |
| | | //非连续指令,需要检测上一条指令是否完成 |
| | | if (commandStep > 0) { |
| | | ShuttleCommand lastCommand = commands.get(commandStep - 1); |
| | |
| | | } |
| | | |
| | | command = commands.get(commandStep); |
| | | } else if (checked == 2) { |
| | | } else if (checked.equals(ShuttleCheckCommandResultType.SUCCESS_GO)) { |
| | | //连续指令直接取数据 |
| | | command = commands.get(commandStep); |
| | | } |
| | |
| | | return false;//申请失败 |
| | | } |
| | | |
| | | if (checked == 2) { |
| | | if (checked.equals(ShuttleCheckCommandResultType.SUCCESS_GO)) { |
| | | nodes.remove(0); |
| | | } |
| | | |
| | |
| | | * 检测命令 |
| | | * 0:未通过 1:通过 2:通过且可提前下发指令 |
| | | */ |
| | | private int checkCommand(ShuttleRedisCommand redisCommand, Integer shuttleNo) { |
| | | private ShuttleCheckCommandResultType checkCommand(ShuttleRedisCommand redisCommand, Integer shuttleNo) { |
| | | TrafficControlThread trafficControlThread = (TrafficControlThread) SlaveConnection.get(SlaveType.TrafficControl, 1); |
| | | if(trafficControlThread == null){ |
| | | return 0; |
| | | return ShuttleCheckCommandResultType.FAIL; |
| | | } |
| | | |
| | | ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo); |
| | | if (shuttleThread == null) { |
| | | return 0; |
| | | return ShuttleCheckCommandResultType.FAIL; |
| | | } |
| | | |
| | | ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); |
| | | if (shuttleProtocol == null) { |
| | | return 0; |
| | | return ShuttleCheckCommandResultType.FAIL; |
| | | } |
| | | |
| | | int commandStep = redisCommand.getCommandStep(); |
| | | if (commandStep == 0) { |
| | | return 1;//第一条命令无需检测 |
| | | return ShuttleCheckCommandResultType.SUCCESS;//第一条命令无需检测 |
| | | } |
| | | |
| | | ShuttleAssignCommand assignCommand = redisCommand.getAssignCommand(); |
| | | List<ShuttleCommand> commands = assignCommand.getCommands(); |
| | | if (commands.isEmpty()) { |
| | | return 0; |
| | | return ShuttleCheckCommandResultType.FAIL; |
| | | } |
| | | |
| | | boolean supportContinuously = false; |
| | |
| | | //小车移动连续下发指令 |
| | | if (assignCommand.getShuttleMoveCommandsContinuously()) { |
| | | if (!supportContinuously) { |
| | | return 0; |
| | | return ShuttleCheckCommandResultType.FAIL; |
| | | } |
| | | |
| | | //移动指令 |
| | | if(lastCommand.getMode() != ShuttleCommandModeType.MOVE.id) { |
| | | return 0; |
| | | return ShuttleCheckCommandResultType.FAIL; |
| | | } |
| | | |
| | | List<NavigateNode> nodes = lastCommand.getNodes(); |
| | | NavigateNode startNode = nodes.get(0); |
| | | if (!startNode.getLinePartAllowGo()) {//直线段部分,允许直接行走 |
| | | return 0; |
| | | return ShuttleCheckCommandResultType.FAIL; |
| | | } |
| | | |
| | | //直线段数据标识 |
| | |
| | | //取指令 |
| | | ShuttleCommand currentCommand = commands.get(commandStep); |
| | | if(currentCommand.getMode() != ShuttleCommandModeType.MOVE.id) { |
| | | return 0; |
| | | return ShuttleCheckCommandResultType.FAIL; |
| | | } |
| | | |
| | | List<NavigateNode> currentNodes = currentCommand.getNodes(); |
| | | NavigateNode currentStartNode = currentNodes.get(0); |
| | | if(!currentStartNode.getLinePartAllowGo()) {//直线段部分,允许直接行走 |
| | | return 0; |
| | | return ShuttleCheckCommandResultType.FAIL; |
| | | } |
| | | |
| | | if(currentStartNode.getLinePartFlag().equals(linePartFlag)) { |
| | | //数据标识一致 |
| | | return 2;//允许小车移动连续下发指令 |
| | | return ShuttleCheckCommandResultType.SUCCESS_GO;//允许小车移动连续下发指令 |
| | | } |
| | | } |
| | | } |
| | | |
| | | return 0; |
| | | return ShuttleCheckCommandResultType.FAIL; |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | //删除redis |
| | | redisUtil.del(RedisKeyType.SHUTTLE_WORK_FLAG.key + redisCommand.getWrkNo()); |
| | | return 0;//禁止再下发命令 |
| | | return ShuttleCheckCommandResultType.FAIL;//禁止再下发命令 |
| | | } |
| | | |
| | | return 1; |
| | | return ShuttleCheckCommandResultType.SUCCESS; |
| | | } |
| | | |
| | | //检测更新命令完成 |