Instrument Neutral Distributed Interface INDI  2.0.2
sestosenso.h
Go to the documentation of this file.
1 /*
2  SestoSenso Focuser
3  Copyright (C) 2013 Jasem Mutlaq (mutlaqja@ikarustech.com)
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 
26 class SestoSenso : public INDI::Focuser
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/receving.
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.
Definition: sestosenso.cpp:549
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: sestosenso.cpp:362
virtual bool ReverseFocuser(bool enabled) override
ReverseFocuser Reverse focuser motion direction.
Definition: sestosenso.cpp:702
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
Definition: sestosenso.cpp:522
virtual ~SestoSenso() override=default
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: sestosenso.cpp:85
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition: sestosenso.cpp:584
const char * getDefaultName() override
Definition: sestosenso.cpp:196
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
Definition: sestosenso.cpp:538
virtual bool Disconnect() override
Disconnect from device.
Definition: sestosenso.cpp:187
virtual bool Handshake() override
perform handshake with device to check communication
Definition: sestosenso.cpp:174
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: sestosenso.cpp:143
ISState
Switch state.
Definition: indiapi.h:150
IPState
Property state.
Definition: indiapi.h:160
__u8 cmd[4]
Definition: pwc-ioctl.h:2
One number descriptor.
One switch descriptor.
One text descriptor.
Number vector property descriptor.
Definition: indiapi.h:319
Switch vector property descriptor.
Definition: indiapi.h:367
Text vector property descriptor.
Definition: indiapi.h:246