Kstars

observatory.h
1 /* Ekos Observatory Module
2  SPDX-FileCopyrightText: Wolfgang Reissenberger <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "ui_observatory.h"
10 #include "observatorymodel.h"
11 #include "observatorydomemodel.h"
12 #include "observatoryweathermodel.h"
13 
14 #include <QWidget>
15 #include <QLineEdit>
16 #include <KLocalizedString>
17 
18 namespace Ekos
19 {
20 
21 class Observatory : public QWidget, public Ui::Observatory
22 {
23  Q_OBJECT
24  Q_CLASSINFO("D-Bus Interface", "org.kde.kstars.Ekos.Observatory")
25  Q_PROPERTY(QStringList logText READ logText NOTIFY newLog)
26 
27  public:
28  Observatory();
29  ObservatoryDomeModel *getDomeModel()
30  {
31  return mObservatoryModel->getDomeModel();
32  }
33  ObservatoryWeatherModel *getWeatherModel()
34  {
35  return mObservatoryModel->getWeatherModel();
36  }
37 
38  // Logging
39  QStringList logText()
40  {
41  return m_LogText;
42  }
43  QString getLogText()
44  {
45  return m_LogText.join("\n");
46  }
47 
48  void clearLog();
49 
50  signals:
51  Q_SCRIPTABLE void newLog(const QString &text);
52 
53  /**
54  * @brief Signal a new observatory status
55  */
56  Q_SCRIPTABLE void newStatus(bool isReady);
57 
58  void newWeatherData(const std::vector<ISD::Weather::WeatherData> &data);
59 
60  private:
61  ObservatoryModel *mObservatoryModel = nullptr;
62 
63  void setDomeModel(ObservatoryDomeModel *model);
64  void setWeatherModel(ObservatoryWeatherModel *model);
65 
66  // motion control
67  void enableMotionControl(bool enabled);
68 
69  // slaving control
70  void enableAutoSync(bool enabled);
71  void showAutoSync(bool enabled);
72 
73  // Logging
74  QStringList m_LogText;
75  void appendLogText(const QString &);
76 
77  // timer for refreshing the observatory status
78  QTimer weatherStatusTimer;
79 
80  // reacting on weather changes
81  void setWarningActions(WeatherActions actions);
82  void setAlertActions(WeatherActions actions);
83 
84  // button handling
85  void toggleButtons(QPushButton *buttonPressed, QString titlePressed, QPushButton *buttonCounterpart,
86  QString titleCounterpart);
87  void activateButton(QPushButton *button, QString title);
88  void buttonPressed(QPushButton *button, QString title);
89 
90  // weather sensor data
91  QGridLayout* sensorDataBoxLayout;
92  // map id -> (label, widget)
93  std::map<QString, QPair<QAbstractButton*, QLineEdit*>*> sensorDataWidgets = {};
94  // map id -> graph key x value vector
95  std::map<QString, QVector<QCPGraphData>*> sensorGraphData = {};
96 
97  // map id -> range (+1: values only > 0, 0: values > 0 and < 0; -1: values < 0)
98  std::map<QString, int> sensorRanges = {};
99 
100  // selected sensor for graph display
101  QString selectedSensorID;
102 
103  // button group for sensor names to ensure, that only one button is pressed
104  QButtonGroup *sensorDataNamesGroup {nullptr};
105 
106  ISD::Weather::Status m_WeatherStatus { ISD::Weather::WEATHER_IDLE };
107 
108  // Initialize the UI controls that configure reactions upon weather events
109  void initWeatherActions(bool enabled);
110 
111  void initSensorGraphs();
112  void updateSensorData(const std::vector<ISD::Weather::WeatherData> &data);
113  void updateSensorGraph(QString sensor_label, QDateTime now, double value);
114 
115 
116  private slots:
117  // observatory status handling
118  void setObseratoryStatusControl(ObservatoryStatusControl control);
119  void statusControlSettingsChanged();
120 
121  void initWeather();
122  void enableWeather(bool enable);
123  void clearSensorDataHistory();
124  void shutdownWeather();
125  void setWeatherStatus(ISD::Weather::Status status);
126 
127  // sensor data graphs
128  void mouseOverLine(QMouseEvent *event);
129  void refreshSensorGraph();
130 
131  // reacting on weather changes
132  void weatherWarningSettingsChanged();
133  void weatherAlertSettingsChanged();
134 
135  // reacting on sensor selection change
136  void selectedSensorChanged(QString id);
137 
138  // reacting on observatory status changes
139  void observatoryStatusChanged(bool ready);
140  void domeAzimuthChanged(double position);
141 
142  void initDome();
143  void shutdownDome();
144 
145  void setDomeStatus(ISD::Dome::Status status);
146  void setDomeParkStatus(ISD::ParkStatus status);
147  void setShutterStatus(ISD::Dome::ShutterStatus status);
148 };
149 }
Q_OBJECTQ_OBJECT
Ekos is an advanced Astrophotography tool for Linux. It is based on a modular extensible framework to...
Definition: align.cpp:70
Q_CLASSINFO(Name, Value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Tue Aug 9 2022 04:06:04 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.