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 void dispatchDebounceQueue();
202
203 KStarsDateTime getNextDawn();
204
205 void sendResponse(const QString &command, const QJsonObject &payload);
206 void sendResponse(const QString &command, const QJsonArray &payload);
207 void sendResponse(const QString &command, const QString &payload);
208 void sendResponse(const QString &command, bool payload);
209
210 void sendPendingProperties();
211
212 typedef struct
213 {
214 int number_integer;
215 uint number_unsigned_integer;
216 double number_double;
217 bool boolean;
218 QString text;
219 QUrl url;
220 } SimpleTypes;
221
222 QObject *findObject(const QString &name);
223 void invokeMethod(QObject *context, const QJsonObject &payload);
224 #if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
225 bool parseArgument(QVariant::Type type, const QVariant &arg, QMetaMethodArgument &genericArg, SimpleTypes &types);
226 #else
227 bool parseArgument(QVariant::Type type, const QVariant &arg, QGenericArgument &genericArg, SimpleTypes &types);
228 #endif
229 Ekos::Manager *m_Manager { nullptr };
231
232 bool m_sendBlobs { true};
233
234 QMap<QString, QSet<QString>> m_PropertySubscriptions;
235 QLineF correctionVector;
236 QRect m_BoundingRect;
237 QSize m_ViewSize;
238 double m_CurrentZoom {100};
239
240 QSet<INDI::Property *> m_PendingProperties;
241 QTimer m_PendingPropertiesTimer;
242 QTimer m_DebouncedSend;
243 QMap<QString, QVariantMap> m_DebouncedMap;
244
245 QDateTime m_ThrottleTS;
246 CatalogsDB::DBManager m_DSOManager;
247
248 typedef enum
249 {
250 North,
251 East,
252 South,
253 West,
254 All
255 } Direction;
256
257 // Throttle interval
258 static const uint16_t THROTTLE_INTERVAL = 1000;
259};
260
261}
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 4 2024 16:38:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.