Changeset View
Changeset View
Standalone View
Standalone View
kstars/ekos/scheduler/schedulestrategy.h
- This file was added.
1 | /* Ekos Scheduling Strategy | ||||
---|---|---|---|---|---|
2 | Copyright (C) Jasem Mutlaq <mutlaqja@ikarustech.com> | ||||
3 | | ||||
4 | This application is free software; you can redistribute it and/or | ||||
5 | modify it under the terms of the GNU General Public | ||||
6 | License as published by the Free Software Foundation; either | ||||
7 | version 2 of the License, or (at your option) any later version. | ||||
8 | */ | ||||
9 | | ||||
10 | #pragma once | ||||
11 | | ||||
12 | #include "schedulerjob.h" | ||||
13 | #include "indiapi.h" | ||||
14 | | ||||
15 | class GeoLocation; | ||||
16 | class KSMoon; | ||||
17 | | ||||
18 | namespace Ekos | ||||
19 | { | ||||
20 | class ScheduleStrategy | ||||
21 | { | ||||
22 | public: | ||||
23 | ScheduleStrategy(); | ||||
24 | | ||||
25 | /** | ||||
26 | * @brief getDarkSkyScore Get the dark sky score of a date and time. The further from dawn the better. | ||||
27 | * @param when date and time to check the dark sky score, now if omitted | ||||
28 | * @return Dark sky score. Daylight get bad score, as well as pre-dawn to dawn. | ||||
29 | */ | ||||
30 | int16_t getDarkSkyScore(QDateTime const &when = QDateTime()) const; | ||||
31 | | ||||
32 | /** | ||||
33 | * @brief getAltitudeScore Get the altitude score of an object. The higher the better | ||||
34 | * @param job Target job | ||||
35 | * @param when date and time to check the target altitude, now if omitted. | ||||
36 | * @return Altitude score. Target altitude below minimum altitude required by job or setting target under 3 degrees below minimum altitude get bad score. | ||||
37 | */ | ||||
38 | int16_t getAltitudeScore(SchedulerJob const *job, QDateTime const &when = QDateTime()) const; | ||||
39 | | ||||
40 | /** | ||||
41 | * @brief getMoonSeparationScore Get moon separation score. The further apart, the better, up a maximum score of 20. | ||||
42 | * @param job Target job | ||||
43 | * @param when date and time to check the moon separation, now if omitted. | ||||
44 | * @return Moon separation score | ||||
45 | */ | ||||
46 | int16_t getMoonSeparationScore(SchedulerJob const *job, QDateTime const &when = QDateTime()) const; | ||||
47 | | ||||
48 | /** | ||||
49 | * @brief calculateJobScore Calculate job dark sky score, altitude score, and moon separation scores and returns the sum. | ||||
50 | * @param job Target | ||||
51 | * @param when date and time to evaluate constraints, now if omitted. | ||||
52 | * @return Total score | ||||
53 | */ | ||||
54 | int16_t calculateJobScore(SchedulerJob const *job, QDateTime const &when = QDateTime()) const; | ||||
55 | | ||||
56 | #if 0 | ||||
57 | /** | ||||
58 | * @brief getWeatherScore Get current weather condition score. | ||||
59 | * @return If weather condition OK, return score 0, else bad score. | ||||
60 | */ | ||||
61 | int16_t getWeatherScore(); | ||||
62 | #endif | ||||
63 | | ||||
64 | /** | ||||
65 | * @brief calculateAltitudeTime calculate the altitude time given the minimum altitude given. | ||||
66 | * @param job active target | ||||
67 | * @param minAltitude minimum altitude required | ||||
68 | * @param minMoonAngle minimum separation from the moon. -1 to ignore. | ||||
69 | * @param when date and time to start searching from, now if omitted. | ||||
70 | * @return The date and time the target is at or above the argument altitude, valid if found, invalid if not achievable (always under altitude). | ||||
71 | */ | ||||
72 | QDateTime calculateAltitudeTime(SchedulerJob const *job, double minAltitude, double minMoonAngle = -1, QDateTime const &when = QDateTime()) const; | ||||
73 | | ||||
74 | /** | ||||
75 | * @brief calculateCulmination find culmination time adjust for the job offset | ||||
76 | * @param job active target | ||||
77 | * @param offset_minutes offset in minutes before culmination to search for. | ||||
78 | * @param when date and time to start searching from, now if omitted | ||||
79 | * @return The date and time the target is in entering the culmination interval, valid if found, invalid if not achievable (currently always valid). | ||||
80 | */ | ||||
81 | QDateTime calculateCulmination(SchedulerJob const *job, int offset_minutes, QDateTime const &when = QDateTime()) const; | ||||
82 | | ||||
83 | /** | ||||
84 | * @brief calculateDawnDusk Get dawn and dusk times for today | ||||
85 | */ | ||||
86 | void calculateDawnDusk(); | ||||
87 | | ||||
88 | double getDawn() const { return Dawn; } | ||||
89 | double getDusk() const { return Dusk; } | ||||
90 | | ||||
91 | /** | ||||
92 | * @brief getCurrentMoonSeparation Get current moon separation in degrees at current time for the given job | ||||
93 | * @param job scheduler job | ||||
94 | * @return Separation in degrees | ||||
95 | */ | ||||
96 | double getCurrentMoonSeparation(SchedulerJob const *job) const; | ||||
97 | | ||||
98 | /** | ||||
99 | * @brief updatePreDawn Update predawn time depending on current time and user offset | ||||
100 | */ | ||||
101 | void updatePreDawn(); | ||||
102 | | ||||
103 | QDateTime getPreDawnDateTime() const { return preDawnDateTime; } | ||||
104 | | ||||
105 | /** | ||||
106 | * @brief findAltitude Find altitude given a specific time | ||||
107 | * @param target Target | ||||
108 | * @param when date time to find altitude | ||||
109 | * @param is_setting whether target is setting at the argument time (optional). | ||||
110 | * @param debug outputs calculation to log file (optional). | ||||
111 | * @return Altitude of the target at the specific date and time given. | ||||
112 | * @warning This function uses the current KStars geolocation. | ||||
113 | */ | ||||
114 | static double findAltitude(const SkyPoint &target, const QDateTime &when, bool *is_setting = nullptr, bool debug = false); | ||||
115 | | ||||
116 | void setWeatherStatus(IPState status) { weatherStatus = status; } | ||||
117 | IPState getWeatherStatus() { return weatherStatus; } | ||||
118 | | ||||
119 | | ||||
120 | bool isWeatherOK(SchedulerJob *job); | ||||
121 | | ||||
122 | private: | ||||
123 | /// Pointer to Moon object | ||||
124 | KSMoon *moon { nullptr }; | ||||
125 | /// Store day fraction of dawn to calculate dark skies range | ||||
126 | double Dawn { -1 }; | ||||
127 | /// Store day fraction of dusk to calculate dark skies range | ||||
128 | double Dusk { -1 }; | ||||
129 | /// Pre-dawn is where we stop all jobs, it is a user-configurable value before Dawn. | ||||
130 | QDateTime preDawnDateTime; | ||||
131 | /// Dusk date time | ||||
132 | QDateTime duskDateTime; | ||||
133 | /// Keep watch of weather status | ||||
134 | IPState weatherStatus { IPS_IDLE }; | ||||
135 | | ||||
136 | | ||||
137 | }; | ||||
138 | | ||||
139 | | ||||
140 | } |