Kstars

observatory.h
1/* Ekos Observatory Module
2 SPDX-FileCopyrightText: Wolfgang Reissenberger <sterne-jaeger@t-online.de>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "ui_observatory.h"
10
11#include "indi/indidome.h"
12#include "indi/indiweather.h"
13
14#include <QWidget>
15#include <QLineEdit>
16#include <KLocalizedString>
17
18namespace Ekos
19{
20
21struct ObservatoryStatusControl
22{
23 bool useDome, useShutter, useWeather;
24};
25
26struct WeatherActions
27{
28 bool parkDome, closeShutter, stopScheduler;
29 uint delay;
30};
31
32
33class Observatory : public QWidget, public Ui::Observatory
34{
36 Q_CLASSINFO("D-Bus Interface", "org.kde.kstars.Ekos.Observatory")
37 Q_PROPERTY(QStringList logText READ logText NOTIFY newLog)
38 Q_PROPERTY(ISD::Weather::Status status READ status NOTIFY newStatus)
39
40 public:
41 Observatory();
42
43 bool setDome(ISD::Dome *device);
44 bool addWeatherSource(ISD::Weather *device);
45
46 ISD::Weather::Status status()
47 {
48 return m_WeatherStatus;
49 }
50
51 // Logging
52 QStringList logText()
53 {
54 return m_LogText;
55 }
56 QString getLogText()
57 {
58 return m_LogText.join("\n");
59 }
60
61 void clearLog();
62
63 /**
64 * @brief Retrieve the settings that define, from which states the
65 * "ready" state of the observatory is derived from.
66 */
67 ObservatoryStatusControl statusControl()
68 {
69 return m_StatusControl;
70 }
71 void setStatusControl(ObservatoryStatusControl control);
72 void removeDevice(const QSharedPointer<ISD::GenericDevice> &deviceRemoved);
73 void setWeatherSource(const QString &name);
74
75
76 signals:
77 Q_SCRIPTABLE void newLog(const QString &text);
78 Q_SCRIPTABLE void newWeatherData(const QJsonArray &data);
79 Q_SCRIPTABLE void newStatus(ISD::Weather::Status status);
80
81 private:
82 // motion control
83 void enableMotionControl(bool enabled);
84
85 // slaving control
86 void enableAutoSync(bool enabled);
87 void showAutoSync(bool enabled);
88
89 // Logging
90 QStringList m_LogText;
91 void appendLogText(const QString &);
92
93 // timer for refreshing the observatory status
94 QTimer weatherStatusTimer;
95
96 // reacting on weather changes
97 void setWarningActions(WeatherActions actions);
98 void setAlertActions(WeatherActions actions);
99
100 // button handling
101 void toggleButtons(QPushButton *buttonPressed, QString titlePressed, QPushButton *buttonCounterpart,
102 QString titleCounterpart);
103 void activateButton(QPushButton *button, QString title);
104 void buttonPressed(QPushButton *button, QString title);
105
106 // weather sensor data
107 QGridLayout* sensorDataBoxLayout;
108 // map id -> (label, widget)
109 std::map<QString, QPair<QAbstractButton*, QLineEdit*>*> sensorDataWidgets = {};
110 // map id -> graph key x value vector
111 std::map<QString, QVector<QCPGraphData>*> sensorGraphData = {};
112
113 // map id -> range (+1: values only > 0, 0: values > 0 and < 0; -1: values < 0)
114 std::map<QString, int> sensorRanges = {};
115
116 // selected sensor for graph display
117 QString selectedSensorID;
118
119 // button group for sensor names to ensure, that only one button is pressed
120 QButtonGroup *sensorDataNamesGroup {nullptr};
121
122 ISD::Weather::Status m_WeatherStatus { ISD::Weather::WEATHER_IDLE };
123
124 // Initialize the UI controls that configure reactions upon weather events
125 void initWeatherActions(bool enabled);
126
127 void initSensorGraphs();
128 void updateSensorData(const QJsonArray &data);
129 void updateSensorGraph(const QString &sensor_label, QDateTime now, double value);
130
131 // hold all sensor data received from the weather station
132 QJsonArray m_WeatherData;
133
134 /**
135 * @brief Activate or deactivate the weather warning actions
136 */
137 void setWarningActionsActive(bool active);
138 /**
139 * @brief Activate or deactivate the weather alert actions
140 */
141 void setAlertActionsActive(bool active);
142
143 /**
144 * @brief Flag whether the X axis should be visible in the sensor graph
145 */
146 bool autoScaleValues()
147 {
148 return m_autoScaleValues;
149 }
150 void setAutoScaleValues(bool show);
151
152 private:
153 // observatory status handling
154 //void setObseratoryStatusControl(ObservatoryStatusControl control);
155 void statusControlSettingsChanged();
156
157 void initWeather();
158 void enableWeather(bool enable);
159 void clearSensorDataHistory();
160 void shutdownWeather();
161 void setWeatherStatus(ISD::Weather::Status status);
162
163 // sensor data graphs
164 void mouseOverLine(QMouseEvent *event);
165 void refreshSensorGraph();
166
167 void execute(WeatherActions actions);
168
169 // reacting on weather changes
170 void weatherWarningSettingsChanged();
171 void weatherAlertSettingsChanged();
172
173 // reacting on sensor selection change
174 void selectedSensorChanged(QString id);
175
176 // reacting on observatory status changes
177 void observatoryStatusChanged(bool ready);
178 void domeAzimuthChanged(double position);
179
180 void shutdownDome();
181
182 void setDomeStatus(ISD::Dome::Status status);
183 void setDomeParkStatus(ISD::ParkStatus status);
184 void setShutterStatus(ISD::Dome::ShutterStatus status);
185
186 /**
187 * @brief Actions to be taken when a weather warning occurs
188 */
189 WeatherActions getWarningActions()
190 {
191 return m_WarningActions;
192 }
193 QString getWarningActionsStatus();
194 bool getWarningActionsActive()
195 {
196 return warningActionsActive;
197 }
198
199 /**
200 * @brief Actions to be taken when a weather alert occurs
201 */
202 WeatherActions getAlertActions()
203 {
204 return m_AlertActions;
205 }
206 QString getAlertActionsStatus();
207 bool getAlertActionsActive()
208 {
209 return alertActionsActive;
210 }
211
212 private:
213 ISD::Dome *m_Dome {nullptr};
214 ISD::Weather *m_WeatherSource {nullptr};
215 QList<ISD::Weather *> m_WeatherSources;
216
217 ObservatoryStatusControl m_StatusControl;
218
219 QTimer warningTimer, alertTimer;
220 struct WeatherActions m_WarningActions, m_AlertActions;
221 bool warningActionsActive, alertActionsActive, m_autoScaleValues;
222 void startAlertTimer();
223 void startWarningTimer();
224};
225}
226
Class handles control of INDI dome devices.
Definition indidome.h:25
Focuser class handles control of INDI Weather devices.
Definition indiweather.h:24
Ekos is an advanced Astrophotography tool for Linux.
Definition align.cpp:83
ISD is a collection of INDI Standard Devices.
Q_CLASSINFO(Name, Value)
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
QString join(QChar separator) const const
QList< QAction * > actions() const const
virtual bool event(QEvent *event) override
void show()
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.