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

KDE's Doxygen guidelines are available online.