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