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

KDE's Doxygen guidelines are available online.