Instrument Neutral Distributed Interface INDI 2.2.5
abstractbaseclient.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2016 Jasem Mutlaq. All rights reserved.
3 Copyright(c) 2022 Pawel Soja <[email protected]>
4
5 INDI Qt Client
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License version 2 as published by the Free Software Foundation.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*******************************************************************************/
21
22#pragma once
23
24#include "indibase.h"
25#include "indimacros.h"
26#include "indiproperty.h"
27
28#include <cstdint>
29#include <memory>
30#include <vector>
31#include <functional>
32
33namespace INDI
34{
35
36class BaseDevice;
37class AbstractBaseClientPrivate;
39{
40 DECLARE_PRIVATE_D(d_ptr_indi, AbstractBaseClient)
41
42 public:
44 virtual ~AbstractBaseClient();
45
46 public:
51 void setServer(const char *hostname, unsigned int port);
52
54 const char *getHost() const;
55
57 int getPort() const;
58
59 public:
64 virtual bool connectServer() = 0;
65
70 virtual bool disconnectServer(int exit_code = 0) = 0;
71
73 bool isServerConnected() const;
74
79 void setConnectionTimeout(uint32_t seconds, uint32_t microseconds);
80
81 public:
86 void setVerbose(bool enable);
87
91 bool isVerbose() const;
92
93 public:
101 void watchDevice(const char *deviceName);
102 void watchDevice(const char *deviceName, const std::function<void (BaseDevice)> &callback);
103
112 void watchProperty(const char *deviceName, const char *propertyName);
113
114 public:
118 void connectDevice(const char *deviceName);
119
123 void disconnectDevice(const char *deviceName);
124
125 public:
129 INDI::BaseDevice getDevice(const char *deviceName);
130
132 std::vector<INDI::BaseDevice> getDevices() const;
133
147 bool getDevices(std::vector<INDI::BaseDevice> &deviceList, uint16_t driverInterface);
148
149 public:
165 void setBLOBMode(BLOBHandling blobH, const char *dev, const char *prop = nullptr);
166
172 BLOBHandling getBLOBMode(const char *dev, const char *prop = nullptr);
173
174 public:
177
181 void sendNewText(const char *deviceName, const char *propertyName, const char *elementName, const char *text);
185 void sendNewNumber(const char *deviceName, const char *propertyName, const char *elementName, double value);
189 void sendNewSwitch(const char *deviceName, const char *propertyName, const char *elementName);
190
192 void startBlob(const char *devName, const char *propName, const char *timestamp);
194 void sendOneBlob(IBLOB *bp);
197 void sendOneBlob(const char *blobName, unsigned int blobSize, const char *blobFormat, void *blobBuffer);
199 void finishBlob();
200
201 public:
206 void sendPingRequest(const char * uid);
207
211 void sendPingReply(const char * uid);
212
213 protected:
216 virtual void newPingReply(std::string uid);
217
218 protected:
224 virtual void newUniversalMessage(std::string message);
225
226 protected:
227 friend class BaseClientPrivate;
229
230 protected:
231 AbstractBaseClient(std::unique_ptr<AbstractBaseClientPrivate> &&dd);
232
233 protected:
234 std::unique_ptr<AbstractBaseClientPrivate> d_ptr_indi;
235};
236
237}
238
239#ifdef SWIG
240%template(BaseDeviceVectorShared) std::vector<INDI::BaseDevice>;
241#endif
int getPort() const
Get the port number.
void setServer(const char *hostname, unsigned int port)
Set the server host name and port.
bool isVerbose() const
isVerbose Is client in verbose mode?
INDI::BaseDevice getDevice(const char *deviceName)
virtual void newUniversalMessage(std::string message)
newUniversalMessage Universal messages are sent from INDI server without a specific device....
void sendNewSwitch(INDI::Property pp)
Send new Switch command to server.
void setBLOBMode(BLOBHandling blobH, const char *dev, const char *prop=nullptr)
Set Binary Large Object policy mode.
void watchProperty(const char *deviceName, const char *propertyName)
watchProperties Add a property to the watch list. When communicating with INDI server.
bool getDevices(std::vector< INDI::BaseDevice > &deviceList, uint16_t driverInterface)
getDevices Returns list of devices that belong to a particular DRIVER_INTERFACE class.
void sendNewProperty(INDI::Property pp)
Send new Property command to server.
virtual bool connectServer()=0
Connect to INDI server.
virtual bool disconnectServer(int exit_code=0)=0
Disconnect from INDI server. Any devices previously created will be deleted and memory cleared.
void setConnectionTimeout(uint32_t seconds, uint32_t microseconds)
setConnectionTimeout Set connection timeout. By default it is 3 seconds.
void finishBlob()
Send closing tag for BLOB command to server.
void disconnectDevice(const char *deviceName)
Disconnect INDI driver.
std::unique_ptr< AbstractBaseClientPrivate > d_ptr_indi
void setVerbose(bool enable)
setVerbose Set verbose mode
void sendPingReply(const char *uid)
Send a ping reply for the given uuid.
void sendOneBlob(IBLOB *bp)
Send ONE blob content to server. The BLOB data in raw binary format and will be converted to base64 a...
virtual void newPingReply(std::string uid)
pingReply are sent by the server on response to pingReply (see above).
bool isServerConnected() const
Get status of the connection.
void sendPingRequest(const char *uid)
Send one ping request, the server will answer back with the same uuid.
void connectDevice(const char *deviceName)
Disconnect INDI driver.
void watchDevice(const char *deviceName)
Add a device to the watch list.
const char * getHost() const
Get the server host name.
std::vector< INDI::BaseDevice > getDevices() const
void sendNewNumber(INDI::Property pp)
Send new Number command to server.
BLOBHandling getBLOBMode(const char *dev, const char *prop=nullptr)
getBLOBMode Get Binary Large Object policy mode IF set previously by setBLOBMode
void sendNewText(INDI::Property pp)
Send new Text command to server.
void startBlob(const char *devName, const char *propName, const char *timestamp)
Send opening tag for BLOB command to server.
Class to provide basic INDI device functionality.
Definition basedevice.h:52
Meditates event notification as generated by driver and passed to clients.
Definition indibase.h:98
Provides generic container for INDI properties.
BLOBHandling
How drivers handle BLOBs incoming from snooping drivers.
Definition indidevapi.h:267
Namespace to encapsulate INDI client, drivers, and mediator classes.
One Blob (Binary Large Object) descriptor.