Instrument Neutral Distributed Interface INDI  2.0.2
lakeside.h
Go to the documentation of this file.
1 /*
2  Lakeside Focuser
3  Copyright (C) 2017 Phil Shepherd (psjshep@googlemail.com)
4  Technical Information kindly supplied by Peter Chance at LakesideAstro (info@lakeside-astro.com)
5 
6  Code template from original Moonlite code by Jasem Mutlaq (mutlaqja@ikarustech.com)
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 
30 class 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 SetFocuserBacklash(int32_t steps) override;
51 
52  private:
53  double lastTemperature { 1e6 };
54  uint32_t currentSpeed, targetPos;
55 
56  struct timeval focusMoveStart;
57  float focusMoveRequest;
58 
59  void GetFocusParams();
60  bool updateMoveDirection();
61  bool updateMaxTravel();
62  bool updateStepSize();
63  bool updateBacklash();
64  bool updateTemperature();
65  bool updateTemperatureK();
66  bool updatePosition();
67  bool LakesideOnline();
68 
69  bool updateActiveTemperatureSlope();
70  bool updateSlope1Inc();
71  bool updateSlope1Dir();
72  bool updateSlope1Deadband();
73  bool updateSlope1Period();
74  bool updateSlope2Inc();
75  bool updateSlope2Dir();
76  bool updateSlope2Deadband();
77  bool updateSlope2Period();
78 
79  bool GetLakesideStatus();
80 
81  char DecodeBuffer(char* in_response);
82  bool SendCmd(const char *in_cmd);
83  bool ReadBuffer(char* response);
84 
85  bool gotoPosition(uint32_t position);
86 
87  bool setCalibration();
88 
89  bool setTemperatureTracking(bool enable);
90  bool setBacklash(int backlash );
91  bool setStepSize(int stepsize );
92  bool setMaxTravel(int);
93  //bool setMoveDirection(int direction);
94 
95  bool setActiveTemperatureSlope(uint32_t active_slope);
96  bool setSlope1Inc(uint32_t slope1_inc);
97  bool setSlope1Dir(uint32_t slope1_direction);
98  bool setSlope1Deadband(uint32_t slope1_deadband);
99  bool setSlope1Period(uint32_t slope1_period);
100  bool setSlope2Inc(uint32_t slope2_inc);
101  bool setSlope2Dir(uint32_t slope2_direction);
102  bool setSlope2Deadband(uint32_t slope2_deadband);
103  bool setSlope2Period(uint32_t slope2_period);
104 
105  void hexDump(char * buf, const char * data, int size);
106 
107  INumber TemperatureN[1];
108  INumberVectorProperty TemperatureNP;
109 
110  INumber TemperatureKN[1];
111  INumberVectorProperty TemperatureKNP;
112 
113  // ISwitch MoveDirectionS[2];
114  // ISwitchVectorProperty MoveDirectionSP;
115 
116  INumber StepSizeN[1];
117  INumberVectorProperty StepSizeNP;
118 
119  // INumber BacklashN[1];
120  // INumberVectorProperty BacklashNP;
121 
122  INumber MaxTravelN[1];
123  INumberVectorProperty MaxTravelNP;
124 
125  ISwitch TemperatureTrackingS[2];
126  ISwitchVectorProperty TemperatureTrackingSP;
127 
128  ISwitch ActiveTemperatureSlopeS[2];
129  ISwitchVectorProperty ActiveTemperatureSlopeSP;
130 
131  INumber Slope1IncN[1];
132  INumberVectorProperty Slope1IncNP;
133 
134  ISwitch Slope1DirS[2];
135  ISwitchVectorProperty Slope1DirSP;
136 
137  INumber Slope1DeadbandN[1];
138  INumberVectorProperty Slope1DeadbandNP;
139 
140  INumber Slope1PeriodN[1];
141  INumberVectorProperty Slope1PeriodNP;
142 
143  INumber Slope2IncN[1];
144  INumberVectorProperty Slope2IncNP;
145 
146  ISwitch Slope2DirS[2];
147  ISwitchVectorProperty Slope2DirSP;
148 
149  INumber Slope2DeadbandN[1];
150  INumberVectorProperty Slope2DeadbandNP;
151 
152  INumber Slope2PeriodN[1];
153  INumberVectorProperty Slope2PeriodNP;
154 
155  static constexpr const char *SETTINGS_TAB { "Settings" };
156  static constexpr const double TEMPERATURE_THRESHOLD { 0.05 };
157 
158 };
virtual IPState MoveAbsFocuser(uint32_t ticks) override
MoveFocuser the focuser to an absolute position.
Definition: lakeside.cpp:2225
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
Definition: lakeside.cpp:2415
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: lakeside.cpp:73
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition: lakeside.cpp:2238
const char * getDefaultName() override
Definition: lakeside.cpp:279
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: lakeside.cpp:1758
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: lakeside.cpp:177
virtual bool Handshake() override
perform handshake with device to check communication
Definition: lakeside.cpp:274
Lakeside()
Definition: lakeside.cpp:61
~Lakeside() override=default
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: lakeside.cpp:1593
virtual bool SetFocuserBacklash(int32_t steps) override
SetFocuserBacklash Set the focuser backlash compensation value.
Definition: lakeside.cpp:1084
virtual bool ReverseFocuser(bool enabled) override
ReverseFocuser Reverse focuser motion direction.
Definition: lakeside.cpp:1178
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
Definition: lakeside.cpp:2217
#define TEMPERATURE_THRESHOLD
Definition: dmfc.cpp:35
ISState
Switch state.
Definition: indiapi.h:150
IPState
Property state.
Definition: indiapi.h:160
const char * SETTINGS_TAB
bool setBacklash(const int fd, int bl_min, int bl_sec)
One number descriptor.
One switch descriptor.
Number vector property descriptor.
Definition: indiapi.h:319
Switch vector property descriptor.
Definition: indiapi.h:367