forked from indilib/indi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gemini.h
282 lines (217 loc) · 8.64 KB
/
gemini.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
/*
Optec Gemini Focuser Rotator INDI driver
Copyright (C) 2017 Jasem Mutlaq (mutlaqja@ikarustech.com)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#pragma once
#include "indifocuser.h"
#include "indirotatorinterface.h"
#include <stdint.h>
#include <map>
class Gemini : public INDI::Focuser, public INDI::RotatorInterface
{
public:
Gemini();
~Gemini();
enum
{
FOCUS_A_COEFF,
FOCUS_B_COEFF,
FOCUS_C_COEFF,
FOCUS_D_COEFF,
FOCUS_E_COEFF,
FOCUS_F_COEFF
};
enum
{
STATUS_MOVING,
STATUS_HOMING,
STATUS_HOMED,
STATUS_FFDETECT,
STATUS_TMPPROBE,
STATUS_REMOTEIO,
STATUS_HNDCTRL,
STATUS_REVERSE,
STATUS_UNKNOWN
};
enum
{
GOTO_CENTER,
GOTO_HOME
};
typedef enum
{
DEVICE_FOCUSER,
DEVICE_ROTATOR
} DeviceType;
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
protected:
virtual bool Handshake() override;
virtual const char *getDefaultName() override;
virtual bool initProperties() override;
virtual bool updateProperties() override;
virtual bool saveConfigItems(FILE *fp) override;
// Focuser Functions
virtual IPState MoveAbsFocuser(uint32_t targetPosition) override;
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
virtual IPState MoveFocuser(FocusDirection dir, int speed, uint16_t duration) override;
virtual bool AbortFocuser() override;
virtual bool SetFocuserBacklash(int32_t steps) override;
virtual bool SetFocuserBacklashEnabled(bool enabled) override;
virtual void TimerHit() override;
// Misc functions
bool ack();
bool isResponseOK();
protected:
// Move from private to public to validate
bool focuserConfigurationComplete = false;
bool rotatorConfigurationComplete = false;
// Rotator Overrides
virtual IPState HomeRotator() override;
virtual IPState MoveRotator(double angle) override;
virtual bool ReverseRotator(bool enabled) override;
virtual bool SetRotatorBacklash(int32_t steps) override;
virtual bool SetRotatorBacklashEnabled(bool enabled) override;
private:
uint32_t focuserSimPosition = 0;
uint32_t rotatorSimPosition = 0;
uint32_t rotatorSimPA = 0;
uint32_t targetFocuserPosition = 0;
uint32_t targetRotatorPosition = 0;
uint32_t targetRotatorAngle = 0;
uint32_t maxControllerTicks = 0;
ISState focuserSimStatus[8];
ISState rotatorSimStatus[8];
bool simCompensationOn;
char focusTarget[8];
struct timeval focusMoveStart;
float focusMoveRequest;
////////////////////////////////////////////////////////////
// Focuser Functions
///////////////////////////////////////////////////////////
// Get functions
bool getFocusConfig();
bool getFocusStatus();
// Set functions
// Position
bool setFocusPosition(uint16_t position);
// Temperature
bool setTemperatureCompensation(bool enable);
bool setTemperatureCompensationMode(char mode);
bool setTemperatureCompensationCoeff(char mode, int16_t coeff);
bool setTemperatureCompensationOnStart(bool enable);
// Backlash
bool setBacklashCompensation(DeviceType type, bool enable);
bool setBacklashCompensationSteps(DeviceType type, uint16_t steps);
// Motion functions
bool home(DeviceType type);
bool halt(DeviceType type);
bool center(DeviceType type);
bool homeOnStart(DeviceType type, bool enable);
////////////////////////////////////////////////////////////
// Focuser Properties
///////////////////////////////////////////////////////////
// Set/Get Temperature
INumber TemperatureN[1];
INumberVectorProperty TemperatureNP;
// Enable/Disable temperature compnesation
ISwitch TemperatureCompensateS[2];
ISwitchVectorProperty TemperatureCompensateSP;
// Enable/Disable temperature compnesation on start
ISwitch TemperatureCompensateOnStartS[2];
ISwitchVectorProperty TemperatureCompensateOnStartSP;
// Temperature Coefficient
INumber TemperatureCoeffN[5];
INumberVectorProperty TemperatureCoeffNP;
// Temperature Coefficient Mode
ISwitch TemperatureCompensateModeS[5];
ISwitchVectorProperty TemperatureCompensateModeSP;
// Enable/Disable backlash
// ISwitch FocuserBacklashCompensationS[2];
// ISwitchVectorProperty FocuserFocusBacklashSP;
// Backlash Value
// INumber FocusBacklashN[1];
// INumberVectorProperty FocusBacklashNP;
// Home On Start
ISwitch FocuserHomeOnStartS[2];
ISwitchVectorProperty FocuserHomeOnStartSP;
// Go to home/center
ISwitch FocuserGotoS[2];
ISwitchVectorProperty FocuserGotoSP;
// Status indicators
ILight FocuserStatusL[8];
ILightVectorProperty FocuserStatusLP;
bool isFocuserAbsolute;
bool isFocuserHoming;
////////////////////////////////////////////////////////////
// Rotator Functions
///////////////////////////////////////////////////////////
// Get functions
bool getRotatorConfig();
bool getRotatorStatus();
IPState MoveAbsRotatorTicks(uint32_t targetTicks);
IPState MoveAbsRotatorAngle(double angle);
bool reverseRotator(bool enable);
////////////////////////////////////////////////////////////
// Rotator Properties
///////////////////////////////////////////////////////////
// Status
ILight RotatorStatusL[8];
ILightVectorProperty RotatorStatusLP;
// Rotator Steps
INumber RotatorAbsPosN[1];
INumberVectorProperty RotatorAbsPosNP;
#if 0
// Reverse Direction
ISwitch RotatorReverseS[2];
ISwitchVectorProperty RotatorReverseSP;
// Rotator Degrees or PA (Position Angle)
INumber RotatorAbsAngleN[1];
INumberVectorProperty RotatorAbsAngleNP;
// Abort
ISwitch AbortRotatorS[1];
ISwitchVectorProperty AbortRotatorSP;
// Go to home/center
ISwitch RotatorGotoS[2];
ISwitchVectorProperty RotatorGotoSP;
#endif
// Home On Start
ISwitch RotatorHomeOnStartS[2];
ISwitchVectorProperty RotatorHomeOnStartSP;
bool isRotatorHoming;
////////////////////////////////////////////////////////////
// Hub Functions
///////////////////////////////////////////////////////////
// Led level
bool setLedLevel(int level);
// Device Nickname
bool setNickname(DeviceType type, const char *nickname);
// Misc functions
bool resetFactory();
float calcTimeLeft(timeval, float);
////////////////////////////////////////////////////////////
// Hub Properties
///////////////////////////////////////////////////////////
// Reset to Factory setting
ISwitch ResetS[1];
ISwitchVectorProperty ResetSP;
// Focus and rotator name configure in the HUB
IText HFocusNameT[2] {};
ITextVectorProperty HFocusNameTP;
// Led Intensity Value
INumber LedN[1];
INumberVectorProperty LedNP;
uint32_t DBG_FOCUS;
};