Instrument Neutral Distributed Interface INDI  2.0.2
gemini.h
Go to the documentation of this file.
1 /*
2  Optec Gemini Focuser Rotator INDI driver
3  Copyright (C) 2017 Jasem Mutlaq (mutlaqja@ikarustech.com)
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"
24 #include "indirotatorinterface.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  {
59  GOTO_HOME
60  };
61  typedef enum
62  {
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  INumber TemperatureN[1];
160  INumberVectorProperty TemperatureNP;
161 
162  // Enable/Disable temperature compnesation
163  ISwitch TemperatureCompensateS[2];
164  ISwitchVectorProperty TemperatureCompensateSP;
165 
166  // Enable/Disable temperature compnesation on start
167  ISwitch TemperatureCompensateOnStartS[2];
168  ISwitchVectorProperty TemperatureCompensateOnStartSP;
169 
170  // Temperature Coefficient
171  INumber TemperatureCoeffN[5];
172  INumberVectorProperty TemperatureCoeffNP;
173 
174  // Temperature Coefficient Mode
175  ISwitch TemperatureCompensateModeS[5];
176  ISwitchVectorProperty TemperatureCompensateModeSP;
177 
178  // Enable/Disable backlash
179  // ISwitch FocuserBacklashCompensationS[2];
180  // ISwitchVectorProperty FocuserFocusBacklashSP;
181 
182  // Backlash Value
183  // INumber FocusBacklashN[1];
184  // INumberVectorProperty FocusBacklashNP;
185 
186  // Home On Start
187  ISwitch FocuserHomeOnStartS[2];
188  ISwitchVectorProperty FocuserHomeOnStartSP;
189 
190  // Go to home/center
191  ISwitch FocuserGotoS[2];
192  ISwitchVectorProperty FocuserGotoSP;
193 
194  // Status indicators
195  ILight FocuserStatusL[8];
196  ILightVectorProperty FocuserStatusLP;
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  ILight RotatorStatusL[8];
219  ILightVectorProperty RotatorStatusLP;
220 
221  // Rotator Steps
222  INumber RotatorAbsPosN[1];
223  INumberVectorProperty RotatorAbsPosNP;
224 
225 #if 0
226  // Reverse Direction
227  ISwitch RotatorReverseS[2];
228  ISwitchVectorProperty RotatorReverseSP;
229 
230 
231 
232  // Rotator Degrees or PA (Position Angle)
233  INumber RotatorAbsAngleN[1];
234  INumberVectorProperty RotatorAbsAngleNP;
235 
236  // Abort
239 
240  // Go to home/center
241  ISwitch RotatorGotoS[2];
242  ISwitchVectorProperty RotatorGotoSP;
243 #endif
244 
245  // Home On Start
246  ISwitch RotatorHomeOnStartS[2];
247  ISwitchVectorProperty RotatorHomeOnStartSP;
248 
249  bool isRotatorHoming;
250 
252  // Hub Functions
254 
255  // Led level
256  bool setLedLevel(int level);
257 
258  // Device Nickname
259  bool setNickname(DeviceType type, const char *nickname);
260 
261  // Misc functions
262  bool resetFactory();
263  float calcTimeLeft(timeval, float);
264 
266  // Hub Properties
268 
269  // Reset to Factory setting
270  ISwitch ResetS[1];
271  ISwitchVectorProperty ResetSP;
272 
273  // Focus and rotator name configure in the HUB
274  IText HFocusNameT[2] {};
275  ITextVectorProperty HFocusNameTP;
276 
277  // Led Intensity Value
278  INumber LedN[1];
279  INumberVectorProperty LedNP;
280 
281  uint32_t DBG_FOCUS;
282 };
Definition: gemini.h:30
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition: gemini.cpp:2984
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Focuser Presets in the configuration file
Definition: gemini.cpp:3305
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
Definition: gemini.cpp:2969
~Gemini()
Definition: gemini.cpp:76
bool isResponseOK()
Definition: gemini.cpp:2824
virtual IPState HomeRotator() override
HomeRotator Go to home position.
Definition: gemini.cpp:3337
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:2879
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
Definition: gemini.cpp:606
virtual bool SetFocuserBacklashEnabled(bool enabled) override
SetFocuserBacklashEnabled Enables or disables the focuser backlash compensation.
Definition: gemini.cpp:3361
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:3325
bool rotatorConfigurationComplete
Definition: gemini.h:98
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: gemini.cpp:629
@ 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
@ 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 updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: gemini.cpp:239
virtual bool SetRotatorBacklashEnabled(bool enabled) override
SetRotatorBacklashEnabled Enables or disables the Rotator backlash compensation.
Definition: gemini.cpp:2643
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
Definition: gemini.cpp:3148
virtual bool SetFocuserBacklash(int32_t steps) override
SetFocuserBacklash Set the focuser backlash compensation value.
Definition: gemini.cpp:3353
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:3345
virtual IPState MoveAbsFocuser(uint32_t targetPosition) override
MoveFocuser the focuser to an absolute position.
Definition: gemini.cpp:2928
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: gemini.cpp:348
@ GOTO_HOME
Definition: gemini.h:59
@ GOTO_CENTER
Definition: gemini.h:58
virtual bool SetRotatorBacklash(int32_t steps) override
SetRotatorBacklash Set the Rotatorer backlash compensation value.
Definition: gemini.cpp:2635
virtual bool Handshake() override
perform handshake with device to check communication
Definition: gemini.cpp:323
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: gemini.cpp:83
virtual const char * getDefaultName() override
Definition: gemini.cpp:339
ISwitchVectorProperty AbortRotatorSP
ISState
Switch state.
Definition: indiapi.h:150
IPState
Property state.
Definition: indiapi.h:160
__le16 type
Definition: pwc-ioctl.h:0
One light descriptor.
One number descriptor.
One switch descriptor.
One text descriptor.
Light vector property descriptor.
Definition: indiapi.h:417
Number vector property descriptor.
Definition: indiapi.h:319
Switch vector property descriptor.
Definition: indiapi.h:367
Text vector property descriptor.
Definition: indiapi.h:246