| | |
| | | import com.zy.core.dispatcher.ShuttleDispatchUtils; |
| | | import com.zy.core.enums.*; |
| | | import com.zy.core.model.CommandResponse; |
| | | import com.zy.core.model.TrafficControlDataModel; |
| | | import com.zy.core.model.command.ShuttleAssignCommand; |
| | | import com.zy.core.model.command.ShuttleCommand; |
| | | import com.zy.core.model.command.ShuttleRedisCommand; |
| | |
| | | return false; |
| | | } |
| | | |
| | | public synchronized boolean executeWork(Integer shuttleNo, Integer taskNo) { |
| | | public boolean executeWork(Integer shuttleNo, Integer taskNo) { |
| | | Object obj = redisUtil.get(RedisKeyType.SHUTTLE_WORK_FLAG.key + taskNo); |
| | | if (obj == null) { |
| | | return false; |
| | |
| | | |
| | | //移动命令,锁定路径 |
| | | if (command.getMode() == ShuttleCommandModeType.MOVE.id) { |
| | | TrafficControlThread trafficControlThread = (TrafficControlThread) SlaveConnection.get(SlaveType.TrafficControl, 1); |
| | | if (trafficControlThread == null) { |
| | | return false; |
| | | } |
| | | |
| | | List<NavigateNode> nodes = JSON.parseArray(JSON.toJSONString(command.getNodes()), NavigateNode.class); |
| | | //申请管制 |
| | | boolean apply = applyTrafficControl(commands, nodes, shuttleNo, taskNo); |
| | | applyTrafficControl(commands, nodes, shuttleNo, taskNo); |
| | | //查询管制 |
| | | boolean apply = queryTrafficControl(shuttleNo, taskNo); |
| | | if(!apply){ |
| | | return false;//申请失败 |
| | | } |
| | |
| | | if (!result) { |
| | | News.error("{} device can't lock path!", shuttleNo); |
| | | shuttleThread.offerSystemMsg("{} device can't lock path!", shuttleNo); |
| | | trafficControlThread.trafficReportError(shuttleNo, taskNo); |
| | | return false;//路径锁定失败 |
| | | } |
| | | } |
| | |
| | | //直线段数据标识 |
| | | Long linePartFlag = startNode.getLinePartFlag(); |
| | | |
| | | //取指令 |
| | | ShuttleCommand currentCommand = commands.get(commandStep); |
| | | if(currentCommand.getMode() != ShuttleCommandModeType.MOVE.id) { |
| | | return 0; |
| | | } |
| | | if(commandStep < commands.size()){ |
| | | //取指令 |
| | | ShuttleCommand currentCommand = commands.get(commandStep); |
| | | if(currentCommand.getMode() != ShuttleCommandModeType.MOVE.id) { |
| | | return 0; |
| | | } |
| | | |
| | | List<NavigateNode> currentNodes = currentCommand.getNodes(); |
| | | NavigateNode currentStartNode = currentNodes.get(0); |
| | | if(!currentStartNode.getLinePartAllowGo()) {//直线段部分,允许直接行走 |
| | | return 0; |
| | | } |
| | | List<NavigateNode> currentNodes = currentCommand.getNodes(); |
| | | NavigateNode currentStartNode = currentNodes.get(0); |
| | | if(!currentStartNode.getLinePartAllowGo()) {//直线段部分,允许直接行走 |
| | | return 0; |
| | | } |
| | | |
| | | if(currentStartNode.getLinePartFlag().equals(linePartFlag)) { |
| | | //数据标识一致 |
| | | return 2;//允许小车移动连续下发指令 |
| | | if(currentStartNode.getLinePartFlag().equals(linePartFlag)) { |
| | | //数据标识一致 |
| | | return 2;//允许小车移动连续下发指令 |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | return false; |
| | | } |
| | | if (targetPoints.contains(Utils.getRow(currentLocNo) + "-" + Utils.getBay(currentLocNo))) { |
| | | command.setComplete(true); |
| | | boolean result = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(shuttleProtocol.getCurrentLocNo()), shuttleProtocol.getShuttleNo(), nodes, false);//解锁路径 |
| | | if (!result) { |
| | | return false;//解锁失败 |
| | | } |
| | | command.setComplete(true); |
| | | }else { |
| | | return false; |
| | | } |
| | |
| | | return trafficControlThread.applyTrafficControl(totalNodeList, nodeList, shuttleNo, taskNo); |
| | | } |
| | | |
| | | //查询是否申请管制成功 |
| | | public boolean queryTrafficControl(Integer shuttleNo, Integer taskNo) { |
| | | TrafficControlThread trafficControlThread = (TrafficControlThread) SlaveConnection.get(SlaveType.TrafficControl, 1); |
| | | if (trafficControlThread == null) { |
| | | return false; |
| | | } |
| | | |
| | | TrafficControlDataModel trafficControlDataModel = trafficControlThread.queryTrafficControl(shuttleNo, taskNo); |
| | | if (trafficControlDataModel == null) { |
| | | return false; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | // /** |
| | | // * 搜索小车路径是否存在冲突 |
| | | // * 0:未检测 1:检测无冲突 2:检测有冲突 |