| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.*; |
| | | import java.util.concurrent.CopyOnWriteArrayList; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | List<RetreatNavigateNode> enableNodes = new ArrayList<>(); |
| | | |
| | | ArrayList<RetreatNavigateNode> neighborNodes = this.getNeighborNodes(currentNode, existNodes, codeMatrix); |
| | | List<RetreatNavigateNode> neighborNodes = this.getNeighborNodes(currentNode, existNodes, codeMatrix); |
| | | boolean pointOfTurn = neighborNodes.size() >= 2; |
| | | label: for (RetreatNavigateNode node : neighborNodes) { |
| | | if (node.getCodeData().equals(breakPoint)) { continue; } |
| | |
| | | |
| | | // lane |
| | | if (pointOfTurn) { |
| | | Lane lane = laneService.search(node.getCodeData()); |
| | | if (null != lane) { |
| | | List<int[]> laneCodeIdxList = laneService.getLaneCodeIdxList(node.getCodeData()); |
| | | if (!Cools.isEmpty(laneCodeIdxList)) { |
| | | Set<String> lanVehicleSet = new HashSet<>(); |
| | | |
| | | for (String laneCodeData : lane.getCodes()) { |
| | | for (int[] codeMatrixIdx : laneCodeIdxList) { |
| | | // overlap with sponsor |
| | | String laneCodeData = codeMatrix[codeMatrixIdx[0]][codeMatrixIdx[1]]; |
| | | if (avoidPathList.contains(laneCodeData)) { |
| | | lanVehicleSet.add(sponsor); |
| | | } |
| | | |
| | | int[] laneCodeMatrixIdx = mapDataDispatcher.getCodeMatrixIdx(null, laneCodeData); |
| | | // scan dynamicMatrix or WaveMatrix |
| | | DynamicNode laneDynamicNode = dynamicMatrix[laneCodeMatrixIdx[0]][laneCodeMatrixIdx[1]]; |
| | | DynamicNode laneDynamicNode = dynamicMatrix[codeMatrixIdx[0]][codeMatrixIdx[1]]; |
| | | String laneVehicle = laneDynamicNode.getVehicle(); |
| | | assert !laneVehicle.equals(DynamicNodeType.BLOCK.val); |
| | | if (!laneVehicle.equals(DynamicNodeType.ACCESS.val)) { |
| | | if (!laneVehicle.equals(agvNo)) { |
| | | lanVehicleSet.add(laneVehicle); |
| | | // redis.setObject(RedisConstant.AGV_TO_STANDBY_FLAG, laneVehicle, true, 30); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (lanVehicleSet.size() + 1 > maxAgvCountInLane) { |
| | | phaseSecond = false; // there is a running way |
| | | continue; |
| | |
| | | weight += WEIGHT_CALC_FACTOR * 2; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | Code code = codeService.selectByData(node.getCodeData()); |
| | |
| | | RetreatNavigateNode currentNode = openQueue.poll(); |
| | | List<RetreatNavigateNode> enableNodes = new ArrayList<>(); |
| | | |
| | | ArrayList<RetreatNavigateNode> neighborNodes = this.getNeighborNodes(currentNode, existNodes, codeMatrix); |
| | | List<RetreatNavigateNode> neighborNodes = this.getNeighborNodes(currentNode, existNodes, codeMatrix); |
| | | |
| | | // 第一步:获取有效转弯点 |
| | | if (null == availablePointOfTurn) { |
| | |
| | | |
| | | for (RetreatNavigateNode node : neighborNodes) { |
| | | // lane |
| | | Lane lane = laneService.search(node.getCodeData()); |
| | | if (null != lane) { |
| | | List<int[]> laneCodeIdxList = laneService.getLaneCodeIdxList(node.getCodeData()); |
| | | if (!Cools.isEmpty(laneCodeIdxList)) { |
| | | Set<String> lanVehicleSet = new HashSet<>(); |
| | | |
| | | for (String laneCodeData : lane.getCodes()) { |
| | | int[] laneCodeMatrixIdx = mapDataDispatcher.getCodeMatrixIdx(null, laneCodeData); |
| | | // scan dynamicMatrix or WaveMatrix |
| | | DynamicNode laneDynamicNode = dynamicMatrix[laneCodeMatrixIdx[0]][laneCodeMatrixIdx[1]]; |
| | | for (int[] codeMatrixIdx : laneCodeIdxList) { |
| | | DynamicNode laneDynamicNode = dynamicMatrix[codeMatrixIdx[0]][codeMatrixIdx[1]]; |
| | | String laneVehicle = laneDynamicNode.getVehicle(); |
| | | assert !laneVehicle.equals(DynamicNodeType.BLOCK.val); |
| | | if (!laneVehicle.equals(DynamicNodeType.ACCESS.val)) { |
| | | if (!laneVehicle.equals(agvNo)) { |
| | | lanVehicleSet.add(laneVehicle); |
| | | // redis.setObject(RedisConstant.AGV_TO_STANDBY_FLAG, laneVehicle, true, 30); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (lanVehicleSet.size() + 1 > maxAgvCountInLane) { |
| | | continue; |
| | | } |
| | |
| | | } |
| | | |
| | | // 获取四周节点 |
| | | private ArrayList<RetreatNavigateNode> getNeighborNodes(RetreatNavigateNode currentNode, Set<RetreatNavigateNode> existNodes, String[][] codeMatrix) { |
| | | private List<RetreatNavigateNode> getNeighborNodes(RetreatNavigateNode currentNode, Set<RetreatNavigateNode> existNodes, String[][] codeMatrix) { |
| | | |
| | | int x = currentNode.getX(); |
| | | int y = currentNode.getY(); |
| | | |
| | | ArrayList<RetreatNavigateNode> neighbourNodes = new ArrayList<>(); |
| | | List<RetreatNavigateNode> neighbourNodes = new CopyOnWriteArrayList<>(); |
| | | |
| | | List<RetreatNavigateNode> possibleNodes = Arrays.asList( |
| | | new RetreatNavigateNode(x, y + 1), // right |