10#include "schedulertypes.h"
11#include "ekos/capture/sequencejob.h"
15#include "kstarsdatetime.h"
20class TestSchedulerUnit;
21class TestEkosSchedulerOps;
49 bool isDarkFlat =
false;
52 JobProgress(
int numCompleted,
const SequenceJob *job)
53 : numCompleted(numCompleted),
type(job->getFrameType()),
54 isDarkFlat(job->jobType() ==
SequenceJob::JOBTYPE_DARKFLAT),
60 SkyPoint const &getTargetCoords()
const
62 if (m_LeadJob !=
nullptr)
63 return m_LeadJob->getTargetCoords();
67 void setTargetCoords(
const dms &ra,
const dms &dec,
double djd);
70 double getPositionAngle()
72 return m_PositionAngle;
74 void setPositionAngle(
double value);
78 QUrl getSequenceFile()
const
82 void setSequenceFile(
const QUrl &value);
87 QUrl getFITSFile()
const
89 if (m_LeadJob !=
nullptr)
90 return m_LeadJob->getFITSFile();
94 void setFITSFile(
const QUrl &value);
99 double getMinAltitude()
const
101 if (m_LeadJob !=
nullptr)
102 return m_LeadJob->getMinAltitude();
106 void setMinAltitude(
const double &value);
111 bool hasMinAltitude()
const
113 return UNDEFINED_ALTITUDE < getMinAltitude();
115 static constexpr int UNDEFINED_ALTITUDE = -90;
120 bool hasAltitudeConstraint()
const;
125 double getMinMoonSeparation()
const
127 if (m_LeadJob !=
nullptr)
128 return m_LeadJob->getMinMoonSeparation();
130 return minMoonSeparation;
132 void setMinMoonSeparation(
const double &value);
137 bool getEnforceWeather()
const
139 if (m_LeadJob !=
nullptr)
140 return m_LeadJob->getEnforceWeather();
142 return enforceWeather;
144 void setEnforceWeather(
bool value);
149 StepPipeline getStepPipeline()
const
151 if (m_LeadJob !=
nullptr)
152 return m_LeadJob->getStepPipeline();
156 void setStepPipeline(
const StepPipeline &value);
161 StartupCondition getStartupCondition()
const
163 if (m_LeadJob !=
nullptr)
164 return m_LeadJob->getStartupCondition();
166 return startupCondition;
168 void setStartupCondition(
const StartupCondition &value);
173 CompletionCondition getCompletionCondition()
const
175 return completionCondition;
177 void setCompletionCondition(
const CompletionCondition &value);
182 StartupCondition getFileStartupCondition()
const
184 if (m_LeadJob !=
nullptr)
185 return m_LeadJob->getFileStartupCondition();
187 return fileStartupCondition;
189 void setFileStartupCondition(
const StartupCondition &value);
196 if (m_LeadJob !=
nullptr)
197 return m_LeadJob->getStartAtTime();
201 void setStartAtTime(
const QDateTime &value);
206 bool getInSequenceFocus()
const
208 return inSequenceFocus;
210 void setInSequenceFocus(
bool value);
215 bool getEnforceTwilight()
const
217 if (m_LeadJob !=
nullptr)
218 return m_LeadJob->getEnforceTwilight();
220 return enforceTwilight;
222 void setEnforceTwilight(
bool value);
227 bool getEnforceArtificialHorizon()
const
229 if (m_LeadJob !=
nullptr)
230 return m_LeadJob->getEnforceArtificialHorizon();
232 return enforceArtificialHorizon;
234 void setEnforceArtificialHorizon(
bool value);
241 if (m_LeadJob !=
nullptr)
242 return m_LeadJob->getName();
246 void setName(
const QString &value);
255 void setIsLead(
bool value)
265 if (m_LeadJob !=
nullptr)
266 return m_LeadJob->getGroup();
270 void setGroup(
const QString &value);
275 QString getOpticalTrain()
const
279 void setOpticalTrain(
const QString &value)
281 opticalTrain = value;
287 int getCompletedIterations()
const
289 return completedIterations;
291 void setCompletedIterations(
int value);
301 SchedulerJobStatus getState()
const
309 bool isStopped()
const
319 return lastAbortTime;
323 return lastErrorTime;
325 void setState(
const SchedulerJobStatus &value,
bool force =
false);
327 void setFollowerState(
const SchedulerJobStatus &value,
bool force);
332 void updateSharedFollowerAttributes();
337 SchedulerJobStage getStage()
const
341 void setStage(
const SchedulerJobStage &value);
346 int getSequenceCount()
const
348 return sequenceCount;
350 void setSequenceCount(
const int count);
355 int getCompletedCount()
const
357 return completedCount;
359 void setCompletedCount(
const int count);
368 void setStartupTime(
const QDateTime &value,
bool refreshDawnDusk =
true);
381 const QString &getStopReason()
const
385 void setStopReason(
const QString &reason)
389 void setFinishAtTime(
const QDateTime &value);
391 void setStopTime(
const QDateTime &value);
395 int64_t getEstimatedTime()
const
397 return estimatedTime;
399 void setEstimatedTime(
const int64_t &value);
404 int64_t getEstimatedTimePerRepeat()
const
406 return estimatedTimePerRepeat;
408 void setEstimatedTimePerRepeat(
const int64_t &value)
410 estimatedTimePerRepeat = value;
415 int64_t getEstimatedStartupTime()
const
417 if (m_LeadJob !=
nullptr)
418 return m_LeadJob->getEstimatedStartupTime();
420 return estimatedStartupTime;
422 void setEstimatedStartupTime(
const int64_t &value)
424 estimatedStartupTime = value;
429 int64_t getEstimatedTimeLeftThisRepeat()
const
431 return estimatedTimeLeftThisRepeat;
433 void setEstimatedTimeLeftThisRepeat(
const int64_t &value)
435 estimatedTimeLeftThisRepeat = value;
440 bool getLightFramesRequired()
const
442 return lightFramesRequired;
444 void setLightFramesRequired(
bool value);
449 bool getCalibrationMountPark()
const
451 return m_CalibrationMountPark;
453 void setCalibrationMountPark(
bool value);
458 uint16_t getRepeatsRequired()
const
460 return repeatsRequired;
462 void setRepeatsRequired(
const uint16_t &value);
467 uint16_t getRepeatsRemaining()
const
469 return repeatsRemaining;
471 void setRepeatsRemaining(
const uint16_t &value);
478 void addProgress(
int numCompleted,
const SequenceJob *job)
480 m_Progress.
append(JobProgress(numCompleted, job));
484 const QString getProgressSummary()
const;
491 return capturedFramesMap;
509 bool isDuplicateOf(SchedulerJob
const *a_job)
const
511 return this != a_job && name == a_job->getName() && sequenceFile == a_job->sequenceFile;
525 static bool decreasingAltitudeOrder(SchedulerJob
const *a, SchedulerJob
const *b,
QDateTime const &when =
QDateTime());
540 QDateTime calculateNextTime(
QDateTime const &when,
bool checkIfConstraintsAreMet =
true,
int increment = 1,
542 QDateTime getNextPossibleStartTime(
const QDateTime &when,
int increment = 1,
bool runningJob =
false,
552 QDateTime getDawnAstronomicalTwilight()
const
554 if (m_LeadJob !=
nullptr)
555 return m_LeadJob->getDawnAstronomicalTwilight();
565 QDateTime getDuskAstronomicalTwilight()
const
567 if (m_LeadJob !=
nullptr)
568 return m_LeadJob->getDuskAstronomicalTwilight();
588 bool satisfiesAltitudeConstraint(
double azimuth,
double altitude,
QString *altitudeReason =
nullptr)
const;
594 void setInitialFilter(
const QString &value);
595 const QString &getInitialFilter()
const;
598 static QString jobStatusString(SchedulerJobStatus status);
599 static QString jobStageString(SchedulerJobStage stage);
600 QString jobStartupConditionString(StartupCondition condition)
const;
601 QString jobCompletionConditionString(CompletionCondition condition)
const;
606 startTimeCache.clear();
608 double getAltitudeAtStartup()
const
610 if (m_LeadJob !=
nullptr)
611 return m_LeadJob->getAltitudeAtStartup();
613 return altitudeAtStartup;
615 double getAltitudeAtStop()
const
617 return altitudeAtStop;
619 bool isSettingAtStartup()
const
621 if (m_LeadJob !=
nullptr)
622 return m_LeadJob->isSettingAtStartup();
624 return settingAtStartup;
626 bool isSettingAtStop()
const
628 return settingAtStop;
631 SchedulerJob *leadJob()
const
635 void setLeadJob(SchedulerJob *newLeadJob)
637 m_LeadJob = newLeadJob;
642 return m_followerJobs;
645 void setStartupFormatted(
const QString &value)
647 m_StartupFormatted = value;
649 const QString &startupFormatted()
const
651 return m_StartupFormatted;
654 void setEndFormatted(
const QString &value)
656 m_EndFormatted = value;
658 const QString &endFormatted()
const
660 return m_EndFormatted;
663 void setAltitudeFormatted(
const QString &value)
665 m_AltitudeFormatted = value;
667 const QString &altitudeFormatted()
const
669 return m_AltitudeFormatted;
673 bool runsDuringAstronomicalNightTimeInternal(
const QDateTime &time,
QDateTime *minDawnDusk,
674 QDateTime *nextPossibleSuccess =
nullptr)
const;
677 SchedulerJob(
KSMoon *moonPtr);
678 friend TestSchedulerUnit;
679 friend TestEkosSchedulerOps;
691 storedHorizon = horizon;
693 static bool hasHorizon()
695 return storedHorizon !=
nullptr;
701 bool m_isLead {
true };
704 int completedIterations { 0 };
706 double m_PositionAngle { -1 };
708 SchedulerJobStage stage { SCHEDSTAGE_IDLE };
711 SchedulerJob *m_LeadJob {
nullptr };
712 QList <SchedulerJob *> m_followerJobs;
720 StartupCondition fileStartupCondition { START_ASAP };
721 StartupCondition startupCondition { START_ASAP };
722 CompletionCondition completionCondition { FINISH_SEQUENCE };
724 int sequenceCount { 0 };
725 int completedCount { 0 };
741 double altitudeAtStartup { 0 };
742 double altitudeAtStop { 0 };
743 bool settingAtStartup {
false };
744 bool settingAtStop {
false };
750 double minAltitude { UNDEFINED_ALTITUDE };
751 double minMoonSeparation { -1 };
753 bool enforceWeather {
false };
754 bool enforceTwilight {
false };
755 bool enforceArtificialHorizon {
false };
760 StepPipeline stepPipeline { USE_NONE };
762 int64_t estimatedTime { -1 };
763 int64_t estimatedTimePerRepeat { 0 };
764 int64_t estimatedStartupTime { 0 };
765 int64_t estimatedTimeLeftThisRepeat { 0 };
766 uint16_t repeatsRequired { 1 };
767 uint16_t repeatsRemaining { 1 };
768 bool inSequenceFocus {
false };
773 QString m_StartupFormatted, m_EndFormatted, m_AltitudeFormatted;
775 bool lightFramesRequired {
false };
776 bool m_CalibrationMountPark {
false};
794 struct StartTimeComputation
814 StartTimeCache startTimeCache;
Represents custom area from the horizon upwards which represent blocked views from the vantage point ...
Contains all relevant information for specifying a location on Earth: City Name, State/Province name,...
Provides necessary information about the Moon.
Extension of QDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day,...
Sequence Job is a container for the details required to capture a series of images.
The sky coordinates of a point in the sky.
An angle, stored as degrees, but expressible in many ways.
Type type(const QSqlDatabase &db)
Ekos is an advanced Astrophotography tool for Linux.
@ SCHEDJOB_ABORTED
Job encountered a transitory issue while processing, and will be rescheduled.
@ SCHEDJOB_IDLE
Job was just created, and is not evaluated yet.
QMap< QString, uint16_t > CapturedFramesMap
mapping signature --> frames count
QString name(StandardAction id)
void append(QList< T > &&value)