Kstars

indimount.h
1/*
2 SPDX-FileCopyrightText: 2012 Jasem Mutlaq <mutlaqja@ikarustech.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include <QtDBus/QDBusArgument>
10#include <QTimer>
11
12#include <KLocalizedString>
13
14#include "indiconcretedevice.h"
15#include "skypoint.h"
16
17class SkyObject;
18
19namespace ISD
20{
21/**
22 * @class Mount
23 * device handle controlling Mounts. It can slew and sync to a specific sky point and supports all standard properties with INDI
24 * telescope device.
25 *
26 * @author Jasem Mutlaq
27 */
28class Mount : public ConcreteDevice
29{
31
32 public:
33 explicit Mount(GenericDevice *parent);
34 virtual ~Mount() override = default;
35
36 typedef enum { MOTION_NORTH, MOTION_SOUTH } VerticalMotion;
37 typedef enum { MOTION_WEST, MOTION_EAST } HorizontalMotion;
38 typedef enum { MOTION_START, MOTION_STOP } MotionCommand;
39 typedef enum { PIER_UNKNOWN = -1, PIER_WEST = 0, PIER_EAST = 1 } PierSide;
40 static QString pierSideStateString(PierSide ps)
41 {
42 switch (ps)
43 {
44 case ISD::Mount::PierSide::PIER_EAST:
45 return "Pier Side: East (pointing West)";
46 case ISD::Mount::PierSide::PIER_WEST:
47 return "Pier Side: West (pointing East)";
48 default:
49 return "Pier Side: Unknown";
50 }
51 }
52
53 typedef enum
54 {
55 MOUNT_IDLE,
56 MOUNT_MOVING,
57 MOUNT_SLEWING,
58 MOUNT_TRACKING,
59 MOUNT_PARKING,
60 MOUNT_PARKED,
61 MOUNT_ERROR
62 } Status;
63 typedef enum { PARK_OPTION_CURRENT, PARK_OPTION_DEFAULT, PARK_OPTION_WRITE_DATA } ParkOptionCommand;
64 typedef enum { TRACK_SIDEREAL, TRACK_SOLAR, TRACK_LUNAR, TRACK_CUSTOM } TrackModes;
65
66
67 static const QList<KLocalizedString> mountStates;
68
69 void registerProperty(INDI::Property prop) override;
70 void processSwitch(INDI::Property prop) override;
71 void processText(INDI::Property prop) override;
72 void processNumber(INDI::Property prop) override;
73
74 // Coordinates
75 bool getEqCoords(double *ra, double *dec);
76 bool isJ2000()
77 {
78 return m_isJ2000;
79 }
80
81 // Slew
82 bool Slew(SkyPoint *ScopeTarget, bool flip=false);
83 bool Slew(double ra, double dec, bool flip=false);
84 bool canGoto()
85 {
86 return m_canGoto;
87 }
88 bool canFlip()
89 {
90 return m_canFlip;
91 }
92
93 // Sync
94 bool Sync(SkyPoint *ScopeTarget);
95 bool Sync(double ra, double dec);
96 bool canSync()
97 {
98 return m_canSync;
99 }
100
101 // Tracking
102 bool canControlTrack() const
103 {
104 return m_canControlTrack;
105 }
106 bool isTracking();
107
108 // Track Mode
109 bool hasTrackModes() const
110 {
111 return m_hasTrackModes;
112 }
113 bool getTrackMode(uint8_t &index);
114
115 // Custom Track Rate
116 bool hasCustomTrackRate() const
117 {
118 return m_hasTrackModes;
119 }
120 bool getCustomTrackRate(double &raRate, double &deRate);
121
122 // Motion
123 bool MoveNS(VerticalMotion dir, MotionCommand cmd);
124 bool StopNS();
125 bool MoveWE(HorizontalMotion dir, MotionCommand cmd);
126 bool StopWE();
127 bool isReversed(INDI_EQ_AXIS axis);
128 bool setReversedEnabled(INDI_EQ_AXIS axis, bool enabled);
129 bool isSlewing();
130 bool isInMotion();
131 bool canAbort()
132 {
133 return m_canAbort;
134 }
135 QString getManualMotionString() const;
136
137 // Guiding
138 bool canGuide();
139 bool doPulse(GuideDirection ra_dir, int ra_msecs, GuideDirection dec_dir, int dec_msecs);
140 bool doPulse(GuideDirection dir, int msecs);
141
142 // Parking
143 bool canPark();
144 bool isParked()
145 {
146 return m_ParkStatus == PARK_PARKED;
147 }
148 bool canCustomPark()
149 {
150 return m_hasCustomParking;
151 }
152 bool sendParkingOptionCommand(ParkOptionCommand command);
153
154 // Status
155 ParkStatus parkStatus()
156 {
157 return m_ParkStatus;
158 }
159
160 Status status(INumberVectorProperty *nvp);
161 Status status();
162 const QString statusString(Status status, bool translated = true) const;
163
164 // Altitude Limits
165 void setAltLimits(double minAltitude, double maxAltitude, bool trackingOnly);
166
167 // Alignment Model
168 bool setAlignmentModelEnabled(bool enable);
169 bool clearAlignmentModel();
170 bool clearParking();
171 bool hasAlignmentModel()
172 {
173 return m_hasAlignmentModel;
174 }
175
176 // Slew Rates
177 bool hasSlewRates()
178 {
179 return m_hasSlewRates;
180 }
181 QStringList slewRates()
182 {
183 return m_slewRates;
184 }
185 int getSlewRate() const;
186
187 // Pier side
188 PierSide pierSide() const
189 {
190 return m_PierSide;
191 }
192
193 // Satellite tracking
194 bool canTrackSatellite()
195 {
196 return m_canTrackSatellite;
197 }
198
199 /**
200 * @short Tracks satellite on provided TLE, initial epoch for trajectory calculation and window in minutes
201 *
202 * This function needs a Two-Line-Element and a time window in the form of an initial point and a
203 * number of minutes on which the trajectory should start. The function was developed wiht the lx200
204 * in mind. If the trajectory has already started, the current time and a window of 1min are sufficient.
205 *
206 * @param tle Two-line-element.
207 * @param satPassStart Start time of the trajectory calculation
208 * @param satPassEnd End time of the trajectory calculation
209 */
210 bool setSatelliteTLEandTrack(QString tle, const KStarsDateTime satPassStart, const KStarsDateTime satPassEnd);
211
212 /**
213 * @brief Hour angle of the current coordinates
214 */
215 const dms hourAngle() const;
216
217 const SkyPoint &currentCoordinates() const
218 {
219 return currentCoords;
220 }
221
222 /**
223 * @brief stopTimers Stop timers to prevent timing race condition when device is unavailable
224 * and timer is still invoked.
225 */
226 void stopTimers();
227
228 void centerLock();
229 void centerUnlock();
230 void find();
231 void setCustomParking(SkyPoint *coords = nullptr);
232
233 protected:
234 /**
235 * @brief Send the coordinates to the mount's INDI driver. Due to the INDI implementation, this
236 * function is shared for syncing, slewing and other (partly scope specific) functions like the
237 * setting parking position. The interpretation of the coordinates depends in the setting of other
238 * INDI switches for slewing, synching, tracking etc.
239 * @param ScopeTarget target coordinates
240 * @return true if sending the coordinates succeeded
241 */
242 bool sendCoords(SkyPoint *ScopeTarget);
243
244 /**
245 * @brief Check whether sending new coordinates will result into a slew
246 */
247 bool slewDefined();
248
249 /**
250 * @brief Helper function to update the J2000 coordinates of a sky point from its JNow coordinates
251 * @param coords sky point with correct JNow values in RA and DEC
252 */
253 void updateJ2000Coordinates(SkyPoint *coords);
254
255 /**
256 * @brief updateParkStatus Updating parking status by checking the TELESCOPE_PARK property.
257 */
258 void updateParkStatus();
259
260 /**
261 * @brief updateTarget update target position from {@see currentPosition} and
262 * (if not pointing into the empty sky) also the target name.
263 */
264 void updateTarget();
265
266 public slots:
267 bool abort();
268 bool park();
269 bool unpark();
270 bool setSlewRate(int index);
271 bool setTrackEnabled(bool enable);
272 bool setCustomTrackRate(double raRate, double deRate);
273 bool setTrackMode(uint8_t index);
274
275 signals:
276 /**
277 * @brief The mount has finished the slew to a new target.
278 * @param currentCoords exact position where the mount is positioned
279 */
280 void newTarget(SkyPoint &currentCoords);
281
282 /**
283 * @brief The mount has finished the slew to a new target.
284 * @param Name Name of object, if any, the mount is positioned at.
285 */
286 void newTargetName(const QString &name);
287 /**
288 * @brief Change in the mount status.
289 */
290 void newStatus(ISD::Mount::Status status);
291 /**
292 * @brief Update event with the current telescope position
293 * @param position mount position. Independent from the mount type,
294 * the EQ coordinates(both JNow and J2000) as well as the alt/az values are filled.
295 * @param pierside for GEMs report the pier side the scope is currently (PierSide::PIER_WEST means
296 * the mount is on the western side of the pier pointing east of the meridian).
297 * @param ha current hour angle
298 */
299 void newCoords(const SkyPoint &position, const PierSide pierside, const dms &ha);
300 void newParkStatus(ISD::ParkStatus status);
301 void slewRateChanged(int rate);
302 void pierSideChanged(PierSide side);
303 void axisReversed(INDI_EQ_AXIS axis, bool reversed);
304
305 private:
306 SkyPoint currentCoords;
307 double minAlt {0}, maxAlt = 90;
308 bool altLimitsTrackingOnly = false;
309 ParkStatus m_ParkStatus = PARK_UNKNOWN;
310 IPState EqCoordPreviousState {IPS_IDLE};
311 Status previousMountStatus {MOUNT_IDLE};
312 QTimer centerLockTimer;
313 QTimer updateCoordinatesTimer;
314 SkyObject *currentObject = nullptr;
315 bool inManualMotion = false;
316 bool inCustomParking = false;
317 IPState NSPreviousState = IPS_IDLE;
318 IPState WEPreviousState = IPS_IDLE;
319 PierSide m_PierSide = PIER_UNKNOWN;
320
321 KStarsDateTime g_satPassStart;
322 KStarsDateTime g_satPassEnd;
323
325 TrackModes currentTrackMode { TRACK_SIDEREAL };
326
327 bool m_hasAlignmentModel = { false };
328 bool m_canControlTrack = { false };
329 bool m_canGoto { false};
330 bool m_canFlip { false};
331 bool m_canSync { false};
332 bool m_canAbort { false };
333 bool m_canTrackSatellite { false };
334 bool m_TLEIsSetForTracking { false };
335 bool m_windowIsSetForTracking { false };
336 bool m_hasTrackModes { false};
337 bool m_hasCustomTrackRate { false};
338 bool m_hasCustomParking { false };
339 bool m_hasSlewRates { false };
340 bool m_isJ2000 { false };
341 bool m_hasEquatorialCoordProperty { false };
342 QStringList m_slewRates;
343};
344}
345
346Q_DECLARE_METATYPE(ISD::Mount::Status)
347QDBusArgument &operator<<(QDBusArgument &argument, const ISD::Mount::Status &source);
348const QDBusArgument &operator>>(const QDBusArgument &argument, ISD::Mount::Status &dest);
349
350Q_DECLARE_METATYPE(ISD::Mount::PierSide)
351QDBusArgument &operator<<(QDBusArgument &argument, const ISD::Mount::PierSide &source);
352const QDBusArgument &operator>>(const QDBusArgument &argument, ISD::Mount::PierSide &dest);
The ConcreteDevice class.
GenericDevice is the Generic Device for INDI devices.
Definition indistd.h:117
device handle controlling Mounts.
Definition indimount.h:29
void updateTarget()
updateTarget update target position from {
void newStatus(ISD::Mount::Status status)
Change in the mount status.
bool slewDefined()
Check whether sending new coordinates will result into a slew.
const dms hourAngle() const
Hour angle of the current coordinates.
void updateJ2000Coordinates(SkyPoint *coords)
Helper function to update the J2000 coordinates of a sky point from its JNow coordinates.
bool sendCoords(SkyPoint *ScopeTarget)
Send the coordinates to the mount's INDI driver.
bool setSatelliteTLEandTrack(QString tle, const KStarsDateTime satPassStart, const KStarsDateTime satPassEnd)
Tracks satellite on provided TLE, initial epoch for trajectory calculation and window in minutes.
void updateParkStatus()
updateParkStatus Updating parking status by checking the TELESCOPE_PARK property.
void stopTimers()
stopTimers Stop timers to prevent timing race condition when device is unavailable and timer is still...
void newTarget(SkyPoint &currentCoords)
The mount has finished the slew to a new target.
void newCoords(const SkyPoint &position, const PierSide pierside, const dms &ha)
Update event with the current telescope position.
void newTargetName(const QString &name)
The mount has finished the slew to a new target.
Extension of QDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day,...
Provides all necessary information about an object in the sky: its coordinates, name(s),...
Definition skyobject.h:42
The sky coordinates of a point in the sky.
Definition skypoint.h:45
An angle, stored as degrees, but expressible in many ways.
Definition dms.h:38
ISD is a collection of INDI Standard Devices.
KCALENDARCORE_EXPORT QDataStream & operator>>(QDataStream &in, const KCalendarCore::Alarm::Ptr &)
KTEXTEDITOR_EXPORT QDebug operator<<(QDebug s, const MovingCursor &cursor)
Q_OBJECTQ_OBJECT
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:53:00 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.