Instrument Neutral Distributed Interface INDI 2.2.5
universal_ror_client.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2024 Jasem Mutlaq. All rights reserved.
3
4 INDI Universal ROR Client. It connects to INDI server running locally at
5 localhost:7624. It checks for both input and output drivers.
6
7 Output driver is used to command Open, Close, and Stop ROR.
8 Input driver is used to query the fully closed and opened states.
9
10 The client does NOT stop the roof if the limit switches are activated. This
11 is the responsiblity of the external hardware.
12
13 This program is free software; you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by the Free
15 Software Foundation; either version 2 of the License, or (at your option)
16 any later version.
17
18 This program is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
21 more details.
22
23 You should have received a copy of the GNU Library General Public License
24 along with this library; see the file COPYING.LIB. If not, write to
25 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
26 Boston, MA 02110-1301, USA.
27
28 The full GNU General Public License is included in this distribution in the
29 file called LICENSE.
30*******************************************************************************/
31
32#pragma once
33
34#include "baseclient.h"
35#include "basedevice.h"
36
38{
39 public:
40 UniversalRORClient(const std::string &input, const std::string &output);
42
44 {
45 return m_InputReady && m_OutputReady;
46 }
47
48 const std::string &inputDevice() const
49 {
50 return m_Input;
51 }
52 const std::string &outputDevice() const
53 {
54 return m_Output;
55 }
56
57 bool openRoof();
58 bool closeRoof();
59 bool stop();
60
61 void setOutputOpenRoof(const std::vector<uint8_t> &value)
62 {
63 m_OutputOpenRoof = value;
64 }
65
66 void setOutputCloseRoof(const std::vector<uint8_t> &value)
67 {
68 m_OutputCloseRoof = value;
69 }
70
71 void setInputFullyOpened(const std::vector<uint8_t> &value)
72 {
73 m_InputFullyOpened = value;
74 }
75
76 void setInputFullyClosed(const std::vector<uint8_t> &value)
77 {
78 m_InputFullyClosed = value;
79 }
80
81 void setFullyOpenedCallback(std::function<void(bool)> callback)
82 {
83 m_FullyOpenedCallback = callback;
84 }
85
86 void setFullyClosedCallback(std::function<void(bool)> callback)
87 {
88 m_FullyClosedCallback = callback;
89 }
90
91 void setConnectionCallback(std::function<void(bool)> callback)
92 {
93 m_ConnectionCallback = callback;
94 }
95
98
99 protected:
100 virtual void newDevice(INDI::BaseDevice dp) override;
101 virtual void newProperty(INDI::Property property) override;
102 virtual void updateProperty(INDI::Property property) override;
103 virtual void serverDisconnected(int exitCode) override;
104
105 private:
106 std::string m_Input, m_Output;
107 bool m_InputReady {false}, m_OutputReady {false};
108 std::vector<uint8_t> m_OutputOpenRoof, m_OutputCloseRoof;
109 std::vector<uint8_t> m_InputFullyOpened, m_InputFullyClosed;
110 std::function<void(bool)> m_FullyOpenedCallback, m_FullyClosedCallback, m_ConnectionCallback;
111};
Class to provide basic client functionality.
Definition baseclient.h:52
Class to provide basic INDI device functionality.
Definition basedevice.h:52
Provides generic container for INDI properties.
void setOutputOpenRoof(const std::vector< uint8_t > &value)
bool syncFullyOpenedState()
Checks fully opened state properties.
void setConnectionCallback(std::function< void(bool)> callback)
virtual void serverDisconnected(int exitCode) override
Emmited when the server gets disconnected.
void setFullyClosedCallback(std::function< void(bool)> callback)
void setInputFullyClosed(const std::vector< uint8_t > &value)
bool stop()
Sets both Close & Open roof outputs to OFF.
virtual void newDevice(INDI::BaseDevice dp) override
Emmited when a new device is created from INDI server.
const std::string & outputDevice() const
const std::string & inputDevice() const
void setFullyOpenedCallback(std::function< void(bool)> callback)
void setOutputCloseRoof(const std::vector< uint8_t > &value)
virtual void newProperty(INDI::Property property) override
Emmited when a new property is created for an INDI driver.
virtual void updateProperty(INDI::Property property) override
Check if any of the relevant digital inputs are for the fully opened or closed states.
void setInputFullyOpened(const std::vector< uint8_t > &value)