| | |
| | | import com.zy.acs.manager.core.constant.MapDataConstant; |
| | | import com.zy.acs.manager.core.domain.DirectionDto; |
| | | import com.zy.acs.manager.core.domain.LaneDto; |
| | | import com.zy.acs.manager.core.domain.PathDto; |
| | | import com.zy.acs.manager.core.domain.SortCodeDto; |
| | | import com.zy.acs.manager.core.domain.UnlockPathTask; |
| | | import com.zy.acs.manager.core.domain.VehicleFootprint; |
| | |
| | | return Math.sqrt(deltaX * deltaX + deltaY * deltaY); |
| | | } |
| | | |
| | | public void lockPath(Integer lev, List<String> pathList, String agvNo) { |
| | | List<int[]> codeMatrixIdxList = mapDataDispatcher.getCodeMatrixIdxList(lev, pathList); |
| | | mapDataDispatcher.modifyDynamicMatrix(lev, codeMatrixIdxList, agvNo); |
| | | public void lockPath(Integer lev, List<PathDto> pathList, String agvNo) { |
| | | if (Cools.isEmpty(agvNo, pathList)) { |
| | | return; |
| | | } |
| | | List<PathDto> normalized = pathList.stream() |
| | | .filter(Objects::nonNull) |
| | | .filter(dto -> !Cools.isEmpty(dto.getCode())) |
| | | .collect(Collectors.toList()); |
| | | if (Cools.isEmpty(normalized)) { |
| | | return; |
| | | } |
| | | List<String> codeList = normalized.stream().map(PathDto::getCode).collect(Collectors.toList()); |
| | | List<int[]> codeMatrixIdxList = mapDataDispatcher.getCodeMatrixIdxList(lev, codeList); |
| | | mapDataDispatcher.modifyDynamicMatrix(lev, codeMatrixIdxList, agvNo, normalized); |
| | | } |
| | | |
| | | public void unlockPath(String agvNo, String codeData) { |
| | |
| | | List<PathDto> pathDtoList = mainService.generateAction(segment.getAgvId(), segmentList, pathList, now); |
| | | // System.out.println("generateAction: " + (System.currentTimeMillis() - startTime)); |
| | | |
| | | mapService.lockPath(null, pathList, agv.getUuid()); |
| | | mapService.lockPath(null, pathDtoList, agv.getUuid()); |
| | | |
| | | } catch (Exception e) { |
| | | log.error("TrafficService.trigger", e); |
| | |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.exception.CoolException; |
| | | import com.zy.acs.manager.common.utils.MapDataUtils; |
| | | import com.zy.acs.manager.core.domain.PathDto; |
| | | 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.Code; |
| | |
| | | import com.zy.acs.manager.manager.service.RouteService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.event.EventListener; |
| | | import org.springframework.boot.context.event.ApplicationReadyEvent; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | |
| | | } |
| | | |
| | | public void modifyDynamicMatrix(Integer lev, List<int[]> codeIdxList, String vehicle) { |
| | | this.modifyDynamicMatrix(lev, codeIdxList, vehicle, false); |
| | | this.modifyDynamicMatrix(lev, codeIdxList, vehicle, false, null); |
| | | } |
| | | |
| | | public void modifyDynamicMatrix(Integer lev, List<int[]> codeIdxList, String vehicle, List<PathDto> pathTrace) { |
| | | this.modifyDynamicMatrix(lev, codeIdxList, vehicle, false, pathTrace); |
| | | } |
| | | |
| | | public synchronized void modifyDynamicMatrix(Integer lev, List<int[]> codeIdxList, String vehicle, boolean reset) { |
| | | this.modifyDynamicMatrix(lev, codeIdxList, vehicle, reset, null); |
| | | } |
| | | |
| | | private synchronized void modifyDynamicMatrix(Integer lev, List<int[]> codeIdxList, String vehicle, boolean reset, List<PathDto> pathTrace) { |
| | | if (Cools.isEmpty(vehicle)) { |
| | | return; |
| | | } |
| | |
| | | DynamicNode[][] dynamicMatrix = getDynamicMatrix(lev); |
| | | |
| | | if (!reset) { |
| | | // long time = System.currentTimeMillis() / 1000; |
| | | int serial = 1; |
| | | for (int[] codeMatrixIdx : codeIdxList) { |
| | | dynamicMatrix[codeMatrixIdx[0]][codeMatrixIdx[1]] = new DynamicNode(vehicle, serial); |
| | | for (int i = 0; i < codeIdxList.size(); i++) { |
| | | int[] codeMatrixIdx = codeIdxList.get(i); |
| | | |
| | | PathDto pathDto = (pathTrace != null && i < pathTrace.size()) ? pathTrace.get(i) : null; |
| | | Double direction = pathDto == null ? null : pathDto.getDirection(); |
| | | boolean turn = pathDto != null && pathDto.isTurn(); |
| | | |
| | | dynamicMatrix[codeMatrixIdx[0]][codeMatrixIdx[1]] = new DynamicNode(vehicle, serial, direction, turn); |
| | | serial++; |
| | | } |
| | | } else { |
| | |
| | | |
| | | private int serial = -1; |
| | | |
| | | private Double direction; |
| | | |
| | | private boolean turn = false; |
| | | |
| | | public DynamicNode() {} |
| | | |
| | | public DynamicNode(String vehicle) { |
| | |
| | | this.serial = DynamicNodeType.ACCESS.val.equals(vehicle) ? -1 : serial; |
| | | } |
| | | |
| | | public DynamicNode(String vehicle, int serial, Double direction, boolean turn) { |
| | | this.vehicle = vehicle; |
| | | this.serial = serial; |
| | | this.direction = direction; |
| | | this.turn = turn; |
| | | } |
| | | |
| | | } |