| | |
| | | import com.core.common.SpringUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.BasShuttle; |
| | | import com.zy.asrs.entity.DeviceConfig; |
| | | import com.zy.asrs.service.BasShuttleService; |
| | | import com.zy.asrs.service.DeviceConfigService; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.MapNode; |
| | | import com.zy.common.model.NavigateNode; |
| | |
| | | import com.zy.core.model.command.ShuttleAssignCommand; |
| | | import com.zy.core.model.command.ShuttleCommand; |
| | | import com.zy.core.model.protocol.ShuttleProtocol; |
| | | import com.zy.core.properties.SlaveProperties; |
| | | import com.zy.core.thread.ShuttleThread; |
| | | import com.zy.system.entity.Config; |
| | | import com.zy.system.service.ConfigService; |
| | |
| | | @Autowired |
| | | private ConfigService configService; |
| | | @Autowired |
| | | private SlaveProperties slaveProperties; |
| | | @Autowired |
| | | private ShuttleDispatchUtils shuttleDispatchUtils; |
| | | @Autowired |
| | | private DeviceConfigService deviceConfigService; |
| | | |
| | | public synchronized List<ShuttleCommand> getStartToTargetCommands(String startLocNo, String endLocNo, Integer mapType, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) { |
| | | return getStartToTargetCommands(startLocNo, endLocNo, mapType, null, assignCommand, shuttleThread); |
| | |
| | | |
| | | private HashMap<String, Integer> findCarMap() { |
| | | HashMap<String, Integer> carMap = new HashMap<>(); |
| | | for (ShuttleSlave slave : slaveProperties.getShuttle()) { |
| | | ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, slave.getId()); |
| | | |
| | | List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() |
| | | .eq("device_type", String.valueOf(SlaveType.Shuttle))); |
| | | for (DeviceConfig device : shuttleList) { |
| | | ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getDeviceNo()); |
| | | if (shuttleThread == null) { |
| | | continue; |
| | | } |
| | |
| | | continue; |
| | | } |
| | | |
| | | carMap.put(currentLocNo, slave.getId()); |
| | | carMap.put(currentLocNo, device.getDeviceNo()); |
| | | } |
| | | return carMap; |
| | | } |
| | |
| | | |
| | | for (int i = 0; i < outerCircle; i++) { |
| | | int idx = i + 1; |
| | | List<NavigateNode> list = extend_nodes(map, currentNode, idx); |
| | | List<NavigateNode> list = extend_outer_nodes(map, currentNode, idx); |
| | | if (list.isEmpty()) { |
| | | continue; |
| | | } |
| | |
| | | |
| | | for (int i = 0; i < innerCircle; i++) { |
| | | int idx = i + 1; |
| | | List<NavigateNode> list = extend_nodes(map, currentNode, idx); |
| | | List<NavigateNode> list = extend_inner_nodes(map, currentNode, idx); |
| | | if (list.isEmpty()) { |
| | | continue; |
| | | } |
| | |
| | | return innerNodes; |
| | | } |
| | | |
| | | private List<NavigateNode> extend_nodes(int[][] map, NavigateNode startNode, int innerCircleIdx) { |
| | | private List<NavigateNode> extend_inner_nodes(int[][] map, NavigateNode startNode, int innerCircleIdx) { |
| | | //默认地图母轨方向x |
| | | String mapDirection = "x"; |
| | | ConfigService configService = SpringUtils.getBean(ConfigService.class); |
| | |
| | | return nodes; |
| | | } |
| | | |
| | | private List<NavigateNode> extend_outer_nodes(int[][] map, NavigateNode startNode, int innerCircleIdx) { |
| | | ArrayList<NavigateNode> nodes = new ArrayList<>(); |
| | | int x = startNode.getX(); |
| | | int y = startNode.getY(); |
| | | int z = startNode.getZ(); |
| | | |
| | | if (is_valid(map, x + innerCircleIdx, y)) { |
| | | NavigateNode node = new NavigateNode(x + innerCircleIdx, y); |
| | | node.setNodeValue(map[x + innerCircleIdx][y]); |
| | | node.setZ(z); |
| | | if (node.getNodeValue().equals(startNode.getNodeValue())) { |
| | | nodes.add(node); |
| | | } |
| | | } |
| | | |
| | | if (is_valid(map, x - innerCircleIdx, y)) { |
| | | NavigateNode node = new NavigateNode(x - innerCircleIdx, y); |
| | | node.setNodeValue(map[x - innerCircleIdx][y]); |
| | | node.setZ(z); |
| | | if (node.getNodeValue().equals(startNode.getNodeValue())) { |
| | | nodes.add(node); |
| | | } |
| | | } |
| | | |
| | | if (is_valid(map, x, y + innerCircleIdx)) { |
| | | NavigateNode node = new NavigateNode(x, y + innerCircleIdx); |
| | | node.setNodeValue(map[x][y + innerCircleIdx]); |
| | | node.setZ(z); |
| | | if (node.getNodeValue().equals(startNode.getNodeValue())) { |
| | | nodes.add(node); |
| | | } |
| | | } |
| | | |
| | | if (is_valid(map, x, y - innerCircleIdx)) { |
| | | NavigateNode node = new NavigateNode(x, y - innerCircleIdx); |
| | | node.setNodeValue(map[x][y - innerCircleIdx]); |
| | | node.setZ(z); |
| | | if (node.getNodeValue().equals(startNode.getNodeValue())) { |
| | | nodes.add(node); |
| | | } |
| | | } |
| | | return nodes; |
| | | } |
| | | |
| | | private boolean is_valid(int[][] map, int x, int y) { |
| | | if (x < 0 || x >= map.length |
| | | || y < 0 || y >= map[0].length) { |