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

KDE's Doxygen guidelines are available online.