Kstars

indidome.h
1/*
2 SPDX-FileCopyrightText: 2015 Jasem Mutlaq <mutlaqja@ikarustech.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include <memory>
10#include <QTimer>
11
12#include "indiconcretedevice.h"
13
14namespace ISD
15{
16/**
17 * @class Dome
18 * Class handles control of INDI dome devices. Both open and closed loop (sensor feedback) domes are supported.
19 *
20 * @author Jasem Mutlaq
21 */
22class Dome : public ConcreteDevice
23{
25 Q_CLASSINFO("D-Bus Interface", "org.kde.kstars.INDI.Dome")
26 Q_PROPERTY(bool canPark READ canPark)
27 Q_PROPERTY(bool canAbsoluteMove READ canAbsoluteMove)
28 Q_PROPERTY(bool canRelativeMove READ canRelativeMove)
29 Q_PROPERTY(bool canAbort READ canAbort)
30 Q_PROPERTY(bool isMoving READ isMoving)
31 Q_PROPERTY(ISD::Dome::Status status READ status NOTIFY newStatus)
32 Q_PROPERTY(ISD::Dome::ShutterStatus shutterStatus READ shutterStatus NOTIFY newShutterStatus)
33 Q_PROPERTY(ISD::ParkStatus parkStatus READ parkStatus NOTIFY newParkStatus)
34 Q_PROPERTY(double position READ position WRITE setPosition NOTIFY positionChanged)
35
36 public:
37 explicit Dome(GenericDevice *parent);
38
39 // DBUS
40 const QString &name()
41 {
42 return m_Parent->getDeviceName();
43 }
44 // DBus
45 bool connected()
46 {
47 return m_Parent->isConnected();
48 }
49
50 typedef enum
51 {
52 DOME_IDLE,
53 DOME_MOVING_CW,
54 DOME_MOVING_CCW,
55 DOME_TRACKING,
56 DOME_PARKING,
57 DOME_UNPARKING,
58 DOME_PARKED,
59 DOME_ERROR
60 } Status;
61
62 typedef enum
63 {
64 SHUTTER_UNKNOWN,
65 SHUTTER_OPEN,
66 SHUTTER_CLOSED,
67 SHUTTER_OPENING,
68 SHUTTER_CLOSING,
69 SHUTTER_ERROR
70 } ShutterStatus;
71
72 typedef enum
73 {
74 DOME_CW,
75 DOME_CCW
76 } DomeDirection;
77
78 typedef enum
79 {
80 MOTION_START,
81 MOTION_STOP
82 } DomeMotionCommand;
83
84
85 void processSwitch(INDI::Property prop) override;
86 void processNumber(INDI::Property prop) override;
87 void registerProperty(INDI::Property prop) override;
88
89 Q_SCRIPTABLE bool canPark() const
90 {
91 return m_CanPark;
92 }
93 Q_SCRIPTABLE bool canAbsoluteMove() const
94 {
95 return m_CanAbsMove;
96 }
97 Q_SCRIPTABLE bool canRelativeMove() const
98 {
99 return m_CanRelMove;
100 }
101 Q_SCRIPTABLE bool canAbort() const
102 {
103 return m_CanAbort;
104 }
105 Q_SCRIPTABLE bool isParked() const
106 {
107 return m_ParkStatus == PARK_PARKED;
108 }
109 bool isMoving() const;
110
111 /**
112 * @return position Dome Azimuth position in degrees
113 */
114 Q_SCRIPTABLE double position() const;
115 /**
116 * @brief setPosition Set azimuth absolute position.
117 * @param position Position in degrees 0 to +360
118 * @return true if successful, false otherwise
119 */
120 Q_SCRIPTABLE bool setPosition(double position);
121
122 bool setRelativePosition(double position);
123
124 bool moveDome(DomeDirection dir, DomeMotionCommand operation);
125
126 /** DBus Interface Function
127 * @brief moveCW Start motion in clock-wise direction.
128 * @return True if command is successful, false otherwise.
129 */
131 {
132 return moveDome(DOME_CW, MOTION_START);
133 }
134
135 /** DBus Interface Function
136 * @brief moveCCW Start motion in counter-clock-wise direction.
137 * @return True if command is successful, false otherwise.
138 */
140 {
141 return moveDome(DOME_CCW, MOTION_START);
142 }
143
144 Q_SCRIPTABLE bool hasShutter() const
145 {
146 return m_HasShutter;
147 }
148
149 /**
150 * @brief isRolloffRoof Do we have a roll off structure?
151 * @return True if we do, false otherwise.
152 */
154 {
155 return (canAbsoluteMove() == false && canRelativeMove() == false);
156 }
157
158 // slaving
159 bool isAutoSync();
160 bool setAutoSync(bool activate);
161
162 Status status() const
163 {
164 return m_Status;
165 }
166 ISD::ParkStatus parkStatus() const
167 {
168 return m_ParkStatus;
169 }
170 static const QString getStatusString (Status status, bool translated = true);
171
172 ShutterStatus shutterStatus();
173 ShutterStatus parseShutterStatus(INDI::Property prop);
174
175 Q_SCRIPTABLE bool abort();
176 Q_SCRIPTABLE bool park();
177 Q_SCRIPTABLE bool unpark();
178
179 Q_SCRIPTABLE bool controlShutter(bool open);
180 bool openShutter()
181 {
182 return controlShutter(true);
183 }
184 bool closeShutter()
185 {
186 return controlShutter(false);
187 }
188
189 signals:
190 void newStatus(ISD::Dome::Status status);
191 void newParkStatus(ISD::ParkStatus status);
192 void newShutterStatus(ISD::Dome::ShutterStatus status);
193 void newAutoSyncStatus(bool enabled);
194 void positionChanged(double degrees);
195
196 private:
197 ParkStatus m_ParkStatus { PARK_UNKNOWN };
198 ShutterStatus m_ShutterStatus { SHUTTER_UNKNOWN };
199 Status m_Status { DOME_IDLE };
200 bool m_CanAbsMove { false };
201 bool m_CanRelMove { false };
202 bool m_CanPark { false };
203 bool m_CanAbort { false };
204 bool m_HasShutter { false };
205 static const QList<const char *> domeStates;
206};
207}
208
209Q_DECLARE_METATYPE(ISD::Dome::Status)
210QDBusArgument &operator<<(QDBusArgument &argument, const ISD::Dome::Status &source);
211const QDBusArgument &operator>>(const QDBusArgument &argument, ISD::Dome::Status &dest);
212
213Q_DECLARE_METATYPE(ISD::Dome::ShutterStatus)
214QDBusArgument &operator<<(QDBusArgument &argument, const ISD::Dome::ShutterStatus &source);
215const QDBusArgument &operator>>(const QDBusArgument &argument, ISD::Dome::ShutterStatus &dest);
The ConcreteDevice class.
Class handles control of INDI dome devices.
Definition indidome.h:23
bool isRolloffRoof()
isRolloffRoof Do we have a roll off structure?
Definition indidome.h:153
Q_SCRIPTABLE bool setPosition(double position)
setPosition Set azimuth absolute position.
Definition indidome.cpp:363
Q_SCRIPTABLE bool moveCW()
DBus Interface Function.
Definition indidome.h:130
Q_SCRIPTABLE bool moveCCW()
DBus Interface Function.
Definition indidome.h:139
GenericDevice is the Generic Device for INDI devices.
Definition indistd.h:117
ISD is a collection of INDI Standard Devices.
KCALENDARCORE_EXPORT QDataStream & operator>>(QDataStream &in, const KCalendarCore::Alarm::Ptr &)
Q_CLASSINFO(Name, Value)
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:48:26 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.