New file |
| | |
| | | package com.zy.acs.manager.core.domain.type; |
| | | |
| | | public enum BlockSeverityType { |
| | | |
| | | // NONE(0), |
| | | NONE(0), |
| | | SEVERE(20000), |
| | | ; |
| | | |
| | | public long duration; |
| | | |
| | | BlockSeverityType(long duration) { |
| | | this.duration = duration; |
| | | } |
| | | |
| | | public static BlockSeverityType query(Long duration) { |
| | | if (null == duration) { |
| | | return BlockSeverityType.NONE; |
| | | } |
| | | if (duration > SEVERE.duration) { |
| | | return BlockSeverityType.SEVERE; |
| | | } |
| | | return BlockSeverityType.NONE; |
| | | } |
| | | |
| | | } |
| | |
| | | import com.zy.acs.common.enums.AgvDirectionType; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.manager.common.utils.MapDataUtils; |
| | | import com.zy.acs.manager.core.domain.type.BlockSeverityType; |
| | | import com.zy.acs.manager.core.service.astart.*; |
| | | import com.zy.acs.manager.core.service.astart.domain.DynamicNode; |
| | | import com.zy.acs.manager.core.service.floyd.FloydNavigateService; |
| | |
| | | * 寻址 ===>> A Star |
| | | */ |
| | | public synchronized List<String> checkoutPath(String agvNo, Code startCode, Code endCode |
| | | , Boolean lock, List<String> blackList, Segment segment) { |
| | | , Boolean lock, List<String> blackList, Segment segment, BlockSeverityType blockSeverity) { |
| | | |
| | | int[] startMapIdx = mapDataDispatcher.getCodeMatrixIdx(null, startCode.getData()); |
| | | int[] endMapIdx = mapDataDispatcher.getCodeMatrixIdx(null, endCode.getData()); |
| | |
| | | NavigateNode startNode = new NavigateNode(startMapIdx[0], startMapIdx[1], startCode.getData()); |
| | | NavigateNode endNode = new NavigateNode(endMapIdx[0], endMapIdx[1], endCode.getData()); |
| | | |
| | | NavigateNode finishNode = aStarNavigateService.execute(agvNo, startNode, endNode, lock, blackList, segment); |
| | | NavigateNode finishNode = aStarNavigateService.execute(agvNo, startNode, endNode, lock, blackList, segment, blockSeverity); |
| | | |
| | | if (null == finishNode) { |
| | | log.warn("{} 号AGV检索[{}] ===>> [{}]路径失败......", agvNo, startCode.getData(), endCode.getData()); |
| | |
| | | import com.zy.acs.manager.common.utils.MapDataUtils; |
| | | import com.zy.acs.manager.core.domain.BlockVehicleDto; |
| | | import com.zy.acs.manager.core.domain.TaskPosDto; |
| | | import com.zy.acs.manager.core.domain.type.BlockSeverityType; |
| | | import com.zy.acs.manager.core.service.astart.MapDataDispatcher; |
| | | import com.zy.acs.manager.core.service.astart.RetreatNavigateNode; |
| | | import com.zy.acs.manager.core.service.astart.WaveNodeType; |
| | |
| | | String agvNo = agv.getUuid(); |
| | | Date now = new Date(); |
| | | Jam jam = jamService.getJam(agv.getId(), startCode.getId(), segment.getId()); |
| | | BlockSeverityType blockSeverity = BlockSeverityType.query(null == jam ? null : jam.getDuration()); |
| | | // judge avoid of jam |
| | | List<Jam> unfinishedOriginJamByCurrAgv = jamService.getUnfinishedOriginJamByAvo(agv.getId(), startCode.getId(), segment.getId()); |
| | | List<String> blackPath = this.getBlackPathList(unfinishedOriginJamByCurrAgv); |
| | |
| | | List<String> pathList = new ArrayList<>(); |
| | | |
| | | // 无障碍解 |
| | | List<String> unlockPathList = mapService.checkoutPath(agvNo, startCode, endCode, false, blackPath, segment); |
| | | List<String> unlockPathList = mapService.checkoutPath(agvNo, startCode, endCode, false, blackPath, segment, null); |
| | | // 避让解 |
| | | List<String> lockPathList = mapService.checkoutPath(agvNo, startCode, endCode, true, blackPath, segment); |
| | | List<String> lockPathList = mapService.checkoutPath(agvNo, startCode, endCode, true, blackPath, segment, null); |
| | | |
| | | if (!Cools.isEmpty(lockPathList) && // 存在避让解 |
| | | Math.abs(lockPathList.size() - unlockPathList.size()) <= Arrays.stream(mapDataDispatcher.getCodeMatrix(lev)).mapToInt(row -> row.length).sum() / 10 |
| | |
| | | pathList = lockPathList; |
| | | } else { |
| | | |
| | | // preview path |
| | | List<String> draftPath = new ArrayList<>(unlockPathList); |
| | | // 可走行路径集合计算 |
| | | List<BlockVehicleDto> blockVehicleList = this.slicePathAndReturnBlockVehicleList(lev, unlockPathList, agvNo, pathList); // jamAgvNo may was wave |
| | | List<BlockVehicleDto> blockVehicleList = this.slicePathAndReturnBlockVehicleList(lev, draftPath, agvNo, pathList); // jamAgvNo may was wave |
| | | |
| | | if (!Cools.isEmpty(pathList)) { |
| | | |
| | |
| | | Integer maxJamTimeoutFactor = null; |
| | | |
| | | // persist jam data |
| | | ArrayList<String> jamPath = new ArrayList<>(unlockPathList); |
| | | jam = this.createOrUpdateJam(agv, startCode, segment, jam, jamPath); |
| | | jam = this.createOrUpdateJam(agv, startCode, segment, jam, draftPath); |
| | | |
| | | // ? has unAvoidable block vehicles |
| | | if (blockVehicleList.stream().anyMatch(blockVehicleDto -> !blockVehicleDto.isAvoidable())) { |
| | |
| | | } else { |
| | | |
| | | // select optimal block vehicle |
| | | // String blockAgvNo = blockVehicleList.stream() |
| | | // .filter(BlockVehicleDto::isAvoidable) |
| | | // .map(BlockVehicleDto::getVehicle) |
| | | // .findFirst().orElse(null); |
| | | String blockAgvNo = this.checkoutBestSolutionOfBlocks(blockVehicleList); |
| | | if (Cools.isEmpty(blockAgvNo)) { |
| | | |
| | |
| | | } |
| | | |
| | | // notify block vehicle to avoid |
| | | if (this.notifyVehicleAvoid(blockAgvNo, blockAgvCode, jamPath, agvNo, jam)) { |
| | | if (this.notifyVehicleAvoid(blockAgvNo, blockAgvCode, draftPath, agvNo, jam)) { |
| | | if (jam.getCycleAvo() == 1) { |
| | | jam.setCycleCode(endCode.getId()); |
| | | } |
| | |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.manager.common.utils.MapDataUtils; |
| | | import com.zy.acs.manager.core.domain.Lane; |
| | | import com.zy.acs.manager.core.domain.type.BlockSeverityType; |
| | | import com.zy.acs.manager.core.service.LaneService; |
| | | import com.zy.acs.manager.core.service.astart.domain.DynamicNode; |
| | | import com.zy.acs.manager.manager.entity.Route; |
| | |
| | | private ConfigService configService; |
| | | |
| | | public synchronized NavigateNode execute(String agvNo, NavigateNode start, NavigateNode end |
| | | , Boolean lock, List<String> blackList, Segment segment) { |
| | | , Boolean lock, List<String> blackList, Segment segment, BlockSeverityType blockSeverity) { |
| | | if (start.getX() == end.getX() && start.getY() == end.getY()) { |
| | | return end; |
| | | } |
| | |
| | | DynamicNode[][] dynamicMatrix = mapDataDispatcher.getDynamicMatrix(null); |
| | | String[][] waveMatrix = mapDataDispatcher.getWaveMatrix(null); |
| | | |
| | | // List<String> included = new ArrayList<>(); |
| | | // if (!Cools.isEmpty(whiteList)) { |
| | | // included.addAll(whiteList); |
| | | // } |
| | | // included.add(agvNo); |
| | | // List<VehicleDto> vehicleDtoList = agvService.getVehicleDtoList(included); |
| | | |
| | | while (openQueue.size() > 0) { |
| | | // 取优先队列顶部元素并且把这个元素从Open表中删除,取F值最小的节点 |
| | | NavigateNode currentNode = openQueue.poll(); |
| | | // 对当前结点进行扩展,得到一个四周结点的数组 |
| | | |
| | | ArrayList<NavigateNode> neighbourNodes = this.getNeighborNodes(currentNode, mapMatrix, existNodes); |
| | | // 对这个结点遍历,看是否有目标结点出现 |
| | | label: for (NavigateNode node : neighbourNodes) { |
| | | for (NavigateNode node : neighbourNodes) { |
| | | boolean isEndNode = node.getX() == end.getX() && node.getY() == end.getY(); |
| | | |
| | | int weight = 0; |
| | | // 节点存在其他车辆 |
| | | // for (VehicleDto vehicleDto : vehicleDtoList) { |
| | | // if (node.getCodeData().equals(vehicleDto.getPosCode())) { |
| | | // if (!Cools.isEmpty(blackList) && blackList.contains(vehicleDto.getVehicle())) { |
| | | // continue label; |
| | | // } |
| | | // if (lock) { |
| | | // continue label; |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | if (!Cools.isEmpty(blackList) && blackList.contains(node.getCodeData())) { |
| | | continue; |
| | |
| | | |
| | | |
| | | //找到目标结点就返回 |
| | | if (node.getX() == end.getX() && node.getY() == end.getY()) { |
| | | if (isEndNode) { |
| | | //并且计算出G, F, H等值 |
| | | node.initNode(currentNode, end); |
| | | return node; |