Instrument Neutral Distributed Interface INDI 2.2.5
sestosenso.h
Go to the documentation of this file.
1/*
2 SestoSenso Focuser
3 Copyright (C) 2013 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"
24#include "inditimer.h"
25
27{
28 public:
29 SestoSenso();
30 virtual ~SestoSenso() override = default;
31
32 const char *getDefaultName() override;
33 virtual bool initProperties() override;
34 virtual bool updateProperties() override;
35 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
36
37 protected:
38 virtual bool Handshake() override;
39 virtual bool Disconnect() override;
40 virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
41 virtual IPState MoveAbsFocuser(uint32_t targetTicks) override;
42 virtual bool ReverseFocuser(bool enabled) override;
43 virtual bool AbortFocuser() override;
44 virtual void TimerHit() override;
45
46 private:
47 bool Ack();
48 bool setMinLimit(uint32_t limit);
49 bool setMaxLimit(uint32_t limit);
50 bool updateMaxLimit();
51
52 bool updateTemperature();
53 bool updatePosition();
54
55 void checkMotionProgressCallback();
56
60 bool sendCommand(const char * cmd, char * res = nullptr, int cmd_len = -1, int res_len = -1);
61 bool getStartupValues();
62 void hexDump(char * buf, const char * data, int size);
63 bool isMotionComplete();
64
65 uint32_t targetPos { 0 };
66 uint32_t lastPos { 0 };
67 double lastTemperature { 0 };
68 uint16_t m_TemperatureCounter { 0 };
69
70 INDI::Timer m_MotionProgressTimer;
71
72 INumber TemperatureN[1];
73 INumberVectorProperty TemperatureNP;
74
75 IText FirmwareT[1] {};
76 ITextVectorProperty FirmwareTP;
77
78 ISwitch CalibrationS[2];
79 ISwitchVectorProperty CalibrationSP;
80 enum
81 {
82 CALIBRATION_START,
83 CALIBRATION_NEXT
84 };
85
86 ISwitch FastMoveS[3];
87 ISwitchVectorProperty FastMoveSP;
88 enum
89 {
90 FASTMOVE_IN,
91 FASTMOVE_OUT,
92 FASTMOVE_STOP
93 };
94
95 IText CalibrationMessageT[1] {};
96 ITextVectorProperty CalibrationMessageTP;
97
98 typedef enum { Idle, GoToMiddle, GoMinimum, GoMaximum, Complete } CalibrationStage;
99 CalibrationStage cStage { Idle };
103 // CR is the stop char
104 static const char SESTO_STOP_CHAR { 0xD };
105 // Update temperature every 10x POLLMS. For 500ms, we would
106 // update the temperature one every 5 seconds.
107 static constexpr const uint8_t SESTO_TEMPERATURE_FREQ {10};
108 // Wait up to a maximum of 3 seconds for serial input
109 static constexpr const uint8_t SESTO_TIMEOUT {3};
110 // Maximum buffer for sending/receiving.
111 static constexpr const uint8_t SESTO_LEN {64};
112
113};
The Timer class provides repetitive and single-shot timers.
Definition inditimer.h:41
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
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 ReverseFocuser(bool enabled) override
ReverseFocuser Reverse focuser motion direction.
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
virtual ~SestoSenso() override=default
virtual bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
const char * getDefaultName() override
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
virtual bool Disconnect() override
Disconnect from device.
virtual bool Handshake() override
Performs a device-specific handshake after a connection is established. This method should be overrid...
virtual bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
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