Instrument Neutral Distributed Interface INDI 2.2.5
sestosenso3.h
Go to the documentation of this file.
1/*
2 SestoSenso 3 Focuser
3 Copyright (C) 2026 Jasem Mutlaq
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 "inditimer.h"
25#include "primalucacommandset.h"
26
28{
29 public:
31 virtual ~SestoSenso3() override = default;
32
33 const char *getDefaultName() override;
34 virtual bool initProperties() override;
35 virtual bool updateProperties() override;
36 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
37 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
38
39 protected:
40 virtual bool Handshake() override;
41 virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
42 virtual IPState MoveAbsFocuser(uint32_t targetTicks) override;
43 virtual bool ReverseFocuser(bool enabled) override;
44 virtual bool AbortFocuser() override;
45 virtual void TimerHit() override;
46 virtual bool SetFocuserBacklash(int32_t steps) override;
47 virtual bool saveConfigItems(FILE *fp) override;
48
49 private:
50 bool Ack();
51 bool updateMaxLimit();
52 bool updateTemperature();
53 bool updatePosition();
54 bool updateVoltageIn();
55 bool fetchMotorSettings();
56 bool applyMotorRates();
57 bool applyMotorCurrents();
58 void setConnectionParams();
59 bool initCommandSet();
60 void checkMotionProgressCallback();
61 bool getStartupValues();
62 bool isMotionComplete();
63
64 // Submodel variants
65 enum SestoSenso3Model
66 {
67 SESTOSENSO3_STANDARD,
68 SESTOSENSO3_SC,
69 SESTOSENSO3_LS,
70 };
71 SestoSenso3Model m_SubModel { SESTOSENSO3_STANDARD };
72
73 FocusDirection backlashDirection { FOCUS_INWARD };
74 uint32_t backlashTicks { 0 };
75 uint32_t targetPos { 0 };
76 uint32_t lastPos { 0 };
77 double lastVoltageIn { 0 };
78 double lastTemperature { 0 };
79 uint16_t m_TemperatureCounter { 0 };
80
81 std::unique_ptr<PrimalucaLabs::SestoSenso3> m_SestoSenso3;
82
83 // Properties
84 INDI::PropertyText FirmwareTP {2};
85 enum
86 {
87 FIRMWARE_SN,
88 FIRMWARE_VERSION,
89 };
90
91 INDI::PropertyNumber VoltageInNP {1};
92
93 INDI::PropertyNumber TemperatureNP {2};
94 enum
95 {
96 TEMPERATURE_EXTERNAL,
97 TEMPERATURE_MOTOR,
98 };
99
100 INDI::PropertyText CalibrationMessageTP {1};
101
102 INDI::PropertySwitch CalibrationSP {2};
103 enum
104 {
105 CALIBRATION_START,
106 CALIBRATION_NEXT
107 };
108
109 INDI::PropertySwitch FastMoveSP {3};
110 enum
111 {
112 FASTMOVE_IN,
113 FASTMOVE_OUT,
114 FASTMOVE_STOP
115 };
116
117 // Semi-automatic calibration move switches (STANDARD and LS only)
118 INDI::PropertySwitch MoveInOut100SP {2};
119 enum
120 {
121 MOVE_IN_100,
122 MOVE_OUT_100
123 };
124
125 INDI::PropertySwitch MoveInOut500SP {2};
126 enum
127 {
128 MOVE_IN_500,
129 MOVE_OUT_500
130 };
131
132 INDI::PropertySwitch MoveInOut1000SP {2};
133 enum
134 {
135 MOVE_IN_1000,
136 MOVE_OUT_1000
137 };
138
139 INDI::PropertySwitch MotorHoldSP {2};
140 enum
141 {
142 MOTOR_HOLD_ON,
143 MOTOR_HOLD_OFF
144 };
145
146 INDI::PropertyNumber MotorRateNP {3};
147 enum
148 {
149 MOTOR_RATE_ACC,
150 MOTOR_RATE_RUN,
151 MOTOR_RATE_DEC
152 };
153
154 INDI::PropertyNumber MotorCurrentNP {4};
155 enum
156 {
157 MOTOR_CURR_ACC,
158 MOTOR_CURR_RUN,
159 MOTOR_CURR_DEC,
160 MOTOR_CURR_HOLD
161 };
162
163 INDI::PropertySwitch MotorApplyPresetSP {3};
164 enum
165 {
166 MOTOR_APPLY_LIGHT,
167 MOTOR_APPLY_MEDIUM,
168 MOTOR_APPLY_HEAVY,
169 };
170
171 INDI::PropertyNumber RecoveryDelayNP {1};
172 enum
173 {
174 RECOVERY_DELAY_VALUE,
175 };
176
177 typedef enum { Idle, GoToMiddle, GoMinimum, GoMaximum, Complete } CalibrationStage;
178 CalibrationStage cStage { Idle };
179
180 INDI::Timer m_MotionProgressTimer;
181
185 static const char SESTO_STOP_CHAR { 0xD };
186 static constexpr const uint8_t SESTO_TEMPERATURE_FREQ {10};
187 static constexpr const uint8_t SESTO_TIMEOUT {5};
188 static constexpr const int SESTO_LEN {1024};
189};
The Timer class provides repetitive and single-shot timers.
Definition inditimer.h:41
virtual bool ReverseFocuser(bool enabled) override
ReverseFocuser Reverse focuser motion direction.
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 IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
virtual ~SestoSenso3() override=default
virtual bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
const char * getDefaultName() override
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
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 initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
virtual bool saveConfigItems(FILE *fp) override
virtual bool SetFocuserBacklash(int32_t steps) override
SetFocuserBacklash Set the focuser backlash compensation value.
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...
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158