Instrument Neutral Distributed Interface INDI  1.9.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 <map>
27 
29 {
30  public:
31  Gemini();
32  ~Gemini();
33 
34  enum
35  {
42  };
43  enum
44  {
54  };
55  enum
56  {
59  };
60  typedef enum
61  {
64  } DeviceType;
65 
66  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
67  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
68  virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
69 
70  protected:
71 
72  virtual bool Handshake() override;
73  virtual const char *getDefaultName() override;
74 
75  virtual bool initProperties() override;
76  virtual bool updateProperties() override;
77  virtual bool saveConfigItems(FILE *fp) override;
78 
79  // Focuser Functions
80  virtual IPState MoveAbsFocuser(uint32_t targetPosition) override;
81  virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
82  virtual IPState MoveFocuser(FocusDirection dir, int speed, uint16_t duration) override;
83  virtual bool AbortFocuser() override;
84 
85  virtual bool SetFocuserBacklash(int32_t steps) override;
86  virtual bool SetFocuserBacklashEnabled(bool enabled) override;
87 
88  virtual void TimerHit() override;
89 
90  // Misc functions
91  bool ack();
92  bool isResponseOK();
93 
94  protected:
95  // Move from private to public to validate
98 
99  // Rotator Overrides
100  virtual IPState HomeRotator() override;
101  virtual IPState MoveRotator(double angle) override;
102  virtual bool ReverseRotator(bool enabled) override;
103  virtual bool SetRotatorBacklash(int32_t steps) override;
104  virtual bool SetRotatorBacklashEnabled(bool enabled) override;
105 
106  private:
107  uint32_t focuserSimPosition = 0;
108  uint32_t rotatorSimPosition = 0;
109  uint32_t rotatorSimPA = 0;
110  uint32_t targetFocuserPosition = 0;
111  uint32_t targetRotatorPosition = 0;
112  uint32_t targetRotatorAngle = 0;
113  uint32_t maxControllerTicks = 0;
114 
115  ISState focuserSimStatus[8];
116  ISState rotatorSimStatus[8];
117 
118  bool simCompensationOn;
119  char focusTarget[8];
120 
121  struct timeval focusMoveStart;
122  float focusMoveRequest;
123 
125  // Focuser Functions
127 
128  // Get functions
129  bool getFocusConfig();
130  bool getFocusStatus();
131 
132  // Set functions
133 
134  // Position
135  bool setFocusPosition(u_int16_t position);
136 
137  // Temperature
138  bool setTemperatureCompensation(bool enable);
139  bool setTemperatureCompensationMode(char mode);
140  bool setTemperatureCompensationCoeff(char mode, int16_t coeff);
141  bool setTemperatureCompensationOnStart(bool enable);
142 
143  // Backlash
144  bool setBacklashCompensation(DeviceType type, bool enable);
145  bool setBacklashCompensationSteps(DeviceType type, uint16_t steps);
146 
147  // Motion functions
148  bool home(DeviceType type);
149  bool halt(DeviceType type);
150  bool center(DeviceType type);
151  bool homeOnStart(DeviceType type, bool enable);
152 
154  // Focuser Properties
156 
157  // Set/Get Temperature
158  INumber TemperatureN[1];
159  INumberVectorProperty TemperatureNP;
160 
161  // Enable/Disable temperature compnesation
162  ISwitch TemperatureCompensateS[2];
163  ISwitchVectorProperty TemperatureCompensateSP;
164 
165  // Enable/Disable temperature compnesation on start
166  ISwitch TemperatureCompensateOnStartS[2];
167  ISwitchVectorProperty TemperatureCompensateOnStartSP;
168 
169  // Temperature Coefficient
170  INumber TemperatureCoeffN[5];
171  INumberVectorProperty TemperatureCoeffNP;
172 
173  // Temperature Coefficient Mode
174  ISwitch TemperatureCompensateModeS[5];
175  ISwitchVectorProperty TemperatureCompensateModeSP;
176 
177  // Enable/Disable backlash
178  // ISwitch FocuserBacklashCompensationS[2];
179  // ISwitchVectorProperty FocuserFocusBacklashSP;
180 
181  // Backlash Value
182  // INumber FocusBacklashN[1];
183  // INumberVectorProperty FocusBacklashNP;
184 
185  // Home On Start
186  ISwitch FocuserHomeOnStartS[2];
187  ISwitchVectorProperty FocuserHomeOnStartSP;
188 
189  // Go to home/center
190  ISwitch FocuserGotoS[2];
191  ISwitchVectorProperty FocuserGotoSP;
192 
193  // Status indicators
194  ILight FocuserStatusL[8];
195  ILightVectorProperty FocuserStatusLP;
196 
197  bool isFocuserAbsolute;
198  bool isFocuserHoming;
199 
201  // Rotator Functions
203 
204  // Get functions
205  bool getRotatorConfig();
206  bool getRotatorStatus();
207 
208  IPState MoveAbsRotatorTicks(uint32_t targetTicks);
209  IPState MoveAbsRotatorAngle(double angle);
210  bool reverseRotator(bool enable);
211 
213  // Rotator Properties
215 
216  // Status
217  ILight RotatorStatusL[8];
218  ILightVectorProperty RotatorStatusLP;
219 
220  // Rotator Steps
221  INumber RotatorAbsPosN[1];
222  INumberVectorProperty RotatorAbsPosNP;
223 
224 #if 0
225  // Reverse Direction
226  ISwitch RotatorReverseS[2];
227  ISwitchVectorProperty RotatorReverseSP;
228 
229 
230 
231  // Rotator Degrees or PA (Position Angle)
232  INumber RotatorAbsAngleN[1];
233  INumberVectorProperty RotatorAbsAngleNP;
234 
235  // Abort
238 
239  // Go to home/center
240  ISwitch RotatorGotoS[2];
241  ISwitchVectorProperty RotatorGotoSP;
242 #endif
243 
244  // Home On Start
245  ISwitch RotatorHomeOnStartS[2];
246  ISwitchVectorProperty RotatorHomeOnStartSP;
247 
248  bool isRotatorHoming;
249 
251  // Hub Functions
253 
254  // Led level
255  bool setLedLevel(int level);
256 
257  // Device Nickname
258  bool setNickname(DeviceType type, const char *nickname);
259 
260  // Misc functions
261  bool resetFactory();
262  float calcTimeLeft(timeval, float);
263 
265  // Hub Properties
267 
268  // Reset to Factory setting
269  ISwitch ResetS[1];
270  ISwitchVectorProperty ResetSP;
271 
272  // Focus and rotator name configure in the HUB
273  IText HFocusNameT[2] {};
274  ITextVectorProperty HFocusNameTP;
275 
276  // Led Intensity Value
277  INumber LedN[1];
278  INumberVectorProperty LedNP;
279 
280  uint32_t DBG_FOCUS;
281 };
Gemini::TimerHit
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition: gemini.cpp:2984
Gemini::initProperties
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: gemini.cpp:83
Gemini::FOCUS_B_COEFF
@ FOCUS_B_COEFF
Definition: gemini.h:37
IPState
IPState
Property state.
Definition: indiapi.h:158
Gemini::~Gemini
~Gemini()
Definition: gemini.cpp:76
Gemini::GOTO_HOME
@ GOTO_HOME
Definition: gemini.h:58
Gemini::AbortFocuser
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
Definition: gemini.cpp:3148
Gemini
Definition: gemini.h:28
_ILightVectorProperty
Light vector property descriptor.
Definition: indiapi.h:415
ISwitch
One switch descriptor.
Gemini::GOTO_CENTER
@ GOTO_CENTER
Definition: gemini.h:57
Gemini::STATUS_REVERSE
@ STATUS_REVERSE
Definition: gemini.h:52
Gemini::DeviceType
DeviceType
Definition: gemini.h:60
INumber
One number descriptor.
Gemini::STATUS_HNDCTRL
@ STATUS_HNDCTRL
Definition: gemini.h:51
Gemini::focuserConfigurationComplete
bool focuserConfigurationComplete
Definition: gemini.h:96
Gemini::MoveRotator
virtual IPState MoveRotator(double angle) override
MoveRotator Go to specific angle.
Definition: gemini.cpp:3327
Gemini::FOCUS_E_COEFF
@ FOCUS_E_COEFF
Definition: gemini.h:40
Gemini::ReverseRotator
virtual bool ReverseRotator(bool enabled) override
ReverseRotator Reverse the direction of the rotator. CW is usually the normal direction,...
Definition: gemini.cpp:3347
Gemini::Handshake
virtual bool Handshake() override
perform handshake with device to check communication
Definition: gemini.cpp:323
Gemini::SetFocuserBacklashEnabled
virtual bool SetFocuserBacklashEnabled(bool enabled) override
SetFocuserBacklashEnabled Enables or disables the focuser backlash compensation.
Definition: gemini.cpp:3363
Gemini::SetFocuserBacklash
virtual bool SetFocuserBacklash(int32_t steps) override
SetFocuserBacklash Set the focuser backlash compensation value.
Definition: gemini.cpp:3355
indifocuser.h
Gemini::SetRotatorBacklash
virtual bool SetRotatorBacklash(int32_t steps) override
SetRotatorBacklash Set the Rotatorer backlash compensation value.
Definition: gemini.cpp:2635
Gemini::MoveRelFocuser
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
Definition: gemini.cpp:2969
_ITextVectorProperty
Text vector property descriptor.
Definition: indiapi.h:244
Gemini::updateProperties
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: gemini.cpp:239
Gemini::DEVICE_ROTATOR
@ DEVICE_ROTATOR
Definition: gemini.h:63
indirotatorinterface.h
Gemini::MoveFocuser
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
type
__le16 type
Definition: pwc-ioctl.h:2
Gemini::rotatorConfigurationComplete
bool rotatorConfigurationComplete
Definition: gemini.h:97
ILight
One light descriptor.
_INumberVectorProperty
Number vector property descriptor.
Definition: indiapi.h:317
Gemini::FOCUS_F_COEFF
@ FOCUS_F_COEFF
Definition: gemini.h:41
Gemini::isResponseOK
bool isResponseOK()
Definition: gemini.cpp:2824
Gemini::HomeRotator
virtual IPState HomeRotator() override
HomeRotator Go to home position.
Definition: gemini.cpp:3339
IText
One text descriptor.
Gemini::FOCUS_A_COEFF
@ FOCUS_A_COEFF
Definition: gemini.h:36
Gemini::SetRotatorBacklashEnabled
virtual bool SetRotatorBacklashEnabled(bool enabled) override
SetRotatorBacklashEnabled Enables or disables the Rotator backlash compensation.
Definition: gemini.cpp:2643
Gemini::ISNewText
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
Gemini::ack
bool ack()
Definition: gemini.cpp:743
Gemini::FOCUS_D_COEFF
@ FOCUS_D_COEFF
Definition: gemini.h:39
Gemini::ISNewNumber
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
INDI::RotatorInterface::AbortRotatorSP
ISwitchVectorProperty AbortRotatorSP
Definition: indirotatorinterface.h:204
Gemini::STATUS_MOVING
@ STATUS_MOVING
Definition: gemini.h:45
Gemini::STATUS_HOMING
@ STATUS_HOMING
Definition: gemini.h:46
Gemini::STATUS_UNKNOWN
@ STATUS_UNKNOWN
Definition: gemini.h:53
Gemini::STATUS_TMPPROBE
@ STATUS_TMPPROBE
Definition: gemini.h:49
Gemini::saveConfigItems
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Focuser Presets in the configuration file
Definition: gemini.cpp:3307
Gemini::MoveAbsFocuser
virtual IPState MoveAbsFocuser(uint32_t targetPosition) override
MoveFocuser the focuser to an absolute position.
Definition: gemini.cpp:2928
Gemini::STATUS_FFDETECT
@ STATUS_FFDETECT
Definition: gemini.h:48
Gemini::STATUS_HOMED
@ STATUS_HOMED
Definition: gemini.h:47
Gemini::FOCUS_C_COEFF
@ FOCUS_C_COEFF
Definition: gemini.h:38
INDI::FocuserInterface::FocusDirection
FocusDirection
Definition: indifocuserinterface.h:66
Gemini::DEVICE_FOCUSER
@ DEVICE_FOCUSER
Definition: gemini.h:62
Gemini::Gemini
Gemini()
Definition: gemini.cpp:47
ISState
ISState
Switch state.
Definition: indiapi.h:148
INDI::RotatorInterface
Definition: indirotatorinterface.h:45
Gemini::STATUS_REMOTEIO
@ STATUS_REMOTEIO
Definition: gemini.h:50
Gemini::ISNewSwitch
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
INDI::Focuser
Definition: indifocuser.h:43
Gemini::getDefaultName
virtual const char * getDefaultName() override
Definition: gemini.cpp:339
INDI::RotatorInterface::AbortRotatorS
ISwitch AbortRotatorS[1]
Definition: indirotatorinterface.h:203
_ISwitchVectorProperty
Switch vector property descriptor.
Definition: indiapi.h:365