| | |
| | | import com.zy.acs.common.utils.RedisSupport; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.manager.common.utils.MapDataUtils; |
| | | import com.zy.acs.manager.core.service.AgvAreaDispatcher; |
| | | import com.zy.acs.manager.core.service.LaneService; |
| | | import com.zy.acs.manager.core.service.astart.domain.AStarNavigateNode; |
| | | import com.zy.acs.manager.core.service.astart.domain.DynamicNode; |
| | | import com.zy.acs.manager.core.utils.RouteGenerator; |
| | | import com.zy.acs.manager.manager.entity.Segment; |
| | | import com.zy.acs.manager.manager.service.AgvService; |
| | | import com.zy.acs.manager.manager.service.JamService; |
| | | import com.zy.acs.manager.system.service.ConfigService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | private LaneService laneService; |
| | | @Autowired |
| | | private ConfigService configService; |
| | | @Autowired |
| | | private AgvAreaDispatcher agvAreaDispatcher; |
| | | @Autowired |
| | | private AgvService agvService; |
| | | |
| | | public synchronized AStarNavigateNode execute(String agvNo, AStarNavigateNode start, AStarNavigateNode end |
| | | , Boolean lock, List<String> blackList, Segment segment) { |
| | | if (start.getX() == end.getX() && start.getY() == end.getY()) { |
| | | return end; |
| | | } |
| | | |
| | | // scope code area: 4ms |
| | | Long agvId = agvService.getAgvId(agvNo); |
| | | Boolean withinArea = agvAreaDispatcher.isAgvExistsInAnyArea(agvId); |
| | | List<String> scopeCodeList = new ArrayList<>(); |
| | | if (withinArea) { |
| | | scopeCodeList = agvAreaDispatcher.getCodesByAgvId(agvId); |
| | | } |
| | | |
| | | Integer maxAgvCountInLane = configService.getVal("maxAgvCountInLane", Integer.class); |
| | | |
| | | PriorityQueue<AStarNavigateNode> openQueue = new PriorityQueue<>(); |
| | |
| | | DynamicNode[][] dynamicMatrix = mapDataDispatcher.getDynamicMatrix(null); |
| | | String[][] waveMatrix = mapDataDispatcher.getWaveMatrix(null); |
| | | |
| | | long getNeighborNodesTime = 0; |
| | | int getNeighborNodesCount = 0; |
| | | |
| | | while (!openQueue.isEmpty()) { |
| | | // 取优先队列顶部元素并且把这个元素从Open表中删除,取F值最小的节点 |
| | | AStarNavigateNode currentNode = openQueue.poll(); |
| | |
| | | } |
| | | long currentTime = System.currentTimeMillis(); |
| | | List<AStarNavigateNode> neighbourNodes = this.getNeighborNodes(currentNode, mapMatrix, existNodes); |
| | | getNeighborNodesTime += System.currentTimeMillis() - currentTime; |
| | | getNeighborNodesCount ++; |
| | | for (AStarNavigateNode node : neighbourNodes) { |
| | | node.setCodeData(codeMatrix[node.getX()][node.getY()]); |
| | | |
| | | if (withinArea) { |
| | | assert !Cools.isEmpty(scopeCodeList); |
| | | if (!scopeCodeList.contains(node.getCodeData())) { continue; } |
| | | } |
| | | |
| | | boolean isEndNode = node.getX() == end.getX() && node.getY() == end.getY(); |
| | | |
| | | int weight = 0; |