Instrument Neutral Distributed Interface INDI 2.2.5
esattoarco.h
Go to the documentation of this file.
1/*
2 Primaluca Labs Essato-Arco Focuser+Rotator Driver
3
4 Copyright (C) 2020 Piotr Zyziuk
5 Copyright (C) 2020-2022 Jasem Mutlaq
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
21 JM 2022.07.16: Major refactor to using json.h and update to Essato Arco
22 Document protocol revision 3.3 (8th July 2022).
23*/
24
25#pragma once
26
27#include "indifocuser.h"
28#include "inditimer.h"
30#include "primalucacommandset.h"
31#include "indipropertytext.h"
32#include "indipropertynumber.h"
33
35{
36 public:
37 EsattoArco();
38 virtual ~EsattoArco() override = default;
39
40 const char *getDefaultName() override;
41 virtual bool initProperties() override;
42 virtual bool updateProperties() override;
43 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
44 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
45
46 protected:
47 // Common
48 virtual bool Handshake() override;
49 virtual void TimerHit() override;
50 virtual bool saveConfigItems(FILE *fp) override;
51
52 // Focuser
53 virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
54 virtual IPState MoveAbsFocuser(uint32_t targetTicks) override;
55 virtual bool AbortFocuser() override;
56 virtual bool SetFocuserBacklash(int32_t steps) override;
57
58 // Rotator
59 virtual IPState MoveRotator(double angle) override;
60 virtual bool SyncRotator(double angle) override;
61 virtual bool AbortRotator() override;
62 virtual bool ReverseRotator(bool enabled) override;
63
64 private:
65 bool Ack();
66 bool setMinLimit(uint32_t limit);
67 bool setMaxLimit(uint32_t limit);
68 bool updateMaxLimit();
69
70 bool updateTemperature();
71 bool updatePosition();
72 bool updateVoltageIn();
73
74 void setConnectionParams();
75 bool initCommandSet();
76
77 bool getStartupValues();
78 void hexDump(char * buf, const char * data, int size);
79 bool isMotionComplete();
80
81 uint16_t m_TemperatureCounter { 0 };
82
83 INDI::PropertyNumber TemperatureNP {2};
84 enum
85 {
86 TEMPERATURE_EXTERNAL,
87 TEMPERATURE_MOTOR,
88 };
89
90 INDI::PropertyNumber SpeedNP {1};
91
92 INDI::PropertyText FirmwareTP {4};
93 enum
94 {
95 ESATTO_FIRMWARE_SN,
96 ESATTO_FIRMWARE_VERSION,
97 ARCO_FIRMWARE_SN,
98 ARCO_FIRMWARE_VERSION,
99 };
100
101 INDI::PropertyNumber VoltageNP {2};
102 enum
103 {
104 VOLTAGE_12V,
105 VOLTAGE_USB
106 };
107
108
109 INDI::PropertySwitch FastMoveSP {3};
110 enum
111 {
112 FASTMOVE_IN,
113 FASTMOVE_OUT,
114 FASTMOVE_STOP
115 };
116
117 INDI::PropertySwitch BacklashMeasurementSP {2};
118 enum
119 {
120 BACKLASH_START,
121 BACKLASH_NEXT
122 };
123 INDI::PropertyText BacklashMessageTP {1};
124
125 // ITextVectorProperty BacklashMessageTP;
126 typedef enum { BacklashIdle, BacklashMinimum, BacklashMaximum, BacklashComplete } BacklashStage;
127 BacklashStage bStage { BacklashIdle };
128
129 //Rotator
130 INDI::PropertyNumber RotatorAbsPosNP {1};
131 enum
132 {
133 ROTATOR_ABSOLUTE_POSITION
134 };
135
136 //ROTATOR CALIBRATION
137 IText RotCalibrationMessageT[1] {};
138 ITextVectorProperty RotCalibrationMessageTP;
139
140 typedef enum { RotCalIdle, RotCalComplete } RotCalibrationStage;
141 RotCalibrationStage rcStage { RotCalIdle };
142
143 INDI::PropertySwitch RotatorCalibrationSP {1};
144 // ISwitchVectorProperty RotatorCalibrationSP;
145 enum
146 {
147 ARCO_CALIBRATION_START
148 };
149
150 std::unique_ptr<PrimalucaLabs::Esatto> m_Esatto;
151 std::unique_ptr<PrimalucaLabs::Arco> m_Arco;
152
153 static constexpr uint8_t TEMPERATURE_FREQUENCY {10};
154};
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 void TimerHit() override
Callback function to be called once SetTimer duration elapses.
const char * getDefaultName() override
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
virtual bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
virtual bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
virtual IPState MoveRotator(double angle) override
MoveRotator Go to specific angle.
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 saveConfigItems(FILE *fp) override
virtual bool ReverseRotator(bool enabled) override
ReverseRotator Reverse the direction of the rotator. CW is usually the normal direction,...
virtual bool SetFocuserBacklash(int32_t steps) override
SetFocuserBacklash Set the focuser backlash compensation value.
virtual bool SyncRotator(double angle) override
SyncRotator Set current angle as the supplied angle without moving the rotator.
virtual bool AbortRotator() override
AbortRotator Abort all motion.
virtual bool Handshake() override
Performs a device-specific handshake after a connection is established. This method should be overrid...
virtual ~EsattoArco() override=default
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
One text descriptor.
Text vector property descriptor.
Definition indiapi.h:244