Kstars

scheduler.h
1 /*
2  SPDX-FileCopyrightText: 2015 Jasem Mutlaq <[email protected]>
3 
4  DBus calls from GSoC 2015 Ekos Scheduler project:
5  SPDX-FileCopyrightText: 2015 Daniel Leu <[email protected]>
6 
7  SPDX-License-Identifier: GPL-2.0-or-later
8 */
9 
10 #pragma once
11 
12 #include "ui_scheduler.h"
13 #include "ekos/align/align.h"
14 #include "indi/indiweather.h"
15 #include "ekos/auxiliary/solverutils.h"
16 #include "schedulerjob.h"
17 
18 #include <lilxml.h>
19 
20 #include <QProcess>
21 #include <QTime>
22 #include <QTimer>
23 #include <QUrl>
24 #include <QtDBus>
25 
26 #include <cstdint>
27 
28 class QProgressIndicator;
29 
30 class GeoLocation;
31 class SchedulerJob;
32 class SkyObject;
33 class KConfigDialog;
34 class TestSchedulerUnit;
35 
36 class TestEkosSchedulerOps;
37 
38 namespace Ekos
39 {
40 
41 class SequenceJob;
42 class GreedyScheduler;
43 
44 /**
45  * @brief The Ekos scheduler is a simple scheduler class to orchestrate automated multi object observation jobs.
46  * @author Jasem Mutlaq
47  * @version 1.2
48  */
49 class Scheduler : public QWidget, public Ui::Scheduler
50 {
51  Q_OBJECT
52  Q_CLASSINFO("D-Bus Interface", "org.kde.kstars.Ekos.Scheduler")
53  Q_PROPERTY(Ekos::SchedulerState status READ status NOTIFY newStatus)
54  Q_PROPERTY(QStringList logText READ logText NOTIFY newLog)
55  Q_PROPERTY(QString profile READ profile WRITE setProfile)
56 
57  public:
58  typedef enum { EKOS_IDLE, EKOS_STARTING, EKOS_STOPPING, EKOS_READY } EkosState;
59  typedef enum { INDI_IDLE, INDI_CONNECTING, INDI_DISCONNECTING, INDI_PROPERTY_CHECK, INDI_READY } INDIState;
60  typedef enum
61  {
62  STARTUP_IDLE,
63  STARTUP_SCRIPT,
64  STARTUP_UNPARK_DOME,
65  STARTUP_UNPARKING_DOME,
66  STARTUP_UNPARK_MOUNT,
67  STARTUP_UNPARKING_MOUNT,
68  STARTUP_UNPARK_CAP,
69  STARTUP_UNPARKING_CAP,
70  STARTUP_ERROR,
71  STARTUP_COMPLETE
72  } StartupState;
73  typedef enum
74  {
75  SHUTDOWN_IDLE,
76  SHUTDOWN_PARK_CAP,
77  SHUTDOWN_PARKING_CAP,
78  SHUTDOWN_PARK_MOUNT,
79  SHUTDOWN_PARKING_MOUNT,
80  SHUTDOWN_PARK_DOME,
81  SHUTDOWN_PARKING_DOME,
82  SHUTDOWN_SCRIPT,
83  SHUTDOWN_SCRIPT_RUNNING,
84  SHUTDOWN_ERROR,
85  SHUTDOWN_COMPLETE
86  } ShutdownState;
87  typedef enum
88  {
89  PARKWAIT_IDLE,
90  PARKWAIT_PARK,
91  PARKWAIT_PARKING,
92  PARKWAIT_PARKED,
93  PARKWAIT_UNPARK,
94  PARKWAIT_UNPARKING,
95  PARKWAIT_UNPARKED,
96  PARKWAIT_ERROR
97  } ParkWaitStatus;
98 
99  /** @brief options what should happen if an error or abort occurs */
100  typedef enum
101  {
102  ERROR_DONT_RESTART,
103  ERROR_RESTART_AFTER_TERMINATION,
104  ERROR_RESTART_IMMEDIATELY
106 
107  /** @brief Algorithms, in the same order as UI. */
108  typedef enum
109  {
110  ALGORITHM_CLASSIC,
111  ALGORITHM_GREEDY
113 
114  /** @brief Columns, in the same order as UI. */
115  typedef enum
116  {
117  SCHEDCOL_NAME = 0,
118  SCHEDCOL_STATUS,
119  SCHEDCOL_CAPTURES,
120  SCHEDCOL_ALTITUDE,
121  SCHEDCOL_SCORE,
122  SCHEDCOL_STARTTIME,
123  SCHEDCOL_ENDTIME,
124  SCHEDCOL_DURATION,
125  SCHEDCOL_LEADTIME,
126  SCHEDCOL_COUNT
128 
129  /** @brief IterationTypes, the different types of scheduler iterations that are run. */
130  typedef enum
131  {
132  RUN_WAKEUP = 0,
133  RUN_SCHEDULER,
134  RUN_JOBCHECK,
135  RUN_SHUTDOWN,
136  RUN_NOTHING
138 
139  /** @brief Constructor, the starndard scheduler constructor. */
140  Scheduler();
141  /** @brief DebugConstructor, a constructor used in testing with a mock ekos. */
142  Scheduler(const QString path, const QString interface,
143  const QString &ekosPathStr, const QString &ekosInterfaceStr);
144  ~Scheduler() = default;
145 
146  QString getCurrentJobName();
147  SchedulerJob *getCurrentJob()
148  {
149  return currentJob;
150  }
151 
152  void appendLogText(const QString &);
153  QStringList logText()
154  {
155  return m_LogText;
156  }
157  QString getLogText()
158  {
159  return m_LogText.join("\n");
160  }
161  void clearLog();
162  void applyConfig();
163 
164  void addObject(SkyObject *object);
165 
166  /**
167  * @brief startSlew DBus call for initiating slew
168  */
169  void startSlew();
170 
171  /**
172  * @brief startFocusing DBus call for feeding ekos the specified settings and initiating focus operation
173  */
174  void startFocusing();
175 
176  /**
177  * @brief startAstrometry initiation of the capture and solve operation. We change the job state
178  * after solver is started
179  */
180  void startAstrometry();
181 
182  /**
183  * @brief startGuiding After ekos is fed the calibration options, we start the guiding process
184  * @param resetCalibration By default calibration is not reset until it is explicitly requested
185  */
186  void startGuiding(bool resetCalibration = false);
187 
188  /**
189  * @brief startCapture The current job file name is solved to an url which is fed to ekos. We then start the capture process
190  * @param restart Set to true if the goal to restart an existing sequence. The only difference is that when a sequence is restarted, sequence file
191  * is not loaded from disk again since that results in erasing all the history of the capture process.
192  */
193  void startCapture(bool restart = false);
194 
195  /**
196  * @brief getNextAction Checking for the next appropriate action regarding the current state of the scheduler and execute it
197  */
198  void getNextAction();
199 
200  /**
201  * @brief disconnectINDI disconnect all INDI devices from server.
202  */
203  void disconnectINDI();
204 
205  /**
206  * @brief stopEkos shutdown Ekos completely
207  */
208  void stopEkos();
209 
210  /**
211  * @brief stopGuiding After guiding is done we need to stop the process
212  */
213  void stopGuiding();
214 
215  /**
216  * @brief setSolverAction set the GOTO mode for the solver
217  * @param mode 0 For Sync, 1 for SlewToTarget, 2 for Nothing
218  */
219  void setSolverAction(Align::GotoMode mode);
220 
221  /** @defgroup SchedulerDBusInterface Ekos DBus Interface - Scheduler Module
222  * Ekos::Align interface provides primary functions to run and stop the scheduler.
223  */
224 
225  /*@{*/
226 
227  /** DBUS interface function.
228  * @brief Start the scheduler main loop and evaluate jobs and execute them accordingly.
229  */
230  Q_SCRIPTABLE Q_NOREPLY void start();
231 
232  /** DBUS interface function.
233  * @brief Stop the scheduler.
234  */
235  Q_SCRIPTABLE Q_NOREPLY void stop();
236 
237  /** DBUS interface function.
238  * @brief Remove all scheduler jobs
239  */
240  Q_SCRIPTABLE Q_NOREPLY void removeAllJobs();
241 
242  /** DBUS interface function.
243  * @brief Loads the Ekos Scheduler List (.esl) file.
244  * @param fileURL path to a file
245  * @return true if loading file is successful, false otherwise.
246  */
247  Q_SCRIPTABLE bool loadScheduler(const QString &fileURL);
248 
249  /** DBUS interface function.
250  * @brief Set the file URL pointing to the capture sequence file
251  * @param sequenceFileURL URL of the capture sequence file
252  */
253  Q_SCRIPTABLE void setSequence(const QString &sequenceFileURL);
254 
255  /** DBUS interface function.
256  * @brief Resets all jobs to IDLE
257  */
258  Q_SCRIPTABLE void resetAllJobs();
259 
260  /** DBUS interface function.
261  * @brief Resets all jobs to IDLE
262  */
263  Q_SCRIPTABLE void sortJobsPerAltitude();
264 
265  Ekos::SchedulerState status()
266  {
267  return state;
268  }
269 
270  void setProfile(const QString &profile)
271  {
272  schedulerProfileCombo->setCurrentText(profile);
273  }
274  QString profile()
275  {
276  return schedulerProfileCombo->currentText();
277  }
278 
279  /**
280  * @brief retrieve the error handling strategy from the UI
281  */
283 
284  /**
285  * @brief select the error handling strategy (no restart, restart after all terminated, restart immediately)
286  */
288 
289  /** @}*/
290 
291  // TODO: This section of static public and private methods should someday
292  // be moved from Scheduler and placed in a separate class,
293  // e.g. SchedulerPlanner or SchedulerJobEval
294 
295  /**
296  * @brief setupJob Massive initialization of a SchedulerJob for testing and exectution
297  * @param job Target
298  */
299  static void setupJob(
300  SchedulerJob &job, const QString &name, int priority, const dms &ra,
301  const dms &dec, double djd, double rotation, const QUrl &sequenceUrl, const QUrl &fitsUrl,
302  SchedulerJob::StartupCondition startup, const QDateTime &startupTime, int16_t startupOffset,
303  SchedulerJob::CompletionCondition completion, const QDateTime &completionTime, int completionRepeats,
304  double minimumAltitude, double minimumMoonSeparation, bool enforceWeather, bool enforceTwilight,
305  bool enforceArtificialHorizon, bool track, bool focus, bool align, bool guide);
306 
307  /**
308  * @brief evaluateJobs Computes estimated start and end times for the SchedulerJobs passed in. Returns a proposed schedule.
309  * @param jobs The input list of SchedulerJobs to evaluate.
310  * @param capturedFramesCount which parts of the schedulerJobs have already been completed.
311  * @param dawn next dawn, as a KStarsDateTime
312  * @param dusk next dusk, as a KStarsDateTime
313  * @param scheduler instance of the scheduler used for logging. Can be nullptr.
314  * @return list of sorted jobs
315  */
316  static QList<SchedulerJob *> evaluateJobs(QList<SchedulerJob *> &jobs, const QMap<QString, uint16_t> &capturedFramesCount,
317  QDateTime const &dawn, QDateTime const &dusk, Scheduler *scheduler);
318 
319  /**
320  * @brief prepareJobsForEvaluation Start of job evaluation
321  * @param jobs The input list of SchedulerJobs to evaluate.
322  * @param state The current scheduler state.
323  * @param capturedFramesCount which parts of the schedulerJobs have already been completed.
324  * @param rescheduleErrors whether jobs that failed with errors should be rescheduled.
325  * @param restartJobs whether jobs that failed for one reason or another shoulc be rescheduled.
326  * @param possiblyDelay a return value indicating whether the timer should try scheduling again after a delay.
327  * @param scheduler instance of the scheduler used for logging. Can be nullptr.
328  * @return Total score
329  */
331  QList<SchedulerJob *> &jobs, SchedulerState state, const QMap<QString, uint16_t> &capturedFramesCount,
332  bool rescheduleErrors, bool restartJobs, bool *possiblyDelay, Scheduler *scheduler);
333 
334  /**
335  * @brief calculateJobScore Calculate job dark sky score, altitude score, and moon separation scores and returns the sum.
336  * @param job Target
337  * @param dawn next dawn, as a KStarsDateTime
338  * @param dusk next dusk, as a KStarsDateTime
339  * @param when date and time to evaluate constraints, now if omitted.
340  * @return Total score
341  *
342  */
343 
344  static int16_t calculateJobScore(SchedulerJob const *job, QDateTime const &dawn, QDateTime const &dusk,
345  QDateTime const &when = QDateTime());
346 
347  /**
348  * @brief estimateJobTime Estimates the time the job takes to complete based on the sequence file and what modules to utilize during the observation run.
349  * @param job target job
350  * @param capturedFramesCount a map of what's been captured already
351  * @param scheduler instance of the scheduler used for logging. Can be nullptr.
352  * @return Estimated time in seconds.
353  */
354  static bool estimateJobTime(SchedulerJob *schedJob, const QMap<QString, uint16_t> &capturedFramesCount,
355  Scheduler *scheduler);
356  /**
357  * @brief loadSequenceQueue Loads what's necessary to estimate job completion time from a capture sequence queue file
358  * @param fileURL the filename
359  * @param schedJob the SchedulerJob is modified accoring to the contents of the sequence queue
360  * @param jobs the returned values read from the file
361  * @param hasAutoFocus a return value indicating whether autofocus can be triggered by the sequence.
362  * @param scheduler instance of the scheduler used for logging. Can be nullptr.
363  * @return Estimated time in seconds.
364  */
365 
366  static bool loadSequenceQueue(const QString &fileURL, SchedulerJob *schedJob, QList<SequenceJob *> &jobs,
367  bool &hasAutoFocus, Scheduler *scheduler);
368 
369  /**
370  * @brief getDarkSkyScore Get the dark sky score of a date and time. The further from dawn the better.
371  * @param when date and time to check the dark sky score, now if omitted
372  * @return Dark sky score. Daylight get bad score, as well as pre-dawn to dawn.
373  */
374  static int16_t getDarkSkyScore(QDateTime const &dawn, QDateTime const &dusk, QDateTime const &when = QDateTime());
375 
376  /** @brief Setter used in testing to fix the local time. Otherwise getter gets from KStars instance. */
377  /** @{ */
378  static KStarsDateTime getLocalTime();
379  static void setLocalTime(KStarsDateTime *time)
380  {
381  storedLocalTime = time;
382  }
383  static bool hasLocalTime()
384  {
385  return storedLocalTime != nullptr;
386  }
387  /** @} */
388 
389  // Scheduler Settings
390  void setSettings(const QJsonObject &settings);
391 
392  void setUpdateInterval(int ms)
393  {
394  m_UpdatePeriodMs = ms;
395  }
396  int getUpdateInterval()
397  {
398  return m_UpdatePeriodMs;
399  }
400 
401  // Primary Settings
402  void setPrimarySettings(const QJsonObject &settings);
403 
404  // Job Startup Conditions
405  void setJobStartupConditions(const QJsonObject &settings);
406 
407  // Job Constraints
408  void setJobConstraints(const QJsonObject &settings);
409 
410  // Job Completion Conditions
411  void setJobCompletionConditions(const QJsonObject &settings);
412 
413  // Observatory Startup Procedure
414  void setObservatoryStartupProcedure(const QJsonObject &settings);
415 
416  // Aborted Job Managemgent Settings
417  void setAbortedJobManagementSettings(const QJsonObject &settings);
418 
419  // Observatory Shutdown Procedure
420  void setObservatoryShutdownProcedure(const QJsonObject &settings);
421 
422  /**
423  * @brief Remove a job from current table row.
424  * @param index
425  */
426  void removeJob();
427 
428  /**
429  * @brief Remove a job by selecting a table row.
430  * @param index
431  */
432  void removeOneJob(int index);
433 
434  /**
435  * @brief addJob Add a new job from form values
436  */
437  void addJob();
438 
439  /**
440  * @brief addToQueue Construct a SchedulerJob and add it to the queue or save job settings from current form values.
441  * jobUnderEdit determines whether to add or edit
442  */
443  void saveJob();
444 
445  const QList<SchedulerJob *> &getJobs() const
446  {
447  return jobs;
448  }
449 
450  QJsonArray getJSONJobs();
451 
452  void toggleScheduler();
453 
454  QJsonObject getSchedulerSettings();
455  /**
456  * @brief createJobSequence Creates a job sequence for the mosaic tool given the prefix and output dir. The currently selected sequence file is modified
457  * and a new version given the supplied parameters are saved to the output directory
458  * @param prefix Prefix to set for the job sequence
459  * @param outputDir Output dir to set for the job sequence
460  * @return True if new file is saved, false otherwise
461  */
462  bool createJobSequence(XMLEle *root, const QString &prefix, const QString &outputDir);
463 
464  XMLEle *getSequenceJobRoot(const QString &filename) const;
465 
466  /**
467  * @brief saveScheduler Save scheduler jobs to a file
468  * @param path path of a file
469  * @return true on success, false on failure.
470  */
471  bool saveScheduler(const QUrl &fileURL);
472 
473 
474  private:
475  /**
476  * @brief processJobInfo a utility used by loadSequenceQueue() to help it read a capture sequence file
477  * @param root the filename
478  * @param schedJob the SchedulerJob is modified accoring to the contents of the sequence queue
479  * @return a capture sequence
480  */
481  static SequenceJob *processJobInfo(XMLEle *root, SchedulerJob *schedJob);
482 
483  /**
484  * @brief timeHeuristics Estimates the number of seconds of overhead above and beyond imaging time, used by estimateJobTime.
485  * @param schedJob the scheduler job.
486  * @return seconds of overhead.
487  */
488  static int timeHeuristics(const SchedulerJob *schedJob);
489 
490  void setAlgorithm(int alg);
491  SchedulerAlgorithm getAlgorithm() const;
492 
493  // Used in testing, instead of KStars::Instance() resources
494  static KStarsDateTime *storedLocalTime;
495 
496  friend TestSchedulerUnit;
497 
498  // TODO: See above TODO. End of static methods that might be moved to
499  // a separate Scheduler-related class.
500 
501  /*@{*/
502 
503  private:
504  /** @internal Safeguard flag to avoid registering signals from widgets multiple times.
505  */
506  bool jobChangesAreWatched { false };
507 
508  protected:
509  /** @internal Enables signal watch on SchedulerJob form values in order to apply changes to current job.
510  * @param enable is the toggle flag, true to watch for changes, false to ignore them.
511  */
512  void watchJobChanges(bool enable);
513 
514  /** @internal Marks the currently selected SchedulerJob as modified change.
515  *
516  * This triggers job re-evaluation.
517  * Next time save button is invoked, the complete content is written to disk.
518  */
519  void setDirty();
520  /** @} */
521 
522  protected:
523  /** @internal Associate job table cells on a row to the corresponding SchedulerJob.
524  * @param row is an integer indexing the row to associate cells from, and also the index of the job in the job list..
525  */
526  void setJobStatusCells(int row);
527 
528  protected slots:
529 
530  /**
531  * @brief registerNewModule Register an Ekos module as it arrives via DBus
532  * and create the appropriate DBus interface to communicate with it.
533  * @param name of module
534  */
535  void registerNewModule(const QString &name);
536 
537  /**
538  * @brief syncProperties Sync startup properties from the various device to enable/disable features in the scheduler
539  * like the ability to park/unpark..etc
540  */
541  void syncProperties();
542 
543  /**
544  * @brief checkInterfaceReady Sometimes syncProperties() is not sufficient since the ready signal could have fired already
545  * and cannot be relied on to know once a module interface is ready. Therefore, we explicitly check if the module interface
546  * is ready.
547  * @param iface interface to test for readiness.
548  */
549  void checkInterfaceReady(QDBusInterface *iface);
550 
551  void setAlignStatus(Ekos::AlignState status);
552  void setGuideStatus(Ekos::GuideState status);
553  void setCaptureStatus(Ekos::CaptureState status);
554  void setFocusStatus(Ekos::FocusState status);
555  void setMountStatus(ISD::Mount::Status status);
556  void setWeatherStatus(ISD::Weather::Status status);
557 
558  /**
559  * @brief select object from KStars's find dialog.
560  */
561  void selectObject();
562 
563  /**
564  * @brief Selects FITS file for solving.
565  */
566  void selectFITS();
567 
568  /**
569  * @brief Selects sequence queue.
570  */
571  void selectSequence();
572 
573  /**
574  * @brief Selects sequence queue.
575  */
576  void selectStartupScript();
577 
578  /**
579  * @brief Selects sequence queue.
580  */
581  void selectShutdownScript();
582 
583  /**
584  * @brief editJob Edit an observation job
585  * @param i index model in queue table
586  */
587  void loadJob(QModelIndex i);
588 
589  /**
590  * @brief setJobAddApply Set first button state to add new job or apply changes.
591  */
592  void setJobAddApply(bool add_mode);
593 
594  /**
595  * @brief setJobManipulation Enable or disable job manipulation buttons.
596  */
597  void setJobManipulation(bool can_reorder, bool can_delete);
598 
599  /**
600  * @brief set all GUI fields to the values of the given scheduler job
601  */
602  void syncGUIToJob(SchedulerJob *job);
603 
604  /**
605  * @brief jobSelectionChanged Update UI state when the job list is clicked once.
606  */
607  void clickQueueTable(QModelIndex index);
608 
609  /**
610  * @brief Update scheduler parameters to the currently selected scheduler job
611  * @param current table position
612  * @param previous table position
613  */
614  void queueTableSelectionChanged(QModelIndex current, QModelIndex previous);
615 
616  /**
617  * @brief reorderJobs Change the order of jobs in the UI based on a subset of its jobs.
618  */
619  bool reorderJobs(QList<SchedulerJob*> reordered_sublist);
620 
621  /**
622  * @brief moveJobUp Move the selected job up in the job list.
623  */
624  void moveJobUp();
625 
626  /**
627  * @brief moveJobDown Move the selected job down in the list.
628  */
629  void moveJobDown();
630 
631  /**
632  * @brief shouldSchedulerSleep Check if the scheduler needs to sleep until the job is ready
633  * @param currentJob Job to check
634  * @return True if we set the scheduler to sleep mode. False, if not required and we need to execute now
635  */
636  bool shouldSchedulerSleep(SchedulerJob *currentJob);
637 
638  bool completeShutdown();
639  void pause();
640  void setPaused();
641  void save();
642  void saveAs();
643 
644  /**
645  * @brief load Open a file dialog to select an ESL file, and load its contents.
646  * @param clearQueue Clear the queue before loading, or append ESL contents to queue.
647  * @param filename If not empty, this file will be used instead of poping up a dialog.
648  */
649  void load(bool clearQueue, const QString &filename = "");
650 
651  /**
652  * @brief appendEkosScheduleList Append the contents of an ESL file to the queue.
653  * @param fileURL File URL to load contents from.
654  * @return True if contents were loaded successfully, else false.
655  */
656  bool appendEkosScheduleList(const QString &fileURL);
657 
658  void resetJobEdit();
659 
660  /**
661  * @brief updateNightTime update the Twilight restriction with the argument job properties.
662  * @param job SchedulerJob for which to display the next dawn and dusk, or the job currently selected if null, or today's next dawn and dusk if no job is selected.
663  */
664  void updateNightTime(SchedulerJob const * job = nullptr);
665 
666  /**
667  * @brief checkJobStatus Check the overall state of the scheduler, Ekos, and INDI. When all is OK, it calls evaluateJobs() when no job is current or executeJob() if a job is selected.
668  * @return False if this function needs to be called again later, true if situation is stable and operations may continue.
669  */
670  bool checkStatus();
671 
672  /**
673  * @brief checkJobStage Check the progress of the job states and make DBUS call to start the next stage until the job is complete.
674  */
675  void checkJobStage();
676  bool checkJobStageClassic();
677  void checkJobStageEplogue();
678 
679  /**
680  * @brief findNextJob Check if the job met the completion criteria, and if it did, then it search for next job candidate. If no jobs are found, it starts the shutdown stage.
681  */
682  void findNextJob();
683 
684  /**
685  * @brief stopCurrentJobAction Stop whatever action taking place in the current job (eg. capture, guiding...etc).
686  */
687  void stopCurrentJobAction();
688 
689  /**
690  * @brief manageConnectionLoss Mitigate loss of connection with the INDI server.
691  * @return true if connection to Ekos/INDI should be attempted again, false if not mitigation is available or needed.
692  */
693  bool manageConnectionLoss();
694 
695  /**
696  * @brief readProcessOutput read running script process output and display it in Ekos
697  */
698  void readProcessOutput();
699 
700  /**
701  * @brief checkProcessExit Check script process exist status. This is called when the process exists either normally or abnormally.
702  * @param exitCode exit code from the script process. Depending on the exist code, the status of startup/shutdown procedure is set accordingly.
703  */
704  void checkProcessExit(int exitCode);
705 
706  /**
707  * @brief resumeCheckStatus If the scheduler primary loop was suspended due to weather or sleep event, resume it again.
708  */
709  void resumeCheckStatus();
710 
711  /**
712  * @brief checkWeather Check weather status and act accordingly depending on the current status of the scheduler and running jobs.
713  */
714  //void checkWeather();
715 
716  /**
717  * @brief wakeUpScheduler Wake up scheduler from sleep state
718  */
719  void wakeUpScheduler();
720 
721  /**
722  * @brief startJobEvaluation Start job evaluation only without starting the scheduler process itself. Display the result to the user.
723  */
724  void startJobEvaluation();
725 
726  /**
727  * @brief startMosaicTool Start Mosaic tool and create jobs if necessary.
728  */
729  void startMosaicTool();
730 
731  /**
732  * @brief displayTwilightWarning Display twilight warning to user if it is unchecked.
733  */
734  void checkTwilightWarning(bool enabled);
735 
736  void runStartupProcedure();
737  void checkStartupProcedure();
738 
739  void runShutdownProcedure();
740  void checkShutdownProcedure();
741 
742  void setINDICommunicationStatus(Ekos::CommunicationStatus status);
743  void setEkosCommunicationStatus(Ekos::CommunicationStatus status);
744 
745  void simClockScaleChanged(float);
746  void simClockTimeChanged();
747 
748  /**
749  * @brief solverDone Process solver solution after it is done.
750  * @param timedOut True if the process timed out.
751  * @param success True if successful, false otherwise.
752  * @param solution The solver solution if successful.
753  * @param elapsedSeconds How many seconds elapsed to solve the image.
754  */
755  void solverDone(bool timedOut, bool success, const FITSImage::Solution &solution, double elapsedSeconds);
756 
757  bool syncControl(const QJsonObject &settings, const QString &key, QWidget * widget);
758 
759  /**
760  * @brief setCaptureComplete Handle one sequence image completion. This is used now only to run alignment check
761  * to ensure it does not deviation from current scheduler job target.
762  * @param metadata Metadata for image including filename, exposure, filter, hfr..etc.
763  */
764  void setCaptureComplete(const QVariantMap &metadata);
765 
766  signals:
767  void newLog(const QString &text);
768  void newStatus(Ekos::SchedulerState state);
769  void weatherChanged(ISD::Weather::Status state);
770  void newTarget(const QString &);
771  // distance in arc-seconds measured by plate solving the a captured image and
772  // comparing that position to the target position.
773  void targetDistance(double distance);
774  // Below 2 are for the Analyze timeline.
775  void jobStarted(const QString &jobName);
776  void jobEnded(const QString &jobName, const QString &endReason);
777  void jobsUpdated(QJsonArray jobsList);
778 
779  private:
780  /**
781  * @brief evaluateJobs evaluates the current state of each objects and gives each one a score based on the constraints.
782  * Given that score, the scheduler will decide which is the best job that needs to be executed.
783  */
784  void evaluateJobs(bool evaluateOnly);
785  void processJobs(QList<SchedulerJob *> sortedJobs, bool jobEvaluationOnly);
786 
787  /**
788  * @brief executeJob After the best job is selected, we call this in order to start the process that will execute the job.
789  * checkJobStatus slot will be connected in order to figure the exact state of the current job each second
790  * @param value
791  * @return True if job is accepted and can be executed, false otherwise.
792  */
793  bool executeJob(SchedulerJob *job);
794 
795  void executeScript(const QString &filename);
796 
797  /**
798  * @brief getWeatherScore Get current weather condition score.
799  * @return If weather condition OK, return score 0, else bad score.
800  */
801  int16_t getWeatherScore() const;
802 
803  /**
804  * @brief calculateDawnDusk Get dawn and dusk times for today
805  */
806  static void calculateDawnDusk();
807 
808  /**
809  * @brief checkEkosState Check ekos startup stages and take whatever action necessary to get Ekos up and running
810  * @return True if Ekos is running, false if Ekos start up is in progress.
811  */
812  bool checkEkosState();
813 
814  /**
815  * @brief isINDIConnected Determines the status of the INDI connection.
816  * @return True if INDI connection is up and usable, else false.
817  */
818  bool isINDIConnected();
819 
820  /**
821  * @brief checkINDIState Check INDI startup stages and take whatever action necessary to get INDI devices connected.
822  * @return True if INDI devices are connected, false if it is under progress.
823  */
824  bool checkINDIState();
825 
826  /**
827  * @brief checkStartupState Check startup procedure stages and make sure all stages are complete.
828  * @return True if startup is complete, false otherwise.
829  */
830  bool checkStartupState();
831 
832  /**
833  * @brief checkShutdownState Check shutdown procedure stages and make sure all stages are complete.
834  * @return
835  */
836  bool checkShutdownState();
837 
838  /**
839  * @brief checkParkWaitState Check park wait state.
840  * @return If parking/unparking in progress, return false. If parking/unparking complete, return true.
841  */
842  bool checkParkWaitState();
843 
844  /**
845  * @brief parkMount Park mount
846  */
847  void parkMount();
848 
849  /**
850  * @brief unParkMount Unpark mount
851  */
852  void unParkMount();
853 
854  /**
855  * @return True if mount is parked
856  */
857  bool isMountParked();
858 
859  /**
860  * @brief parkDome Park dome
861  */
862  void parkDome();
863 
864  /**
865  * @brief unParkDome Unpark dome
866  */
867  void unParkDome();
868 
869  /**
870  * @return True if dome is parked
871  */
872  bool isDomeParked();
873 
874  /**
875  * @brief parkCap Close dust cover
876  */
877  void parkCap();
878 
879  /**
880  * @brief unCap Open dust cover
881  */
882  void unParkCap();
883 
884  /**
885  * @brief checkMountParkingStatus check mount parking status and updating corresponding states accordingly.
886  */
887  void checkMountParkingStatus();
888 
889  /**
890  * @brief checkDomeParkingStatus check dome parking status and updating corresponding states accordingly.
891  */
892  void checkDomeParkingStatus();
893 
894  /**
895  * @brief checkDomeParkingStatus check dome parking status and updating corresponding states accordingly.
896  */
897  void checkCapParkingStatus();
898 
899  /**
900  * @brief processJobInfo Process the job information from a scheduler file and populate jobs accordingly
901  * @param root XML root element of JOB
902  * @return true on success, false on failure.
903  */
904  bool processJobInfo(XMLEle *root);
905 
906  /** @internal Change the current job, updating associated widgets.
907  * @param job is an existing SchedulerJob to set as current, or nullptr.
908  */
909  void setCurrentJob(SchedulerJob *job);
910 
911  /**
912  * @brief processFITSSelection When a FITS file is selected, open it and try to guess
913  * the object name, and its J2000 RA/DE to fill the UI with such info automatically.
914  */
915  void processFITSSelection();
916 
917  void loadProfiles();
918 
919 
920 
921  /**
922  * @brief updateCompletedJobsCount For each scheduler job, examine sequence job storage and count captures.
923  * @param forced forces recounting captures unconditionally if true, else only IDLE, EVALUATION or new jobs are examined.
924  */
925  void updateCompletedJobsCount(bool forced = false);
926 
927  /**
928  * @brief Update the flag for the given job whether light frames are required
929  * @param oneJob scheduler job where the flag should be updated
930  * @param seqjobs list of capture sequences of the job
931  * @param framesCount map capture signature -> frame count
932  * @return true iff the job need to capture light frames
933  */
934  void updateLightFramesRequired(SchedulerJob *oneJob, const QList<SequenceJob *> &seqjobs,
935  const SchedulerJob::CapturedFramesMap &framesCount);
936 
937  /**
938  * @brief Calculate the map signature -> expected number of captures from the given list of capture sequence jobs,
939  * i.e. the expected number of captures from a single scheduler job run.
940  * @param seqJobs list of capture sequence jobs
941  * @param expected map to be filled
942  * @return total expected number of captured frames of a single run of all jobs
943  */
944  static uint16_t calculateExpectedCapturesMap(const QList<SequenceJob *> &seqJobs, QMap<QString, uint16_t> &expected);
945 
946  /**
947  * @brief Fill the map signature -> frame count so that a single iteration of the scheduled job creates as many frames as possible
948  * in addition to the already captured ones, but does not the expected amount.
949  * @param expected map signature -> expected frames count
950  * @param capturedFramesCount map signature -> already captured frames count
951  * @param schedJob scheduler job for which these calculations are done
952  * @param capture_map map signature -> frame count that will be handed over to the capture module to control that a single iteration
953  * of the scheduler job creates as many frames as possible, but does not exceed the expected ones.
954  * @return total number of captured frames, truncated to the maximal number of frames the scheduler job could produce
955  */
956  static uint16_t fillCapturedFramesMap(const QMap<QString, uint16_t> &expected,
957  const SchedulerJob::CapturedFramesMap &capturedFramesCount,
958  SchedulerJob &schedJob, SchedulerJob::CapturedFramesMap &capture_map);
959 
960  int getCompletedFiles(const QString &path, const QString &seqPrefix);
961 
962  // retrieve the guiding status
963  GuideState getGuidingStatus();
964 
965  // Returns milliseconds since startCurrentOperationTImer() was called.
966  qint64 getCurrentOperationMsec();
967  // Starts the above operation timer.
968  void startCurrentOperationTimer();
969 
970  // Controls for the guiding timer, which restarts guiding after failure.
971  void cancelGuidingTimer();
972  bool isGuidingTimerActive();
973  void startGuidingTimer(int milliseconds);
974  void processGuidingTimer();
975 
976  // Returns true if the job is storing its captures on the same machine as the scheduler.
977  bool canCountCaptures(const SchedulerJob &job);
978 
979  Ekos::Scheduler *ui { nullptr };
980  //DBus interfaces
981  QPointer<QDBusInterface> focusInterface { nullptr };
982  QPointer<QDBusInterface> ekosInterface { nullptr };
983  QPointer<QDBusInterface> captureInterface { nullptr };
984  QPointer<QDBusInterface> mountInterface { nullptr };
985  QPointer<QDBusInterface> alignInterface { nullptr };
986  QPointer<QDBusInterface> guideInterface { nullptr };
987  QPointer<QDBusInterface> domeInterface { nullptr };
988  QPointer<QDBusInterface> weatherInterface { nullptr };
989  QPointer<QDBusInterface> capInterface { nullptr };
990 
991  // Interface strings for the dbus. Changeable for mocks when testing. Private so only tests can change.
992  QString schedulerPathString { "/KStars/Ekos/Scheduler" };
993  QString kstarsInterfaceString { "org.kde.kstars" };
994 
995  QString focusInterfaceString { "org.kde.kstars.Ekos.Focus" };
996  void setFocusInterfaceString(const QString &interface)
997  {
998  focusInterfaceString = interface;
999  }
1000  QString focusPathString { "/KStars/Ekos/Focus" };
1001  void setFocusPathString(const QString &interface)
1002  {
1003  focusPathString = interface;
1004  }
1005 
1006  // This is only used in the constructor
1007  QString ekosInterfaceString { "org.kde.kstars.Ekos" };
1008  QString ekosPathString { "/KStars/Ekos" };
1009 
1010  QString mountInterfaceString { "org.kde.kstars.Ekos.Mount" };
1011  void setMountInterfaceString(const QString &interface)
1012  {
1013  mountInterfaceString = interface;
1014  }
1015  QString mountPathString { "/KStars/Ekos/Mount" };
1016  void setMountPathString(const QString &interface)
1017  {
1018  mountPathString = interface;
1019  }
1020 
1021  QString captureInterfaceString { "org.kde.kstars.Ekos.Capture" };
1022  void setCaptureInterfaceString(const QString &interface)
1023  {
1024  captureInterfaceString = interface;
1025  }
1026  QString capturePathString { "/KStars/Ekos/Capture" };
1027  void setCapturePathString(const QString &interface)
1028  {
1029  capturePathString = interface;
1030  }
1031 
1032  QString alignInterfaceString { "org.kde.kstars.Ekos.Align" };
1033  void setAlignInterfaceString(const QString &interface)
1034  {
1035  alignInterfaceString = interface;
1036  }
1037  QString alignPathString { "/KStars/Ekos/Align" };
1038  void setAlignPathString(const QString &interface)
1039  {
1040  alignPathString = interface;
1041  }
1042 
1043  QString guideInterfaceString { "org.kde.kstars.Ekos.Guide" };
1044  void setGuideInterfaceString(const QString &interface)
1045  {
1046  guideInterfaceString = interface;
1047  }
1048  QString guidePathString { "/KStars/Ekos/Guide" };
1049  void setGuidePathString(const QString &interface)
1050  {
1051  guidePathString = interface;
1052  }
1053 
1054  QString domeInterfaceString { "org.kde.kstars.Ekos.Dome" };
1055  void setDomeInterfaceString(const QString &interface)
1056  {
1057  domeInterfaceString = interface;
1058  }
1059  QString domePathString { "/KStars/Ekos/Dome" };
1060  void setDomePathString(const QString &interface)
1061  {
1062  domePathString = interface;
1063  }
1064 
1065  QString weatherInterfaceString { "org.kde.kstars.Ekos.Weather" };
1066  void setWeatherInterfaceString(const QString &interface)
1067  {
1068  weatherInterfaceString = interface;
1069  }
1070  QString weatherPathString { "/KStars/Ekos/Weather" };
1071  void setWeatherPathString(const QString &interface)
1072  {
1073  weatherPathString = interface;
1074  }
1075 
1076  QString dustCapInterfaceString { "org.kde.kstars.Ekos.DustCap" };
1077  void setDustCapInterfaceString(const QString &interface)
1078  {
1079  dustCapInterfaceString = interface;
1080  }
1081  QString dustCapPathString { "/KStars/Ekos/DustCap" };
1082  void setDustCapPathString(const QString &interface)
1083  {
1084  dustCapPathString = interface;
1085  }
1086 
1087  // Scheduler and job state and stages
1088  SchedulerState state { SCHEDULER_IDLE };
1089  EkosState ekosState { EKOS_IDLE };
1090  INDIState indiState { INDI_IDLE };
1091  StartupState startupState { STARTUP_IDLE };
1092  ShutdownState shutdownState { SHUTDOWN_IDLE };
1093  ParkWaitStatus parkWaitState { PARKWAIT_IDLE };
1094  Ekos::CommunicationStatus m_EkosCommunicationStatus { Ekos::Idle };
1095  Ekos::CommunicationStatus m_INDICommunicationStatus { Ekos::Idle };
1096  /// List of all jobs as entered by the user or file
1097  QList<SchedulerJob *> jobs;
1098  /// Active job
1099  SchedulerJob *currentJob { nullptr };
1100  /// URL to store the scheduler file
1101  QUrl schedulerURL;
1102  /// URL for Ekos Sequence
1103  QUrl sequenceURL;
1104  /// FITS URL to solve
1105  QUrl fitsURL;
1106  /// Startup script URL
1107  QUrl startupScriptURL;
1108  /// Shutdown script URL
1109  QUrl shutdownScriptURL;
1110  /// Store all log strings
1111  QStringList m_LogText;
1112  /// Busy indicator widget
1113  QProgressIndicator *pi { nullptr };
1114  /// Are we editing a job right now? Job row index
1115  int jobUnderEdit { -1 };
1116  /// Pointer to Geographic location
1117  GeoLocation *geo { nullptr };
1118  /// How many repeated job batches did we complete thus far?
1119  uint16_t captureBatch { 0 };
1120  /// Startup and Shutdown scripts process
1121  QProcess scriptProcess;
1122  /// Store next dawn to calculate dark skies range
1123  static QDateTime Dawn;
1124  /// Store next dusk to calculate dark skies range
1125  static QDateTime Dusk;
1126  /// Pre-dawn is where we stop all jobs, it is a user-configurable value before Dawn.
1127  static QDateTime preDawnDateTime;
1128  /// Was job modified and needs saving?
1129  bool mDirty { false };
1130  /// Keep watch of weather status
1131  ISD::Weather::Status weatherStatus { ISD::Weather::WEATHER_IDLE };
1132  /// Keep track of how many times we didn't receive weather updates
1133  uint8_t noWeatherCounter { 0 };
1134 
1135  // Utilities to control the preemptiveShutdown feature.
1136  // Is the scheduler shutting down until later when it will resume a job?
1137  void enablePreemptiveShutdown(const QDateTime &wakeupTime);
1138  void disablePreemptiveShutdown();
1139  QDateTime getPreemptiveShutdownWakeupTime();
1140  bool preemptiveShutdown();
1141  // The various preemptiveShutdown states are controlled by this one variable.
1142  QDateTime preemptiveShutdownWakeupTime;
1143 
1144  /// Keep track of Load & Slew operation
1145  bool loadAndSlewProgress { false };
1146  /// Check if initial autofocus is completed and do not run autofocus until there is a change is telescope position/alignment.
1147  bool autofocusCompleted { false };
1148  /// Keep track of INDI connection failures
1149  uint8_t indiConnectFailureCount { 0 };
1150  /// Keep track of Ekos connection failures
1151  uint8_t ekosConnectFailureCount { 0 };
1152  /// Keep track of Ekos focus module failures
1153  uint8_t focusFailureCount { 0 };
1154  /// Keep track of Ekos guide module failures
1155  uint8_t guideFailureCount { 0 };
1156  /// Keep track of Ekos align module failures
1157  uint8_t alignFailureCount { 0 };
1158  /// Keep track of Ekos capture module failures
1159  uint8_t captureFailureCount { 0 };
1160  /// Counter to keep debug logging in check
1161  uint8_t checkJobStageCounter { 0 };
1162  /// Call checkWeather when weatherTimer time expires. It is equal to the UpdatePeriod time in INDI::Weather device.
1163  //QTimer weatherTimer;
1164 
1165  /// Delay for restarting the guider
1166  /// used by cancelGuidingTimer(), isGuidingTimerActive(), startGuidingTimer
1167  /// and processGuidingTimer.
1168  int restartGuidingInterval { -1 };
1169  KStarsDateTime restartGuidingTime;
1170 
1171  /// Generic time to track timeout of current operation in progress.
1172  /// Used by startCurrentOperationTimer() and getCurrentOperationMsec().
1173  KStarsDateTime currentOperationTime;
1174  bool currentOperationTimeStarted { false };
1175 
1176  QUrl dirPath;
1177 
1178  QMap<QString, uint16_t> m_CapturedFramesCount;
1179 
1180  bool m_MountReady { false };
1181  bool m_CaptureReady { false };
1182  bool m_DomeReady { false };
1183  bool m_CapReady { false };
1184 
1185  // When a module is commanded to perform an action, wait this many milliseconds
1186  // before check its state again. If State is still IDLE, then it either didn't received the command
1187  // or there is another problem.
1188  static const uint32_t ALIGN_INACTIVITY_TIMEOUT = 120000;
1189  static const uint32_t FOCUS_INACTIVITY_TIMEOUT = 120000;
1190  static const uint32_t CAPTURE_INACTIVITY_TIMEOUT = 120000;
1191  static const uint16_t GUIDE_INACTIVITY_TIMEOUT = 60000;
1192 
1193  // Methods & variables that control the scheduler's iterations.
1194 
1195  // Executes the scheduler
1196  void execute();
1197  // Repeatedly runs a scheduler iteration and then sleeps timerInterval millisconds
1198  // and run the next iteration. This continues until the sleep time is negative.
1199  void iterate();
1200  // Initialize the scheduler.
1201  void init();
1202  // Run a single scheduler iteration.
1203  int runSchedulerIteration();
1204 
1205  // This is the time between typical scheduler iterations.
1206  // The time can be modified for testing.
1207  int m_UpdatePeriodMs = 1000;
1208 
1209  // Setup the parameters for the next scheduler iteration.
1210  // When milliseconds is not passed in, it uses m_UpdatePeriodMs.
1211  void setupNextIteration(SchedulerTimerState nextState);
1212  void setupNextIteration(SchedulerTimerState nextState, int milliseconds);
1213  // True if the scheduler is between iterations and delaying longer than the typical update period.
1214  bool currentlySleeping();
1215  // Used by the constructor in testing mainly so a mock ekos could be used.
1216  void setupScheduler(const QString &ekosPathStr, const QString &ekosInterfaceStr);
1217  // Prints all the relative state variables set during an iteration. For debugging.
1218  void printStates(const QString &label);
1219 
1220 
1221  // The type of scheduler iteration that should be run next.
1222  SchedulerTimerState timerState { RUN_NOTHING };
1223  // Variable keeping the number of millisconds the scheduler should wait
1224  // after the current scheduler iteration.
1225  int timerInterval { -1 };
1226  // Whether the scheduler has been setup for the next iteration,
1227  // that is, whether timerInterval and timerState have been set this iteration.
1228  bool iterationSetup { false };
1229  // The timer used to wakeup the scheduler between iterations.
1230  QTimer iterationTimer;
1231  // Counter for how many scheduler iterations have been processed.
1232  int schedulerIteration { 0 };
1233  // The time when the scheduler first started running iterations.
1234  qint64 startMSecs { 0 };
1235 
1236  /// Target coordinates for pointing check
1237  QSharedPointer<SolverUtils> m_Solver;
1238  // Used when solving position every nth capture.
1239  uint32_t m_SolverIteration {0};
1240 
1241  void syncGreedyParams();
1242  QPointer<Ekos::GreedyScheduler> m_GreedyScheduler;
1243 
1244  friend TestEkosSchedulerOps;
1245  QPointer<GreedyScheduler> &getGreedyScheduler()
1246  {
1247  return m_GreedyScheduler;
1248  }
1249 };
1250 }
Q_OBJECTQ_OBJECT
void startAstrometry()
startAstrometry initiation of the capture and solve operation.
Definition: scheduler.cpp:5395
Extension of QDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day,...
ErrorHandlingStrategy
options what should happen if an error or abort occurs
Definition: scheduler.h:100
Q_PROPERTY(...)
void setJobManipulation(bool can_reorder, bool can_delete)
setJobManipulation Enable or disable job manipulation buttons.
Definition: scheduler.cpp:1635
void checkTwilightWarning(bool enabled)
displayTwilightWarning Display twilight warning to user if it is unchecked.
Definition: scheduler.cpp:7153
void resumeCheckStatus()
resumeCheckStatus If the scheduler primary loop was suspended due to weather or sleep event,...
Definition: scheduler.cpp:6878
void startJobEvaluation()
startJobEvaluation Start job evaluation only without starting the scheduler process itself.
Definition: scheduler.cpp:6832
void disconnectINDI()
disconnectINDI disconnect all INDI devices from server.
Definition: scheduler.cpp:5638
void startFocusing()
startFocusing DBus call for feeding ekos the specified settings and initiating focus operation
Definition: scheduler.cpp:4991
void moveJobDown()
moveJobDown Move the selected job down in the list.
Definition: scheduler.cpp:1721
static QList< SchedulerJob * > evaluateJobs(QList< SchedulerJob * > &jobs, const QMap< QString, uint16_t > &capturedFramesCount, QDateTime const &dawn, QDateTime const &dusk, Scheduler *scheduler)
evaluateJobs Computes estimated start and end times for the SchedulerJobs passed in.
Definition: scheduler.cpp:2362
void readProcessOutput()
readProcessOutput read running script process output and display it in Ekos
Definition: scheduler.cpp:3704
Ekos is an advanced Astrophotography tool for Linux. It is based on a modular extensible framework to...
Definition: align.cpp:70
void addJob()
addJob Add a new job from form values
Definition: scheduler.cpp:1106
Q_CLASSINFO(Name, Value)
ErrorHandlingStrategy getErrorHandlingStrategy()
retrieve the error handling strategy from the UI
Definition: scheduler.cpp:6885
void watchJobChanges(bool enable)
Definition: scheduler.cpp:739
void setCaptureComplete(const QVariantMap &metadata)
setCaptureComplete Handle one sequence image completion.
Definition: scheduler.cpp:8305
bool checkStatus()
checkJobStatus Check the overall state of the scheduler, Ekos, and INDI.
Definition: scheduler.cpp:3770
void startSlew()
startSlew DBus call for initiating slew
Definition: scheduler.cpp:4950
void registerNewModule(const QString &name)
registerNewModule Register an Ekos module as it arrives via DBus and create the appropriate DBus inte...
Definition: scheduler.cpp:7491
void checkProcessExit(int exitCode)
checkProcessExit Check script process exist status.
Definition: scheduler.cpp:3709
void selectFITS()
Selects FITS file for solving.
Definition: scheduler.cpp:946
bool createJobSequence(XMLEle *root, const QString &prefix, const QString &outputDir)
createJobSequence Creates a job sequence for the mosaic tool given the prefix and output dir.
Definition: scheduler.cpp:7093
Q_SCRIPTABLE void setSequence(const QString &sequenceFileURL)
DBUS interface function.
Definition: scheduler.cpp:1047
void selectStartupScript()
Selects sequence queue.
Definition: scheduler.cpp:1078
void wakeUpScheduler()
checkWeather Check weather status and act accordingly depending on the current status of the schedule...
Definition: scheduler.cpp:2920
The QProgressIndicator class lets an application display a progress indicator to show that a long tas...
bool saveScheduler(const QUrl &fileURL)
saveScheduler Save scheduler jobs to a file
Definition: scheduler.cpp:4775
SchedulerColumns
Columns, in the same order as UI.
Definition: scheduler.h:115
void removeOneJob(int index)
Remove a job by selecting a table row.
Definition: scheduler.cpp:1856
void moveJobUp()
moveJobUp Move the selected job up in the job list.
Definition: scheduler.cpp:1683
Sequence Job is a container for the details required to capture a series of images.
Definition: sequencejob.h:18
static int16_t getDarkSkyScore(QDateTime const &dawn, QDateTime const &dusk, QDateTime const &when=QDateTime())
getDarkSkyScore Get the dark sky score of a date and time.
Definition: scheduler.cpp:2955
void load(bool clearQueue, const QString &filename="")
load Open a file dialog to select an ESL file, and load its contents.
Definition: scheduler.cpp:4383
void stopGuiding()
stopGuiding After guiding is done we need to stop the process
Definition: scheduler.cpp:5612
Q_SCRIPTABLE Q_NOREPLY void stop()
DBUS interface function.
Definition: scheduler.cpp:1872
Scheduler()
Constructor, the starndard scheduler constructor.
Definition: scheduler.cpp:404
void updateNightTime(SchedulerJob const *job=nullptr)
updateNightTime update the Twilight restriction with the argument job properties.
Definition: scheduler.cpp:1536
void checkJobStage()
checkJobStage Check the progress of the job states and make DBUS call to start the next stage until t...
Definition: scheduler.cpp:3875
static void setupJob(SchedulerJob &job, const QString &name, int priority, const dms &ra, const dms &dec, double djd, double rotation, const QUrl &sequenceUrl, const QUrl &fitsUrl, SchedulerJob::StartupCondition startup, const QDateTime &startupTime, int16_t startupOffset, SchedulerJob::CompletionCondition completion, const QDateTime &completionTime, int completionRepeats, double minimumAltitude, double minimumMoonSeparation, bool enforceWeather, bool enforceTwilight, bool enforceArtificialHorizon, bool track, bool focus, bool align, bool guide)
setupJob Massive initialization of a SchedulerJob for testing and exectution
Definition: scheduler.cpp:1124
bool reorderJobs(QList< SchedulerJob * > reordered_sublist)
reorderJobs Change the order of jobs in the UI based on a subset of its jobs.
Definition: scheduler.cpp:1654
Q_SCRIPTABLE Q_NOREPLY void start()
DBUS interface function.
Definition: scheduler.cpp:294
static QList< SchedulerJob * > prepareJobsForEvaluation(QList< SchedulerJob * > &jobs, SchedulerState state, const QMap< QString, uint16_t > &capturedFramesCount, bool rescheduleErrors, bool restartJobs, bool *possiblyDelay, Scheduler *scheduler)
prepareJobsForEvaluation Start of job evaluation
Definition: scheduler.cpp:2188
Q_SCRIPTABLE void sortJobsPerAltitude()
DBUS interface function.
Definition: scheduler.cpp:6851
CaptureState
Capture states.
Definition: ekos.h:91
void selectSequence()
Selects sequence queue.
Definition: scheduler.cpp:1069
void removeJob()
Remove a job from current table row.
Definition: scheduler.cpp:1807
void stopCurrentJobAction()
stopCurrentJobAction Stop whatever action taking place in the current job (eg.
Definition: scheduler.cpp:4284
void getNextAction()
getNextAction Checking for the next appropriate action regarding the current state of the scheduler a...
Definition: scheduler.cpp:4186
QString join(const QString &separator) const const
void startCapture(bool restart=false)
startCapture The current job file name is solved to an url which is fed to ekos.
Definition: scheduler.cpp:5520
An angle, stored as degrees, but expressible in many ways.
Definition: dms.h:37
bool manageConnectionLoss()
manageConnectionLoss Mitigate loss of connection with the INDI server.
Definition: scheduler.cpp:4330
bool appendEkosScheduleList(const QString &fileURL)
appendEkosScheduleList Append the contents of an ESL file to the queue.
Definition: scheduler.cpp:4431
Q_SCRIPTABLE bool loadScheduler(const QString &fileURL)
DBUS interface function.
Definition: scheduler.cpp:4425
SchedulerAlgorithm
Algorithms, in the same order as UI.
Definition: scheduler.h:108
static int16_t calculateJobScore(SchedulerJob const *job, QDateTime const &dawn, QDateTime const &dusk, QDateTime const &when=QDateTime())
calculateJobScore Calculate job dark sky score, altitude score, and moon separation scores and return...
Definition: scheduler.cpp:3001
void solverDone(bool timedOut, bool success, const FITSImage::Solution &solution, double elapsedSeconds)
solverDone Process solver solution after it is done.
Definition: scheduler.cpp:8338
void saveJob()
addToQueue Construct a SchedulerJob and add it to the queue or save job settings from current form va...
Definition: scheduler.cpp:1200
static bool estimateJobTime(SchedulerJob *schedJob, const QMap< QString, uint16_t > &capturedFramesCount, Scheduler *scheduler)
estimateJobTime Estimates the time the job takes to complete based on the sequence file and what modu...
Definition: scheduler.cpp:5861
void syncProperties()
syncProperties Sync startup properties from the various device to enable/disable features in the sche...
Definition: scheduler.cpp:7574
SchedulerTimerState
IterationTypes, the different types of scheduler iterations that are run.
Definition: scheduler.h:130
Q_SCRIPTABLE Q_NOREPLY void removeAllJobs()
DBUS interface function.
Definition: scheduler.cpp:4413
static KStarsDateTime getLocalTime()
Setter used in testing to fix the local time.
Definition: scheduler.cpp:274
void syncGUIToJob(SchedulerJob *job)
set all GUI fields to the values of the given scheduler job
Definition: scheduler.cpp:1437
void setJobAddApply(bool add_mode)
setJobAddApply Set first button state to add new job or apply changes.
Definition: scheduler.cpp:1617
The Ekos scheduler is a simple scheduler class to orchestrate automated multi object observation jobs...
Definition: scheduler.h:49
void checkInterfaceReady(QDBusInterface *iface)
checkInterfaceReady Sometimes syncProperties() is not sufficient since the ready signal could have fi...
Definition: scheduler.cpp:7654
void stopEkos()
stopEkos shutdown Ekos completely
Definition: scheduler.cpp:5646
void setJobStatusCells(int row)
Definition: scheduler.cpp:1759
void queueTableSelectionChanged(QModelIndex current, QModelIndex previous)
Update scheduler parameters to the currently selected scheduler job.
Definition: scheduler.cpp:1591
void selectShutdownScript()
Selects sequence queue.
Definition: scheduler.cpp:1092
void setSolverAction(Align::GotoMode mode)
setSolverAction set the GOTO mode for the solver
Definition: scheduler.cpp:5631
void selectObject()
select object from KStars's find dialog.
Definition: scheduler.cpp:912
static bool loadSequenceQueue(const QString &fileURL, SchedulerJob *schedJob, QList< SequenceJob * > &jobs, bool &hasAutoFocus, Scheduler *scheduler)
loadSequenceQueue Loads what's necessary to estimate job completion time from a capture sequence queu...
Definition: scheduler.cpp:7358
void startGuiding(bool resetCalibration=false)
startGuiding After ekos is fed the calibration options, we start the guiding process
Definition: scheduler.cpp:5480
Q_SCRIPTABLE void resetAllJobs()
DBUS interface function.
Definition: scheduler.cpp:7140
Information about an object in the sky.
Definition: skyobject.h:41
void startMosaicTool()
startMosaicTool Start Mosaic tool and create jobs if necessary.
Definition: scheduler.cpp:6951
void setErrorHandlingStrategy(ErrorHandlingStrategy strategy)
select the error handling strategy (no restart, restart after all terminated, restart immediately)
Definition: scheduler.cpp:6897
void findNextJob()
findNextJob Check if the job met the completion criteria, and if it did, then it search for next job ...
Definition: scheduler.cpp:5125
bool shouldSchedulerSleep(SchedulerJob *currentJob)
shouldSchedulerSleep Check if the scheduler needs to sleep until the job is ready
Definition: scheduler.cpp:8160
void clickQueueTable(QModelIndex index)
jobSelectionChanged Update UI state when the job list is clicked once.
Definition: scheduler.cpp:1612
Relevant data about an observing location on Earth.
Definition: geolocation.h:27
void loadJob(QModelIndex i)
editJob Edit an observation job
Definition: scheduler.cpp:1552
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 12 2022 04:00:57 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.