10#include "schedulertypes.h"
11#include "ekos/capture/sequencejob.h"
15#include "kstarsdatetime.h"
20class TestSchedulerUnit;
21class TestEkosSchedulerOps;
31 QJsonObject toJson()
const;
49 bool isDarkFlat =
false;
50 QMap<SequenceJob::PropertyID, QVariant> properties;
52 JobProgress(
int numCompleted,
const SequenceJob *job)
53 : numCompleted(numCompleted), type(job->getFrameType()),
54 isDarkFlat(job->jobType() == SequenceJob::JOBTYPE_DARKFLAT),
55 properties(job->getCoreProperties()) {};
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 double getMaxMoonAltitude()
const
139 if (m_LeadJob !=
nullptr)
140 return m_LeadJob->getMaxMoonAltitude();
142 return maxMoonAltitude;
144 void setMaxMoonAltitude(
const double &value);
149 bool getEnforceWeather()
const
151 if (m_LeadJob !=
nullptr)
152 return m_LeadJob->getEnforceWeather();
154 return enforceWeather;
156 void setEnforceWeather(
bool value);
161 StepPipeline getStepPipeline()
const
163 if (m_LeadJob !=
nullptr)
164 return m_LeadJob->getStepPipeline();
168 void setStepPipeline(
const StepPipeline &value);
175 if (m_LeadJob !=
nullptr)
176 return m_LeadJob->getStartupCondition();
178 return startupCondition;
187 return completionCondition;
196 if (m_LeadJob !=
nullptr)
197 return m_LeadJob->getFileStartupCondition();
199 return fileStartupCondition;
206 QDateTime getStartAtTime()
const
208 if (m_LeadJob !=
nullptr)
209 return m_LeadJob->getStartAtTime();
213 void setStartAtTime(
const QDateTime &value);
218 bool getInSequenceFocus()
const
220 return inSequenceFocus;
222 void setInSequenceFocus(
bool value);
227 bool getEnforceTwilight()
const
229 if (m_LeadJob !=
nullptr)
230 return m_LeadJob->getEnforceTwilight();
232 return enforceTwilight;
234 void setEnforceTwilight(
bool value);
239 bool getEnforceArtificialHorizon()
const
241 if (m_LeadJob !=
nullptr)
242 return m_LeadJob->getEnforceArtificialHorizon();
244 return enforceArtificialHorizon;
246 void setEnforceArtificialHorizon(
bool value);
251 QString getName()
const
253 if (m_LeadJob !=
nullptr)
254 return m_LeadJob->getName();
258 void setName(
const QString &value);
267 void setIsLead(
bool value)
275 QString getGroup()
const
277 if (m_LeadJob !=
nullptr)
278 return m_LeadJob->getGroup();
282 void setGroup(
const QString &value);
287 QString getOpticalTrain()
const
291 void setOpticalTrain(
const QString &value)
293 opticalTrain = value;
299 int getCompletedIterations()
const
301 return completedIterations;
303 void setCompletedIterations(
int value);
321 bool isStopped()
const
325 QDateTime getStateTime()
const
329 QDateTime getLastAbortTime()
const
331 return lastAbortTime;
333 QDateTime getLastErrorTime()
const
335 return lastErrorTime;
344 void updateSharedFollowerAttributes();
358 int getSequenceCount()
const
360 return sequenceCount;
362 void setSequenceCount(
const int count);
367 int getCompletedCount()
const
369 return completedCount;
371 void setCompletedCount(
const int count);
376 QDateTime getStartupTime()
const
380 void setStartupTime(
const QDateTime &value,
bool refreshDawnDusk =
true);
385 QDateTime getFinishAtTime()
const
389 QDateTime getStopTime()
const
393 const QString &getStopReason()
const
397 void setStopReason(
const QString &reason)
401 void setFinishAtTime(
const QDateTime &value);
403 void setStopTime(
const QDateTime &value);
407 int64_t getEstimatedTime()
const
409 return estimatedTime;
411 void setEstimatedTime(
const int64_t &value);
416 int64_t getEstimatedTimePerRepeat()
const
418 return estimatedTimePerRepeat;
420 void setEstimatedTimePerRepeat(
const int64_t &value)
422 estimatedTimePerRepeat = value;
427 int64_t getEstimatedStartupTime()
const
429 if (m_LeadJob !=
nullptr)
430 return m_LeadJob->getEstimatedStartupTime();
432 return estimatedStartupTime;
434 void setEstimatedStartupTime(
const int64_t &value)
436 estimatedStartupTime = value;
441 int64_t getEstimatedTimeLeftThisRepeat()
const
443 return estimatedTimeLeftThisRepeat;
445 void setEstimatedTimeLeftThisRepeat(
const int64_t &value)
447 estimatedTimeLeftThisRepeat = value;
452 bool getLightFramesRequired()
const
454 return lightFramesRequired;
456 void setLightFramesRequired(
bool value);
461 bool getCalibrationMountPark()
const
463 return m_CalibrationMountPark;
465 void setCalibrationMountPark(
bool value);
470 uint16_t getRepeatsRequired()
const
472 return repeatsRequired;
474 void setRepeatsRequired(
const uint16_t &value);
479 uint16_t getRepeatsRemaining()
const
481 return repeatsRemaining;
483 void setRepeatsRemaining(
const uint16_t &value);
490 void addProgress(
int numCompleted,
const SequenceJob *job)
492 m_Progress.append(JobProgress(numCompleted, job));
496 const QString getProgressSummary()
const;
503 return capturedFramesMap;
521 bool isDuplicateOf(SchedulerJob
const *a_job)
const
523 return this != a_job && name == a_job->getName() && sequenceFile == a_job->sequenceFile;
537 static bool decreasingAltitudeOrder(SchedulerJob
const *a, SchedulerJob
const *b, QDateTime
const &when = QDateTime());
546 bool moonConstraintsOK(QDateTime
const &when = QDateTime(), QString *reason =
new QString())
const;
554 QDateTime calculateNextTime(QDateTime
const &when,
bool checkIfConstraintsAreMet =
true,
int increment = 1,
555 QString *reason =
nullptr,
bool runningJob =
false,
const QDateTime &until = QDateTime())
const;
556 QDateTime getNextPossibleStartTime(
const QDateTime &when,
int increment = 1,
bool runningJob =
false,
557 const QDateTime &until = QDateTime())
const;
558 QDateTime getNextEndTime(
const QDateTime &start,
int increment = 1, QString *reason =
nullptr,
559 const QDateTime &until = QDateTime())
const;
566 QDateTime getDawnAstronomicalTwilight()
const
568 if (m_LeadJob !=
nullptr)
569 return m_LeadJob->getDawnAstronomicalTwilight();
579 QDateTime getDuskAstronomicalTwilight()
const
581 if (m_LeadJob !=
nullptr)
582 return m_LeadJob->getDuskAstronomicalTwilight();
593 bool runsDuringAstronomicalNightTime(
const QDateTime &time = QDateTime(), QDateTime *nextPossibleSuccess =
nullptr)
const;
602 bool satisfiesAltitudeConstraint(
double azimuth,
double altitude, QString *altitudeReason =
nullptr)
const;
608 void setInitialFilter(
const QString &value);
609 const QString &getInitialFilter()
const;
620 startTimeCache.clear();
622 double getAltitudeAtStartup()
const
624 if (m_LeadJob !=
nullptr)
625 return m_LeadJob->getAltitudeAtStartup();
627 return altitudeAtStartup;
629 double getAltitudeAtStop()
const
631 return altitudeAtStop;
633 bool isSettingAtStartup()
const
635 if (m_LeadJob !=
nullptr)
636 return m_LeadJob->isSettingAtStartup();
638 return settingAtStartup;
640 bool isSettingAtStop()
const
642 return settingAtStop;
645 SchedulerJob *leadJob()
const
649 void setLeadJob(SchedulerJob *newLeadJob)
651 m_LeadJob = newLeadJob;
654 QList<SchedulerJob *> &followerJobs()
656 return m_followerJobs;
659 void setStartupFormatted(
const QString &value)
661 m_StartupFormatted = value;
663 const QString &startupFormatted()
const
665 return m_StartupFormatted;
668 void setEndFormatted(
const QString &value)
670 m_EndFormatted = value;
672 const QString &endFormatted()
const
674 return m_EndFormatted;
677 void setAltitudeFormatted(
const QString &value)
679 m_AltitudeFormatted = value;
681 const QString &altitudeFormatted()
const
683 return m_AltitudeFormatted;
687 bool runsDuringAstronomicalNightTimeInternal(
const QDateTime &time, QDateTime *minDawnDusk,
688 QDateTime *nextPossibleSuccess =
nullptr)
const;
691 SchedulerJob(KSMoon *moonPtr);
692 friend TestSchedulerUnit;
693 friend TestEkosSchedulerOps;
697 static KStarsDateTime getLocalTime();
702 static const ArtificialHorizon *getHorizon();
703 static void setHorizon(ArtificialHorizon *horizon)
705 storedHorizon = horizon;
707 static bool hasHorizon()
709 return storedHorizon !=
nullptr;
715 bool m_isLead {
true };
717 QString opticalTrain;
718 int completedIterations { 0 };
719 SkyPoint targetCoords;
720 double m_PositionAngle { -1 };
725 SchedulerJob *m_LeadJob {
nullptr };
726 QList <SchedulerJob *> m_followerJobs;
731 QDateTime lastAbortTime;
732 QDateTime lastErrorTime;
738 int sequenceCount { 0 };
739 int completedCount { 0 };
742 QDateTime startAtTime;
744 QDateTime startupTime;
746 QDateTime finishAtTime;
755 double altitudeAtStartup { 0 };
756 double altitudeAtStop { 0 };
757 bool settingAtStartup {
false };
758 bool settingAtStop {
false };
764 double minAltitude { UNDEFINED_ALTITUDE };
765 double minMoonSeparation { -1 };
766 double maxMoonAltitude { 90 };
768 bool enforceWeather {
false };
769 bool enforceTwilight {
false };
770 bool enforceArtificialHorizon {
false };
775 StepPipeline stepPipeline { USE_NONE };
777 int64_t estimatedTime { -1 };
778 int64_t estimatedTimePerRepeat { 0 };
779 int64_t estimatedStartupTime { 0 };
780 int64_t estimatedTimeLeftThisRepeat { 0 };
781 uint16_t repeatsRequired { 1 };
782 uint16_t repeatsRemaining { 1 };
783 bool inSequenceFocus {
false };
784 QString m_InitialFilter;
786 QString dateTimeDisplayFormat;
788 QString m_StartupFormatted, m_EndFormatted, m_AltitudeFormatted;
790 bool lightFramesRequired {
false };
791 bool m_CalibrationMountPark {
false};
796 KSMoon *moon {
nullptr };
799 QList<JobProgress> m_Progress;
809 struct StartTimeComputation
818 bool check(
const QDateTime &from,
const QDateTime &until,
819 QDateTime *result, QDateTime *newFrom)
const;
821 void add(
const QDateTime &from,
const QDateTime &until,
const QDateTime &result)
const;
827 mutable QList<StartTimeComputation> startComputations;
829 StartTimeCache startTimeCache;
832 static KStarsDateTime *storedLocalTime;
833 static GeoLocation *storedGeo;
834 static ArtificialHorizon *storedHorizon;
Represents custom area from the horizon upwards which represent blocked views from the vantage point ...
Provides necessary information about the Moon.
An angle, stored as degrees, but expressible in many ways.
Ekos is an advanced Astrophotography tool for Linux.
SchedulerJobStage
Running stages of a SchedulerJob.
StartupCondition
Conditions under which a SchedulerJob may start.
SchedulerJobStatus
States of a SchedulerJob.
@ 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
CompletionCondition
Conditions under which a SchedulerJob may complete.