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

KDE's Doxygen guidelines are available online.