| | |
| | | /** |
| | | * 站点任务检测 下发小车取放任务 |
| | | */ |
| | | public synchronized List<List<List<WrkMast>>> DevpTaskNoRun() { |
| | | List<List<List<WrkMast>>> wrkMastListAll = new ArrayList<>(); |
| | | public synchronized void DevpTaskNoRun() { |
| | | |
| | | try { |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", 1L).orderBy("modi_time", true)); |
| | | if (wrkMasts.isEmpty()) { |
| | | return wrkMastListAll; |
| | | return; |
| | | } |
| | | long differenceInSeconds = TimeCalculatorUtils.differenceInMilliseconds(wrkMasts.get(0).getModiTime(), new Date()); |
| | | if (differenceInSeconds <= 1000) { |
| | | return wrkMastListAll; |
| | | return; |
| | | } |
| | | |
| | | BasCircularShuttle basCircularShuttle = basCircularShuttleService.selectOne(new EntityWrapper<BasCircularShuttle>().eq("rgv_id", 1)); |
| | | RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, basCircularShuttle.getRgvNo()); |
| | | RgvProtocol rgvProtocol = rgvThread.getRgvProtocol(); |
| | | if (rgvProtocol == null) { |
| | | return wrkMastListAll; |
| | | return; |
| | | } |
| | | List<BasDevpPosition> basDevpPositions = basDevpPositionService.selectList(new EntityWrapper<BasDevpPosition>().orderBy("plc_position", true)); |
| | | List<BasDevpPosition> basDevpPositionDevRegion = basDevpPositionService.selectList(new EntityWrapper<BasDevpPosition>().orderBy("dev_region", true)); |
| | |
| | | BasDevpPosition[] basDevpPositionsListUN = SortTheExecutionOfTheCarUtil.devpNoSortUN(basDevpPositionsList); |
| | | List<List<Integer>> siteListAll = SortTheExecutionOfTheCarUtil.siteListAll(basDevpPositionDevRegion); |
| | | // List<List<WrkMast>> wrkMastLists = getWrkMastLists(basDevpPositionsListUN); |
| | | return getWrkMastListAll(siteListAll,basDevpPositionsListUN); |
| | | List<List<List<WrkMast>>> wrkMastListAll = getWrkMastListAll(siteListAll, basDevpPositionsListUN); |
| | | //下发任务 |
| | | // taskDown(wrkMastLists); |
| | | |
| | | taskDown(wrkMastListAll); |
| | | } catch (Exception e) { |
| | | log.error("自动下发小车取放任务失败,异常:" + e); |
| | | } |
| | | return wrkMastListAll; |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | // public synchronized void taskDown(List<List<WrkMast>> wrkMastLists) { |
| | | // long rgvId = 0; |
| | | // runRgv: |
| | | // for (List<WrkMast> wrkMastList : wrkMastLists) { |
| | | // for (WrkMast wrkMast : wrkMastList) { |
| | | // while (rgvId <= rgvCount) { |
| | | // rgvId++; |
| | | //// log.info("存在任务,RGV号={},任务数据={}", rgvId, JSON.toJSON(wrkMast)); |
| | | // if (rgvId > rgvCount) { |
| | | // break runRgv; |
| | | // } |
| | | // BasCircularShuttle basCircularShuttle = basCircularShuttleService.selectOne(new EntityWrapper<BasCircularShuttle>().eq("rgv_id", rgvId)); |
| | | // if (basCircularShuttle.getStatus() != 0){ |
| | | // continue ; |
| | | // } |
| | | // RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, basCircularShuttle.getRgvNo()); |
| | | // RgvProtocol rgvProtocol = rgvThread.getRgvProtocol(); |
| | | // if (rgvProtocol == null) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("rgv_no", rgvProtocol.getRgvNo()).eq("wrk_sts", 2L)); |
| | | // if (!wrkMasts.isEmpty()) { |
| | | // continue; |
| | | // } |
| | | // if (rgvProtocol != null |
| | | // && rgvProtocol.modeType == RgvModeType.AUTO |
| | | // && (rgvProtocol.getStatusType() == RgvStatusType.IDLE || rgvProtocol.getStatusType() == RgvStatusType.ROAM) |
| | | // && rgvProtocol.getTaskNo1() == 0 |
| | | // && rgvProtocol.getAlarm() == 0) { |
| | | // if (rgvProtocol.getStatusType() == RgvStatusType.ROAM) { |
| | | // double finalVelocity = 0.0; // 最终速度 (m/s) |
| | | // double distance = (Math.pow(finalVelocity, 2) - Math.pow(rgvProtocol.instantaneousSpeed / 60, 2)) / (2 * acceleration); |
| | | // BasDevpPosition basDevpPosition = basDevpPositionService.selectOne(new EntityWrapper<BasDevpPosition>().eq("dev_no", wrkMast.getSourceStaNo())); |
| | | // if ((distance * proportion + (rgvProtocol.instantaneousSpeed / 60) * proportion * rgvDate) > (SortTheExecutionOfTheCarUtil.LatelyAndLessThan(basDevpPosition.getPlcPosition(), rgvProtocol.getRgvPos(), perimeter) )) { |
| | | //// List<BasDevpPosition> basDevpPositions = basDevpPositionService.selectList(new EntityWrapper<BasDevpPosition>().orderBy("plc_position", true)); |
| | | //// if (basDevpPositions.isEmpty()) { |
| | | //// log.error("获取所有站点信息异常,RGV任务下发失败,请联系管理员!!!"); |
| | | //// break runRgv; |
| | | //// } |
| | | //// List<Integer> devpList = SortTheExecutionOfTheCarUtil.BasDevpPositionExtractSites(basDevpPositions); |
| | | //// |
| | | //// if (!SortTheExecutionOfTheCarUtil.calculateShortestDistanceDirection(devpList,rgvProtocol.getEndStaM(),wrkMast.getSourceStaNo())){ |
| | | // continue; |
| | | //// } |
| | | // } |
| | | // } |
| | | // RgvCommand rgvCommand = new RgvCommand(); |
| | | // rgvCommand.setRgvNo(rgvProtocol.getRgvNo()); |
| | | // rgvCommand.setAckFinish1((short) 0); // 工位1任务完成确认位 |
| | | // rgvCommand.setTaskNo1(wrkMast.getWrkNo().shortValue()); |
| | | // rgvCommand.setTaskMode1(RgvTaskModeType.FETCH_PUT); // 工位1任务模式: 取放货 |
| | | // rgvCommand.setSourceStaNo1(wrkMast.getSourceStaNo().shortValue()); //工位1起点 |
| | | // rgvCommand.setDestinationStaNo1(wrkMast.getStaNo().shortValue()); //工位1目标站点 |
| | | // rgvCommand.setCommand((short) 1); //工位1任务确认 |
| | | // rgvCommand.setRgvSome(basCircularShuttle.getRgvSome()==1 ? (short) 1 : (short) 0); |
| | | // if (!MessageQueue.offer(SlaveType.Rgv, rgvProtocol.getRgvNo(), new Task(2, rgvCommand))) { |
| | | // // |
| | | // log.error("RGV命令下发失败,RGV号={},任务数据={}", rgvId, JSON.toJSON(rgvCommand)); |
| | | // break runRgv; |
| | | // } |
| | | // log.info("RGV命令下发成功,RGV号={},任务数据={}", rgvId, JSON.toJSON(rgvCommand)); |
| | | // |
| | | // wrkMast.setWrkSts(2L); |
| | | // wrkMast.setRgvNo(rgvProtocol.getRgvNo()); |
| | | // Date now = new Date(); |
| | | // wrkMast.setAppeTime(now); |
| | | // wrkMast.setCrnStrTime(now); |
| | | // try { |
| | | // wrkMastService.updateById(wrkMast); |
| | | // break; |
| | | // } catch (Exception e) { |
| | | // log.error("更新小车任务失败,任务号:" + wrkMast.getWrkNo()); |
| | | // } |
| | | // break runRgv; |
| | | // } else if (rgvProtocol != null |
| | | // && rgvProtocol.modeType == RgvModeType.AUTO |
| | | // && rgvProtocol.getStatusType() == RgvStatusType.WALK |
| | | // && rgvProtocol.getTaskNo1() == 0 |
| | | // && rgvProtocol.getAlarm() == 0) { |
| | | // if (rgvProtocol.getStatusType() == RgvStatusType.WALK) { |
| | | // double finalVelocity = 0.0; // 最终速度 (m/s) |
| | | // double distance = (Math.pow(finalVelocity, 2) - Math.pow(rgvProtocol.instantaneousSpeed / 60, 2)) / (2 * acceleration); |
| | | // BasDevpPosition basDevpPosition = basDevpPositionService.selectOne(new EntityWrapper<BasDevpPosition>().eq("dev_no", wrkMast.getSourceStaNo())); |
| | | // if ((distance * proportion + (rgvProtocol.instantaneousSpeed / 60) * proportion * rgvDate) > (SortTheExecutionOfTheCarUtil.LatelyAndLessThan(basDevpPosition.getPlcPosition(), rgvProtocol.getRgvPos(), perimeter) )) { |
| | | //// List<BasDevpPosition> basDevpPositions = basDevpPositionService.selectList(new EntityWrapper<BasDevpPosition>().orderBy("plc_position", true)); |
| | | //// if (basDevpPositions.isEmpty()) { |
| | | //// log.error("获取所有站点信息异常,RGV任务下发失败,请联系管理员!!!"); |
| | | //// break runRgv; |
| | | //// } |
| | | //// List<Integer> devpList = SortTheExecutionOfTheCarUtil.BasDevpPositionExtractSites(basDevpPositions); |
| | | //// |
| | | //// if (!SortTheExecutionOfTheCarUtil.calculateShortestDistanceDirection(devpList,rgvProtocol.getEndStaM(),wrkMast.getSourceStaNo())){ |
| | | // continue; |
| | | //// } |
| | | // } |
| | | // } |
| | | // RgvCommand rgvCommand = new RgvCommand(); |
| | | // rgvCommand.setRgvNo(rgvProtocol.getRgvNo()); |
| | | // rgvCommand.setAckFinish1((short) 0); // 工位1任务完成确认位 |
| | | // rgvCommand.setTaskNo1(wrkMast.getWrkNo().shortValue()); |
| | | // rgvCommand.setTaskMode1(RgvTaskModeType.X_MOVE); // 工位1任务模式: 取放货 |
| | | // rgvCommand.setSourceStaNo1(wrkMast.getSourceStaNo().shortValue()); //工位1起点 |
| | | // rgvCommand.setDestinationStaNo1(wrkMast.getStaNo().shortValue()); //工位1目标站点 |
| | | // rgvCommand.setCommand((short) 1); //工位1任务确认 |
| | | // rgvCommand.setRgvSome(basCircularShuttle.getRgvSome()==1 ? (short) 1 : (short) 0); |
| | | // if (!MessageQueue.offer(SlaveType.Rgv, rgvProtocol.getRgvNo(), new Task(3, rgvCommand))) { |
| | | // // |
| | | // log.error("RGV命令下发失败,RGV号={},任务数据={}", rgvId, JSON.toJSON(rgvCommand)); |
| | | // break runRgv; |
| | | // } |
| | | // log.info("RGV命令下发成功,RGV号={},任务数据={}", rgvId, JSON.toJSON(rgvCommand)); |
| | | // |
| | | // wrkMast.setWrkSts(2L); |
| | | // wrkMast.setRgvNo(rgvProtocol.getRgvNo()); |
| | | // Date now = new Date(); |
| | | // wrkMast.setAppeTime(now); |
| | | // wrkMast.setCrnStrTime(now); |
| | | // try { |
| | | // wrkMastService.updateById(wrkMast); |
| | | // break; |
| | | // } catch (Exception e) { |
| | | // log.error("更新小车任务失败,任务号:" + wrkMast.getWrkNo()); |
| | | // } |
| | | // break runRgv; |
| | | // } else { |
| | | // break runRgv; |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | public synchronized void taskDown(List<List<List<WrkMast>>> wrkMastListAll) { |
| | | //0小车车号 1小车编号 |
| | | List<Integer> rgvNoM = new ArrayList<>(); |
| | | List<Integer> rgvNoR = new ArrayList<>(); |
| | | int wrkMastRunCount = 0; |