Instrument Neutral Distributed Interface INDI  1.9.2
baseclient.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright(c) 2011 Jasem Mutlaq. All rights reserved.
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 *******************************************************************************/
18 
19 #pragma once
20 
21 #include "indiapi.h"
22 #include "indibase.h"
23 #include "indimacros.h"
24 
25 #include <string>
26 #include <vector>
27 
28 #include <memory>
29 
30 // #define MAXRBUF 2048 // #PS: defined in indibase.h
31 
50 namespace INDI
51 {
52  class BaseClientPrivate;
53 }
55 {
56  DECLARE_PRIVATE(BaseClient)
57 
58  public:
59  BaseClient();
60  virtual ~BaseClient();
61 
62  public:
67  void setServer(const char *hostname, unsigned int port);
68 
70  const char *getHost() const;
71 
73  int getPort() const;
74 
79  bool connectServer();
80 
87  bool disconnectServer(int exit_code = 0);
88 
90  bool isServerConnected() const;
91 
96  void setConnectionTimeout(uint32_t seconds, uint32_t microseconds);
97 
98  void serverDisconnected(int exit_code) override;
99 
100  public:
105  void setVerbose(bool enable);
106 
110  bool isVerbose() const;
111 
112  public:
121  void watchProperty(const char *deviceName, const char *propertyName);
122 
123  public:
131  void watchDevice(const char *deviceName);
132 
136  void connectDevice(const char *deviceName);
137 
141  void disconnectDevice(const char *deviceName);
142 
146  INDI::BaseDevice *getDevice(const char *deviceName);
147 
149  const std::vector<INDI::BaseDevice *> &getDevices() const;
150 
164  bool getDevices(std::vector<INDI::BaseDevice *> &deviceList, uint16_t driverInterface);
165 
166  public:
182  void setBLOBMode(BLOBHandling blobH, const char *dev, const char *prop = nullptr);
183 
189  BLOBHandling getBLOBMode(const char *dev, const char *prop = nullptr);
190 
194  void sendNewText(const char *deviceName, const char *propertyName, const char *elementName, const char *text);
198  void sendNewNumber(const char *deviceName, const char *propertyName, const char *elementName, double value);
202  void sendNewSwitch(const char *deviceName, const char *propertyName, const char *elementName);
203 
205  void startBlob(const char *devName, const char *propName, const char *timestamp);
207  void sendOneBlob(IBLOB *bp);
209  void sendOneBlob(const char *blobName, unsigned int blobSize, const char *blobFormat, void *blobBuffer);
211  void finishBlob();
212 
213  protected:
218  virtual void newUniversalMessage(std::string message);
219 
220  protected:
221  std::unique_ptr<INDI::BaseClientPrivate> d_ptr;
222 };
INDI::BaseClient::connectDevice
void connectDevice(const char *deviceName)
Connect to INDI driver.
Definition: baseclient.cpp:900
indibase.h
INDI::BaseClient::sendOneBlob
void sendOneBlob(IBLOB *bp)
Send ONE blob content to server. The BLOB data in raw binary format and will be converted to base64 a...
Definition: baseclient.cpp:1041
indimacros.h
INDI::BaseClient::disconnectServer
bool disconnectServer(int exit_code=0)
Disconnect from INDI server.
Definition: baseclient.cpp:882
indiapi.h
Constants and Data structure definitions for the interface to the reference INDI C API implementation...
INDI::BaseClient::finishBlob
void finishBlob()
Send closing tag for BLOB command to server.
Definition: baseclient.cpp:1060
timestamp
const char * timestamp()
Create an ISO 8601 formatted time stamp. The format is YYYY-MM-DDTHH:MM:SS.
Definition: indicom.c:334
INDI::BaseClient::getPort
int getPort() const
Get the port number.
Definition: baseclient.cpp:935
INDI::BaseClient::BaseClient
BaseClient()
Definition: baseclient.cpp:828
INDI::BaseClient::setVerbose
void setVerbose(bool enable)
setVerbose Set verbose mode
Definition: baseclient.cpp:837
INDI::BaseClient::getDevices
const std::vector< INDI::BaseDevice * > & getDevices() const
Definition: baseclient.cpp:923
INDI::BaseClient::setConnectionTimeout
void setConnectionTimeout(uint32_t seconds, uint32_t microseconds)
setConnectionTimeout Set connection timeout. By default it is 3 seconds.
Definition: baseclient.cpp:849
INDI::BaseClient::isVerbose
bool isVerbose() const
isVerbose Is client in verbose mode?
Definition: baseclient.cpp:843
INDI::BaseClient::watchDevice
void watchDevice(const char *deviceName)
Add a device to the watch list.
Definition: baseclient.cpp:863
_ITextVectorProperty
Text vector property descriptor.
Definition: indiapi.h:244
INDI::BaseClient::sendNewNumber
void sendNewNumber(INumberVectorProperty *pp)
Send new Number command to server.
Definition: baseclient.cpp:976
_INumberVectorProperty
Number vector property descriptor.
Definition: indiapi.h:317
INDI::BaseClient::newUniversalMessage
virtual void newUniversalMessage(std::string message)
newUniversalMessage Universal messages are sent from INDI server without a specific device....
Definition: baseclient.cpp:941
INDI::BaseClient::serverDisconnected
void serverDisconnected(int exit_code) override
Emmited when the server gets disconnected.
Definition: baseclient.cpp:889
INDI::BaseMediator
Meditates event notification as generated by driver and passed to clients.
Definition: indibase.h:80
INDI::BaseClient::getDevice
INDI::BaseDevice * getDevice(const char *deviceName)
Definition: baseclient.cpp:912
BLOBHandling
BLOBHandling
How drivers handle BLOBs incoming from snooping drivers.
Definition: indidevapi.h:268
INDI::BaseClient::setBLOBMode
void setBLOBMode(BLOBHandling blobH, const char *dev, const char *prop=nullptr)
Set Binary Large Object policy mode.
Definition: baseclient.cpp:1066
INDI::BaseClient::isServerConnected
bool isServerConnected() const
Get status of the connection.
Definition: baseclient.cpp:894
INDI::BaseClient::getHost
const char * getHost() const
Get the server host name.
Definition: baseclient.cpp:929
INDI::BaseClient
Class to provide basic client functionality.
Definition: baseclient.h:54
INDI::BaseClient::sendNewSwitch
void sendNewSwitch(ISwitchVectorProperty *pp)
Send new Switch command to server.
Definition: baseclient.cpp:1006
INDI::BaseClient::getBLOBMode
BLOBHandling getBLOBMode(const char *dev, const char *prop=nullptr)
getBLOBMode Get Binary Large Object policy mode IF set previously by setBLOBMode
Definition: baseclient.cpp:1094
INDI::BaseClient::~BaseClient
virtual ~BaseClient()
Definition: baseclient.cpp:832
INDI::BaseClient::sendNewText
void sendNewText(ITextVectorProperty *pp)
Send new Text command to server.
Definition: baseclient.cpp:946
INDI
Namespace to encapsulate INDI client, drivers, and mediator classes.
Definition: AlignmentSubsystemForClients.cpp:11
INDI::BaseClient::disconnectDevice
void disconnectDevice(const char *deviceName)
Disconnect INDI driver.
Definition: baseclient.cpp:906
INDI::BaseClient::d_ptr
std::unique_ptr< INDI::BaseClientPrivate > d_ptr
Definition: baseclient.h:221
INDI::BaseClient::startBlob
void startBlob(const char *devName, const char *propName, const char *timestamp)
Send opening tag for BLOB command to server.
Definition: baseclient.cpp:1035
INDI::BaseClient::setServer
void setServer(const char *hostname, unsigned int port)
Set the server host name and port.
Definition: baseclient.cpp:856
INDI::BaseClient::watchProperty
void watchProperty(const char *deviceName, const char *propertyName)
watchProperties Add a property to the watch list. When communicating with INDI server.
Definition: baseclient.cpp:869
INDI::BaseDevice
Class to provide basic INDI device functionality.
Definition: basedevice.h:45
IBLOB
One Blob (Binary Large Object) descriptor.
_ISwitchVectorProperty
Switch vector property descriptor.
Definition: indiapi.h:365
INDI::BaseClient::connectServer
bool connectServer()
Connect to INDI server.
Definition: baseclient.cpp:876