10#include "schedulertypes.h"
11#include "ekos/capture/sequencejob.h"
12#include "greedyscheduler.h"
16#include "kstarsdatetime.h"
21class TestSchedulerUnit;
22class TestEkosSchedulerOps;
32 QJsonObject toJson()
const;
50 bool isDarkFlat =
false;
51 QMap<SequenceJob::PropertyID, QVariant> properties;
53 JobProgress(
int numCompleted,
const QSharedPointer<SequenceJob> &job)
54 : numCompleted(numCompleted), type(job->getFrameType()),
55 isDarkFlat(job->jobType() == SequenceJob::JOBTYPE_DARKFLAT),
56 properties(job->getCoreProperties()) {};
61 SkyPoint
const &getTargetCoords()
const
63 if (m_LeadJob !=
nullptr)
64 return m_LeadJob->getTargetCoords();
68 void setTargetCoords(
const dms &ra,
const dms &dec,
double djd);
71 double getPositionAngle()
73 return m_PositionAngle;
75 void setPositionAngle(
double value);
79 QUrl getSequenceFile()
const
83 void setSequenceFile(
const QUrl &value);
88 QUrl getFITSFile()
const
90 if (m_LeadJob !=
nullptr)
91 return m_LeadJob->getFITSFile();
95 void setFITSFile(
const QUrl &value);
100 double getMinAltitude()
const
102 if (m_LeadJob !=
nullptr)
103 return m_LeadJob->getMinAltitude();
107 void setMinAltitude(
const double &value);
112 bool hasMinAltitude()
const
114 return UNDEFINED_ALTITUDE < getMinAltitude();
116 static constexpr int UNDEFINED_ALTITUDE = -90;
121 bool hasAltitudeConstraint()
const;
126 double getMinMoonSeparation()
const
128 if (m_LeadJob !=
nullptr)
129 return m_LeadJob->getMinMoonSeparation();
131 return minMoonSeparation;
133 void setMinMoonSeparation(
const double &value);
138 double getMaxMoonAltitude()
const
140 if (m_LeadJob !=
nullptr)
141 return m_LeadJob->getMaxMoonAltitude();
143 return maxMoonAltitude;
145 void setMaxMoonAltitude(
const double &value);
150 StepPipeline getStepPipeline()
const
152 if (m_LeadJob !=
nullptr)
153 return m_LeadJob->getStepPipeline();
157 void setStepPipeline(
const StepPipeline &value);
164 if (m_LeadJob !=
nullptr)
165 return m_LeadJob->getStartupCondition();
167 return startupCondition;
176 return completionCondition;
185 if (m_LeadJob !=
nullptr)
186 return m_LeadJob->getFileStartupCondition();
188 return fileStartupCondition;
195 QDateTime getStartAtTime()
const
197 if (m_LeadJob !=
nullptr)
198 return m_LeadJob->getStartAtTime();
202 void setStartAtTime(
const QDateTime &value);
207 bool getInSequenceFocus()
const
209 return inSequenceFocus;
211 void setInSequenceFocus(
bool value);
216 bool getEnforceTwilight()
const
218 if (m_LeadJob !=
nullptr)
219 return m_LeadJob->getEnforceTwilight();
221 return enforceTwilight;
223 void setEnforceTwilight(
bool value);
228 bool getEnforceArtificialHorizon()
const
230 if (m_LeadJob !=
nullptr)
231 return m_LeadJob->getEnforceArtificialHorizon();
233 return enforceArtificialHorizon;
235 void setEnforceArtificialHorizon(
bool value);
240 QString getName()
const
242 if (m_LeadJob !=
nullptr)
243 return m_LeadJob->getName();
247 void setName(
const QString &value);
256 void setIsLead(
bool value)
264 QString getGroup()
const
266 if (m_LeadJob !=
nullptr)
267 return m_LeadJob->getGroup();
271 void setGroup(
const QString &value);
276 QString getOpticalTrain()
const
280 void setOpticalTrain(
const QString &value)
282 opticalTrain = value;
288 int getCompletedIterations()
const
290 return completedIterations;
292 void setCompletedIterations(
int value);
310 bool isStopped()
const
314 QDateTime getStateTime()
const
318 QDateTime getLastAbortTime()
const
320 return lastAbortTime;
322 QDateTime getLastErrorTime()
const
324 return lastErrorTime;
333 void updateSharedFollowerAttributes();
347 int getSequenceCount()
const
349 return sequenceCount;
351 void setSequenceCount(
const int count);
356 int getCompletedCount()
const
358 return completedCount;
360 void setCompletedCount(
const int count);
365 QDateTime getStartupTime()
const
369 void setStartupTime(
const QDateTime &value,
bool refreshDawnDusk =
true);
374 QDateTime getFinishAtTime()
const
378 QDateTime getStopTime()
const
382 const QString &getStopReason()
const
386 void setStopReason(
const QString &reason)
390 void setFinishAtTime(
const QDateTime &value);
392 void setStopTime(
const QDateTime &value);
396 int64_t getEstimatedTime()
const
398 return estimatedTime;
400 void setEstimatedTime(
const int64_t &value);
405 int64_t getEstimatedTimePerRepeat()
const
407 return estimatedTimePerRepeat;
409 void setEstimatedTimePerRepeat(
const int64_t &value)
411 estimatedTimePerRepeat = value;
416 int64_t getEstimatedStartupTime()
const
418 if (m_LeadJob !=
nullptr)
419 return m_LeadJob->getEstimatedStartupTime();
421 return estimatedStartupTime;
423 void setEstimatedStartupTime(
const int64_t &value)
425 estimatedStartupTime = value;
430 int64_t getEstimatedTimeLeftThisRepeat()
const
432 return estimatedTimeLeftThisRepeat;
434 void setEstimatedTimeLeftThisRepeat(
const int64_t &value)
436 estimatedTimeLeftThisRepeat = value;
441 bool getLightFramesRequired()
const
443 return lightFramesRequired;
445 void setLightFramesRequired(
bool value);
450 bool getCalibrationMountPark()
const
452 return m_CalibrationMountPark;
454 void setCalibrationMountPark(
bool value);
459 uint16_t getRepeatsRequired()
const
461 return repeatsRequired;
463 void setRepeatsRequired(
const uint16_t &value);
468 uint16_t getRepeatsRemaining()
const
470 return repeatsRemaining;
472 void setRepeatsRemaining(
const uint16_t &value);
479 void addProgress(
int numCompleted,
const QSharedPointer<SequenceJob> &job)
481 m_Progress.append(JobProgress(numCompleted, job));
485 const QString getProgressSummary()
const;
492 return capturedFramesMap;
510 bool isDuplicateOf(SchedulerJob
const *a_job)
const
512 return this != a_job && name == a_job->getName() && sequenceFile == a_job->sequenceFile;
526 static bool decreasingAltitudeOrder(SchedulerJob
const *a, SchedulerJob
const *b, QDateTime
const &when = QDateTime());
535 bool moonConstraintsOK(QDateTime
const &when = QDateTime(), QString *reason =
new QString(),
536 double *margin =
nullptr)
const;
544 QDateTime calculateNextTime(QDateTime
const &when,
bool checkIfConstraintsAreMet =
true,
int increment = 1,
545 QString *reason =
nullptr,
bool runningJob =
false,
const QDateTime &until = QDateTime())
const;
546 QDateTime getNextPossibleStartTime(
const QDateTime &when,
int increment = 1,
bool runningJob =
false,
547 const QDateTime &until = QDateTime())
const;
548 QDateTime getNextEndTime(
const QDateTime &start,
int increment = 1, QString *reason =
nullptr,
549 const QDateTime &until = QDateTime())
const;
550 bool checkAltitudeAndMoon(SkyObject o,
const KStarsDateTime <Offset, QString *reason,
double *margin)
const;
558 QDateTime getDawnAstronomicalTwilight()
const
560 if (m_LeadJob !=
nullptr)
561 return m_LeadJob->getDawnAstronomicalTwilight();
571 QDateTime getDuskAstronomicalTwilight()
const
573 if (m_LeadJob !=
nullptr)
574 return m_LeadJob->getDuskAstronomicalTwilight();
585 bool runsDuringAstronomicalNightTime(
const QDateTime &time = QDateTime(), QDateTime *nextPossibleSuccess =
nullptr)
const;
594 bool satisfiesAltitudeConstraint(
double azimuth,
double altitude, QString *altitudeReason =
nullptr,
595 double *margin =
nullptr)
const;
601 void setInitialFilter(
const QString &value);
602 const QString &getInitialFilter()
const;
613 startTimeCache.clear();
615 double getAltitudeAtStartup()
const
617 if (m_LeadJob !=
nullptr)
618 return m_LeadJob->getAltitudeAtStartup();
620 return altitudeAtStartup;
622 double getAltitudeAtStop()
const
624 return altitudeAtStop;
626 bool isSettingAtStartup()
const
628 if (m_LeadJob !=
nullptr)
629 return m_LeadJob->isSettingAtStartup();
631 return settingAtStartup;
633 bool isSettingAtStop()
const
635 return settingAtStop;
638 SchedulerJob *leadJob()
const
642 void setLeadJob(SchedulerJob *newLeadJob)
644 m_LeadJob = newLeadJob;
647 QList<SchedulerJob *> &followerJobs()
649 return m_followerJobs;
652 void setStartupFormatted(
const QString &value)
654 m_StartupFormatted = value;
656 const QString &startupFormatted()
const
658 return m_StartupFormatted;
661 void setEndFormatted(
const QString &value)
663 m_EndFormatted = value;
665 const QString &endFormatted()
const
667 return m_EndFormatted;
670 void setAltitudeFormatted(
const QString &value)
672 m_AltitudeFormatted = value;
674 const QString &altitudeFormatted()
const
676 return m_AltitudeFormatted;
679 void clearSimulatedSchedule()
681 m_SimulatedSchedule.
clear();
683 void setSimulatedSchedule(
const QList<GreedyScheduler::JobSchedule> &schedule)
685 m_SimulatedSchedule = schedule;
687 void appendSimulatedSchedule(
const GreedyScheduler::JobSchedule &jobSchedule)
689 m_SimulatedSchedule.
append(jobSchedule);
691 const QList<GreedyScheduler::JobSchedule> &getSimulatedSchedule()
const
693 return m_SimulatedSchedule;
697 bool runsDuringAstronomicalNightTimeInternal(
const QDateTime &time, QDateTime *minDawnDusk,
698 QDateTime *nextPossibleSuccess =
nullptr)
const;
701 SchedulerJob(KSMoon *moonPtr);
702 friend TestSchedulerUnit;
703 friend TestEkosSchedulerOps;
707 static KStarsDateTime getLocalTime();
712 static const ArtificialHorizon *getHorizon();
713 static void setHorizon(ArtificialHorizon *horizon)
715 storedHorizon = horizon;
717 static bool hasHorizon()
719 return storedHorizon !=
nullptr;
725 bool m_isLead {
true };
727 QString opticalTrain;
728 int completedIterations { 0 };
729 SkyPoint targetCoords;
730 double m_PositionAngle { -1 };
735 SchedulerJob *m_LeadJob {
nullptr };
736 QList <SchedulerJob *> m_followerJobs;
741 QDateTime lastAbortTime;
742 QDateTime lastErrorTime;
748 int sequenceCount { 0 };
749 int completedCount { 0 };
752 QDateTime startAtTime;
754 QDateTime startupTime;
756 QDateTime finishAtTime;
765 double altitudeAtStartup { 0 };
766 double altitudeAtStop { 0 };
767 bool settingAtStartup {
false };
768 bool settingAtStop {
false };
774 double minAltitude { UNDEFINED_ALTITUDE };
775 double minMoonSeparation { -1 };
776 double maxMoonAltitude { 90 };
778 bool enforceTwilight {
false };
779 bool enforceArtificialHorizon {
false };
784 StepPipeline stepPipeline { USE_NONE };
786 int64_t estimatedTime { -1 };
787 int64_t estimatedTimePerRepeat { 0 };
788 int64_t estimatedStartupTime { 0 };
789 int64_t estimatedTimeLeftThisRepeat { 0 };
790 uint16_t repeatsRequired { 1 };
791 uint16_t repeatsRemaining { 1 };
792 bool inSequenceFocus {
false };
793 QString m_InitialFilter;
795 QString dateTimeDisplayFormat;
797 QString m_StartupFormatted, m_EndFormatted, m_AltitudeFormatted;
799 bool lightFramesRequired {
false };
800 bool m_CalibrationMountPark {
false};
805 KSMoon *moon {
nullptr };
808 QList<JobProgress> m_Progress;
811 QList<GreedyScheduler::JobSchedule> m_SimulatedSchedule;
821 struct StartTimeComputation
830 bool check(
const QDateTime &from,
const QDateTime &until,
831 QDateTime *result, QDateTime *newFrom)
const;
833 void add(
const QDateTime &from,
const QDateTime &until,
const QDateTime &result)
const;
839 mutable QList<StartTimeComputation> startComputations;
841 StartTimeCache startTimeCache;
844 static KStarsDateTime *storedLocalTime;
845 static GeoLocation *storedGeo;
846 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.
void append(QList< T > &&value)