Instrument Neutral Distributed Interface INDI 2.2.5
nightcrawler.h
Go to the documentation of this file.
1/*
2 NightCrawler NightCrawler Focuser & Rotator
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
27{
28 public:
29
31
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 INDI::PropertyNumber GotoAuxNP {1};
102
103 INDI::PropertyNumber SyncFocusNP {1};
104
105 INDI::PropertyNumber SyncAuxNP {1};
106
107 INDI::PropertySwitch AbortAuxSP {1};
108
109 INDI::PropertyNumber VoltageNP {1};
110
111 INDI::PropertyNumber TemperatureNP {1};
112
113 INumber TemperatureOffsetN[1];
114 INumberVectorProperty TemperatureOffsetNP;
115
116 INDI::PropertyNumber FocusStepDelayNP {1};
117 INDI::PropertyNumber RotatorStepDelayNP {1};
118 INDI::PropertyNumber AuxStepDelayNP {1};
119
120 INDI::PropertyLight LimitSwitchLP {3};
121 enum { ROTATION_SWITCH, OUT_SWITCH, IN_SWITCH };
122
123 INDI::PropertySwitch HomeSelectionSP {3};
124 INDI::PropertySwitch FindHomeSP {1};
125
126 INDI::PropertySwitch EncoderSP {2};
127
128 INDI::PropertyNumber BrightnessNP {2};
129 enum { BRIGHTNESS_DISPLAY, BRIGHTNESS_SLEEP };
130
131 // Rotator Steps
132 INDI::PropertyNumber RotatorAbsPosNP {1};
133
134 INDI::PropertyNumber CustomRotatorStepNP {1};
135
136 double lastTemperature { 0 };
137 double lastVoltage { 0 };
138 int32_t m_RotatorTicksPerDegree { 0 };
139 int32_t m_RotatorStepsPerRevolution {0};
140 double lastFocuserPosition { 0 };
141 double lastRotatorPosition { 0 };
142 double lastAuxPosition { 0 };
143 double targetPosition { 0 };
144 IPState rotationLimit { IPS_IDLE };
145 IPState outSwitchLimit { IPS_IDLE };
146 IPState inSwitchLimit { IPS_IDLE };
147};
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
Processes incoming new switch states from the client for this device. Handles updates to FocuserInter...
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
Performs a device-specific handshake after a connection is established. This method should be overrid...
static void abnormalDisconnectCallback(void *userpointer)
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...
virtual bool SyncRotator(double angle) override
SyncRotator Set current angle as the supplied angle without moving the rotator.
virtual bool saveConfigItems(FILE *fp) override
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
virtual bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
virtual bool ReverseRotator(bool enabled) override
ReverseRotator Reverse the direction of the rotator. CW is usually the normal direction,...
virtual bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
@ IPS_IDLE
Definition indiapi.h:159
uint16_t type
Definition pwc-ioctl.h:0
One number descriptor.
Number vector property descriptor.
Definition indiapi.h:317