Merge remote-tracking branch 'origin/shuttle_rcs_dev' into shuttle_rcs_dev
| | |
| | | assignCommand.setAuto(true);//自动模式 |
| | | |
| | | //获取小车到提升机行走命令 |
| | | List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), liftThread.getCurrentLocNo(), NavigationMapType.getNormalWithDevice(), assignCommand, shuttleThread); |
| | | List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), liftThread.getCurrentLocNo(), NavigationMapType.getNormalWithDevice(), assignCommand, shuttleThread, "inLift"); |
| | | if (commands == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "{}任务,{}小车,路径计算失败", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo()); |
| | | return false;//路径解锁失败 |
| | |
| | | private DeviceConfigService deviceConfigService; |
| | | |
| | | public synchronized List<ShuttleCommand> getStartToTargetCommands(String startLocNo, String endLocNo, List<NavigationMapType> mapTypes, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) { |
| | | return getStartToTargetCommands(startLocNo, endLocNo, mapTypes, null, assignCommand, shuttleThread); |
| | | return getStartToTargetCommands(startLocNo, endLocNo, mapTypes, null, assignCommand, shuttleThread, "move"); |
| | | } |
| | | |
| | | public synchronized List<ShuttleCommand> getStartToTargetCommands(String startLocNo, String endLocNo, List<NavigationMapType> mapTypes, List<int[]> whites, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) { |
| | | public synchronized List<ShuttleCommand> getStartToTargetCommands(String startLocNo, String endLocNo, List<NavigationMapType> mapTypes, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread, String moveType) { |
| | | return getStartToTargetCommands(startLocNo, endLocNo, mapTypes, null, assignCommand, shuttleThread, moveType); |
| | | } |
| | | |
| | | public synchronized List<ShuttleCommand> getStartToTargetCommands(String startLocNo, String endLocNo, List<NavigationMapType> mapTypes, List<int[]> whites, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread, String moveType) { |
| | | ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); |
| | | if (shuttleProtocol == null) { |
| | | return null; |
| | |
| | | long endTime = System.currentTimeMillis(); |
| | | News.info("getSection path time:{}", (endTime - startTime)); |
| | | //将每一段路径分成command指令 |
| | | for (List<NavigateNode> nodes : data) { |
| | | for (int i = 0; i < data.size(); i++) { |
| | | List<NavigateNode> nodes = data.get(i); |
| | | |
| | | //开始路径 |
| | | NavigateNode startPath = nodes.get(0); |
| | | |
| | |
| | | String distCodeNum = NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY(), endPath.getZ()); |
| | | //获取移动命令 |
| | | ShuttleCommand command = shuttleThread.getMoveCommand(assignCommand.getDeviceTaskNo(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed, nodes); |
| | | |
| | | if (i + 1 == data.size()) { |
| | | if (moveType.equals("inLift")) { |
| | | command = shuttleThread.getMoveLiftCommand(assignCommand.getDeviceTaskNo(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed, nodes, true); |
| | | }else if (moveType.equals("outLift")) { |
| | | command = shuttleThread.getMoveLiftCommand(assignCommand.getDeviceTaskNo(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed, nodes, false); |
| | | } |
| | | } |
| | | |
| | | command.setNodes(nodes);//将行走节点添加到每一步命令中 |
| | | commands.add(command); |
| | | } |
| | |
| | | |
| | | ShuttleCommand getMoveCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed, List<NavigateNode> nodes);//获取移动命令 |
| | | |
| | | ShuttleCommand getMoveLiftCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed, List<NavigateNode> nodes, Boolean moveIn);//获取移动命令 |
| | | |
| | | ShuttleCommand getLiftCommand(Integer taskNo, Boolean lift);//顶升命令 true=>顶升 false=>下降 |
| | | |
| | | ShuttleCommand getChargeCommand(Integer taskNo, Boolean charge);//充电开关命令 true=>开 false=>关 |
| | |
| | | HashMap<String, Object> body = new HashMap<>(); |
| | | body.put("requestType", "move");//移动命令 |
| | | body.put("taskId", taskId);//TaskID需要随机 |
| | | // body.put("start", navigateNodeToNyPointNode(NavigatePositionConvert.codeToNode(startCodeNum, device.getHostId())));//起点 |
| | | // body.put("target", navigateNodeToNyPointNode(NavigatePositionConvert.codeToNode(distCodeNum, device.getHostId())));//终点 |
| | | body.put("path", path); |
| | | request.setBody(body); |
| | | |
| | | NavigateNode startNode = nodes.get(0); |
| | | for (NavigateNode node : nodes) { |
| | | HashMap<String, Object> data = new HashMap<>(); |
| | | String codeNum = NavigatePositionConvert.xyToPosition(node.getX(), node.getY(), node.getZ()); |
| | | Map<String, Object> nyNode = navigateNodeToNyPointNode(NavigatePositionConvert.codeToNode(codeNum)); |
| | | int xp = Integer.parseInt(String.valueOf(nyNode.get("y"))); |
| | | int yp = Integer.parseInt(String.valueOf(nyNode.get("x"))); |
| | | int z = Integer.parseInt(String.valueOf(nyNode.get("z"))); |
| | | |
| | | List<List<MapNode>> mapData = navigateMapData.getJsonData(startNode.getZ(), NavigationMapType.getMapTypes(NavigationMapType.NONE), null, null); |
| | | List<MapNode> mapNodes = mapData.get(node.getX()); |
| | | MapNode mapNode = mapNodes.get(node.getY()); |
| | | |
| | | data.put("xp", xp); |
| | | data.put("yp", yp); |
| | | data.put("z", z); |
| | | data.put("x", mapNode.getXBase()); |
| | | data.put("y", mapNode.getYBase()); |
| | | path.add(data); |
| | | } |
| | | |
| | | httpStandard.setRequest(request); |
| | | |
| | | LocMastService locMastService = SpringUtils.getBean(LocMastService.class); |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("qr_code_value", distCodeNum)); |
| | | if (locMast == null) { |
| | | throw new CoolException("库位信息不存在"); |
| | | } |
| | | |
| | | ShuttleCommand command = new ShuttleCommand(); |
| | | command.setShuttleNo(deviceConfig.getDeviceNo()); |
| | | command.setBody(JSON.toJSONString(httpStandard)); |
| | | command.setMode(ShuttleCommandModeType.MOVE.id); |
| | | command.setTargetLocNo(locMast.getLocNo()); |
| | | command.setTaskNo(taskId); |
| | | return command; |
| | | } |
| | | |
| | | @Override |
| | | public ShuttleCommand getMoveLiftCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed, List<NavigateNode> nodes, Boolean moveIn) { |
| | | NavigateMapData navigateMapData = SpringUtils.getBean(NavigateMapData.class); |
| | | NyShuttleHttpCommand httpStandard = getHttpStandard(deviceConfig.getDeviceNo(), taskNo); |
| | | NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest(); |
| | | |
| | | ArrayList<HashMap<String, Object>> path = new ArrayList<>(); |
| | | |
| | | Integer taskId = getTaskId(); |
| | | HashMap<String, Object> body = new HashMap<>(); |
| | | if (moveIn) { |
| | | body.put("requestType", "intoLift");//进提升机 |
| | | }else { |
| | | body.put("requestType", "outLift");//出提升机 |
| | | } |
| | | body.put("taskId", taskId);//TaskID需要随机 |
| | | body.put("path", path); |
| | | request.setBody(body); |
| | | |