| | |
| | | import com.zy.acs.manager.manager.entity.Code; |
| | | import com.zy.acs.manager.manager.entity.Loc; |
| | | import com.zy.acs.manager.manager.entity.Segment; |
| | | import com.zy.acs.manager.manager.entity.Sta; |
| | | import com.zy.acs.manager.manager.service.ActionService; |
| | | import com.zy.acs.manager.manager.service.CodeService; |
| | | import com.zy.acs.manager.system.service.ConfigService; |
| | |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | public static Double mapToNearest(Double angle) { |
| | | if (null == angle) { |
| | | return null; |
| | | } |
| | | angle = (angle + 360) % 360; |
| | | double remainder = angle % 45; |
| | | if (remainder < 22.5) { |
| | | return angle - remainder; |
| | | } else { |
| | | return angle + (45 - remainder); |
| | | } |
| | | } |
| | | |
| | | // 角度计算 |
| | | public Double calculateDirection(Code startCode, Code endCode, int angleOffsetVal) { |
| | |
| | | |
| | | double deltaX = x1 - x0; |
| | | double deltaY = y1 - y0; |
| | | double angle = -Math.atan2(deltaX, deltaY); |
| | | double angle = Math.atan2(deltaX, deltaY); |
| | | angle = Math.toDegrees(angle) + angleOffsetVal; |
| | | angle = (angle + 360) % 360; // 将角度转换为正值 |
| | | |
| | |
| | | } |
| | | |
| | | // 坐标货架阈值 todo:luxiaotao |
| | | public AgvDirectionType calculateAgvWorkDirection(Loc loc, Code code) { |
| | | public AgvDirectionType calculateAgvWorkDirectionByShelf(Loc loc, Code code) { |
| | | Integer compDirect = loc.getCompDirect(); |
| | | AgvDirectionType agvDirectionType = null; |
| | | if (compDirect == 0) { |
| | |
| | | return agvDirectionType; |
| | | } |
| | | |
| | | public Double getStaAngle(Sta sta, Double workDirection) { |
| | | if (null == sta) { |
| | | return null; |
| | | } |
| | | if (Cools.isEmpty(sta.getAngle())) { |
| | | return workDirection; |
| | | } |
| | | return Double.parseDouble(sta.getAngle()); |
| | | } |
| | | |
| | | public Double calculateAgvWorkDirectionByStation(Double staWorkDirection, Double lastDirection) { |
| | | return Math.abs(staWorkDirection - lastDirection) + 90.0D; |
| | | } |
| | | |
| | | public double calculateDistance(double x1, double y1, double x2, double y2) { |
| | | double deltaX = x2 - x1; |
| | |
| | | } |
| | | |
| | | public void unlockPath(String agvNo, String codeData) { |
| | | if (Cools.isEmpty(agvNo, codeData)) { |
| | | return; |
| | | } |
| | | try { |
| | | unlockTaskQueue.offer(new UnlockPathTask(agvNo, codeData), 5, TimeUnit.SECONDS); |
| | | |
| | | // Integer lev = null; |
| | | // |
| | | // String[][] codeMatrix = mapDataDispatcher.getCodeMatrix(null); |
| | | // int[] codeMatrixIdx = mapDataDispatcher.getCodeMatrixIdx(lev, codeData); |
| | | // |
| | | // |
| | | // DynamicNode[][] dynamicMatrix = mapDataDispatcher.getDynamicMatrix(lev); |
| | | // |
| | | // DynamicNode dynamicNode = dynamicMatrix[codeMatrixIdx[0]][codeMatrixIdx[1]]; |
| | | // |
| | | // |
| | | // int serial = dynamicNode.getSerial(); |
| | | // |
| | | // List<int[]> resetCodeIdxList = new ArrayList<>(); |
| | | // |
| | | // for (int i = 0; i < dynamicMatrix.length; i++) { |
| | | // for (int j = 0; j < dynamicMatrix[i].length; j++) { |
| | | // |
| | | //// if (i == codeMatrixIdx[0] && j == codeMatrixIdx[1]) { continue; } |
| | | // |
| | | // DynamicNode node = dynamicMatrix[i][j]; |
| | | // if (node.getVehicle().equals(agvNo)) { |
| | | // if (node.getSerial() < serial) { |
| | | // resetCodeIdxList.add(new int[] {i, j}); |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // if (!Cools.isEmpty(resetCodeIdxList)) { |
| | | // |
| | | // mapDataDispatcher.clearDynamicMatrixByCodeList(lev, resetCodeIdxList); |
| | | // } |
| | | |
| | | } catch (InterruptedException e) { |
| | | log.error("unlockTaskQueue", e); |
| | | } |