Instrument Neutral Distributed Interface INDI  1.9.2
rainbowRSF.h
Go to the documentation of this file.
1 /*
2  Rainbow Astro Focuser
3  Copyright (C) 2020 Abdulaziz Bouland (boulandab@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 <memory>
24 #include "indifocuser.h"
25 
26 class RainbowRSF : public INDI::Focuser
27 {
28  public:
29  RainbowRSF();
30 
31  const char *getDefaultName() override;
32  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
33 
34  protected:
35  virtual bool initProperties() override;
36  virtual bool updateProperties() override;
37  virtual void TimerHit() override;
38  virtual bool Handshake() override;
39 
43  // Move focuser to absolute position from 0 to 16000 (-8000 to 8000)
44  virtual IPState MoveAbsFocuser(uint32_t targetTicks) override;
45  // Move focuser to a relative position from the current position
46  virtual IPState MoveRelFocuser(FocusDirection dir, unsigned int ticks) override;
47 
48 
49  // Get temperature in Celcius
50  bool updateTemperature();
51  // Find home
52  bool findHome();
53  // Update position
54  bool updatePosition();
55 
59  bool sendCommand(const char * cmd, char * res, int res_len);
60 
61  private:
62 
66  ISwitchVectorProperty GoHomeSP;
67  ISwitch GoHomeS[1];
68 
69  INumberVectorProperty TemperatureNP;
70  INumber TemperatureN[1];
71 
72  uint32_t m_TargetPosition { 0 };
73  uint32_t m_LastPosition { 0 };
74  double m_LastTemperature { 0 };
75  uint16_t m_TemperatureCounter { 0 };
76 
77  const static uint32_t homePosition { 8000 };
78 
79 
83  // # is the stop char
84  static const char DRIVER_STOP_CHAR { '#' };
85  // Update temperature every 10x POLLMS. For 500ms, we would
86  // update the temperature one every 5 seconds.
87  static constexpr const uint8_t DRIVER_TEMPERATURE_FREQ {10};
88  // Wait up to a maximum of 3 seconds for serial input
89  static constexpr const uint8_t DRIVER_TIMEOUT {3};
90  // Maximum buffer for sending/receving.
91  static constexpr const uint8_t DRIVER_LEN {16};
92 };
RainbowRSF::updateTemperature
bool updateTemperature()
Definition: rainbowRSF.cpp:295
RainbowRSF::MoveRelFocuser
virtual IPState MoveRelFocuser(FocusDirection dir, unsigned int ticks) override
Definition: rainbowRSF.cpp:340
cmd
__u8 cmd[4]
Definition: pwc-ioctl.h:4
IPState
IPState
Property state.
Definition: indiapi.h:158
RainbowRSF::updateProperties
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: rainbowRSF.cpp:109
ISwitch
One switch descriptor.
INumber
One number descriptor.
RainbowRSF::Handshake
virtual bool Handshake() override
perform handshake with device to check communication
Definition: rainbowRSF.cpp:153
indifocuser.h
_INumberVectorProperty
Number vector property descriptor.
Definition: indiapi.h:317
RainbowRSF
Definition: rainbowRSF.h:26
RainbowRSF::ISNewSwitch
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: rainbowRSF.cpp:129
RainbowRSF::updatePosition
bool updatePosition()
Definition: rainbowRSF.cpp:191
RainbowRSF::MoveAbsFocuser
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
Focuser Command Functions.
Definition: rainbowRSF.cpp:322
RainbowRSF::initProperties
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: rainbowRSF.cpp:71
INDI::FocuserInterface::FocusDirection
FocusDirection
Definition: indifocuserinterface.h:66
RainbowRSF::sendCommand
bool sendCommand(const char *cmd, char *res, int res_len)
Communication Functions.
Definition: rainbowRSF.cpp:416
ISState
ISState
Switch state.
Definition: indiapi.h:148
RainbowRSF::findHome
bool findHome()
Definition: rainbowRSF.cpp:354
RainbowRSF::TimerHit
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition: rainbowRSF.cpp:374
RainbowRSF::RainbowRSF
RainbowRSF()
Definition: rainbowRSF.cpp:53
INDI::Focuser
Definition: indifocuser.h:43
RainbowRSF::getDefaultName
const char * getDefaultName() override
Definition: rainbowRSF.cpp:63
_ISwitchVectorProperty
Switch vector property descriptor.
Definition: indiapi.h:365