Instrument Neutral Distributed Interface INDI 2.2.5
steeldrive2.h
Go to the documentation of this file.
1/*
2 Baader SteelDriveII Focuser
3
4 Copyright (C) 2019 Jasem Mutlaq ([email protected])
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
20*/
21
22#pragma once
23
24#include "indifocuser.h"
25
26#include <map>
27
29{
30 public:
32
33 typedef enum { GOING_UP, GOING_DOWN, STOPPED, ZEROED } State;
35
36 virtual bool Handshake() override;
37 const char *getDefaultName() override;
38 virtual bool initProperties() override;
39 virtual bool updateProperties() override;
40
41 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
42 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
43
44 protected:
45 virtual IPState MoveAbsFocuser(uint32_t targetTicks) override;
46 virtual IPState MoveRelFocuser(FocusDirection dir, unsigned int ticks) override;
47 virtual bool SyncFocuser(uint32_t ticks) override;
48 virtual bool ReverseFocuser(bool enabled) override;
49 virtual bool SetFocuserMaxPosition(uint32_t ticks) override;
50 virtual bool AbortFocuser() override;
51 virtual void TimerHit() override;
52
53 virtual bool saveConfigItems(FILE *fp) override;
54
55 private:
59 bool getParameter(const std::string &parameter, std::string &value);
60
64 bool setParameter(const std::string &parameter, const std::string &value);
65
69 bool getSummary();
70 bool sendCommandOK(const char * cmd);
71 bool sendCommand(const char * cmd, char * res = nullptr, int cmd_len = -1, int res_len = -1);
72 void hexDump(char * buf, const char * data, int size);
73 std::vector<std::string> split(const std::string &input, const std::string &regex);
74
78 void getStartupValues();
79 template <typename T> std::string to_string(const T a_value, const int n = 2);
80
84
85 // Focuser Information
87 IText InfoT[2] {};
88 enum
89 {
90 INFO_NAME,
91 INFO_VERSION
92 };
93
94 // Focuser Operations
95 ISwitchVectorProperty OperationSP;
96 ISwitch OperationS[3];
97 enum
98 {
99 OPERATION_REBOOT,
100 OPERATION_RESET,
101 OPERATION_ZEROING,
102 };
103
104 // Temperature Compensation
105 ISwitchVectorProperty TemperatureCompensationSP;
106 ISwitch TemperatureCompensationS[2];
107 enum
108 {
109 TC_ENABLED,
110 TC_DISABLED
111 };
112
113 // TC State
114 ISwitchVectorProperty TemperatureStateSP;
115 ISwitch TemperatureStateS[2];
116 enum
117 {
118 TC_ACTIVE,
119 TC_PAUSED
120 };
121
122 // Temperature Compensation Settings
123 INumberVectorProperty TemperatureSettingsNP;
124 INumber TemperatureSettingsN[3];
125 enum
126 {
127 TC_FACTOR,
128 TC_PERIOD,
129 TC_DELTA
130 };
131
132 // Temperature Sensors
133 INumberVectorProperty TemperatureSensorNP;
134 INumber TemperatureSensorN[3];
135 enum
136 {
137 TEMP_0,
138 TEMP_1,
139 TEMP_AVG
140 };
141
142 // Stepper Drive
143 INumberVectorProperty StepperDriveNP;
144 INumber StepperDriveN[2];
145 enum
146 {
147 CURRENT_MOVE,
148 CURRENT_HOLD
149 };
150
154 State m_State { STOPPED };
155 std::map<Summary, std::string> m_Summary;
156 bool m_ConfirmFactoryReset { false };
157
161 static constexpr const char * SETTINGS_TAB = "Settings";
162 static constexpr const char * COMPENSATION_TAB = "Compensation";
163 // 0xA is the stop char
164 static const char DRIVER_STOP_CHAR { 0x0A };
165 // Wait up to a maximum of 3 seconds for serial input
166 static constexpr const uint8_t DRIVER_TIMEOUT {3};
167 // Maximum buffer for sending/receiving.
168 static constexpr const uint8_t DRIVER_LEN {192};
169};
virtual bool SetFocuserMaxPosition(uint32_t ticks) override
Reverse Focuser Motion.
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 void TimerHit() override
Callback function to be called once SetTimer duration elapses.
virtual bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
virtual IPState MoveRelFocuser(FocusDirection dir, unsigned int ticks) override
virtual bool ReverseFocuser(bool enabled) override
Reverse Focuser Motion.
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
const char * getDefaultName() override
virtual bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
virtual bool saveConfigItems(FILE *fp) override
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
virtual bool Handshake() override
Performs a device-specific handshake after a connection is established. This method should be overrid...
virtual bool SyncFocuser(uint32_t ticks) override
Sync focuser.
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...
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
State
Definition lilxml.cpp:74
uint8_t cmd[4]
Definition pwc-ioctl.h:2
One number descriptor.
One switch descriptor.
One text descriptor.
Number vector property descriptor.
Definition indiapi.h:317
Switch vector property descriptor.
Definition indiapi.h:365
Text vector property descriptor.
Definition indiapi.h:244