Instrument Neutral Distributed Interface INDI  2.0.2
nightcrawler.h
Go to the documentation of this file.
1 /*
2  NightCrawler NightCrawler Focuser & Rotator
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 
27 {
28  public:
29 
31 
32  NightCrawler();
33  virtual ~NightCrawler() = default;
34 
35  virtual bool Handshake() override;
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  static void abnormalDisconnectCallback(void *userpointer);
43 
44  protected:
45  // Focuser
46  virtual IPState MoveAbsFocuser(uint32_t targetTicks) override;
47  virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
48  virtual bool AbortFocuser() override;
49 
50 
51  // Rotator
52  virtual IPState HomeRotator() override;
53  virtual IPState MoveRotator(double angle) override;
54  virtual bool SyncRotator(double angle) override;
55  virtual bool AbortRotator() override;
56  virtual bool ReverseRotator(bool enabled) override;
57 
58  // Misc.
59  virtual bool saveConfigItems(FILE *fp) override;
60  virtual void TimerHit() override;
61 
62  private:
63  // Get Firmware
64  bool getFirmware();
65  // Get Focuer Type
66  bool getFocuserType();
67  // Check if connection is OK
68  bool Ack();
69  // Goto Position
70  bool gotoMotor(MotorType type, int32_t position);
71  // Get Position
72  bool getPosition(MotorType type);
73  // Sync to Position
74  bool syncMotor(MotorType type, uint32_t position);
75  // Start/Stop Motors
76  bool startMotor(MotorType type);
77  bool stopMotor(MotorType type);
78  bool isMotorMoving(MotorType type);
79  // Sensors (Temperature + Voltage)
80  bool getTemperature();
81  bool getVoltage();
82  // Abnormal disconnect
83  void abnormalDisconnect();
84  // Temperature offset
85  bool setTemperatureOffset(double offset);
86  // Motor step rate in 100 microsecond intervals
87  bool getStepDelay(MotorType type);
88  bool setStepDelay(MotorType type, uint32_t delay);
89  // Limit Switch
90  bool getLimitSwitchStatus();
91  // Home
92  bool findHome(uint8_t motorTypes);
93  bool isHomingComplete();
94  // Encoders
95  bool setEncodersEnabled(bool enable);
96  // Brightness
97  bool setDisplayBrightness(uint8_t value);
98  bool setSleepBrightness(uint8_t value);
99 
100 
101  INumber GotoAuxN[1];
102  INumberVectorProperty GotoAuxNP;
103 
104  INumber SyncFocusN[1];
105  INumberVectorProperty SyncFocusNP;
106 
107  INumber SyncAuxN[1];
108  INumberVectorProperty SyncAuxNP;
109 
110  ISwitch AbortAuxS[1];
111  ISwitchVectorProperty AbortAuxSP;
112 
113  INumber VoltageN[1];
114  INumberVectorProperty VoltageNP;
115 
116  INumber TemperatureN[1];
117  INumberVectorProperty TemperatureNP;
118 
119  INumber TemperatureOffsetN[1];
120  INumberVectorProperty TemperatureOffsetNP;
121 
122  INumber FocusStepDelayN[1];
123  INumberVectorProperty FocusStepDelayNP;
124  INumber RotatorStepDelayN[1];
125  INumberVectorProperty RotatorStepDelayNP;
126  INumber AuxStepDelayN[1];
127  INumberVectorProperty AuxStepDelayNP;
128 
129  ILight LimitSwitchL[3];
130  ILightVectorProperty LimitSwitchLP;
131  enum { ROTATION_SWITCH, OUT_SWITCH, IN_SWITCH };
132 
133  ISwitch HomeSelectionS[3];
134  ISwitchVectorProperty HomeSelectionSP;
135  ISwitch FindHomeS[1];
136  ISwitchVectorProperty FindHomeSP;
137 
138  ISwitch EncoderS[2];
139  ISwitchVectorProperty EncoderSP;
140 
141  INumber BrightnessN[2];
142  INumberVectorProperty BrightnessNP;
143  enum { BRIGHTNESS_DISPLAY, BRIGHTNESS_SLEEP };
144 
145  // Rotator Steps
146  INumber RotatorAbsPosN[1];
147  INumberVectorProperty RotatorAbsPosNP;
148 
149  INDI::PropertyNumber CustomRotatorStepNP {1};
150 
151  double lastTemperature { 0 };
152  double lastVoltage { 0 };
153  int32_t m_RotatorTicksPerDegree { 0 };
154  int32_t m_RotatorStepsPerRevolution {0};
155  double lastFocuserPosition { 0 };
156  double lastRotatorPosition { 0 };
157  double lastAuxPosition { 0 };
158  double targetPosition { 0 };
159  IPState rotationLimit { IPS_IDLE };
160  IPState outSwitchLimit { IPS_IDLE };
161  IPState inSwitchLimit { IPS_IDLE };
162 };
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
virtual ~NightCrawler()=default
virtual IPState MoveRotator(double angle) override
MoveRotator Go to specific angle.
const char * getDefaultName() override
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool AbortRotator() override
AbortRotator Abort all motion.
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
virtual IPState HomeRotator() override
HomeRotator Go to home position.
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
virtual bool Handshake() override
perform handshake with device to check communication
static void abnormalDisconnectCallback(void *userpointer)
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool SyncRotator(double angle) override
SyncRotator Set current angle as the supplied angle without moving the rotator.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Focuser Presets in the configuration file
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool ReverseRotator(bool enabled) override
ReverseRotator Reverse the direction of the rotator. CW is usually the normal direction,...
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
ISState
Switch state.
Definition: indiapi.h:150
IPState
Property state.
Definition: indiapi.h:160
@ IPS_IDLE
Definition: indiapi.h:161
__le16 type
Definition: pwc-ioctl.h:0
One light descriptor.
One number descriptor.
One switch 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