Instrument Neutral Distributed Interface INDI 2.2.5
rainbowRSF.h
Go to the documentation of this file.
1/*
2 Rainbow Astro Focuser
3 Copyright (C) 2020 Abdulaziz Bouland ([email protected])
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#include "indielapsedtimer.h"
26
28{
29 public:
30 RainbowRSF();
31
32 const char *getDefaultName() override;
33 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
34
35 protected:
36 virtual bool initProperties() override;
37 virtual bool updateProperties() override;
38 virtual void TimerHit() override;
39 virtual bool Handshake() override;
40
44 // Move focuser to absolute position from 0 to 16000 (-8000 to 8000)
45 virtual IPState MoveAbsFocuser(uint32_t targetTicks) override;
46 // Move focuser to a relative position from the current position
47 virtual IPState MoveRelFocuser(FocusDirection dir, unsigned int ticks) override;
48
49
50 // Get temperature in Celcius
51 bool updateTemperature();
52 // Find home
53 bool findHome();
54 // Update position
55 bool updatePosition();
56
60 bool sendCommand(const char * cmd, char * res, int res_len);
61
62 private:
63
67 ISwitchVectorProperty GoHomeSP;
68 ISwitch GoHomeS[1];
69
70 INumberVectorProperty TemperatureNP;
71 INumber TemperatureN[1];
72
73 uint32_t m_TargetPosition { 0 };
74 uint32_t m_LastPosition { 0 };
75 double m_LastTemperature { 0 };
76 uint16_t m_TemperatureCounter { 0 };
77
78 const static uint32_t homePosition { 8000 };
79
80 // Timer used to timeout when waiting for requested movement to complete.
81 INDI::ElapsedTimer m_MovementTimer;
82 bool m_MovementTimerActive { false };
83
87 // # is the stop char
88 static const char DRIVER_STOP_CHAR { '#' };
89 // Update temperature every 10x POLLMS. For 500ms, we would
90 // update the temperature one every 5 seconds.
91 static constexpr const uint8_t DRIVER_TEMPERATURE_FREQ {10};
92 // Wait up to a maximum of 3 seconds for serial input
93 static constexpr const uint8_t DRIVER_TIMEOUT {3};
94 // Maximum buffer for sending/receiving.
95 static constexpr const uint8_t DRIVER_LEN {16};
96};
The ElapsedTimer class provides a fast way to calculate elapsed times.
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
Focuser Command Functions.
bool updatePosition()
virtual bool Handshake() override
Performs a device-specific handshake after a connection is established. This method should be overrid...
bool updateTemperature()
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
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 IPState MoveRelFocuser(FocusDirection dir, unsigned int ticks) override
bool sendCommand(const char *cmd, char *res, int res_len)
Communication Functions.
bool findHome()
const char * getDefaultName() override
virtual bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
virtual bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
uint8_t cmd[4]
Definition pwc-ioctl.h:2
One number descriptor.
One switch descriptor.
Number vector property descriptor.
Definition indiapi.h:317
Switch vector property descriptor.
Definition indiapi.h:365