| | |
| | | //小车移动到提升机口,计算路径 |
| | | //计算小车起点到中点所需命令 |
| | | LocMast currentLocMast = locMastService.queryByQrCode(shuttleProtocol.getCurrentCode().toString()); |
| | | List<NavigateNode> firstMastResult = NavigateUtils.calc(currentLocMast.getLocNo(), assignCommand.getSourceLocNo(), NavigationMapType.NORMAL.id);//小车到中点,处于无货状态,使用正常通道地图 |
| | | |
| | | if (firstMastResult != null) { |
| | | List<NavigateNode> firstMastResult = NavigateUtils.calc(currentLocMast.getLocNo(), assignCommand.getSourceLocNo(), NavigationMapType.NORMAL.id, Utils.getShuttlePoints(assignCommand.getShuttleNo().intValue(), Utils.getLev(currentLocMast.getLocNo())));//小车到中点,处于无货状态,使用正常通道地图 |
| | | boolean checkResult = Utils.checkShuttlePath(firstMastResult, shuttleProtocol.getShuttleNo().intValue()); |
| | | if (firstMastResult != null && checkResult) { |
| | | allNode.addAll(firstMastResult);//将节点进行保存 |
| | | //获取分段路径 |
| | | ArrayList<ArrayList<NavigateNode>> data = NavigateUtils.getSectionPath(firstMastResult); |
| | |
| | | } |
| | | |
| | | //计算中点到终点路径 |
| | | List<NavigateNode> secMastResult = NavigateUtils.calc(assignCommand.getSourceLocNo(), assignCommand.getLocNo(), NavigationMapType.DFX.id);//小车从中点到终点,处于有货状态,使用DFX地图 |
| | | |
| | | if (secMastResult != null) { |
| | | List<NavigateNode> secMastResult = NavigateUtils.calc(assignCommand.getSourceLocNo(), assignCommand.getLocNo(), NavigationMapType.DFX.id, Utils.getShuttlePoints(assignCommand.getShuttleNo().intValue(), Utils.getLev(assignCommand.getSourceLocNo())));//小车从中点到终点,处于有货状态,使用DFX地图 |
| | | boolean checkResult2 = Utils.checkShuttlePath(secMastResult, shuttleProtocol.getShuttleNo().intValue()); |
| | | if (secMastResult != null && checkResult2) { |
| | | allNode.addAll(secMastResult);//将节点进行保存 |
| | | //获取分段路径 |
| | | ArrayList<ArrayList<NavigateNode>> data = NavigateUtils.getSectionPath(secMastResult); |
| | |
| | | } |
| | | |
| | | LocMast locMast = locMastService.queryByQrCode(startQr); |
| | | List<NavigateNode> result = NavigateUtils.calc(locMast.getLocNo(), assignCommand.getLocNo(), NavigationMapType.NONE.id);//手动命令-移动命令,使用无过滤地图 |
| | | |
| | | if (result != null) { |
| | | List<NavigateNode> result = NavigateUtils.calc(locMast.getLocNo(), assignCommand.getLocNo(), NavigationMapType.NONE.id, Utils.getShuttlePoints(assignCommand.getShuttleNo().intValue(), Utils.getLev(locMast.getLocNo())));//手动命令-移动命令,使用无过滤地图 |
| | | boolean checkResult3 = Utils.checkShuttlePath(result, shuttleProtocol.getShuttleNo().intValue()); |
| | | if (result != null && checkResult3) { |
| | | //所使用的路径进行锁定禁用 |
| | | navigateMapData = new NavigateMapData(Utils.getLev(locMast.getLocNo())); |
| | | navigateMapData.writeNavigateNodeToRedisMap(result, true);////所使用的路径进行锁定禁用 |
| | |
| | | int lev = Utils.getLev(locMast1.getLocNo());//穿梭车当前高度 |
| | | String liftSiteLocNo = Utils.levToOutInStaLocNo(lev);//当前楼层站点库位号 |
| | | LocMast liftSitelocMast = locMastService.selectById(liftSiteLocNo); |
| | | List<NavigateNode> result1 = NavigateUtils.calc(locMast1.getLocNo(), liftSiteLocNo, NavigationMapType.NONE.id);//移动到提升机,使用无过滤地图 |
| | | |
| | | List<NavigateNode> result1 = NavigateUtils.calc(locMast1.getLocNo(), liftSiteLocNo, NavigationMapType.NONE.id, Utils.getShuttlePoints(assignCommand.getShuttleNo().intValue(), Utils.getLev(locMast1.getLocNo())));//移动到提升机,使用无过滤地图 |
| | | boolean checkResult4 = Utils.checkShuttlePath(result1, shuttleProtocol.getShuttleNo().intValue()); |
| | | Short endStartCode = null; |
| | | if (result1 != null) { |
| | | if (result1 != null && checkResult4) { |
| | | //所使用的路径进行锁定禁用 |
| | | navigateMapData = new NavigateMapData(Utils.getLev(locMast1.getLocNo())); |
| | | navigateMapData.writeNavigateNodeToRedisMap(result1, true);////所使用的路径进行锁定禁用 |
| | |
| | | return false; |
| | | } |
| | | |
| | | List<ShuttleCommand> errorCommands = redisCommand.getErrorCommands(); |
| | | if (errorCommands.size() > 0) { |
| | | //优先执行该指令 |
| | | ShuttleCommand errorCommand = errorCommands.get(0);//取出指令 |
| | | // List<ShuttleCommand> errorCommands = redisCommand.getErrorCommands(); |
| | | // if (errorCommands.size() > 0) { |
| | | // //优先执行该指令 |
| | | // ShuttleCommand errorCommand = errorCommands.get(0);//取出指令 |
| | | // |
| | | // if(errorCommand.getCommandWord() == 1){//正常行走命令,需要先执行完找库位命令后,再执行 |
| | | // LocMastService locMastService = SpringUtils.getBean(LocMastService.class); |
| | | // LocMast locMast = locMastService.queryByQrCode(shuttleProtocol.getCurrentCode().toString()); |
| | | // LocMast distLocMast = locMastService.queryByQrCode(errorCommand.getStartCodeNum().toString()); |
| | | // if (shuttleProtocol.getCurrentCode().equals(errorCommand.getStartCodeNum())) { |
| | | // //起点和终点属于同一库位,无需再执行移动操作 |
| | | // errorCommands.remove(0);//移除该命令 |
| | | // redisCommand.setErrorCommands(new ArrayList<ShuttleCommand>()); |
| | | // shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.WORKING); |
| | | // //当前步序 |
| | | // int commandStep = redisCommand.getCommandStep(); |
| | | // //步序回退 |
| | | // commandStep--; |
| | | // redisCommand.setCommandStep(commandStep); |
| | | // //任务数据保存到redis |
| | | // redisUtil.set("shuttle_wrk_no_" + wrkNo, JSON.toJSONString(redisCommand)); |
| | | // shuttleProtocol.setPakMk(true); |
| | | // return true; |
| | | // }else { |
| | | // List<NavigateNode> result = NavigateUtils.calc(locMast.getLocNo(), distLocMast.getLocNo(), NavigationMapType.DFX.id, Utils.getShuttlePoints(errorCommand.getShuttleNo().intValue()));//错误恢复,使用DFX地图 |
| | | // if (result != null) { |
| | | // //获取分段路径 |
| | | // ArrayList<ArrayList<NavigateNode>> data = NavigateUtils.getSectionPath(result); |
| | | // //将每一段路径分成command指令 |
| | | // for (ArrayList<NavigateNode> nodes : data) { |
| | | // //开始路径 |
| | | // NavigateNode startPath = nodes.get(0); |
| | | // //目标路径 |
| | | // NavigateNode endPath = nodes.get(nodes.size() - 1); |
| | | // Integer allDistance = NavigateUtils.getCurrentPathAllDistance(nodes);//计算当前路径行走总距离 |
| | | // |
| | | // String qrCodeValue = distLocMast.getQrCodeValue(); |
| | | // errorCommand.setCommandWord((short) 1); |
| | | // errorCommand.setStartCodeNum(shuttleProtocol.getCurrentCode()); |
| | | // errorCommand.setMiddleCodeNum((short) 1); |
| | | // errorCommand.setDistCodeNum((short) Integer.parseInt(qrCodeValue)); |
| | | // errorCommand.setStartToDistDistance(allDistance); |
| | | // errorCommand.setRunSpeed((short) 1000); |
| | | // errorCommand.setRunDirection(ShuttleRunDirection.get(startPath.getDirection()).id); |
| | | // errorCommand.setForceMoveDistance(0); |
| | | // errorCommand.setIOControl((short) 0); |
| | | // errorCommand.setCommandEnd((short) 1); |
| | | // break; |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.WORKING); |
| | | // //当前步序 |
| | | // int commandStep = redisCommand.getCommandStep(); |
| | | // //步序回退 |
| | | // commandStep--; |
| | | // redisCommand.setCommandStep(commandStep); |
| | | // } |
| | | // |
| | | // if (!write(errorCommand)) { |
| | | // News.error("四向穿梭车命令下发失败,穿梭车号={},任务数据={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(errorCommand)); |
| | | // return false; |
| | | // } else { |
| | | // News.info("四向穿梭车命令下发成功,穿梭车号={},任务数据={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(errorCommand)); |
| | | // errorCommands.remove(0); |
| | | // redisCommand.setErrorCommands(errorCommands); |
| | | // //任务数据保存到redis |
| | | // redisUtil.set("shuttle_wrk_no_" + wrkNo, JSON.toJSONString(redisCommand)); |
| | | // return true; |
| | | // } |
| | | // } |
| | | |
| | | if(errorCommand.getCommandWord() == 1){//正常行走命令,需要先执行完找库位命令后,再执行 |
| | | LocMastService locMastService = SpringUtils.getBean(LocMastService.class); |
| | | LocMast locMast = locMastService.queryByQrCode(shuttleProtocol.getCurrentCode().toString()); |
| | | LocMast distLocMast = locMastService.queryByQrCode(errorCommand.getStartCodeNum().toString()); |
| | | if (shuttleProtocol.getCurrentCode().equals(errorCommand.getStartCodeNum())) { |
| | | //起点和终点属于同一库位,无需再执行移动操作 |
| | | errorCommands.remove(0);//移除该命令 |
| | | redisCommand.setErrorCommands(new ArrayList<ShuttleCommand>()); |
| | | shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.WORKING); |
| | | //当前步序 |
| | | int commandStep = redisCommand.getCommandStep(); |
| | | //步序回退 |
| | | commandStep--; |
| | | redisCommand.setCommandStep(commandStep); |
| | | //任务数据保存到redis |
| | | redisUtil.set("shuttle_wrk_no_" + wrkNo, JSON.toJSONString(redisCommand)); |
| | | shuttleProtocol.setPakMk(true); |
| | | return true; |
| | | }else { |
| | | List<NavigateNode> result = NavigateUtils.calc(locMast.getLocNo(), distLocMast.getLocNo(), NavigationMapType.DFX.id);//错误恢复,使用DFX地图 |
| | | if (result != null) { |
| | | //获取分段路径 |
| | | ArrayList<ArrayList<NavigateNode>> data = NavigateUtils.getSectionPath(result); |
| | | //将每一段路径分成command指令 |
| | | for (ArrayList<NavigateNode> nodes : data) { |
| | | //开始路径 |
| | | NavigateNode startPath = nodes.get(0); |
| | | //目标路径 |
| | | NavigateNode endPath = nodes.get(nodes.size() - 1); |
| | | Integer allDistance = NavigateUtils.getCurrentPathAllDistance(nodes);//计算当前路径行走总距离 |
| | | |
| | | String qrCodeValue = distLocMast.getQrCodeValue(); |
| | | errorCommand.setCommandWord((short) 1); |
| | | errorCommand.setStartCodeNum(shuttleProtocol.getCurrentCode()); |
| | | errorCommand.setMiddleCodeNum((short) 1); |
| | | errorCommand.setDistCodeNum((short) Integer.parseInt(qrCodeValue)); |
| | | errorCommand.setStartToDistDistance(allDistance); |
| | | errorCommand.setRunSpeed((short) 1000); |
| | | errorCommand.setRunDirection(ShuttleRunDirection.get(startPath.getDirection()).id); |
| | | errorCommand.setForceMoveDistance(0); |
| | | errorCommand.setIOControl((short) 0); |
| | | errorCommand.setCommandEnd((short) 1); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.WORKING); |
| | | //当前步序 |
| | | int commandStep = redisCommand.getCommandStep(); |
| | | //步序回退 |
| | | commandStep--; |
| | | redisCommand.setCommandStep(commandStep); |
| | | } |
| | | |
| | | if (!write(errorCommand)) { |
| | | News.error("四向穿梭车命令下发失败,穿梭车号={},任务数据={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(errorCommand)); |
| | | return false; |
| | | } else { |
| | | News.info("四向穿梭车命令下发成功,穿梭车号={},任务数据={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(errorCommand)); |
| | | errorCommands.remove(0); |
| | | redisCommand.setErrorCommands(errorCommands); |
| | | //任务数据保存到redis |
| | | redisUtil.set("shuttle_wrk_no_" + wrkNo, JSON.toJSONString(redisCommand)); |
| | | return true; |
| | | } |
| | | } |
| | | LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, 1); |
| | | LiftProtocol liftProtocol = liftThread.getLiftProtocol(); |
| | | |
| | | List<ShuttleCommand> commands = redisCommand.getAssignCommand().getCommands(); |
| | | //当前步序 |
| | |
| | | if (command.getDistCodeNum().intValue() == shuttleProtocol.getCurrentCode().intValue()) { |
| | | //上一条指令的目标位置和当前小车位置相同,则认定上一条任务完成 |
| | | command.setComplete(true); |
| | | |
| | | //上一条指令起点是提升机二维码,则清零提升机任务号 |
| | | if (command.getStartCodeNum().intValue() == liftProtocol.getBarcode().intValue()) { |
| | | //判断提升机是否处于空闲 |
| | | if (liftProtocol.isIdleNoTask()) { |
| | | liftProtocol.setTaskNo((short) 0);//清空任务号 |
| | | } |
| | | } |
| | | } |
| | | } else if (command.getCommandWord().intValue() == 2) { |
| | | //托盘顶升命令 |
| | |
| | | } |
| | | } |
| | | |
| | | if (commands.size() == 0) { |
| | | return false; |
| | | } |
| | | |
| | | //取出命令 |
| | | ShuttleCommand command = commands.get(commandStep); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, 1); |
| | | LiftProtocol liftProtocol = liftThread.getLiftProtocol(); |
| | | |
| | | |
| | | //判断小车当前二维码是否为提升机二维码 |
| | | if (shuttleProtocol.getCurrentCode().intValue() == liftProtocol.getBarcode().intValue()) { |
| | |
| | | if (!liftProtocol.isIdleNoTask()) { |
| | | return false;//提升机忙,禁止下发命令 |
| | | } |
| | | if (liftProtocol.getTaskNo().intValue() != wrkNo) { |
| | | if (liftProtocol.getTaskNo().intValue() != 0 && liftProtocol.getTaskNo().intValue() != wrkNo) { |
| | | //提升机工作号和当前工作不相同,禁止下发命令 |
| | | return false; |
| | | } |
| | |
| | | if (!staProtocol.isLiftArrival()) { |
| | | return false;//站点提升机到位信号false,禁止下发命令 |
| | | } |
| | | |
| | | //条件满足,占用提升机 |
| | | liftProtocol.setTaskNo(wrkNo); |
| | | } |
| | | } |
| | | |
| | |
| | | return true; |
| | | }else { |
| | | if (liftProtocol.getPositionArrivalFeedback$() == shuttleLocNoLev) { |
| | | liftProtocol.setTaskNo(wrkNo);//给提升机写工作号,防止被占用 |
| | | return true;//提升机到位 |
| | | } |
| | | executeLift(liftThread, liftProtocol, redisCommand, shuttleLocNoLev);//调度提升机 |
| | |
| | | } |
| | | |
| | | private boolean executeLift(LiftThread liftThread, LiftProtocol liftProtocol, ShuttleRedisCommand redisCommand, Integer shuttleLocNoLev) {//调度提升机 |
| | | if (liftProtocol.getRunning()) { |
| | | //提升机运行中,禁止下发 |
| | | if (!liftProtocol.isIdle()) { |
| | | //提升机不空闲禁止下发 |
| | | return false; |
| | | } |
| | | |
| | | if (liftProtocol.getPlatShuttleCheck()) { |
| | | //提升机内有车禁止下发 |
| | | return false; |
| | | } |
| | | |