Instrument Neutral Distributed Interface INDI 2.2.5
rti_dome.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2026 Jasem Mutlaq. All rights reserved.
3
4 RTI Dome INDI Driver
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License version 2 as published by the Free Software Foundation.
9 .
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14 .
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*******************************************************************************/
20
21#pragma once
22
23#include "indidome.h"
24
25class RTIDome : public INDI::Dome
26{
27 public:
28 RTIDome();
29 virtual ~RTIDome() override = default;
30
31 virtual const char *getDefaultName() override;
32 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
33 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
34
35 protected:
36 virtual bool initProperties() override;
37 virtual bool updateProperties() override;
38
39 virtual bool Handshake() override;
40 virtual void TimerHit() override;
41
42 virtual IPState MoveRel(double azDiff) override;
43 virtual IPState MoveAbs(double az) override;
44 virtual IPState Move(DomeDirection dir, DomeMotionCommand operation) override;
45 virtual IPState ControlShutter(ShutterOperation operation) override;
46 virtual bool Abort() override;
47 virtual bool Sync(double az) override;
48
49 // Parking
50 virtual IPState Park() override;
51 virtual IPState UnPark() override;
52 virtual bool SetCurrentPark() override;
53 virtual bool SetDefaultPark() override;
54
55 private:
56
57 double m_TargetAz {0};
58 // True when the shutter controller has responded to a ping (H#/o# check)
59 bool m_bShutterPresent {false};
60 // Counter used to schedule periodic shutter-presence re-checks
61 int m_nShutterPollCounter {0};
62
66 bool setupInitialParameters();
67
71 bool getFirmwareVersion();
72 bool getShutterFirmwareVersion();
73 bool getDomeAzimuth(double &az);
74 bool getSlewingStatus(int &status);
75 bool getHomedStatus(int &status);
76 bool queryShutterState(int &status);
77 bool getStepsPerRotation(uint32_t &steps);
78 bool getStepRate(uint32_t &rate);
79 bool getAcceleration(uint32_t &accel);
80 bool getHomePosition(double &az);
81 bool getParkPosition(double &az);
82 bool getMotorReversed(bool &reversed);
83 bool getRainAction(int &action);
84 bool getRainStatus(bool &raining);
85 bool getShutterVoltage(double &voltage, double &cutoff);
87 bool sendShutterHello();
89 bool getShutterPresent(bool &present);
90
94 bool gotoAzimuth(double az);
95 bool syncAzimuth(double az);
96 bool stopDome();
97 bool findHome();
98 bool setHomePosition(double az);
99 bool setParkPosition(double az);
100 bool setStepsPerRotation(uint32_t steps);
101 bool setStepRate(uint32_t rate);
102 bool setAcceleration(uint32_t accel);
103 bool setMotorReversed(bool reversed);
104 bool setRainAction(int action);
105 bool openShutter();
106 bool closeShutter();
107
111
119 bool sendCommand(const char *cmd, char *res = nullptr);
120 void hexDump(char *buf, const char *data, int size);
121
125
126 // Firmware versions (rotation + shutter)
127 INDI::PropertyText FirmwareTP {2};
128 enum
129 {
130 FIRMWARE_ROTATION,
131 FIRMWARE_SHUTTER
132 };
133
134 // Dome and shutter text status
135 INDI::PropertyText StatusTP {2};
136 enum
137 {
138 STATUS_DOME,
139 STATUS_SHUTTER
140 };
141
142 // Motor settings: steps/rotation, speed, acceleration
143 INDI::PropertyNumber SettingsNP {3};
144 enum
145 {
146 SETTINGS_STEPS_PER_ROTATION,
147 SETTINGS_STEP_RATE,
148 SETTINGS_ACCELERATION
149 };
150
151 // Home position in degrees
152 INDI::PropertyNumber HomePositionNP {1};
153
154 // Find Home button
155 INDI::PropertySwitch HomeSP {1};
156 enum
157 {
158 HOME_FIND
159 };
160
161 // Rain sensor action
162 INDI::PropertySwitch RainActionSP {3};
163 enum
164 {
165 RAIN_DO_NOTHING,
166 RAIN_GOTO_HOME,
167 RAIN_GOTO_PARK
168 };
169
170 // Motor direction
171 INDI::PropertySwitch ReversedSP {2};
172 enum
173 {
174 REVERSED_NORMAL,
175 REVERSED_REVERSED
176 };
177
178 // Shutter voltage info
179 INDI::PropertyNumber ShutterVoltsNP {2};
180 enum
181 {
182 SHUTTER_VOLTAGE_CURRENT,
183 SHUTTER_VOLTAGE_CUTOFF
184 };
185
189 static constexpr const char *SETTINGS_TAB = "Settings";
190 static constexpr const char *INFO_TAB = "Info";
191 // '#' is the stop character for all RTI dome commands/responses
192 static const char DRIVER_STOP_CHAR { '#' };
193 // Wait up to a maximum of 3 seconds for serial input
194 static constexpr const uint8_t DRIVER_TIMEOUT {3};
195 // Maximum buffer for sending/receiving.
196 static constexpr const uint8_t DRIVER_LEN {64};
197 // Dome AZ threshold in degrees
198 static constexpr const double DOME_AZ_THRESHOLD {0.01};
199};
Class to provide general functionality of a Dome device.
Definition indidome.h:75
ShutterOperation
Shutter operation command.
Definition indidome.h:114
DomeMotionCommand
Definition indidome.h:97
virtual IPState ControlShutter(ShutterOperation operation) override
Open or Close shutter.
Definition rti_dome.cpp:706
virtual bool Handshake() override
perform handshake with device to check communication
Definition rti_dome.cpp:257
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition rti_dome.cpp:385
virtual IPState UnPark() override
UnPark dome. The action of the Unpark command is dome specific, but it may include opening the shutte...
Definition rti_dome.cpp:697
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition rti_dome.cpp:308
virtual IPState Park() override
Goto Park Position. The park position is an absolute azimuth value.
Definition rti_dome.cpp:688
virtual IPState MoveRel(double azDiff) override
Move the Dome to an relative position.
Definition rti_dome.cpp:646
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
Definition rti_dome.cpp:56
virtual ~RTIDome() override=default
virtual bool SetDefaultPark() override
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
Definition rti_dome.cpp:764
virtual const char * getDefaultName() override
Definition rti_dome.cpp:265
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition rti_dome.cpp:273
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition rti_dome.cpp:490
virtual bool Abort() override
Abort all dome motion.
Definition rti_dome.cpp:731
virtual bool SetCurrentPark() override
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
Definition rti_dome.cpp:755
virtual bool Sync(double az) override
Sync sets the dome current azimuth as the supplied azimuth position.
Definition rti_dome.cpp:661
virtual IPState Move(DomeDirection dir, DomeMotionCommand operation) override
Move the Dome in a particular direction.
Definition rti_dome.cpp:669
virtual IPState MoveAbs(double az) override
Move the Dome to an absolute azimuth.
Definition rti_dome.cpp:636
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
uint8_t cmd[4]
Definition pwc-ioctl.h:2