Instrument Neutral Distributed Interface INDI 2.2.5
lakeside.h
Go to the documentation of this file.
1/*
2 Lakeside Focuser
3 Copyright (C) 2017 Phil Shepherd ([email protected])
4 Technical Information kindly supplied by Peter Chance at LakesideAstro ([email protected])
5
6 Code template from original Moonlite code by Jasem Mutlaq ([email protected])
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22*/
23
24#pragma once
25
26#include "indifocuser.h"
27
28#include <cstdint>
29
30class Lakeside : public INDI::Focuser
31{
32 public:
33 Lakeside();
34 ~Lakeside() override = default;
35
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 protected:
43
44 virtual bool Handshake() override;
45 virtual IPState MoveAbsFocuser(uint32_t ticks) override;
46 virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
47 virtual bool AbortFocuser() override;
48 virtual void TimerHit() override;
49 virtual bool ReverseFocuser(bool enabled) override;
50 virtual bool SetFocuserBacklashEnabled(bool enabled) override;
51 virtual bool SetFocuserBacklash(int32_t steps) override;
52
53 private:
54 double lastTemperature { 1e6 };
55 uint32_t currentSpeed, targetPos;
56
57 struct timeval focusMoveStart;
58 float focusMoveRequest;
59
60 void GetFocusParams();
61 bool updateMoveDirection();
62 bool updateMaxTravel();
63 bool updateStepSize();
64 bool updateBacklash();
65 bool updateTemperature();
66 bool updateTemperatureK();
67 bool updatePosition();
68 bool LakesideOnline();
69
70 bool updateActiveTemperatureSlope();
71 bool updateSlope1Inc();
72 bool updateSlope1Dir();
73 bool updateSlope1Deadband();
74 bool updateSlope1Period();
75 bool updateSlope2Inc();
76 bool updateSlope2Dir();
77 bool updateSlope2Deadband();
78 bool updateSlope2Period();
79
80 bool GetLakesideStatus();
81
82 char DecodeBuffer(char* in_response);
83 bool SendCmd(const char *in_cmd);
84 bool ReadBuffer(char* response);
85
86 bool gotoPosition(uint32_t position);
87
88 bool setCalibration();
89
90 bool setTemperatureTracking(bool enable);
91 bool setBacklash(int backlash );
92 bool setStepSize(int stepsize );
93 bool setMaxTravel(int);
94 //bool setMoveDirection(int direction);
95
96 bool setActiveTemperatureSlope(uint32_t active_slope);
97 bool setSlope1Inc(uint32_t slope1_inc);
98 bool setSlope1Dir(uint32_t slope1_direction);
99 bool setSlope1Deadband(uint32_t slope1_deadband);
100 bool setSlope1Period(uint32_t slope1_period);
101 bool setSlope2Inc(uint32_t slope2_inc);
102 bool setSlope2Dir(uint32_t slope2_direction);
103 bool setSlope2Deadband(uint32_t slope2_deadband);
104 bool setSlope2Period(uint32_t slope2_period);
105
106 void hexDump(char * buf, const char * data, int size);
107
108 INumber TemperatureN[1];
109 INumberVectorProperty TemperatureNP;
110
111 INumber TemperatureKN[1];
112 INumberVectorProperty TemperatureKNP;
113
114 // ISwitch MoveDirectionS[2];
115 // ISwitchVectorProperty MoveDirectionSP;
116
117 INumber StepSizeN[1];
118 INumberVectorProperty StepSizeNP;
119
120 // INumber BacklashN[1];
121 // INumberVectorProperty BacklashNP;
122
123 INumber MaxTravelN[1];
124 INumberVectorProperty MaxTravelNP;
125
126 ISwitch TemperatureTrackingS[2];
127 ISwitchVectorProperty TemperatureTrackingSP;
128
129 ISwitch ActiveTemperatureSlopeS[2];
130 ISwitchVectorProperty ActiveTemperatureSlopeSP;
131
132 INumber Slope1IncN[1];
133 INumberVectorProperty Slope1IncNP;
134
135 ISwitch Slope1DirS[2];
136 ISwitchVectorProperty Slope1DirSP;
137
138 INumber Slope1DeadbandN[1];
139 INumberVectorProperty Slope1DeadbandNP;
140
141 INumber Slope1PeriodN[1];
142 INumberVectorProperty Slope1PeriodNP;
143
144 INumber Slope2IncN[1];
145 INumberVectorProperty Slope2IncNP;
146
147 ISwitch Slope2DirS[2];
148 ISwitchVectorProperty Slope2DirSP;
149
150 INumber Slope2DeadbandN[1];
151 INumberVectorProperty Slope2DeadbandNP;
152
153 INumber Slope2PeriodN[1];
154 INumberVectorProperty Slope2PeriodNP;
155
156 static constexpr const char *SETTINGS_TAB { "Settings" };
157 static constexpr const double TEMPERATURE_THRESHOLD { 0.05 };
158
159};
virtual IPState MoveAbsFocuser(uint32_t ticks) override
MoveFocuser the focuser to an absolute position.
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
virtual bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
Definition lakeside.cpp:73
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
const char * getDefaultName() override
Definition lakeside.cpp:279
virtual bool SetFocuserBacklashEnabled(bool enabled) override
SetFocuserBacklashEnabled Enables or disables the focuser backlash compensation.
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 updateProperties() override
Updates the state and definition of properties based on the current connection status....
Definition lakeside.cpp:177
virtual bool Handshake() override
Performs a device-specific handshake after a connection is established. This method should be overrid...
Definition lakeside.cpp:274
~Lakeside() override=default
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 SetFocuserBacklash(int32_t steps) override
SetFocuserBacklash Set the focuser backlash compensation value.
virtual bool ReverseFocuser(bool enabled) override
ReverseFocuser Reverse focuser motion direction.
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
#define TEMPERATURE_THRESHOLD
Definition dmfc.cpp:35
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
#define SETTINGS_TAB
Definition robofocus.cpp:44
One number descriptor.
One switch descriptor.
Number vector property descriptor.
Definition indiapi.h:317
Switch vector property descriptor.
Definition indiapi.h:365