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

KDE's Doxygen guidelines are available online.