Kstars

schedulerprocess.h
1/*
2 SPDX-FileCopyrightText: 2023 Wolfgang Reissenberger <sterne-jaeger@openfuture.de>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "schedulertypes.h"
10#include "ekos/auxiliary/modulelogger.h"
11#include "ekos/align/align.h"
12#include "ekos/auxiliary/solverutils.h"
13#include "indi/indiweather.h"
14#include "dms.h"
15
16#include <QObject>
17#include <QPointer>
18#include <QDBusInterface>
19#include <QProcess>
20
21namespace Ekos
22{
23
24class SchedulerJob;
25class GreedyScheduler;
26class SchedulerModuleState;
27
28/**
29 * @class SchedulerProcess
30 * @brief The SchedulerProcess class holds the entire business logic for controlling the
31 * execution of the EKOS scheduler.
32 */
33class SchedulerProcess : public QObject, public ModuleLogger
34{
36 Q_CLASSINFO("D-Bus Interface", "org.kde.kstars.Ekos.Scheduler")
37 Q_PROPERTY(Ekos::SchedulerState status READ status NOTIFY newStatus)
38 Q_PROPERTY(QString profile READ profile WRITE setProfile)
39 Q_PROPERTY(QStringList logText READ logText NOTIFY newLog)
40
41public:
43
44
45 // ////////////////////////////////////////////////////////////////////
46 // external DBUS interface
47 // ////////////////////////////////////////////////////////////////////
48
49 SchedulerState status();
50
51 // ////////////////////////////////////////////////////////////////////
52 // process steps
53 // ////////////////////////////////////////////////////////////////////
54
55 /**
56 * @brief execute Execute the schedule, start if idle or paused.
57 */
58 Q_SCRIPTABLE void execute();
59
60 /**
61 * @brief findNextJob Check if the job met the completion criteria, and if it did, then it search for next job candidate.
62 * If no jobs are found, it starts the shutdown stage.
63 */
64 void findNextJob();
65
66 /**
67 * @brief stopCurrentJobAction Stop whatever action taking place in the current job (eg. capture, guiding...etc).
68 */
70
71 /**
72 * @brief executeJob After the best job is selected, we call this in order to start the process that will execute the job.
73 * checkJobStatus slot will be connected in order to figure the exact state of the current job each second
74 * @return True if job is accepted and can be executed, false otherwise.
75 */
76 bool executeJob(SchedulerJob *job);
77
78 /**
79 * @brief wakeUpScheduler Wake up scheduler from sleep state
80 */
82
83 /** DBUS interface function.
84 * @brief Setup the main loop and start.
85 */
86 Q_SCRIPTABLE Q_NOREPLY void start();
87
88 /** DBUS interface function.
89 * @brief stop Stop the scheduler execution. If stopping succeeded,
90 * a {@see #schedulerStopped()} signal is emitted
91 */
92 Q_SCRIPTABLE Q_NOREPLY void stop();
93
94 /** DBUS interface function.
95 * @brief Remove all scheduler jobs
96 */
97 Q_SCRIPTABLE Q_NOREPLY void removeAllJobs();
98
99 /** DBUS interface function.
100 * @brief Loads the Ekos Scheduler List (.esl) file.
101 * @param fileURL path to a file
102 * @return true if loading file is successful, false otherwise.
103 */
105
106 /** DBUS interface function.
107 * @brief Set the file URL pointing to the capture sequence file
108 * @param sequenceFileURL URL of the capture sequence file
109 */
110 Q_SCRIPTABLE Q_NOREPLY void setSequence(const QString &sequenceFileURL);
111
112 /** DBUS interface function.
113 * @brief Resets all jobs to IDLE
114 */
115 Q_SCRIPTABLE Q_NOREPLY void resetAllJobs();
116
117 /**
118 * @brief shouldSchedulerSleep Check if the scheduler needs to sleep until the job is ready
119 * @param job Job to check
120 * @return True if we set the scheduler to sleep mode. False, if not required and we need to execute now
121 */
122 bool shouldSchedulerSleep(SchedulerJob *job);
123
124 /**
125 * @brief startSlew DBus call for initiating slew
126 */
127 Q_SCRIPTABLE Q_NOREPLY void startSlew();
128
129 /**
130 * @brief startFocusing DBus call for feeding ekos the specified settings and initiating focus operation
131 */
132 Q_SCRIPTABLE Q_NOREPLY void startFocusing();
133
134 /**
135 * @brief startAstrometry initiation of the capture and solve operation. We change the job state
136 * after solver is started
137 */
138 Q_SCRIPTABLE Q_NOREPLY void startAstrometry();
139
140 /**
141 * @brief startGuiding After ekos is fed the calibration options, we start the guiding process
142 * @param resetCalibration By default calibration is not reset until it is explicitly requested
143 */
144 Q_SCRIPTABLE Q_NOREPLY void startGuiding(bool resetCalibration = false);
145
146 /**
147 * @brief stopGuiding After guiding is done we need to stop the process
148 */
149 Q_SCRIPTABLE Q_NOREPLY void stopGuiding();
150
151 /**
152 * @brief processGuidingTimer Check the guiding timer, and possibly restart guiding.
153 */
154 void processGuidingTimer();
155
156 /**
157 * @brief startCapture The current job file name is solved to an url which is fed to ekos. We then start the capture process
158 * @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
159 * is not loaded from disk again since that results in erasing all the history of the capture process.
160 */
161 Q_SCRIPTABLE Q_NOREPLY void startCapture(bool restart = false);
162
163 /**
164 * @brief updateCompletedJobsCount For each scheduler job, examine sequence job storage and count captures.
165 * @param forced forces recounting captures unconditionally if true, else only IDLE, EVALUATION or new jobs are examined.
166 */
167 void updateCompletedJobsCount(bool forced = false);
168
169 /**
170 * @brief setSolverAction set the GOTO mode for the solver
171 * @param mode 0 For Sync, 1 for SlewToTarget, 2 for Nothing
172 */
173 void setSolverAction(Align::GotoMode mode);
174
175 /**
176 * @brief loadProfiles Load the existing EKOS profiles
177 */
178 void loadProfiles();
179
180 /**
181 * @brief checkEkosState Check ekos startup stages and take whatever action necessary to get Ekos up and running
182 * @return True if Ekos is running, false if Ekos start up is in progress.
183 */
184 bool checkEkosState();
185
186 /**
187 * @brief checkINDIState Check INDI startup stages and take whatever action necessary to get INDI devices connected.
188 * @return True if INDI devices are connected, false if it is under progress.
189 */
190 bool checkINDIState();
191
192 /**
193 * @brief completeShutdown Try to complete the scheduler shutdown
194 * @return false iff some further action is required
195 */
197
198 /**
199 * @brief disconnectINDI disconnect all INDI devices from server.
200 */
201 Q_SCRIPTABLE Q_NOREPLY void disconnectINDI();
202
203 /**
204 * @brief manageConnectionLoss Mitigate loss of connection with the INDI server.
205 * @return true if connection to Ekos/INDI should be attempted again, false if not mitigation is available or needed.
206 */
208
209 /**
210 * @brief checkDomeParkingStatus check dome parking status and updating corresponding states accordingly.
211 */
213
214 /**
215 * @brief checkStartupState Check startup procedure stages and make sure all stages are complete.
216 * @return True if startup is complete, false otherwise.
217 */
218 bool checkStartupState();
219 /**
220 * @brief checkShutdownState Check shutdown procedure stages and make sure all stages are complete.
221 * @return
222 */
223 bool checkShutdownState();
224
225 /**
226 * @brief checkParkWaitState Check park wait state.
227 * @return If parking/unparking in progress, return false. If parking/unparking complete, return true.
228 */
230
231 /**
232 * @brief runStartupProcedure Execute the startup of the scheduler itself to be prepared
233 * for running scheduler jobs.
234 */
235 Q_SCRIPTABLE Q_NOREPLY void runStartupProcedure();
236
237 /**
238 * @brief runShutdownProcedure Shutdown the scheduler itself and EKOS (if configured to do so).
239 */
240 Q_SCRIPTABLE Q_NOREPLY void runShutdownProcedure();
241
242 /**
243 * @brief setPaused pausing the scheduler
244 */
245 Q_SCRIPTABLE Q_NOREPLY void setPaused();
246
247 /**
248 * @brief resetJobs Reset all jobs counters
249 */
250 Q_SCRIPTABLE Q_NOREPLY void resetJobs();
251
252 /**
253 * @brief selectActiveJob Select the job that should be executed
254 */
255 void selectActiveJob(const QList<SchedulerJob *> &jobs);
256
257 /**
258 * @brief startJobEvaluation Start job evaluation only without starting the scheduler process itself. Display the result to the user.
259 */
260 Q_SCRIPTABLE Q_NOREPLY void startJobEvaluation();
261
262 /**
263 * @brief evaluateJobs evaluates the current state of each objects and gives each one a score based on the constraints.
264 * Given that score, the scheduler will decide which is the best job that needs to be executed.
265 */
266 Q_SCRIPTABLE Q_NOREPLY void evaluateJobs(bool evaluateOnly);
267
268 /**
269 * @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.
270 * @return False if this function needs to be called again later, true if situation is stable and operations may continue.
271 */
272 bool checkStatus();
273
274 /**
275 * @brief getNextAction Checking for the next appropriate action regarding the current state of the scheduler and execute it
276 */
277 void getNextAction();
278
279 /**
280 * @brief Repeatedly runs a scheduler iteration and then sleeps timerInterval millisconds
281 * and run the next iteration. This continues until the sleep time is negative.
282 */
283 void iterate();
284
285 /**
286 * @brief Run a single scheduler iteration.
287 */
289
290 /**
291 * @brief checkJobStage Check the progress of the job states and make DBUS calls to start the next stage until the job is complete.
292 */
293 void checkJobStage();
294 void checkJobStageEpilogue();
295
296 /**
297 * @brief applyConfig Apply configuration changes from the global configuration dialog.
298 */
299 void applyConfig();
300
301 /**
302 * @brief saveScheduler Save scheduler jobs to a file
303 * @param path path of a file
304 * @return true on success, false on failure.
305 */
307
308 /**
309 * @brief appendEkosScheduleList Append the contents of an ESL file to the queue.
310 * @param fileURL File URL to load contents from.
311 * @return True if contents were loaded successfully, else false.
312 */
314
315 /**
316 * @brief appendLogText Append a new line to the logging.
317 */
318 Q_SCRIPTABLE Q_NOREPLY void appendLogText(const QString &logentry) override;
319
320 /**
321 * @brief clearLog Clear log entry
322 */
323 Q_SCRIPTABLE void clearLog();
324
325 /**
326 * @return True if mount is parked
327 */
329 /**
330 * @return True if dome is parked
331 */
333
334 void simClockScaleChanged(float);
335 void simClockTimeChanged();
336
337 // ////////////////////////////////////////////////////////////////////
338 // state machine and scheduler
339 // ////////////////////////////////////////////////////////////////////
341 QSharedPointer<SchedulerModuleState> moduleState() const
342 {
343 return m_moduleState;
344 }
345
346 QPointer<Ekos::GreedyScheduler> m_GreedyScheduler;
347 QPointer<GreedyScheduler> &getGreedyScheduler()
348 {
349 return m_GreedyScheduler;
350 }
351
352 // ////////////////////////////////////////////////////////////////////
353 // DBUS interfaces to devices
354 // ////////////////////////////////////////////////////////////////////
355
356 QString focusInterfaceString { "org.kde.kstars.Ekos.Focus" };
357 void setFocusInterfaceString(const QString &interface)
358 {
359 focusInterfaceString = interface;
360 }
361 QString focusPathString { "/KStars/Ekos/Focus" };
362 void setFocusPathString(const QString &interface)
363 {
364 focusPathString = interface;
365 }
366
367 QString mountInterfaceString { "org.kde.kstars.Ekos.Mount" };
368 void setMountInterfaceString(const QString &interface)
369 {
370 mountInterfaceString = interface;
371 }
372 QString mountPathString { "/KStars/Ekos/Mount" };
373 void setMountPathString(const QString &interface)
374 {
375 mountPathString = interface;
376 }
377
378 QString captureInterfaceString { "org.kde.kstars.Ekos.Capture" };
379 void setCaptureInterfaceString(const QString &interface)
380 {
381 captureInterfaceString = interface;
382 }
383 QString capturePathString { "/KStars/Ekos/Capture" };
384 void setCapturePathString(const QString &interface)
385 {
386 capturePathString = interface;
387 }
388
389 QString alignInterfaceString { "org.kde.kstars.Ekos.Align" };
390 void setAlignInterfaceString(const QString &interface)
391 {
392 alignInterfaceString = interface;
393 }
394 QString alignPathString { "/KStars/Ekos/Align" };
395 void setAlignPathString(const QString &interface)
396 {
397 alignPathString = interface;
398 }
399
400 QString guideInterfaceString { "org.kde.kstars.Ekos.Guide" };
401 void setGuideInterfaceString(const QString &interface)
402 {
403 guideInterfaceString = interface;
404 }
405 QString guidePathString { "/KStars/Ekos/Guide" };
406 void setGuidePathString(const QString &interface)
407 {
408 guidePathString = interface;
409 }
410
411 QString domeInterfaceString { "org.kde.kstars.INDI.Dome" };
412 void setDomeInterfaceString(const QString &interface)
413 {
414 domeInterfaceString = interface;
415 }
416
417 QString domePathString;
418 void setDomePathString(const QString &interface)
419 {
420 domePathString = interface;
421 }
422
423 QString weatherInterfaceString { "org.kde.kstars.INDI.Weather" };
424 void setWeatherInterfaceString(const QString &interface)
425 {
426 weatherInterfaceString = interface;
427 }
428 QString weatherPathString;
429 void setWeatherPathString(const QString &interface)
430 {
431 weatherPathString = interface;
432 }
433
434 QString dustCapInterfaceString { "org.kde.kstars.INDI.DustCap" };
435 void setDustCapInterfaceString(const QString &interface)
436 {
437 dustCapInterfaceString = interface;
438 }
439 QString dustCapPathString;
440 void setDustCapPathString(const QString &interface)
441 {
442 dustCapPathString = interface;
443 }
444
445 QPointer<QDBusInterface> ekosInterface() const
446 {
447 return m_ekosInterface;
448 }
449 void setEkosInterface(QPointer<QDBusInterface> newInterface)
450 {
451 m_ekosInterface = newInterface;
452 }
453 QPointer<QDBusInterface> indiInterface() const
454 {
455 return m_indiInterface;
456 }
457 void setIndiInterface(QPointer<QDBusInterface> newInterface)
458 {
459 m_indiInterface = newInterface;
460 }
461 QPointer<QDBusInterface> focusInterface() const
462 {
463 return m_focusInterface;
464 }
465 void setFocusInterface(QPointer<QDBusInterface> newInterface)
466 {
467 m_focusInterface = newInterface;
468 }
469 QPointer<QDBusInterface> captureInterface() const
470 {
471 return m_captureInterface;
472 }
473 void setCaptureInterface(QPointer<QDBusInterface> newInterface)
474 {
475 m_captureInterface = newInterface;
476 }
477 QPointer<QDBusInterface> mountInterface() const
478 {
479 return m_mountInterface;
480 }
481 void setMountInterface(QPointer<QDBusInterface> newInterface)
482 {
483 m_mountInterface = newInterface;
484 }
485 QPointer<QDBusInterface> alignInterface() const
486 {
487 return m_alignInterface;
488 }
489 void setAlignInterface(QPointer<QDBusInterface> newInterface)
490 {
491 m_alignInterface = newInterface;
492 }
493 QPointer<QDBusInterface> guideInterface() const
494 {
495 return m_guideInterface;
496 }
497 void setGuideInterface(QPointer<QDBusInterface> newInterface)
498 {
499 m_guideInterface = newInterface;
500 }
501 QPointer<QDBusInterface> domeInterface() const
502 {
503 return m_domeInterface;
504 }
505 void setDomeInterface(QPointer<QDBusInterface> newInterface)
506 {
507 m_domeInterface = newInterface;
508 }
509 QPointer<QDBusInterface> weatherInterface() const
510 {
511 return m_weatherInterface;
512 }
513 void setWeatherInterface(QPointer<QDBusInterface> newInterface)
514 {
515 m_weatherInterface = newInterface;
516 }
517 QPointer<QDBusInterface> capInterface() const
518 {
519 return m_capInterface;
520 }
521 void setCapInterface(QPointer<QDBusInterface> newInterface)
522 {
523 m_capInterface = newInterface;
524 }
525
526 /**
527 * @brief createJobSequence Creates a job sequence for the mosaic tool given the prefix and output dir. The currently selected sequence file is modified
528 * and a new version given the supplied parameters are saved to the output directory
529 * @param prefix Prefix to set for the job sequence
530 * @param outputDir Output dir to set for the job sequence
531 * @return True if new file is saved, false otherwise
532 */
533 bool createJobSequence(XMLEle *root, const QString &prefix, const QString &outputDir);
534
535 /**
536 * @brief getSequenceJobRoot Read XML data from capture sequence job
537 * @param filename
538 * @return
539 */
540 XMLEle *getSequenceJobRoot(const QString &filename) const;
541
542 /**
543 * @brief getGuidingStatus Retrieve the guiding status.
544 */
545 GuideState getGuidingStatus();
546
547 QProcess &scriptProcess()
548 {
549 return m_scriptProcess;
550 }
551
552 const QString &profile() const;
553 void setProfile(const QString &newProfile);
554
555 QStringList logText();
556
557signals:
558 // new log text for the module log window
559 void newLog(const QString &text);
560 // status updates
561 void newStatus(SchedulerState state);
562 void newWeatherStatus(ISD::Weather::Status state);
563 void schedulerStopped();
564 void shutdownStarted();
565 void schedulerSleeping(bool shutdown, bool sleep);
566 void schedulerPaused();
567 void changeSleepLabel(QString text, bool show = true);
568 // state changes
569 void jobsUpdated(QJsonArray jobsList);
570 void updateJobTable(SchedulerJob *job = nullptr);
571 void clearJobTable();
572 void changeCurrentSequence(const QString &sequenceFileURL);
573 void interfaceReady(QDBusInterface *iface);
574 // loading jobs
575 void addJob(SchedulerJob *job);
576 void syncGreedyParams();
577 void syncGUIToGeneralSettings();
578 void updateSchedulerURL(const QString &fileURL);
579 // distance in arc-seconds measured by plate solving the a captured image and
580 // comparing that position to the target position.
581 void targetDistance(double distance);
582 // required for Analyze timeline
583 void jobStarted(const QString &jobName);
584 void jobEnded(const QString &jobName, const QString &endReason);
585
586
587private slots:
588 void setINDICommunicationStatus(Ekos::CommunicationStatus status);
589 void setEkosCommunicationStatus(Ekos::CommunicationStatus status);
590
591 /**
592 * @brief syncProperties Sync startup properties from the various device to enable/disable features in the scheduler
593 * like the ability to park/unpark..etc
594 */
595 void syncProperties()
596 {
597 checkInterfaceReady(qobject_cast<QDBusInterface*>(sender()));
598 }
599
600 // ////////////////////////////////////////////////////////////////////
601 // alignment checks
602 // ////////////////////////////////////////////////////////////////////
603
604 /**
605 * @brief checkAlignment Handle one sequence image completion. This is used now only to run alignment check
606 * to ensure it does not deviation from current scheduler job target.
607 * @param metadata Metadata for image including filename, exposure, filter, hfr..etc.
608 */
609 void checkAlignment(const QVariantMap &metadata);
610
611 /**
612 * @brief solverDone Process solver solution after it is done.
613 * @param timedOut True if the process timed out.
614 * @param success True if successful, false otherwise.
615 * @param solution The solver solution if successful.
616 * @param elapsedSeconds How many seconds elapsed to solve the image.
617 */
618 void solverDone(bool timedOut, bool success, const FITSImage::Solution &solution, double elapsedSeconds);
619
620 /**
621 * @brief checkInterfaceReady Sometimes syncProperties() is not sufficient since the ready signal could have fired already
622 * and cannot be relied on to know once a module interface is ready. Therefore, we explicitly check if the module interface
623 * is ready.
624 * @param iface interface to test for readiness.
625 */
626 void checkInterfaceReady(QDBusInterface *iface);
627
628 /**
629 * @brief registerNewModule Register an Ekos module as it arrives via DBus
630 * and create the appropriate DBus interface to communicate with it.
631 * @param name of module
632 */
633 void registerNewModule(const QString &name);
634
635 /**
636 * @brief registerNewDevice register interfaces associated with devices
637 * @param name Device name
638 * @param interface Device driver interface
639 */
640 void registerNewDevice(const QString &name, int interface);
641
642 // ////////////////////////////////////////////////////////////////////
643 // device handling
644 // ////////////////////////////////////////////////////////////////////
645 void setAlignStatus(Ekos::AlignState status);
646 void setGuideStatus(Ekos::GuideState status);
647 void setCaptureStatus(Ekos::CaptureState status);
648 void setFocusStatus(Ekos::FocusState status);
649 void setMountStatus(ISD::Mount::Status status);
650 void setWeatherStatus(ISD::Weather::Status status);
651
652private:
653 // When a module is commanded to perform an action, wait this many milliseconds
654 // before check its state again. If State is still IDLE, then it either didn't received the command
655 // or there is another problem.
656 static const uint32_t ALIGN_INACTIVITY_TIMEOUT = 120000;
657 static const uint32_t FOCUS_INACTIVITY_TIMEOUT = 120000;
658 static const uint32_t CAPTURE_INACTIVITY_TIMEOUT = 120000;
659 static const uint16_t GUIDE_INACTIVITY_TIMEOUT = 60000;
660 /// Counter to keep debug logging in check
661 uint8_t checkJobStageCounter { 0 };
662
663 // Startup and Shutdown scripts process
664 QProcess m_scriptProcess;
665 // solver for alignment checks
667 // ////////////////////////////////////////////////////////////////////
668 // DBUS interfaces
669 // ////////////////////////////////////////////////////////////////////
670 // Interface strings for the dbus. Changeable for mocks when testing. Private so only tests can change.
671 QString schedulerProcessPathString { "/KStars/Ekos/Scheduler" };
672 QString kstarsInterfaceString { "org.kde.kstars" };
673 // This is only used in the constructor
674 QString ekosInterfaceString { "org.kde.kstars.Ekos" };
675 QString ekosPathString { "/KStars/Ekos" };
676 QString INDIInterfaceString { "org.kde.kstars.INDI" };
677 QString INDIPathString {"/KStars/INDI"};
678 // DBus interfaces to devices
679 QPointer<QDBusInterface> m_ekosInterface { nullptr };
680 QPointer<QDBusInterface> m_indiInterface { nullptr };
681 QPointer<QDBusInterface> m_focusInterface { nullptr };
682 QPointer<QDBusInterface> m_captureInterface { nullptr };
683 QPointer<QDBusInterface> m_mountInterface { nullptr };
684 QPointer<QDBusInterface> m_alignInterface { nullptr };
685 QPointer<QDBusInterface> m_guideInterface { nullptr };
686 QPointer<QDBusInterface> m_domeInterface { nullptr };
687 QPointer<QDBusInterface> m_weatherInterface { nullptr };
688 QPointer<QDBusInterface> m_capInterface { nullptr };
689 // ////////////////////////////////////////////////////////////////////
690 // process steps
691 // ////////////////////////////////////////////////////////////////////
692
693 /**
694 * @brief executeScript Execute pre- or post job script
695 */
696 void executeScript(const QString &filename);
697
698 /**
699 * @brief stopEkos shutdown Ekos completely
700 */
701 void stopEkos();
702
703 /**
704 * @brief checkMountParkingStatus check mount parking status and updating corresponding states accordingly.
705 */
706 void checkMountParkingStatus();
707
708 /**
709 * @brief checkDomeParkingStatus check dome parking status and updating corresponding states accordingly.
710 */
711 void checkDomeParkingStatus();
712
713 // ////////////////////////////////////////////////////////////////////
714 // device handling
715 // ////////////////////////////////////////////////////////////////////
716 /**
717 * @brief parkCap Close dust cover
718 */
719 void parkCap();
720
721 /**
722 * @brief unCap Open dust cover
723 */
724 void unParkCap();
725
726 /**
727 * @brief parkMount Park mount
728 */
729 void parkMount();
730
731 /**
732 * @brief unParkMount Unpark mount
733 */
734 void unParkMount();
735
736 /**
737 * @brief parkDome Park dome
738 */
739 void parkDome();
740
741 /**
742 * @brief unParkDome Unpark dome
743 */
744 void unParkDome();
745
746 // ////////////////////////////////////////////////////////////////////
747 // helper functions
748 // ////////////////////////////////////////////////////////////////////
749
750 /**
751 * @brief checkStartupProcedure restart regularly {@see #checkStartupState()} until completed
752 */
753 void checkStartupProcedure();
754
755 /**
756 * @brief checkShutdownProcedure Check regularly if the shutdown has completed (see
757 * {@see #checkShutdownState()}) and stop EKOS if the corresponding configuration flag is set.
758 */
759 void checkShutdownProcedure();
760
761 /**
762 * @brief checkProcessExit Check script process exist status. This is called when the process exists either normally or abnormally.
763 * @param exitCode exit code from the script process. Depending on the exist code, the status of startup/shutdown procedure is set accordingly.
764 */
765 void checkProcessExit(int exitCode);
766
767 /**
768 * @brief readProcessOutput read running script process output and display it in Ekos
769 */
770 void readProcessOutput();
771
772 /**
773 * @brief Returns true if the job is storing its captures on the same machine as the scheduler.
774 */
775 bool canCountCaptures(const SchedulerJob &job);
776
777 /**
778 * @brief activeJob Shortcut to the active job held in the state machine
779 */
780 SchedulerJob *activeJob();
781
782 // Prints all the relative state variables set during an iteration. For debugging.
783 void printStates(const QString &label);
784
785};
786} // Ekos namespace
The SchedulerProcess class holds the entire business logic for controlling the execution of the EKOS ...
Q_SCRIPTABLE Q_NOREPLY void startAstrometry()
startAstrometry initiation of the capture and solve operation.
bool shouldSchedulerSleep(SchedulerJob *job)
shouldSchedulerSleep Check if the scheduler needs to sleep until the job is ready
Q_SCRIPTABLE Q_NOREPLY void startCapture(bool restart=false)
startCapture The current job file name is solved to an url which is fed to ekos.
void loadProfiles()
loadProfiles Load the existing EKOS profiles
Q_SCRIPTABLE Q_NOREPLY void runStartupProcedure()
runStartupProcedure Execute the startup of the scheduler itself to be prepared for running scheduler ...
void checkCapParkingStatus()
checkDomeParkingStatus check dome parking status and updating corresponding states accordingly.
void getNextAction()
getNextAction Checking for the next appropriate action regarding the current state of the scheduler a...
Q_SCRIPTABLE bool isMountParked()
Q_SCRIPTABLE Q_NOREPLY void startJobEvaluation()
startJobEvaluation Start job evaluation only without starting the scheduler process itself.
Q_SCRIPTABLE Q_NOREPLY void resetJobs()
resetJobs Reset all jobs counters
void selectActiveJob(const QList< SchedulerJob * > &jobs)
selectActiveJob Select the job that should be executed
Q_SCRIPTABLE void wakeUpScheduler()
wakeUpScheduler Wake up scheduler from sleep state
Q_SCRIPTABLE Q_NOREPLY void setPaused()
setPaused pausing the scheduler
Q_SCRIPTABLE bool checkParkWaitState()
checkParkWaitState Check park wait state.
bool executeJob(SchedulerJob *job)
executeJob After the best job is selected, we call this in order to start the process that will execu...
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.
void iterate()
Repeatedly runs a scheduler iteration and then sleeps timerInterval millisconds and run the next iter...
Q_SCRIPTABLE Q_NOREPLY void startGuiding(bool resetCalibration=false)
startGuiding After ekos is fed the calibration options, we start the guiding process
void findNextJob()
findNextJob Check if the job met the completion criteria, and if it did, then it search for next job ...
Q_SCRIPTABLE bool appendEkosScheduleList(const QString &fileURL)
appendEkosScheduleList Append the contents of an ESL file to the queue.
Q_SCRIPTABLE void execute()
execute Execute the schedule, start if idle or paused.
Q_SCRIPTABLE bool isDomeParked()
Q_SCRIPTABLE bool saveScheduler(const QUrl &fileURL)
saveScheduler Save scheduler jobs to a file
Q_SCRIPTABLE Q_NOREPLY void appendLogText(const QString &logentry) override
appendLogText Append a new line to the logging.
Q_SCRIPTABLE Q_NOREPLY void start()
DBUS interface function.
Q_SCRIPTABLE Q_NOREPLY void removeAllJobs()
DBUS interface function.
Q_SCRIPTABLE void stopCurrentJobAction()
stopCurrentJobAction Stop whatever action taking place in the current job (eg.
Q_SCRIPTABLE Q_NOREPLY void stopGuiding()
stopGuiding After guiding is done we need to stop the process
bool checkShutdownState()
checkShutdownState Check shutdown procedure stages and make sure all stages are complete.
Q_SCRIPTABLE Q_NOREPLY void startSlew()
startSlew DBus call for initiating slew
bool checkEkosState()
checkEkosState Check ekos startup stages and take whatever action necessary to get Ekos up and runnin...
bool checkStatus()
checkJobStatus Check the overall state of the scheduler, Ekos, and INDI.
bool checkINDIState()
checkINDIState Check INDI startup stages and take whatever action necessary to get INDI devices conne...
XMLEle * getSequenceJobRoot(const QString &filename) const
getSequenceJobRoot Read XML data from capture sequence job
Q_SCRIPTABLE Q_NOREPLY void runShutdownProcedure()
runShutdownProcedure Shutdown the scheduler itself and EKOS (if configured to do so).
Q_SCRIPTABLE Q_NOREPLY void setSequence(const QString &sequenceFileURL)
DBUS interface function.
Q_SCRIPTABLE bool loadScheduler(const QString &fileURL)
DBUS interface function.
Q_SCRIPTABLE Q_NOREPLY void startFocusing()
startFocusing DBus call for feeding ekos the specified settings and initiating focus operation
void checkJobStage()
checkJobStage Check the progress of the job states and make DBUS calls to start the next stage until ...
bool checkStartupState()
checkStartupState Check startup procedure stages and make sure all stages are complete.
void processGuidingTimer()
processGuidingTimer Check the guiding timer, and possibly restart guiding.
GuideState getGuidingStatus()
getGuidingStatus Retrieve the guiding status.
Q_SCRIPTABLE Q_NOREPLY void resetAllJobs()
DBUS interface function.
void applyConfig()
applyConfig Apply configuration changes from the global configuration dialog.
Q_SCRIPTABLE void clearLog()
clearLog Clear log entry
Q_SCRIPTABLE Q_NOREPLY void disconnectINDI()
disconnectINDI disconnect all INDI devices from server.
Q_SCRIPTABLE Q_NOREPLY void stop()
DBUS interface function.
bool manageConnectionLoss()
manageConnectionLoss Mitigate loss of connection with the INDI server.
void updateCompletedJobsCount(bool forced=false)
updateCompletedJobsCount For each scheduler job, examine sequence job storage and count captures.
Q_SCRIPTABLE Q_NOREPLY void evaluateJobs(bool evaluateOnly)
evaluateJobs evaluates the current state of each objects and gives each one a score based on the cons...
int runSchedulerIteration()
Run a single scheduler iteration.
void setSolverAction(Align::GotoMode mode)
setSolverAction set the GOTO mode for the solver
Q_SCRIPTABLE bool completeShutdown()
completeShutdown Try to complete the scheduler shutdown
The SchedulerState class holds all attributes defining the scheduler's state.
Ekos is an advanced Astrophotography tool for Linux.
Definition align.cpp:79
AlignState
Definition ekos.h:145
CaptureState
Capture states.
Definition ekos.h:92
Q_CLASSINFO(Name, Value)
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
QObject * sender() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:48:26 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.