Instrument Neutral Distributed Interface INDI 2.2.5
gemini.h
Go to the documentation of this file.
1/*
2 Optec Gemini Focuser Rotator INDI driver
3 Copyright (C) 2017 Jasem Mutlaq ([email protected])
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
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 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
19*/
20
21#pragma once
22
23#include "indifocuser.h"
25
26#include <stdint.h>
27#include <map>
28
30{
31 public:
32 Gemini();
33 ~Gemini();
34
35 enum
36 {
43 };
44 enum
45 {
55 };
56 enum
57 {
60 };
66
67 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
68 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
69 virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
70
71 protected:
72
73 virtual bool Handshake() override;
74 virtual const char *getDefaultName() override;
75
76 virtual bool initProperties() override;
77 virtual bool updateProperties() override;
78 virtual bool saveConfigItems(FILE *fp) override;
79
80 // Focuser Functions
81 virtual IPState MoveAbsFocuser(uint32_t targetPosition) override;
82 virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
83 virtual IPState MoveFocuser(FocusDirection dir, int speed, uint16_t duration) override;
84 virtual bool AbortFocuser() override;
85
86 virtual bool SetFocuserBacklash(int32_t steps) override;
87 virtual bool SetFocuserBacklashEnabled(bool enabled) override;
88
89 virtual void TimerHit() override;
90
91 // Misc functions
92 bool ack();
93 bool isResponseOK();
94
95 protected:
96 // Move from private to public to validate
99
100 // Rotator Overrides
101 virtual IPState HomeRotator() override;
102 virtual IPState MoveRotator(double angle) override;
103 virtual bool ReverseRotator(bool enabled) override;
104 virtual bool SetRotatorBacklash(int32_t steps) override;
105 virtual bool SetRotatorBacklashEnabled(bool enabled) override;
106
107 private:
108 uint32_t focuserSimPosition = 0;
109 uint32_t rotatorSimPosition = 0;
110 uint32_t rotatorSimPA = 0;
111 uint32_t targetFocuserPosition = 0;
112 uint32_t targetRotatorPosition = 0;
113 uint32_t targetRotatorAngle = 0;
114 uint32_t maxControllerTicks = 0;
115
116 ISState focuserSimStatus[8];
117 ISState rotatorSimStatus[8];
118
119 bool simCompensationOn;
120 char focusTarget[8];
121
122 struct timeval focusMoveStart;
123 float focusMoveRequest;
124
126 // Focuser Functions
128
129 // Get functions
130 bool getFocusConfig();
131 bool getFocusStatus();
132
133 // Set functions
134
135 // Position
136 bool setFocusPosition(uint16_t position);
137
138 // Temperature
139 bool setTemperatureCompensation(bool enable);
140 bool setTemperatureCompensationMode(char mode);
141 bool setTemperatureCompensationCoeff(char mode, int16_t coeff);
142 bool setTemperatureCompensationOnStart(bool enable);
143
144 // Backlash
145 bool setBacklashCompensation(DeviceType type, bool enable);
146 bool setBacklashCompensationSteps(DeviceType type, uint16_t steps);
147
148 // Motion functions
149 bool home(DeviceType type);
150 bool halt(DeviceType type);
151 bool center(DeviceType type);
152 bool homeOnStart(DeviceType type, bool enable);
153
155 // Focuser Properties
157
158 // Set/Get Temperature
159 INDI::PropertyNumber TemperatureNP {1};
160
161 // Enable/Disable temperature compnesation
162 INDI::PropertySwitch TemperatureCompensateSP {2};
163
164 // Enable/Disable temperature compnesation on start
165 INDI::PropertySwitch TemperatureCompensateOnStartSP {2};
166
167 // Temperature Coefficient
168 INDI::PropertyNumber TemperatureCoeffNP{5};
169 enum
170 {
171 A,
172 B,
173 C,
174 D,
175 E
176 };
177
178 // Temperature Coefficient Mode
179 INDI::PropertySwitch TemperatureCompensateModeSP {5};
180
181 // Enable/Disable backlash
182 // ISwitch FocuserBacklashCompensationS[2];
183 // ISwitchVectorProperty FocuserFocusBacklashSP;
184
185 // Backlash Value
186 // INumber FocusBacklashN[1];
187 // INumberVectorProperty FocusBacklashNP;
188
189 // Home On Start
190 INDI::PropertySwitch FocuserHomeOnStartSP {2};
191
192 // Go to home/center
193 INDI::PropertySwitch FocuserGotoSP {2};
194
195 // Status indicators
196 INDI::PropertyLight FocuserStatusLP {8};
197
198 bool isFocuserAbsolute;
199 bool isFocuserHoming;
200
202 // Rotator Functions
204
205 // Get functions
206 bool getRotatorConfig();
207 bool getRotatorStatus();
208
209 IPState MoveAbsRotatorTicks(uint32_t targetTicks);
210 IPState MoveAbsRotatorAngle(double angle);
211 bool reverseRotator(bool enable);
212
214 // Rotator Properties
216
217 // Status
218 INDI::PropertyLight RotatorStatusLP {8};
219
220 // Rotator Steps
221 INDI::PropertyNumber RotatorAbsPosNP {1};
222
223#if 0
224 // Reverse Direction
225 ISwitch RotatorReverseS[2];
226 ISwitchVectorProperty RotatorReverseSP;
227
228
229
230 // Rotator Degrees or PA (Position Angle)
231 INumber RotatorAbsAngleN[1];
232 INumberVectorProperty RotatorAbsAngleNP;
233
234 // Abort
235 ISwitch AbortRotatorS[1];
237
238 // Go to home/center
239 ISwitch RotatorGotoS[2];
240 ISwitchVectorProperty RotatorGotoSP;
241#endif
242
243 // Home On Start
244 INDI::PropertySwitch RotatorHomeOnStartSP {2};
245
246 bool isRotatorHoming;
247
249 // Hub Functions
251
252 // Led level
253 bool setLedLevel(int level);
254
255 // Device Nickname
256 bool setNickname(DeviceType type, const char *nickname);
257
258 // Misc functions
259 bool resetFactory();
260 float calcTimeLeft(timeval, float);
261
263 // Hub Properties
265
266 // Reset to Factory setting
267 INDI::PropertySwitch ResetSP {1};
268
269 // Focus and rotator name configure in the HUB
270 INDI::PropertyText HFocusNameTP {2};
271
272 // Led Intensity Value
273 INDI::PropertyNumber LedNP {1};
274
275 uint32_t DBG_FOCUS;
276};
@ FOCUS_F_COEFF
Definition gemini.h:42
@ FOCUS_C_COEFF
Definition gemini.h:39
@ FOCUS_B_COEFF
Definition gemini.h:38
@ FOCUS_A_COEFF
Definition gemini.h:37
@ FOCUS_D_COEFF
Definition gemini.h:40
@ FOCUS_E_COEFF
Definition gemini.h:41
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition gemini.cpp:2985
virtual bool saveConfigItems(FILE *fp) override
Definition gemini.cpp:3306
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
Definition gemini.cpp:2970
~Gemini()
Definition gemini.cpp:76
bool isResponseOK()
Definition gemini.cpp:2825
virtual IPState HomeRotator() override
HomeRotator Go to home position.
Definition gemini.cpp:3338
Gemini()
Definition gemini.cpp:47
virtual IPState MoveFocuser(FocusDirection dir, int speed, uint16_t duration) override
MoveFocuser the focuser in a particular direction with a specific speed for a finite duration.
Definition gemini.cpp:2880
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Processes incoming new text values from the client for this device. Delegates processing to the contr...
Definition gemini.cpp:606
virtual bool SetFocuserBacklashEnabled(bool enabled) override
SetFocuserBacklashEnabled Enables or disables the focuser backlash compensation.
Definition gemini.cpp:3362
@ GOTO_HOME
Definition gemini.h:59
@ GOTO_CENTER
Definition gemini.h:58
bool focuserConfigurationComplete
Definition gemini.h:97
bool ack()
Definition gemini.cpp:743
virtual IPState MoveRotator(double angle) override
MoveRotator Go to specific angle.
Definition gemini.cpp:3326
bool rotatorConfigurationComplete
Definition gemini.h:98
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Processes incoming new number values from the client for this device. Handles updates to FocuserInter...
Definition gemini.cpp:629
virtual bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
Definition gemini.cpp:239
virtual bool SetRotatorBacklashEnabled(bool enabled) override
SetRotatorBacklashEnabled Enables or disables the Rotator backlash compensation.
Definition gemini.cpp:2644
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
Definition gemini.cpp:3149
virtual bool SetFocuserBacklash(int32_t steps) override
SetFocuserBacklash Set the focuser backlash compensation value.
Definition gemini.cpp:3354
DeviceType
Definition gemini.h:62
@ DEVICE_ROTATOR
Definition gemini.h:64
@ DEVICE_FOCUSER
Definition gemini.h:63
virtual bool ReverseRotator(bool enabled) override
ReverseRotator Reverse the direction of the rotator. CW is usually the normal direction,...
Definition gemini.cpp:3346
virtual IPState MoveAbsFocuser(uint32_t targetPosition) override
MoveFocuser the focuser to an absolute position.
Definition gemini.cpp:2929
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Processes incoming new switch states from the client for this device. Handles updates to FocuserInter...
Definition gemini.cpp:348
@ STATUS_TMPPROBE
Definition gemini.h:50
@ STATUS_REVERSE
Definition gemini.h:53
@ STATUS_REMOTEIO
Definition gemini.h:51
@ STATUS_HOMING
Definition gemini.h:47
@ STATUS_HOMED
Definition gemini.h:48
@ STATUS_FFDETECT
Definition gemini.h:49
@ STATUS_UNKNOWN
Definition gemini.h:54
@ STATUS_HNDCTRL
Definition gemini.h:52
@ STATUS_MOVING
Definition gemini.h:46
virtual bool SetRotatorBacklash(int32_t steps) override
SetRotatorBacklash Set the Rotatorer backlash compensation value.
Definition gemini.cpp:2636
virtual bool Handshake() override
Performs a device-specific handshake after a connection is established. This method should be overrid...
Definition gemini.cpp:323
virtual bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
Definition gemini.cpp:83
virtual const char * getDefaultName() override
Definition gemini.cpp:339
INDI::PropertySwitch AbortRotatorSP
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
uint16_t type
Definition pwc-ioctl.h:0
One number descriptor.
One switch descriptor.
Number vector property descriptor.
Definition indiapi.h:317
Switch vector property descriptor.
Definition indiapi.h:365