Instrument Neutral Distributed Interface INDI 2.2.5
universal_ror.h
Go to the documentation of this file.
1/*******************************************************************************
2 Universal Roll Off Roof driver.
3 Copyright(c) 2024 Jasem Mutlaq. All rights reserved.
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation.
8 .
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13 .
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*******************************************************************************/
19
20#pragma once
21
22#include "indidome.h"
23#include "inditimer.h"
25
27{
28 public:
30 virtual ~UniversalROR() = default;
31
32 virtual bool initProperties() override;
33 const char *getDefaultName() override;
34 bool updateProperties() override;
35
36 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
37 virtual bool ISNewText(const char * dev, const char * name, char * texts[], char * names[], int n) override;
38 virtual bool saveConfigItems(FILE *fp) override;
39 virtual bool ISSnoopDevice(XMLEle *root) override;
40
41 protected:
42 bool Connect() override;
43 bool Disconnect() override;
44
45 void TimerHit() override;
46
47 virtual IPState Move(DomeDirection dir, DomeMotionCommand operation) override;
48 virtual IPState Park() override;
49 virtual IPState UnPark() override;
50 virtual bool Abort() override;
51 virtual void ActiveDevicesUpdated() override;
52
53 private:
54 bool setupParms();
55 bool syncIndexes();
56 std::vector<uint8_t> extract(const std::string &text);
57 void checkConnectionStatus();
58 bool m_FullOpenLimitSwitch {false}, m_FullClosedLimitSwitch {false};
59
60 INDI::PropertyText InputTP {2};
61 INDI::PropertyLight LimitSwitchLP {2};
62 enum
63 {
64 FullyOpened,
65 FullyClosed
66 };
67
68 INDI::PropertyText OutputTP {2};
69 enum
70 {
71 OpenRoof,
72 CloseRoof
73 };
74
75 std::vector<uint8_t> m_OutputOpenRoof, m_OutputCloseRoof;
76 std::vector<uint8_t> m_InputFullyOpened, m_InputFullyClosed;
77 std::unique_ptr<UniversalRORClient> m_Client;
78
79 // Connection tracking
80 int m_ConnectionAttempts {0};
81 static constexpr int MAX_CONNECTION_ATTEMPTS {5}; // 5 attempts * 5 seconds = 25 seconds max wait time
82 INDI::Timer m_ConnectionTimer;
83};
Class to provide general functionality of a Dome device.
Definition indidome.h:75
DomeMotionCommand
Definition indidome.h:97
The Timer class provides repetitive and single-shot timers.
Definition inditimer.h:41
bool Disconnect() override
Disconnect from device.
const char * getDefaultName() override
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
virtual bool Abort() override
Abort all dome motion.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual IPState Park() override
Goto Park Position. The park position is an absolute azimuth value.
bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
void TimerHit() override
Callback function to be called once SetTimer duration elapses.
bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
virtual IPState UnPark() override
UnPark dome. The action of the Unpark command is dome specific, but it may include opening the shutte...
virtual void ActiveDevicesUpdated() override
virtual IPState Move(DomeDirection dir, DomeMotionCommand operation) override
Move the Dome in a particular direction.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Dome Presets in the configuration file
virtual ~UniversalROR()=default
virtual bool ISSnoopDevice(XMLEle *root) override
Process a snoop event from INDI server. This function is called when a snooped property is updated in...
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158