Kstars
schedulerutils.cpp
30 double rotation = 0.0, minimumAltitude = 0.0, minimumMoonSeparation = 0.0, maxMoonAltitude = 90.0;
182void SchedulerUtils::setupJob(SchedulerJob &job, const QString &name, bool isLead, const QString &group,
183 const QString &train, const dms &ra, const dms &dec, double djd, double rotation, const QUrl &sequenceUrl,
184 const QUrl &fitsUrl, StartupCondition startup, const QDateTime &startupTime, CompletionCondition completion,
185 const QDateTime &completionTime, int completionRepeats, double minimumAltitude, double minimumMoonSeparation,
186 double maxMoonAltitude, bool enforceWeather, bool enforceTwilight, bool enforceArtificialHorizon, bool track, bool focus,
228 job.setStepPipeline(static_cast<SchedulerJob::StepPipeline>(job.getStepPipeline() | SchedulerJob::USE_TRACK));
230 job.setStepPipeline(static_cast<SchedulerJob::StepPipeline>(job.getStepPipeline() | SchedulerJob::USE_FOCUS));
232 job.setStepPipeline(static_cast<SchedulerJob::StepPipeline>(job.getStepPipeline() | SchedulerJob::USE_ALIGN));
234 job.setStepPipeline(static_cast<SchedulerJob::StepPipeline>(job.getStepPipeline() | SchedulerJob::USE_GUIDE));
258 const CapturedFramesMap &capturedFramesCount, SchedulerJob &schedJob, CapturedFramesMap &capture_map,
321void SchedulerUtils::updateLightFramesRequired(SchedulerJob * oneJob, const QList<SequenceJob *> &seqjobs,
337 if (oneSeqJob->getFrameType() == FRAME_LIGHT && expected[signature] * oneJob->getRepeatsRequired() > framesCount[signature])
369bool SchedulerUtils::loadSequenceQueue(const QString &fileURL, SchedulerJob * schedJob, QList<SequenceJob *> &jobs,
377 if (logger != nullptr) logger->appendLogText(i18n("Unable to open sequence queue file '%1'", fileURL));
426bool SchedulerUtils::estimateJobTime(SchedulerJob * schedJob, const CapturedFramesMap &capturedFramesCount,
434 bool result = loadSequenceQueue(schedJob->getSequenceFile().toLocalFile(), schedJob, seqJobs, hasAutoFocus, logger);
438 QString("Warning: Failed estimating the duration of job '%1', its sequence file is invalid.").arg(
447 if (schedJob != jobWarned && hasAutoFocus && !(schedJob->getStepPipeline() & SchedulerJob::USE_FOCUS))
450 i18n("Warning: Job '%1' has its focus step disabled, periodic and/or HFR procedures currently set in its sequence will not occur.",
457 * If option "Remember Job Progress" is disabled, this map will be empty, and the Capture module will process all requested captures unconditionally.
471 uint16_t totalCompletedCount = fillCapturedFramesMap(expected, capturedFramesCount, *schedJob, capture_map,
478 QString seqName = i18n("Job '%1' %2x%3\" %4", schedJob->getName(), seqJob->getCoreProperty(SequenceJob::SJ_Count).toInt(),
485 QString("%1 duration cannot be estimated time since the sequence saves the files remotely.").arg(seqName);
494 int captures_required = seqJob->getCoreProperty(SequenceJob::SJ_Count).toInt() * schedJob->getRepeatsRequired();
496 const int capturesRequiredPerRepeat = std::max(1, seqJob->getCoreProperty(SequenceJob::SJ_Count).toInt());
497 int capturesLeftThisRepeat = std::max(0, capturesRequiredPerRepeat - (captures_completed % capturesRequiredPerRepeat));
500 // Something else is causing this iteration to be incomplete. Nothing left to do for this seqJob.
508 * The objective of this block is to fill the storage map of the scheduler job with completed counts for each capture storage.
510 * Sequence jobs capture to a storage folder, and are given a count of captures to store at that location.
511 * The tricky part is to make sure the repeat count of the scheduler job is properly transferred to each sequence job.
513 * For instance, a scheduler job repeated three times must execute the full list of sequence jobs three times, thus
514 * has to tell each sequence job it misses all captures, three times. It cannot tell the sequence job three captures are
515 * missing, first because that's not how the sequence job is designed (completed count, not required count), and second
516 * because this would make the single sequence job repeat three times, instead of repeating the full list of sequence
519 * The consolidated storage map will be assigned to each sequence job based on their signature when the scheduler job executes them.
521 * For instance, consider a RGBL sequence of single captures. The map will store completed captures for R, G, B and L storages.
522 * If R and G have 1 file each, and B and L have no files, map[storage(R)] = map[storage(G)] = 1 and map[storage(B)] = map[storage(L)] = 0.
525 * In the case of a RGBLRGB sequence of single captures, the second R, G and B map items will count one less capture than what is really in storage.
526 * If R and G have 1 file each, and B and L have no files, map[storage(R1)] = map[storage(B1)] = 1, and all others will be 0.
529 * This doesn't handle the case of duplicated scheduler jobs, that is, scheduler jobs with the same storage for capture sets.
530 * Those scheduler jobs will all change state to completion at the same moment as they all target the same storage.
531 * This is why it is important to manage the repeat count of the scheduler job, as stated earlier.
536 qCInfo(KSTARS_EKOS_SCHEDULER) << QString("%1 sees %2 captures in output folder '%3'.").arg(seqName).arg(
539 // Enumerate sequence jobs to check how many captures are completed overall in the same storage as the current one
546 // If the previous sequence signature matches the current, skip counting to take duplicates into account
555 qCDebug(KSTARS_EKOS_SCHEDULER) << QString("%1 has completed %2/%3 of its required captures in output folder '%4'.").arg(
562 captures_completed = schedJob->getCompletedCount() / allCapturesPerRepeat * seqJob->getCoreProperty(
570 // Check if we still need any light frames. Because light frames changes the flow of the observatory startup
572 // We check if the frame type is LIGHT and if either the number of captures_completed frames is less than required
575 // FIXME: As it is implemented now, FINISH_LOOP may loop over a capture-complete, therefore inoperant, scheduler job.
576 bool const areJobCapturesComplete = (0 == captures_required || captures_completed >= captures_required);
581 qCInfo(KSTARS_EKOS_SCHEDULER) << QString("%1 completed its sequence of %2 light frames.").arg(seqName).arg(
597 imagingTimePerRepeat += fabs(secsPerCapture * seqJob->getCoreProperty(SequenceJob::SJ_Count).toInt());
605 // Wild guess, 10s of autofocus for each capture required. Can vary a lot, but this is just a completion estimate.
647 QString("Job '%1' is configured to loop until Scheduler is stopped manually, has undefined imaging time.")
658 qCDebug(KSTARS_EKOS_SCHEDULER) << QString("Job '%1' has a startup time and fixed completion time, will run for %2.")
669 QString("Job '%1' has no startup time but fixed completion time, will run for %2 if started now.")
673 // Rely on the estimated imaging time to determine whether this job is complete or not - this makes the estimated time null
680 qCDebug(KSTARS_EKOS_SCHEDULER) << QString("Job '%1' will not run, complete with %2/%3 captures.")
694 qCInfo(KSTARS_EKOS_SCHEDULER) << QString("Job '%1' estimated to take %2 to complete.").arg(schedJob->getName(),
704 /* FIXME: estimation should base on actual measure of each step, eventually with preliminary data as what it used now */
744 expected[signature] = static_cast<uint16_t>(seqJob->getCoreProperty(SequenceJob::SJ_Count).toInt()) + (expected.contains(
750double SchedulerUtils::findAltitude(const SkyPoint &target, const QDateTime &when, bool * is_setting,
753 // FIXME: block calculating target coordinates at a particular time is duplicated in several places
757 // Retrieve the argument date/time, or fall back to current time - don't use QDateTime's timezone!
784 qCDebug(KSTARS_EKOS_SCHEDULER) << QString("When:%9 LST:%8 RA:%1 RA0:%2 DEC:%3 DEC0:%4 alt:%5 setting:%6 HA:%7")
a dms subclass that caches its sine and cosine values every time the angle is changed.
Definition cachingdms.h:19
Contains all relevant information for specifying a location on Earth: City Name, State/Province name,...
Definition geolocation.h:28
There are several time-dependent values used in position calculations, that are not specific to an ob...
Definition ksnumbers.h:43
Extension of QDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day,...
Definition kstarsdatetime.h:36
Sequence Job is a container for the details required to capture a series of images.
Provides all necessary information about an object in the sky: its coordinates, name(s),...
Definition skyobject.h:50
virtual void updateCoordsNow(const KSNumbers *num)
updateCoordsNow Shortcut for updateCoords( const KSNumbers *num, false, nullptr, nullptr,...
Definition skypoint.h:410
void EquatorialToHorizontal(const CachingDms *LST, const CachingDms *lat)
Determine the (Altitude, Azimuth) coordinates of the SkyPoint from its (RA, Dec) coordinates,...
Definition skypoint.cpp:77
const QString toHMSString(const bool machineReadable=false, const bool highPrecision=false) const
Definition dms.cpp:378
QString i18n(const char *text, const TYPE &arg...)
QMap< QString, uint16_t > CapturedFramesMap
mapping signature --> frames count
Definition capturetypes.h:16
CompletionCondition
Conditions under which a SchedulerJob may complete.
Definition schedulertypes.h:80
GeoCoordinates geo(const QVariant &location)
QString name(const QVariant &location)
QString path(const QString &relativePath)
const QList< QKeySequence > & completion()
QCA_EXPORT Logger * logger()
QDateTime fromString(QStringView string, QStringView format, QCalendar cal)
bool isValid() const const
Qt::TimeSpec timeSpec() const const
bool open(FILE *fh, OpenMode mode, FileHandleFlags handleFlags)
void setFileName(const QString &name)
QString path() const const
bool getChar(char *c)
ReadOnly
void append(QList< T > &&value)
qsizetype count() const const
T & first()
QLocale c()
double toDouble(QStringView s, bool *ok) const const
int toInt(QStringView s, bool *ok) const const
QString arg(Args &&... args) const const
int compare(QLatin1StringView s1, const QString &s2, Qt::CaseSensitivity cs)
ISODate
UTC
QTextStream & dec(QTextStream &stream)
QUrl fromUserInput(const QString &userInput, const QString &workingDirectory, UserInputResolutionOptions options)
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Feb 21 2025 11:54:28 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Feb 21 2025 11:54:28 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.