12#include "indi/indiweather.h"
13#include "kstarsdatetime.h"
14#include "geolocation.h"
15#include "schedulertypes.h"
16#include "ekos/capture/capturetypes.h"
32class SchedulerModuleState :
public QObject
39 SchedulerModuleState();
53 const QString ¤tProfile()
const
55 return m_currentProfile;
62 void setCurrentProfile(
const QString &newName,
bool signal =
true);
68 void updateProfiles(
const QStringList &newProfiles);
70 SchedulerJob *activeJob()
const
74 void setActiveJob(SchedulerJob *newActiveJob);
103 void updateJobStage(SchedulerJobStage stage);
121 void setDirty(
bool value)
129 return m_schedulerState;
133 const StartupState &startupState()
const
135 return m_startupState;
138 int currentPosition()
const
140 return m_currentPosition;
142 void setCurrentPosition(
int newCurrentPosition);
144 void setStartupState(StartupState state);
146 const QUrl &startupScriptURL()
const
148 return m_startupScriptURL;
150 void setStartupScriptURL(
const QUrl &newURL)
152 m_startupScriptURL = newURL;
155 const ShutdownState &shutdownState()
const
157 return m_shutdownState;
159 void setShutdownState(ShutdownState state);
161 const QUrl &shutdownScriptURL()
const
163 return m_shutdownScriptURL;
165 void setShutdownScriptURL(
const QUrl &newShutdownScriptURL)
167 m_shutdownScriptURL = newShutdownScriptURL;
170 const ParkWaitState &parkWaitState()
const
172 return m_parkWaitState;
174 void setParkWaitState(ParkWaitState state);
179 bool currentlySleeping()
181 return iterationTimer().
isActive() && timerState() == RUN_WAKEUP;
193 bool removeJob(
const int currentRow);
198 void refreshFollowerLists();
203 SchedulerJob *findLead(
int position,
bool upward =
true);
210 void enablePreemptiveShutdown(
const QDateTime &wakeupTime);
211 void disablePreemptiveShutdown();
212 const QDateTime &preemptiveShutdownWakeupTime()
const;
213 bool preemptiveShutdown()
const;
219 EkosState ekosState()
const
223 void setEkosState(EkosState state);
225 CommunicationStatus ekosCommunicationStatus()
const
227 return m_EkosCommunicationStatus;
229 void setEkosCommunicationStatus(CommunicationStatus newEkosCommunicationStatus)
231 m_EkosCommunicationStatus = newEkosCommunicationStatus;
234 void resetEkosConnectFailureCount(uint8_t newEkosConnectFailureCount = 0)
236 m_ekosConnectFailureCount = newEkosConnectFailureCount;
238 bool increaseEkosConnectFailureCount();
240 void resetParkingCapFailureCount(uint8_t value = 0)
242 m_parkingCapFailureCount = value;
244 bool increaseParkingCapFailureCount();
245 void resetParkingMountFailureCount(uint8_t value = 0)
247 m_parkingMountFailureCount = value;
249 bool increaseParkingMountFailureCount();
250 uint8_t parkingMountFailureCount()
const
252 return m_parkingMountFailureCount;
254 void resetParkingDomeFailureCount(uint8_t value = 0)
256 m_parkingDomeFailureCount = value;
258 bool increaseParkingDomeFailureCount();
260 int indexToUse()
const
264 void setIndexToUse(
int newIndexToUse)
266 m_IndexToUse = newIndexToUse;
269 int healpixToUse()
const
271 return m_HealpixToUse;
273 void setHealpixToUse(
int newHealpixToUse)
275 m_HealpixToUse = newHealpixToUse;
280 return m_CapturedFramesCount;
285 m_CapturedFramesCount = newCapturedFramesCount;
288 void setWeatherGracePeriodActive(
bool active)
290 m_WeatherGracePeriodActive = active;
292 bool weatherGracePeriodActive()
const
294 return m_WeatherGracePeriodActive;
300 void resetFailureCounters();
305 INDIState indiState()
const
309 void setIndiState(INDIState state);
311 CommunicationStatus indiCommunicationStatus()
const
313 return m_INDICommunicationStatus;
315 void setIndiCommunicationStatus(CommunicationStatus newINDICommunicationStatus)
317 m_INDICommunicationStatus = newINDICommunicationStatus;
318 emit indiCommunicationStatusChanged(m_INDICommunicationStatus);
321 void resetIndiConnectFailureCount(uint8_t newIndiConnectFailureCount = 0)
323 m_indiConnectFailureCount = newIndiConnectFailureCount;
325 bool increaseIndiConnectFailureCount();
330 bool isINDIConnected()
const
332 return (indiCommunicationStatus() == Ekos::Success);
337 bool mountReady()
const
341 void setMountReady(
bool readiness)
343 m_MountReady = readiness;
345 bool captureReady()
const
347 return m_CaptureReady;
349 void setCaptureReady(
bool readiness)
351 m_CaptureReady = readiness;
353 bool domeReady()
const
357 void setDomeReady(
bool readiness)
359 m_DomeReady = readiness;
361 bool capReady()
const
365 void setCapReady(
bool readiness)
367 m_CapReady = readiness;
370 uint16_t captureBatch()
const
372 return m_captureBatch;
374 void resetCaptureBatch()
378 uint16_t increaseCaptureBatch()
380 return m_captureBatch++;
383 uint8_t captureFailureCount()
const
385 return m_captureFailureCount;
387 void resetCaptureFailureCount()
389 m_captureFailureCount = 0;
391 bool increaseCaptureFailureCount();
393 uint8_t focusFailureCount(
const QString &trainname)
const
395 return m_focusFailureCount[trainname];
397 void resetFocusFailureCount(
const QString &trainname)
399 m_focusFailureCount[trainname] = 0;
401 void resetFocusFailureCount()
403 m_focusFailureCount.
clear();
405 bool increaseFocusFailureCount(
const QString &trainname);
407 bool increaseAllFocusFailureCounts();
409 bool autofocusCompleted(
const QString &trainname)
const;
410 void setAutofocusCompleted(
const QString &trainname,
bool value);
411 bool autofocusCompleted()
const;
413 void resetAutofocusCompleted()
415 m_autofocusCompleted.
clear();
418 uint8_t guideFailureCount()
const
420 return m_guideFailureCount;
422 void resetGuideFailureCount()
424 m_guideFailureCount = 0;
426 bool increaseGuideFailureCount();
428 uint8_t alignFailureCount()
const
430 return m_alignFailureCount;
432 void resetAlignFailureCount()
434 m_alignFailureCount = 0;
436 bool increaseAlignFailureCount();
438 int restartGuidingInterval()
const
440 return m_restartGuidingInterval;
445 return m_restartGuidingTime;
448 ISD::Weather::Status weatherStatus()
const
450 return m_weatherStatus;
452 void setWeatherStatus(ISD::Weather::Status newWeatherStatus)
454 m_weatherStatus = newWeatherStatus;
461 qint64 getCurrentOperationMsec()
const;
467 void startCurrentOperationTimer();
470 void cancelGuidingTimer();
471 bool isGuidingTimerActive();
472 void startGuidingTimer(
int milliseconds);
479 storedLocalTime = time;
481 static bool hasLocalTime()
483 return storedLocalTime !=
nullptr;
500 void calculateDawnDusk();
512 return m_PreDawnDateTime;
522 static bool hasGeo();
530 void setupNextIteration(SchedulerTimerState nextState);
531 void setupNextIteration(SchedulerTimerState nextState,
int milliseconds);
533 SchedulerTimerState timerState()
const
538 void setTimerState(SchedulerTimerState newTimerState)
540 m_timerState = newTimerState;
545 return m_iterationTimer;
548 bool iterationSetup()
const
550 return m_iterationSetup;
552 void setIterationSetup(
bool setup)
554 m_iterationSetup = setup;
557 qint64 startMSecs()
const
561 void setStartMSecs(qint64 value)
563 m_startMSecs = value;
565 int increaseSchedulerIteration()
567 return ++m_schedulerIteration;
569 void resetSchedulerIteration()
571 m_schedulerIteration = 0;
574 int timerInterval()
const
576 return m_timerInterval;
578 void setTimerInterval(
int value)
580 m_timerInterval = value;
583 void setUpdatePeriodMs(
int ms)
585 m_UpdatePeriodMs = ms;
587 int updatePeriodMs()
const
589 return m_UpdatePeriodMs;
592 uint sequenceExecutionCounter()
const
594 return m_sequenceExecutionCounter;
596 void resetSequenceExecutionCounter()
598 m_sequenceExecutionCounter = 1;
600 void increaseSequenceExecutionCounter()
602 m_sequenceExecutionCounter++;
605 static uint maxFailureAttempts();
613 return logText().
join(
"\n");
622 bool checkRepeatSequence();
624 void resetSolverIteration()
626 m_solverIteration = 0;
628 uint32_t increaseSolverIteration()
630 return ++m_solverIteration;
638 void ekosStateChanged(EkosState state);
640 void indiStateChanged(INDIState state);
642 void indiCommunicationStatusChanged(CommunicationStatus status);
646 void startupStateChanged(StartupState state);
648 void shutdownStateChanged(ShutdownState state);
650 void parkWaitStateChanged(ParkWaitState state);
652 void profilesChanged();
654 void currentProfileChanged();
656 void newLog(
const QString &text);
658 void currentPositionChanged(
int pos);
660 void jobStageChanged(SchedulerJobStage stage);
662 void updateNightTime(SchedulerJob
const * job =
nullptr);
672 SchedulerJob *m_activeJob {
nullptr };
680 StartupState m_startupState { STARTUP_IDLE };
682 QUrl m_startupScriptURL;
684 ShutdownState m_shutdownState { SHUTDOWN_IDLE };
687 int m_currentPosition { -1 };
689 QUrl m_shutdownScriptURL;
691 ParkWaitState m_parkWaitState { PARKWAIT_IDLE };
699 bool m_dirty {
false };
703 EkosState m_ekosState { EKOS_IDLE };
705 INDIState m_indiState { INDI_IDLE };
707 CommunicationStatus m_EkosCommunicationStatus { Ekos::Idle };
708 CommunicationStatus m_INDICommunicationStatus { Ekos::Idle };
711 bool m_MountReady {
false };
712 bool m_CaptureReady {
false };
713 bool m_DomeReady {
false };
714 bool m_CapReady {
false };
719 int m_IndexToUse { -1 };
720 int m_HealpixToUse { -1 };
724 QMap <QString, bool> m_autofocusCompleted;
727 uint32_t m_solverIteration {0};
731 ISD::Weather::Status m_weatherStatus { ISD::Weather::WEATHER_IDLE };
737 uint m_sequenceExecutionCounter { 1 };
739 uint8_t m_indiConnectFailureCount { 0 };
741 uint8_t m_ekosConnectFailureCount { 0 };
743 uint8_t m_parkingCapFailureCount { 0 };
745 uint8_t m_parkingMountFailureCount { 0 };
747 uint8_t m_parkingDomeFailureCount { 0 };
749 uint16_t m_captureBatch { 0 };
751 uint8_t m_captureFailureCount { 0 };
753 QMap <QString, uint8_t> m_focusFailureCount;
755 uint8_t m_guideFailureCount { 0 };
757 uint8_t m_alignFailureCount { 0 };
766 SchedulerTimerState m_timerState { RUN_NOTHING };
769 int m_timerInterval { -1 };
772 bool m_iterationSetup {
false };
776 int m_schedulerIteration { 0 };
778 qint64 m_startMSecs { 0 };
781 int m_UpdatePeriodMs = 1000;
796 bool currentOperationTimeStarted {
false };
798 int m_restartGuidingInterval { -1 };
803 QDateTime m_preemptiveShutdownWakeupTime;
805 bool m_WeatherGracePeriodActive {
false};
The SchedulerProcess class holds the entire business logic for controlling the execution of the EKOS ...
Contains all relevant information for specifying a location on Earth: City Name, State/Province name,...
Extension of QDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day,...
The SchedulerState class holds all attributes defining the scheduler's state.
Ekos is an advanced Astrophotography tool for Linux.
QMap< QString, uint16_t > CapturedFramesMap
mapping signature --> frames count
QString join(QChar separator) const const
bool isActive() const const