Kstars

schedulerutils.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
8#pragma once
9
10#include "schedulertypes.h"
11#include "ekos/capture/capturetypes.h"
12#include "ekos/auxiliary/modulelogger.h"
13#include "dms.h"
14#include "libindi/lilxml.h"
15
16#include <QString>
17#include <QUrl>
18#include <QDateTime>
19
20class SkyPoint;
21
22namespace Ekos {
23
24class SchedulerJob;
25class SequenceJob;
26
27class SchedulerUtils
28{
29public:
30 SchedulerUtils();
31
32
33 /**
34 * @brief createJob Create job from its XML representation
35 * @param root XML description of the job to be created
36 * @param leadJob candidate for lead (only necessary if the new job's type is follower)
37 */
38 static SchedulerJob *createJob(XMLEle *root, SchedulerJob *leadJob);
39
40 /**
41 * @brief setupJob Initialize a job with all fields accessible from the UI.
42 */
43 static void setupJob(SchedulerJob &job, const QString &name, bool isLead, const QString &group, const QString &train, const dms &ra, const dms &dec,
44 double djd, double rotation, const QUrl &sequenceUrl, const QUrl &fitsUrl, StartupCondition startup,
45 const QDateTime &startupTime, CompletionCondition completion, const QDateTime &completionTime, int completionRepeats,
46 double minimumAltitude, double minimumMoonSeparation, bool enforceWeather, bool enforceTwilight,
47 bool enforceArtificialHorizon, bool track, bool focus, bool align, bool guide);
48
49
50 /**
51 * @brief Fill the map signature -> frame count so that a single iteration of the scheduled job creates as many frames as possible
52 * in addition to the already captured ones, but does not the expected amount.
53 * @param expected map signature -> expected frames count
54 * @param capturedFramesCount map signature -> already captured frames count
55 * @param schedJob scheduler job for which these calculations are done
56 * @param capture_map map signature -> frame count that will be handed over to the capture module to control that a single iteration
57 * of the scheduler job creates as many frames as possible, but does not exceed the expected ones.
58 * @param completedIterations How many times has the job completed its capture sequence (for repeated jobs).
59 * @return total number of captured frames, truncated to the maximal number of frames the scheduler job could produce
60 */
61 static uint16_t fillCapturedFramesMap(const CapturedFramesMap &expected, const CapturedFramesMap &capturedFramesCount, SchedulerJob &schedJob,
62 CapturedFramesMap &capture_map, int &completedIterations);
63
64
65 /**
66 * @brief Update the flag for the given job whether light frames are required
67 * @param oneJob scheduler job where the flag should be updated
68 * @param seqjobs list of capture sequences of the job
69 * @param framesCount map capture signature -> frame count
70 * @return true iff the job need to capture light frames
71 */
72 static void updateLightFramesRequired(SchedulerJob *oneJob, const QList<SequenceJob *> &seqjobs, const CapturedFramesMap &framesCount);
73
74 /**
75 * @brief processJobInfo a utility used by loadSequenceQueue() to help it read a capture sequence file
76 * @param root the filename
77 * @param schedJob the SchedulerJob is modified accoring to the contents of the sequence queue
78 * @return a capture sequence
79 */
80 static SequenceJob *processSequenceJobInfo(XMLEle *root, SchedulerJob *schedJob);
81
82 /**
83 * @brief loadSequenceQueue Loads what's necessary to estimate job completion time from a capture sequence queue file
84 * @param fileURL the filename
85 * @param schedJob the SchedulerJob is modified according to the contents of the sequence queue
86 * @param jobs the returned values read from the file
87 * @param hasAutoFocus a return value indicating whether autofocus can be triggered by the sequence.
88 * @param logger module logging utility
89 */
90
91 static bool loadSequenceQueue(const QString &fileURL, SchedulerJob *schedJob, QList<SequenceJob *> &jobs, bool &hasAutoFocus, ModuleLogger *logger);
92
93 /**
94 * @brief estimateJobTime Estimates the time the job takes to complete based on the sequence file and what modules to utilize during the observation run.
95 * @param job target job
96 * @param capturedFramesCount a map of what's been captured already
97 * @param logger module logging utility
98 * @return true if the time could be estimated, false if the corresponding sequence file is invalid
99 */
100 static bool estimateJobTime(SchedulerJob *schedJob, const CapturedFramesMap &capturedFramesCount, ModuleLogger *logger);
101
102 /**
103 * @brief timeHeuristics Estimates the number of seconds of overhead above and beyond imaging time, used by estimateJobTime.
104 * @param schedJob the scheduler job.
105 * @return seconds of overhead.
106 */
107 static int timeHeuristics(const SchedulerJob *schedJob);
108
109 /**
110 * @brief Calculate the map signature -> expected number of captures from the given list of capture sequence jobs,
111 * i.e. the expected number of captures from a single scheduler job run.
112 * @param seqJobs list of capture sequence jobs
113 * @param expected map to be filled
114 * @return total expected number of captured frames of a single run of all jobs
115 */
116 static uint16_t calculateExpectedCapturesMap(const QList<SequenceJob *> &seqJobs, CapturedFramesMap &expected);
117
118 /**
119 * @brief findAltitude Find altitude given a specific time
120 * @param target Target
121 * @param when date time to find altitude
122 * @param is_setting whether target is setting at the argument time (optional).
123 * @param debug outputs calculation to log file (optional).
124 * @return Altitude of the target at the specific date and time given.
125 * @warning This function uses the current KStars geolocation.
126 */
127 static double findAltitude(const SkyPoint &target, const QDateTime &when, bool *is_setting = nullptr, bool debug = false);
128
129 /**
130 * @brief create a new list with only the master jobs from the input
131 */
132 static QList<SchedulerJob *> filterLeadJobs(const QList<SchedulerJob *> &jobs);
133};
134
135
136} // namespace
Sequence Job is a container for the details required to capture a series of images.
The sky coordinates of a point in the sky.
Definition skypoint.h:45
An angle, stored as degrees, but expressible in many ways.
Definition dms.h:38
Ekos is an advanced Astrophotography tool for Linux.
Definition align.cpp:83
QMap< QString, uint16_t > CapturedFramesMap
mapping signature --> frames count
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.