Instrument Neutral Distributed Interface INDI 2.2.5
nexdome_beaver.h
Go to the documentation of this file.
1/*
2 NexDome Beaver Controller
3
4 Copyright (C) 2021 Jasem Mutlaq ([email protected])
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
20*/
21
22#pragma once
23
24#include <memory>
25#include <indidome.h>
26#include <indipropertytext.h>
27#include <indipropertyswitch.h>
28#include <indipropertynumber.h>
29
30class Beaver : public INDI::Dome
31{
32 public:
33 Beaver();
34 virtual ~Beaver() override = default;
35
36 const char *getDefaultName() override;
37 virtual bool initProperties() override;
38 virtual bool updateProperties() override;
39 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
40 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
41
42 protected:
43 bool Handshake() override;
44 virtual void TimerHit() override;
45
46 // Rotator
47 virtual IPState MoveAbs(double az) override;
48 virtual IPState MoveRel(double azDiff) override;
49 virtual IPState Move(DomeDirection dir, DomeMotionCommand operation) override;
50 virtual bool SetCurrentPark() override;
51 virtual bool SetDefaultPark() override;
52
53 // Shutter
54 virtual IPState ControlShutter(ShutterOperation operation) override;
55
56 // Abort
57 virtual bool Abort() override;
58
59 // Config
60 virtual bool saveConfigItems(FILE * fp) override;
61
62 // Parking
63 virtual IPState Park() override;
64 virtual IPState UnPark() override;
65
66 // Beaver status
67 enum
68 {
82 };
83
84 private:
85
89 bool echo();
90
94 bool rotatorGotoAz(double az);
95 bool rotatorGetAz();
96 bool rotatorSyncAZ(double az);
97 bool rotatorSetHome(double az);
98 bool rotatorSetPark(double az);
99 bool rotatorGotoPark();
100 bool rotatorGotoHome();
101 bool rotatorMeasureHome();
102 bool rotatorFindHome();
103 bool rotatorFullMeasure();
104 bool rotatorIsHome();
105 bool rotatorIsParked();
106 bool rotatorUnPark();
107 bool rotatorSetPark();
108 bool abortAll();
109 bool rotatorAbort();
110
111 bool rotatorGetSettings();
112 bool rotatorSetSettings(double maxSpeed, double minSpeed, double acceleration, double timeout);
113
117 //bool shutterSetSettings(double maxSpeed, double minSpeed, double acceleration, double timeout, double voltage);
118 bool shutterSetSettings(double maxSpeed, double minSpeed, double acceleration, double voltage);
119
120 bool shutterGetSettings();
121 bool shutterFindHome();
122 bool shutterAbort();
123 bool shutterOnLine();
124
128 bool sendCommand(const char * cmd, double &res);
129 bool sendRawCommand(const char * cmd, char *resString);
130 bool getDomeStatus(uint16_t &domeStatus);
131 void hexDump(char * buf, const char * data, int size);
132 std::vector<std::string> split(const std::string &input, const std::string &regex);
133
137 // Beaver Firmware Version
138 INDI::PropertyText VersionTP {1};
139 // Home offset from north
140 INDI::PropertyNumber HomePositionNP {1};
141 // Home set options
142 INDI::PropertySwitch HomeOptionsSP {2};
143 enum
144 {
145 HOMECURRENT,
146 HOMEDEFAULT
147 };
148
149 // Goto Home
150 INDI::PropertySwitch GotoHomeSP {1};
151 // Shutter voltage
152 INDI::PropertyNumber ShutterVoltsNP {1};
153 // Rotator Status
154 INDI::PropertyText RotatorStatusTP {1};
155 // Shutter Status
156 INDI::PropertyText ShutterStatusTP {1};
157 // Rotator Calibration
158 INDI::PropertySwitch RotatorCalibrationSP {3};
159 enum
160 {
161 ROTATOR_HOME_FIND,
162 ROTATOR_HOME_MEASURE,
163 ROTATOR_FULL_MEASURE
164 };
165 // Rotator Abort
166 INDI::PropertySwitch RotatorAbortSP {1};
167 // Shutter Calibration
168 INDI::PropertySwitch ShutterCalibrationSP {1};
169 enum
170 {
171 SHUTTER_HOME_FIND
172 };
173 // Shutter Abort
174 INDI::PropertySwitch ShutterAbortSP {1};
175 // Shutter Configuration
176 INDI::PropertyNumber ShutterSettingsNP {4};
177 enum
178 {
179 SHUTTER_MAX_SPEED,
180 SHUTTER_MIN_SPEED,
181 SHUTTER_ACCELERATION,
182 SHUTTER_SAFE_VOLTAGE
183 };
184 INDI::PropertyNumber ShutterSettingsTimeoutNP {1};
185
186 // Rotator Configuration
187 INDI::PropertyNumber RotatorSettingsNP {4};
188 enum
189 {
190 ROTATOR_MAX_SPEED,
191 ROTATOR_MIN_SPEED,
192 ROTATOR_ACCELERATION,
193 ROTATOR_TIMEOUT
194 };
195
199 double m_TargetRotatorAz {-1};
200
204 static constexpr const char * ROTATOR_TAB = "Rotator";
205 static constexpr const char * SHUTTER_TAB = "Shutter";
206 // '#' is the stop char
207 static const char DRIVER_STOP_CHAR { 0x23 };
208 // Wait up to a maximum of 3 seconds for serial input
209 static constexpr const uint8_t DRIVER_TIMEOUT {3};
210 // Maximum buffer for sending/receiving.
211 static constexpr const uint8_t DRIVER_LEN {128};
212 int domeDir = 1;
213 double lastAzDiff = 1;
214};
@ DOME_STATUS_SHUTTER_CLOSING
@ DOME_STATUS_SHUTTER_COMM
@ DOME_STATUS_SHUTTER_OPENED
@ DOME_STATUS_UNSAFE_RG
@ DOME_STATUS_ROTATOR_PARKED
@ DOME_STATUS_SHUTTER_CLOSED
@ DOME_STATUS_ROTATOR_MOVING
@ DOME_STATUS_SHUTTER_MOVING
@ DOME_STATUS_SHUTTER_OPENING
@ DOME_STATUS_SHUTTER_ERROR
@ DOME_STATUS_ROTATOR_HOME
@ DOME_STATUS_ROTATOR_ERROR
@ DOME_STATUS_UNSAFE_CW
virtual IPState UnPark() override
Rotator unpark.
virtual IPState ControlShutter(ShutterOperation operation) override
open or close the shutter (will not show if shutter is not present)
virtual IPState Move(DomeDirection dir, DomeMotionCommand operation) override
Rotator move (calc's offset and calles abs move)
virtual IPState MoveRel(double azDiff) override
Rotator relative move (calc's offset and calles abs move)
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual ~Beaver() override=default
virtual IPState Park() override
Rotator park.
virtual bool SetCurrentPark() override
Rotator set park position to current.
virtual void TimerHit() override
Timer hit - update appropriate fields.
virtual bool SetDefaultPark() override
Rotator set park position to default (0 az)
virtual bool Abort() override
abort everything
const char * getDefaultName() override
Set default name.
bool Handshake() override
Handshake.
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
virtual IPState MoveAbs(double az) override
Rotator absolute move.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Number field updated.
virtual bool saveConfigItems(FILE *fp) override
INDI save config.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Switch field updated.
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