12#include "indi/indiweather.h"
13#include "kstarsdatetime.h"
14#include "geolocation.h"
15#include "schedulertypes.h"
16#include "ekos/capture/capturetypes.h"
25class SchedulerProcess;
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;
291 void resetFailureCounters();
296 INDIState indiState()
const
300 void setIndiState(INDIState state);
302 CommunicationStatus indiCommunicationStatus()
const
304 return m_INDICommunicationStatus;
306 void setIndiCommunicationStatus(CommunicationStatus newINDICommunicationStatus)
308 m_INDICommunicationStatus = newINDICommunicationStatus;
309 emit indiCommunicationStatusChanged(m_INDICommunicationStatus);
312 void resetIndiConnectFailureCount(uint8_t newIndiConnectFailureCount = 0)
314 m_indiConnectFailureCount = newIndiConnectFailureCount;
316 bool increaseIndiConnectFailureCount();
321 bool isINDIConnected()
const
323 return (indiCommunicationStatus() == Ekos::Success);
328 bool mountReady()
const
332 void setMountReady(
bool readiness)
334 m_MountReady = readiness;
336 bool captureReady()
const
338 return m_CaptureReady;
340 void setCaptureReady(
bool readiness)
342 m_CaptureReady = readiness;
344 bool domeReady()
const
348 void setDomeReady(
bool readiness)
350 m_DomeReady = readiness;
352 bool capReady()
const
356 void setCapReady(
bool readiness)
358 m_CapReady = readiness;
361 uint16_t captureBatch()
const
363 return m_captureBatch;
365 void resetCaptureBatch()
369 uint16_t increaseCaptureBatch()
371 return m_captureBatch++;
374 uint8_t captureFailureCount()
const
376 return m_captureFailureCount;
378 void resetCaptureFailureCount()
380 m_captureFailureCount = 0;
382 bool increaseCaptureFailureCount();
384 uint8_t focusFailureCount()
const
386 return m_focusFailureCount;
388 void resetFocusFailureCount()
390 m_focusFailureCount = 0;
392 bool increaseFocusFailureCount();
394 bool autofocusCompleted()
const
396 return m_autofocusCompleted;
398 void setAutofocusCompleted(
bool value)
400 m_autofocusCompleted = value;
403 uint8_t guideFailureCount()
const
405 return m_guideFailureCount;
407 void resetGuideFailureCount()
409 m_guideFailureCount = 0;
411 bool increaseGuideFailureCount();
413 uint8_t alignFailureCount()
const
415 return m_alignFailureCount;
417 void resetAlignFailureCount()
419 m_alignFailureCount = 0;
421 bool increaseAlignFailureCount();
423 int restartGuidingInterval()
const
425 return m_restartGuidingInterval;
430 return m_restartGuidingTime;
433 ISD::Weather::Status weatherStatus()
const
435 return m_weatherStatus;
437 void setWeatherStatus(ISD::Weather::Status newWeatherStatus)
439 m_weatherStatus = newWeatherStatus;
446 qint64 getCurrentOperationMsec()
const;
452 void startCurrentOperationTimer();
455 void cancelGuidingTimer();
456 bool isGuidingTimerActive();
457 void startGuidingTimer(
int milliseconds);
464 storedLocalTime = time;
466 static bool hasLocalTime()
468 return storedLocalTime !=
nullptr;
485 void calculateDawnDusk();
497 return m_PreDawnDateTime;
507 static bool hasGeo();
515 void setupNextIteration(SchedulerTimerState nextState);
516 void setupNextIteration(SchedulerTimerState nextState,
int milliseconds);
518 SchedulerTimerState timerState()
const
523 void setTimerState(SchedulerTimerState newTimerState)
525 m_timerState = newTimerState;
530 return m_iterationTimer;
533 bool iterationSetup()
const
535 return m_iterationSetup;
537 void setIterationSetup(
bool setup)
539 m_iterationSetup = setup;
542 qint64 startMSecs()
const
546 void setStartMSecs(qint64 value)
548 m_startMSecs = value;
550 int increaseSchedulerIteration()
552 return ++m_schedulerIteration;
554 void resetSchedulerIteration()
556 m_schedulerIteration = 0;
559 int timerInterval()
const
561 return m_timerInterval;
563 void setTimerInterval(
int value)
565 m_timerInterval = value;
568 void setUpdatePeriodMs(
int ms)
570 m_UpdatePeriodMs = ms;
572 int updatePeriodMs()
const
574 return m_UpdatePeriodMs;
577 uint sequenceExecutionCounter()
const
579 return m_sequenceExecutionCounter;
581 void resetSequenceExecutionCounter()
583 m_sequenceExecutionCounter = 1;
585 void increaseSequenceExecutionCounter()
587 m_sequenceExecutionCounter++;
590 static uint maxFailureAttempts();
598 return logText().
join(
"\n");
607 bool checkRepeatSequence();
609 void resetSolverIteration()
611 m_solverIteration = 0;
613 uint32_t increaseSolverIteration()
615 return ++m_solverIteration;
623 void ekosStateChanged(EkosState state);
625 void indiStateChanged(INDIState state);
627 void indiCommunicationStatusChanged(CommunicationStatus status);
631 void startupStateChanged(StartupState state);
633 void shutdownStateChanged(ShutdownState state);
635 void parkWaitStateChanged(ParkWaitState state);
637 void profilesChanged();
639 void currentProfileChanged();
641 void newLog(
const QString &text);
643 void currentPositionChanged(
int pos);
645 void jobStageChanged(SchedulerJobStage stage);
647 void updateNightTime(SchedulerJob
const * job =
nullptr);
657 SchedulerJob *m_activeJob {
nullptr };
665 StartupState m_startupState { STARTUP_IDLE };
667 QUrl m_startupScriptURL;
669 ShutdownState m_shutdownState { SHUTDOWN_IDLE };
672 int m_currentPosition { -1 };
674 QUrl m_shutdownScriptURL;
676 ParkWaitState m_parkWaitState { PARKWAIT_IDLE };
684 bool m_dirty {
false };
688 EkosState m_ekosState { EKOS_IDLE };
690 INDIState m_indiState { INDI_IDLE };
692 CommunicationStatus m_EkosCommunicationStatus { Ekos::Idle };
693 CommunicationStatus m_INDICommunicationStatus { Ekos::Idle };
696 bool m_MountReady {
false };
697 bool m_CaptureReady {
false };
698 bool m_DomeReady {
false };
699 bool m_CapReady {
false };
704 int m_IndexToUse { -1 };
705 int m_HealpixToUse { -1 };
709 bool m_autofocusCompleted {
false };
712 uint32_t m_solverIteration {0};
716 ISD::Weather::Status m_weatherStatus { ISD::Weather::WEATHER_IDLE };
722 uint m_sequenceExecutionCounter { 1 };
724 uint8_t m_indiConnectFailureCount { 0 };
726 uint8_t m_ekosConnectFailureCount { 0 };
728 uint8_t m_parkingCapFailureCount { 0 };
730 uint8_t m_parkingMountFailureCount { 0 };
732 uint8_t m_parkingDomeFailureCount { 0 };
734 uint16_t m_captureBatch { 0 };
736 uint8_t m_captureFailureCount { 0 };
738 uint8_t m_focusFailureCount { 0 };
740 uint8_t m_guideFailureCount { 0 };
742 uint8_t m_alignFailureCount { 0 };
751 SchedulerTimerState m_timerState { RUN_NOTHING };
754 int m_timerInterval { -1 };
757 bool m_iterationSetup {
false };
761 int m_schedulerIteration { 0 };
763 qint64 m_startMSecs { 0 };
766 int m_UpdatePeriodMs = 1000;
781 bool currentOperationTimeStarted {
false };
783 int m_restartGuidingInterval { -1 };
788 QDateTime m_preemptiveShutdownWakeupTime;
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