Kstars

message.h
1/*
2 SPDX-FileCopyrightText: 2018 Jasem Mutlaq <mutlaqja@ikarustech.com>
3
4 Message Channel
5
6 SPDX-License-Identifier: GPL-2.0-or-later
7*/
8
9#pragma once
10
11#include <QtWebSockets/QWebSocket>
12#include <memory>
13
14#include "ekos/ekos.h"
15#include "ekos/align/polaralignmentassistant.h"
16#include "ekos/manager.h"
17#include "catalogsdb.h"
18#include "nodemanager.h"
19#include <QQueue>
20
21namespace EkosLive
22{
23class Message : public QObject
24{
26
27 public:
28 explicit Message(Ekos::Manager *manager, QVector<QSharedPointer<NodeManager>> &nodeManagers);
29 virtual ~Message() = default;
30
31 bool isConnected() const;
32
33 // Module Status Updates
34 void updateMountStatus(const QJsonObject &status, bool throttle = false);
35 void updateCaptureStatus(const QJsonObject &status);
36 void updateFocusStatus(const QJsonObject &status);
37 void updateGuideStatus(const QJsonObject &status);
38 void updateDomeStatus(const QJsonObject &status);
39 void updateCapStatus(const QJsonObject &status);
40 void updateAlignStatus(const QJsonObject &status);
41
42 // Send devices as they come
43 void sendEvent(const QString &message, KSNotification::EventSource source, KSNotification::EventType event);
44 void sendScopes();
45 void sendDSLRLenses();
46 void sendDrivers();
47 void sendDevices();
48 void sendTrains();
49 void sendTrainProfiles();
50
51 // Scheduler
52 void sendSchedulerJobs();
53 void sendSchedulerJobList(QJsonArray jobsList);
54 void sendSchedulerStatus(const QJsonObject &status);
55
56 signals:
57 void connected();
58 void disconnected();
59 void expired(const QUrl &url);
60 void optionsUpdated();
61 void resetPolarView();
62
63 public slots:
64 // Connection
65 void sendConnection();
66 void sendModuleState(const QString &name);
67 void setPendingPropertiesEnabled(bool enabled);
68
69 // Ekos
70 void setEkosStatingStatus(Ekos::CommunicationStatus status);
71
72 // INDI
73 void setINDIStatus(Ekos::CommunicationStatus status);
74
75 // Alignment
76 void setAlignStatus(Ekos::AlignState newState);
77 void setAlignSolution(const QVariantMap &solution);
78 void sendAlignSettings(const QVariantMap &settings);
79
80 // Guide
81 void sendGuideSettings(const QVariantMap &settings);
82
83 // Focus
84 void sendFocusSettings(const QVariantMap &settings);
85
86 // Mount
87 void sendMountSettings(const QVariantMap &settings);
88
89 // Dark Library
90 void sendDarkLibrarySettings(const QVariantMap &settings);
91
92 //Scheduler
93 void sendSchedulerSettings(const QVariantMap &settings);
94
95 // Polar
96 void setPAHStage(Ekos::PolarAlignmentAssistant::Stage stage);
97 void setPAHMessage(const QString &message);
98 void setPolarResults(QLineF correctionVector, double polarError, double azError, double altError);
99 void setUpdatedErrors(double total, double az, double alt);
100 void setPAHEnabled(bool enabled);
101 void setBoundingRect(QRect rect, QSize view, double currentZoom);
102
103 // Capture
104 void sendCaptureSequence(const QJsonArray &sequenceArray);
105 void sendPreviewLabel(const QString &preview);
106 void sendCaptureSettings(const QVariantMap &settings);
107
108 // Focus
109 void autofocusAborted();
110
111 // DSLR
112 void requestDSLRInfo(const QString &cameraName);
113
114 // Port Selection
115 void requestPortSelection(bool show);
116
117 // Trains
118 void requestOpticalTrains(bool show);
119
120 // Dialogs
121 void sendDialog(const QJsonObject &message);
122 void processDialogResponse(const QJsonObject &payload);
123
124 // Process properties
125 void processNewProperty(INDI::Property prop);
126 void processDeleteProperty(INDI::Property prop);
127 void processUpdateProperty(INDI::Property prop);
128
129 // Process message
130 void processMessage(const QSharedPointer<ISD::GenericDevice> &device, int id);
131
132 // StellarSolver
133 void sendStellarSolverProfiles();
134
135 void sendManualRotatorStatus(double currentPA, double targetPA, double threshold);
136
137 private slots:
138
139 // Connection
140 void onConnected();
141 void onDisconnected();
142
143 // Communication
144 void onTextReceived(const QString &);
145
146 private:
147 // Profiles
148 void sendProfiles();
149 void setProfileMapping(const QJsonObject &payload);
150 void sendStates();
151
152 // Capture
153 void processCaptureCommands(const QString &command, const QJsonObject &payload);
154 void sendTemperature(double value);
155
156 // Mount
157 void processMountCommands(const QString &command, const QJsonObject &payload);
158
159 // Focus
160 void processFocusCommands(const QString &command, const QJsonObject &payload);
161
162 // Guide
163 void processGuideCommands(const QString &command, const QJsonObject &payload);
164
165 // Align
166 void processAlignCommands(const QString &command, const QJsonObject &payload);
167
168 // Scheduler
169 void processSchedulerCommands(const QString &command, const QJsonObject &payload);
170
171 // Polar
172 void processPolarCommands(const QString &command, const QJsonObject &payload);
173
174 // Profile
175 void processProfileCommands(const QString &command, const QJsonObject &payload);
176
177 // Options
178 void processOptionsCommands(const QString &command, const QJsonObject &payload);
179
180 // Scopes
181 void processScopeCommands(const QString &command, const QJsonObject &payload);
182
183 // DSLRs
184 void processDSLRCommands(const QString &command, const QJsonObject &payload);
185
186 // Trains
187 void processTrainCommands(const QString &command, const QJsonObject &payload);
188
189 // Filter Manager commands
190 void processFilterManagerCommands(const QString &command, const QJsonObject &payload);
191
192 // Dark Library commands
193 void processDarkLibraryCommands(const QString &command, const QJsonObject &payload);
194
195 // Low-level Device commands
196 void processDeviceCommands(const QString &command, const QJsonObject &payload);
197
198 // Process Astronomy Library command
199 void processAstronomyCommands(const QString &command, const QJsonObject &payload);
200
201 // Process file commands
202 void processFileCommands(const QString &command, const QJsonObject &payload);
203
204 void dispatchDebounceQueue();
205
206 KStarsDateTime getNextDawn();
207
208 void sendResponse(const QString &command, const QJsonObject &payload);
209 void sendResponse(const QString &command, const QJsonArray &payload);
210 void sendResponse(const QString &command, const QString &payload);
211 void sendResponse(const QString &command, bool payload);
212
213 void sendPendingProperties();
214
215 typedef struct
216 {
217 int number_integer;
218 uint number_unsigned_integer;
219 double number_double;
220 bool boolean;
221 QString text;
222 QUrl url;
223 } SimpleTypes;
224
225 QObject *findObject(const QString &name);
226 void invokeMethod(QObject *context, const QJsonObject &payload);
227 #if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
228 bool parseArgument(QVariant::Type type, const QVariant &arg, QMetaMethodArgument &genericArg, SimpleTypes &types);
229 #else
230 bool parseArgument(QVariant::Type type, const QVariant &arg, QGenericArgument &genericArg, SimpleTypes &types);
231 #endif
232 Ekos::Manager *m_Manager { nullptr };
234
235 bool m_sendBlobs { true};
236
237 QMap<QString, QSet<QString>> m_PropertySubscriptions;
238 QLineF correctionVector;
239 QRect m_BoundingRect;
240 QSize m_ViewSize;
241 double m_CurrentZoom {100};
242
243 QSet<INDI::Property *> m_PendingProperties;
244 QTimer m_PendingPropertiesTimer;
245 QTimer m_DebouncedSend;
246 QMap<QString, QVariantMap> m_DebouncedMap;
247
248 QDateTime m_ThrottleTS;
249 CatalogsDB::DBManager m_DSOManager;
250
251 typedef enum
252 {
253 North,
254 East,
255 South,
256 West,
257 All
258 } Direction;
259
260 // Throttle interval
261 static const uint16_t THROTTLE_INTERVAL = 1000;
262};
263
264}
Manages the catalog database and provides an interface to provide an interface to query and modify th...
Definition catalogsdb.h:183
Extension of QDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day,...
Generic record interfaces and implementations.
Definition cloud.cpp:22
AlignState
Definition ekos.h:145
Q_OBJECTQ_OBJECT
virtual bool event(QEvent *e)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:40 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.