Instrument Neutral Distributed Interface INDI 2.2.5
domepro2.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2020 Jasem Mutlaq. All rights reserved.
3
4 Astrometric Solutions DomePro2 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#include <map>
25
26class DomePro2 : public INDI::Dome
27{
28 public:
29 DomePro2();
30 virtual ~DomePro2() override = default;
31
32 virtual const char *getDefaultName() override;
33 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
34 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
35 virtual bool saveConfigItems(FILE *fp) override;
36
37
38 protected:
39 virtual bool initProperties() override;
40 virtual bool updateProperties() override;
41
42 virtual bool Handshake() override;
43 virtual void TimerHit() override;
44
45 virtual IPState MoveRel(double azDiff) override;
46 virtual IPState MoveAbs(double az) override;
47 virtual IPState Move(DomeDirection dir, DomeMotionCommand operation) override;
48 virtual IPState ControlShutter(ShutterOperation operation) override;
49 virtual bool Abort() override;
50 virtual bool Sync(double az) override;
51
52 // Parking
53 virtual IPState Park() override;
54 virtual IPState UnPark() override;
55 virtual bool SetCurrentPark() override;
56 virtual bool SetDefaultPark() override;
57
58 private:
59
60 // ShutterOperation m_TargetShutter { SHUTTER_OPEN }; // #PS: unused
61 double targetAz {0};
62
66 bool setupInitialParameters();
67 uint8_t processShutterStatus();
68
69
73 bool getFirmwareVersion();
74 bool getHardwareConfig();
75 bool getDomeStatus();
76 bool getShutterStatus();
77 bool getDomeAzCPR();
78 bool getDomeAzCoast();
79 bool getDomeAzPos();
80 bool getDomeHomeAz();
81 bool getDomeParkAz();
82 bool getDomeAzStallCount();
83
84
88 bool setDomeAzCPR(uint32_t cpr);
89 bool gotoDomeAz(uint32_t az);
90 bool setDomeAzCoast(uint32_t coast);
91 bool killDomeAzMovement();
92 bool killDomeShutterMovement();
93 bool setDomeHomeAz(uint32_t az);
94 bool setDomeParkAz(uint32_t az);
95 bool setDomeAzStallCount(uint32_t steps);
96 bool calibrateDomeAz(double az);
97 bool gotoDomePark();
98 bool openDomeShutters();
99 bool closeDomeShutters();
100 bool gotoHomeDomeAz();
101 bool discoverHomeDomeAz();
102 bool setDomeLeftOn();
103 bool setDomeRightOn();
104
105
109
110
114
126 bool sendCommand(const char * cmd, char * res = nullptr, int cmd_len = -1, int res_len = -1);
127 void hexDump(char * buf, const char * data, int size);
128 std::vector<std::string> split(const std::string &input, const std::string &regex);
129
133 INDI::PropertyText VersionTP {2};
134 enum
135 {
136 VERSION_FIRMWARE,
137 VERSION_HARDWARE
138 };
139
140 INDI::PropertySwitch HomeSP {2};
141 enum
142 {
143 HOME_DISCOVER,
144 HOME_GOTO
145 };
146
147 INDI::PropertyText StatusTP {2};
148 enum
149 {
150 STATUS_DOME,
151 STATUS_SHUTTER
152 };
153
154 INDI::PropertyNumber SettingsNP {5};
155 enum
156 {
157 SETTINGS_AZ_CPR,
158 SETTINGS_AZ_COAST,
159 SETTINGS_AZ_HOME,
160 SETTINGS_AZ_PARK,
161 SETTINGS_AZ_STALL_COUNT
162 };
163
167 static constexpr const char * INFO_TAB = "Info";
168 static constexpr const char * SETTINGS_TAB = "Settings";
169 // 0x3B is the stop char
170 static const char DRIVER_STOP_CHAR { 0x3B };
171 // Wait up to a maximum of 3 seconds for serial input
172 static constexpr const uint8_t DRIVER_TIMEOUT {3};
173 // Maximum buffer for sending/receiving.
174 static constexpr const uint8_t DRIVER_LEN {64};
175 // Dome AZ Threshold
176 static constexpr const double DOME_AZ_THRESHOLD {0.01};
177 // Dome hardware types
178 const std::map<uint8_t, std::string> DomeHardware =
179 {
180 {0x0D, "DomePro2-d for classic domes"},
181 {0x0E, "DomePro2-c for clamcshell domes"},
182 {0x0F, "DomePro2-r for roll-off roof"}
183 };
184 // Shutter statuses
185 const std::map<uint8_t, std::string> ShutterStatus =
186 {
187 {0x00, "Opened"},
188 {0x01, "Closed"},
189 {0x02, "Opening"},
190 {0x03, "Closing"},
191 {0x04, "ShutterError"},
192 {0x05, "shutter module is not communicating to the azimuth module"},
193 {0x06, "shutter 1 opposite direction timeout error on open occurred"},
194 {0x07, "shutter 1 opposite direction timeout error on close occurred"},
195 {0x08, "shutter 2 opposite direction timeout error on open occurred"},
196 {0x09, "shutter 2 opposite direction timeout error on close occurred"},
197 {0x0A, "shutter 1 completion timeout error on open occurred"},
198 {0x0B, "shutter 1 completion timeout error on close occurred"},
199 {0x0C, "shutter 2 completion timeout error on open occurred"},
200 {0x0D, "shutter 2 completion timeout error on close occurred"},
201 {0x0E, "shutter 1 limit fault on open occurred"},
202 {0x0F, "shutter 1 limit fault on close occurred"},
203 {0x10, "shutter 2 limit fault on open occurred"},
204 {0x11, "shutter 2 limit fault on close occurred"},
205 {0x12, "Shutter disabled (Shutter Enable input is not asserted)"},
206 {0x13, "Intermediate"},
207 {0x14, "GoTo"},
208 {0x15, "shutter 1 OCP trip on open occurred"},
209 {0x16, "shutter 1 OCP trip on close occurred"},
210 {0x17, "shutter 2 OCP trip on open occurred"},
211 {0x18, "shutter 2 OCP trip on close occurred"}
212 };
213 // Dome statuses
214 const std::map<std::string, std::string> DomeStatus =
215 {
216 {"Fixed", "Idle"},
217 {"Left", "Moving Left"},
218 {"Right", "Moving Right"},
219 {"Goto", "GoTo"},
220 {"Homing", "Homing"},
221 {"Parking", "Parking"},
222 {"Gauging", "Gauging"},
223 {"Timeout", "Azimuth movement timeout"},
224 {"Stall", "Azimuth encoder registering insufficient counts… motor stalled"},
225 {"OCP", "Over Current Protection was tripped"}
226 };
227
228
229
230};
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition domepro2.cpp:290
virtual IPState UnPark() override
UnPark dome. The action of the Unpark command is dome specific, but it may include opening the shutte...
Definition domepro2.cpp:420
virtual IPState ControlShutter(ShutterOperation operation) override
Open or Close shutter.
Definition domepro2.cpp:428
virtual bool Sync(double az) override
Sync sets the dome current azimuth as the supplied azimuth position.
Definition domepro2.cpp:373
virtual const char * getDefaultName() override
Definition domepro2.cpp:124
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition domepro2.cpp:159
virtual bool SetCurrentPark() override
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
Definition domepro2.cpp:484
virtual IPState MoveRel(double azDiff) override
Move the Dome to an relative position.
Definition domepro2.cpp:357
virtual IPState MoveAbs(double az) override
Move the Dome to an absolute azimuth.
Definition domepro2.cpp:345
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
Definition domepro2.cpp:46
virtual bool SetDefaultPark() override
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
Definition domepro2.cpp:493
virtual IPState Move(DomeDirection dir, DomeMotionCommand operation) override
Move the Dome in a particular direction.
Definition domepro2.cpp:384
virtual bool Handshake() override
perform handshake with device to check communication
Definition domepro2.cpp:116
virtual bool Abort() override
Abort all dome motion.
Definition domepro2.cpp:446
virtual ~DomePro2() override=default
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Dome Presets in the configuration file
Definition domepro2.cpp:474
virtual IPState Park() override
Goto Park Position. The park position is an absolute azimuth value.
Definition domepro2.cpp:410
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition domepro2.cpp:213
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition domepro2.cpp:132
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
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
uint8_t cmd[4]
Definition pwc-ioctl.h:2