| | |
| | | //状态8,等待命令进行入库搬运动作 |
| | | |
| | | //判断提升机是否空闲 |
| | | if (!liftProtocol.isIdle()) { |
| | | if (!liftProtocol.isIdleNoTask()) { |
| | | try { |
| | | Thread.sleep(1000);//休眠1s |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | continue;//提升机忙 |
| | | } |
| | | //判断提升机任务号和当前工作档任务号是否一致 |
| | | if (liftProtocol.getTaskNo().intValue() != 0 && liftProtocol.getTaskNo().intValue() != wrkMast.getWrkNo()) { |
| | | continue; |
| | | } |
| | | |
| | | //判断提升机楼层是否到位,判断站点是否给出提升机到位信号 |
| | |
| | | }else if(wrkMast.getWrkSts() == 25) {//状态25,需要向小车下发命令从提升机移动出去,需要判断提升机状是否空闲、提升机是否到达目标楼层、目标楼层站点是否存在、目标楼层站点是否给出提升机到位信号 |
| | | |
| | | //判断提升机是否空闲 |
| | | if (!liftProtocol.isIdle()) { |
| | | if (!liftProtocol.isIdleNoTask()) { |
| | | try { |
| | | Thread.sleep(1000);//休眠1s |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | continue;//提升机忙 |
| | | } |
| | | //判断提升机任务号和当前工作档任务号是否一致 |
| | | if (liftProtocol.getTaskNo().intValue() != 0 && liftProtocol.getTaskNo().intValue() != wrkMast.getWrkNo()) { |
| | | continue; |
| | | } |
| | | |
| | | //判断提升机楼层是否到位,判断站点是否给出提升机到位信号 |
| | |
| | | BasDevp basDevp = basDevpService.queryByLocNo(liftSiteLocNo); |
| | | Short endStartCode = Short.parseShort(basDevp.getQrCodeValue());//站点二维码 |
| | | |
| | | String disLocNo = "190020" + Utils.getLev(liftSiteLocNo);//避让位置 |
| | | String disLocNo = "2000202" + Utils.getLev(liftSiteLocNo);//避让位置 |
| | | LocMast locMast1 = locMastService.queryByLoc(disLocNo); |
| | | if (locMast1 == null) { |
| | | continue;//找不到库位 |
| | |
| | | ShuttleCommand moveCommand = shuttleThread.getMoveCommand(startCode, distCode, 1400, commands.get(0).getRunDirection(), startCode, 1400, 500); |
| | | commands.add(0, moveCommand);//将该指令添加到队头 |
| | | |
| | | //获取当前小车所在楼层的站点信息 |
| | | BasDevp basDevp = basDevpService.queryByLocNo(liftSiteLocNo); |
| | | Short endStartCode = Short.parseShort(basDevp.getQrCodeValue());//站点二维码 |
| | | |
| | | String disLocNo = "2000202" + Utils.getLev(liftSiteLocNo);//避让位置 |
| | | LocMast locMast1 = locMastService.queryByLoc(disLocNo); |
| | | if (locMast1 == null) { |
| | | continue;//找不到库位 |
| | | } |
| | | short disCode = Short.parseShort(locMast1.getQrCodeValue()); |
| | | //任务执行完后,小车进入移开提升机口站点位置,以免坠落 |
| | | ShuttleCommand moveCommand2 = shuttleThread.getMoveCommand(endStartCode, disCode, 1400, ShuttleRunDirection.BOTTOM.id, endStartCode, 1400, 500); |
| | | commands.add(moveCommand2); |
| | | |
| | | |
| | | //分配目标库位 |
| | | shuttleProtocol.setLocNo(wrkMast.getSourceLocNo()); |
| | | //分配任务号 |
| | |
| | | //获取四向穿梭车线程 |
| | | ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId()); |
| | | ShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); |
| | | if (shuttleProtocol == null) { |
| | | if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) { |
| | | continue; |
| | | } |
| | | if (!shuttleProtocol.isIdle()) { |
| | |
| | | //设置四向穿梭车为空闲状态 |
| | | shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE); |
| | | } |
| | | //任务号清零 |
| | | shuttleProtocol.setTaskNo((short) 0); |
| | | //源库位清零 |
| | | shuttleProtocol.setSourceLocNo(null); |
| | | //目标库位清零 |
| | | shuttleProtocol.setLocNo(null); |
| | | //标记复位 |
| | | shuttleProtocol.setPakMk(true); |
| | | //任务指令清零 |
| | | shuttleProtocol.setAssignCommand(null); |
| | | if (wrkCharge.getWrkSts() != 57) { |
| | | //任务号清零 |
| | | shuttleProtocol.setTaskNo((short) 0); |
| | | //源库位清零 |
| | | shuttleProtocol.setSourceLocNo(null); |
| | | //目标库位清零 |
| | | shuttleProtocol.setLocNo(null); |
| | | //标记复位 |
| | | shuttleProtocol.setPakMk(true); |
| | | //任务指令清零 |
| | | shuttleProtocol.setAssignCommand(null); |
| | | } |
| | | News.info("四向穿梭车已确认且任务完成状态,复位。四向穿梭车号={}", shuttleProtocol.getShuttleNo()); |
| | | } else { |
| | | News.error("四向穿梭车已确认且任务完成状态,复位失败,但未找到工作档。四向穿梭车号={},工作号={}", shuttleProtocol.getShuttleNo(), shuttleProtocol.getTaskNo()); |
| | |
| | | continue; |
| | | } |
| | | |
| | | //判断提升机是否处于空闲状态 |
| | | if (!liftProtocol.isIdle()) { |
| | | |
| | | // if (!liftProtocol.isIdle()) { |
| | | // continue; |
| | | // } |
| | | |
| | | //判断提升机是否处于空闲状态,没有判断任务号,可能提升机处于空闲,但是还有任务未完成 |
| | | if (!liftProtocol.isIdleNoTask()) { |
| | | continue; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | if (wrkMast.getWrkSts() == 2) {//2.设备上走 |
| | | if (liftProtocol.getTaskNo().intValue() != 0) { |
| | | //存在未完成任务号 |
| | | continue; |
| | | } |
| | | if (liftProtocol.getPlatShuttleCheck()) { |
| | | //提升机此时有四向车,可能有未完成的任务,禁止分配新任务 |
| | | continue; |
| | | } |
| | | |
| | | //工作档目标库位号 |
| | | String wrkMastLocNo = wrkMast.getLocNo(); |
| | | //工作档目标库位楼层 |
| | |
| | | |
| | | wrkMast.setWrkSts(3L);//3.提升机搬运中 |
| | | } else if (wrkMast.getWrkSts() == 6) {//6.迁移小车至提升机口完成 => 7.提升机迁移小车中 |
| | | if (liftProtocol.getTaskNo().intValue() != 0 && liftProtocol.getTaskNo().intValue() != wrkMast.getWrkNo()) { |
| | | //提升机存在未完成任务,且提升机任务号和当前工作档任务号不一致 |
| | | continue; |
| | | } |
| | | liftProtocol.setShuttleNo(wrkMast.getShuttleNo().shortValue());//设置四向穿梭车号 |
| | | |
| | | //判断小车是否在提升机内,且处于空闲状态 |
| | |
| | | } |
| | | if (shuttleProtocol.getCurrentCode().intValue() != liftProtocol.getBarcode().intValue()) { |
| | | continue;//小车当前二维码和提升机内部二维码不一致,不允许执行 |
| | | } |
| | | if (!liftProtocol.getPlatShuttleCheck()) { |
| | | //提升机未检测到小车,禁止执行 |
| | | continue; |
| | | } |
| | | |
| | | //工作档目标库位号 |
| | |
| | | |
| | | wrkMast.setWrkSts(7L);//6.迁移小车至提升机口完成 => 7.提升机迁移小车中 |
| | | } else if(wrkMast.getWrkSts() == 23) {//23.迁移小车至提升机口完成 => 24.提升机迁移小车中 |
| | | if (liftProtocol.getTaskNo().intValue() != 0 && liftProtocol.getTaskNo().intValue() != wrkMast.getWrkNo()) { |
| | | //提升机存在未完成任务,且提升机任务号和当前工作档任务号不一致 |
| | | continue; |
| | | } |
| | | liftProtocol.setShuttleNo(wrkMast.getShuttleNo().shortValue());//设置四向穿梭车号 |
| | | |
| | | //判断小车是否在提升机内,且处于空闲状态 |
| | |
| | | } |
| | | if (shuttleProtocol.getCurrentCode().intValue() != liftProtocol.getBarcode().intValue()) { |
| | | continue;//小车当前二维码和提升机内部二维码不一致,不允许执行 |
| | | } |
| | | if (!liftProtocol.getPlatShuttleCheck()) { |
| | | //提升机未检测到小车,禁止执行 |
| | | continue; |
| | | } |
| | | |
| | | //工作档目标库位号 |
| | |
| | | |
| | | wrkMast.setWrkSts(24L);//23.迁移小车至提升机口完成 => 24.提升机迁移小车中 |
| | | } else if (wrkMast.getWrkSts() == 27) {//27.小车出库搬运完成 |
| | | if (liftProtocol.getTaskNo().intValue() != 0 && liftProtocol.getTaskNo().intValue() != wrkMast.getWrkNo()) { |
| | | //提升机存在未完成任务,且提升机任务号和当前工作档任务号不一致 |
| | | continue; |
| | | } |
| | | if (liftProtocol.getPlatShuttleCheck()) { |
| | | //提升机此时有四向车,可能有未完成的任务,禁止分配新任务 |
| | | continue; |
| | | } |
| | | |
| | | //工作档源库位号 |
| | | String wrkMastLocNo = wrkMast.getSourceLocNo(); |
| | | //工作档源库位楼层 |
| | |
| | | && !liftProtocol.getRunning() |
| | | ) { |
| | | |
| | | //标记复位 |
| | | liftProtocol.setPakMk(true); |
| | | |
| | | DevpThread devpThread = null; |
| | | Integer devpId = null; |
| | | for (DevpSlave devp : slaveProperties.getDevp()){ |
| | |
| | | case 28://28.提升机搬运中 ==> 29.提升机搬运完成 |
| | | wrkMast.setWrkSts(29L); |
| | | wrkMast.setWrkSts(34L);//34.出库完成,暂时先直接完成出库工作档,后续需要根据输送线给出的状态来确定34.出库完成状态 |
| | | //任务号清零 |
| | | liftProtocol.setTaskNo((short) 0); |
| | | break; |
| | | default: |
| | | } |
| | |
| | | if (wrkMastMapper.updateById(wrkMast) > 0) { |
| | | //设置提升机为空闲状态 |
| | | liftProtocol.setProtocolStatus(LiftProtocolStatusType.IDLE); |
| | | //任务号清零 |
| | | liftProtocol.setTaskNo((short) 0); |
| | | //标记复位 |
| | | liftProtocol.setPakMk(true); |
| | | //任务指令清零 |
| | | liftProtocol.setAssignCommand(null); |
| | | News.info("提升机已确认且任务完成状态,复位。提升机号={}", liftProtocol.getLiftNo()); |
| | | News.info("提升机已确认且任务完成状态。提升机号={}", liftProtocol.getLiftNo()); |
| | | } else { |
| | | News.error("提升机已确认且任务完成状态,复位失败,但未找到工作档。提升机号={},工作号={}", liftProtocol.getLiftNo(), liftProtocol.getTaskNo()); |
| | | } |
| | |
| | | for (ShuttleSlave shuttle : slaveProperties.getShuttle()) { |
| | | WrkCharge wrkCharge = wrkChargeService.selectWorking(null, WrkChargeType.charge); |
| | | if (wrkCharge == null) { |
| | | return; |
| | | continue; |
| | | } |
| | | |
| | | ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkCharge.getShuttleNo()); |
| | | if (shuttleThread == null) { |
| | | return; |
| | | continue; |
| | | } |
| | | ShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); |
| | | if (shuttleProtocol == null) { |
| | | return; |
| | | continue; |
| | | } |
| | | |
| | | //当前穿梭车库位号 |
| | | String currentLocNo = shuttleProtocol.getCurrentLocNo(); |
| | | if (currentLocNo == null) { |
| | | return; |
| | | } |
| | | //小车当前层高 |
| | | Integer currentLev = Utils.getLev(currentLocNo); |
| | | //获取提升机 |
| | | LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, 1); |
| | | if (liftThread == null) { |
| | | return; |
| | | continue; |
| | | } |
| | | LiftProtocol liftProtocol = liftThread.getLiftProtocol(); |
| | | if (liftProtocol == null) { |
| | | return; |
| | | continue; |
| | | } |
| | | //充电库位号 |
| | | String chargeLocNo = wrkCharge.getLocNo(); |
| | |
| | | Integer chargeLocNoLev = Utils.getLev(chargeLocNo); |
| | | |
| | | if (wrkCharge.getWrkSts() == 51) { |
| | | //当前穿梭车库位号 |
| | | String currentLocNo = shuttleProtocol.getCurrentLocNo(); |
| | | if (currentLocNo == null) { |
| | | continue; |
| | | } |
| | | //小车当前层高 |
| | | Integer currentLev = Utils.getLev(currentLocNo); |
| | | |
| | | if (currentLev == chargeLocNoLev) { |
| | | //同一层无需经过提升机 |
| | | //直接计算车到充电库位 |
| | |
| | | //获取小车到充电库位路径指令 |
| | | List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, chargeLocNo, NavigationMapType.NONE.id, assignCommand, shuttleThread); |
| | | if (commands == null) { |
| | | return;//未找到路径 |
| | | continue;//未找到路径 |
| | | } |
| | | //进行充电中 |
| | | shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.CHARGING); |
| | |
| | | //小车移动到提升机口站点,计算路径 |
| | | List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, liftSiteLocNo, NavigationMapType.NONE.id, assignCommand, shuttleThread); |
| | | if (commands == null) { |
| | | return;//未找到路径 |
| | | continue;//未找到路径 |
| | | } |
| | | |
| | | //获取当前小车所在楼层的站点信息 |
| | | BasDevp basDevp = basDevpService.queryByLocNo(liftSiteLocNo); |
| | | if (basDevp == null) { |
| | | return;//找不到站点信息 |
| | | continue;//找不到站点信息 |
| | | } |
| | | Short basDevpQrCode = Short.parseShort(basDevp.getQrCodeValue());//站点二维码 |
| | | |
| | |
| | | |
| | | //判断提升机是否处于空闲状态 |
| | | if (!liftProtocol.isIdle()) { |
| | | return; |
| | | continue; |
| | | } |
| | | |
| | | //判断小车是否在提升机内 |
| | | if (shuttleProtocol.getCurrentCode().intValue() != liftProtocol.getBarcode().intValue()) { |
| | | //小车不在提升机内 |
| | | return; |
| | | continue; |
| | | } |
| | | |
| | | //给提升机分配任务 |
| | |
| | | |
| | | Short liftLev = liftProtocol.getLev(); |
| | | if (liftLev == null) { |
| | | return; |
| | | continue; |
| | | } |
| | | //判断提升机楼层是否到达目标楼层 |
| | | if (liftLev.intValue() != chargeLocNoLev) { |
| | | return;//没有到达目标楼层 |
| | | continue;//没有到达目标楼层 |
| | | } |
| | | |
| | | //此时车在提升机内部,下达一步指令让车移动到提升机口 |
| | | Integer staNo = Utils.levToOutInStaNo(liftLev >= 2 ? liftLev + 1 : liftLev);//站点号 |
| | | BasDevp basDevp = basDevpService.selectById(staNo); |
| | | if (basDevp == null) { |
| | | return;//站点不存在 |
| | | continue;//站点不存在 |
| | | } |
| | | |
| | | //获取小车到充电库位路径指令 |
| | | List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, chargeLocNo, NavigationMapType.NONE.id, assignCommand, shuttleThread); |
| | | //获取提升机口到充电库位路径指令 |
| | | List<ShuttleCommand> commands = this.shuttleAssignCommand(basDevp.getLocNo(), chargeLocNo, NavigationMapType.NONE.id, assignCommand, shuttleThread); |
| | | if (commands == null) { |
| | | return;//未找到路径 |
| | | continue;//未找到路径 |
| | | } |
| | | |
| | | short startCode = liftProtocol.getBarcode();//提升机内部二维码 |