Instrument Neutral Distributed Interface INDI  2.0.2
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
INDI::AbstractBaseClient Class Referenceabstract

#include <abstractbaseclient.h>

Inheritance diagram for INDI::AbstractBaseClient:
INDI::BaseMediator INDI::BaseClient INDI::BaseClientQt Imager LoaderClient MathPluginManagerClient MyClient MyClient SkySafariClient WatchDogClient

Public Member Functions

 AbstractBaseClient ()=delete
 
virtual ~AbstractBaseClient ()
 
void setServer (const char *hostname, unsigned int port)
 Set the server host name and port. More...
 
const char * getHost () const
 Get the server host name. More...
 
int getPort () const
 Get the port number. More...
 
virtual bool connectServer ()=0
 Connect to INDI server. More...
 
virtual bool disconnectServer (int exit_code=0)=0
 Disconnect from INDI server. Any devices previously created will be deleted and memory cleared. More...
 
bool isServerConnected () const
 Get status of the connection. More...
 
void setConnectionTimeout (uint32_t seconds, uint32_t microseconds)
 setConnectionTimeout Set connection timeout. By default it is 3 seconds. More...
 
void setVerbose (bool enable)
 setVerbose Set verbose mode More...
 
bool isVerbose () const
 isVerbose Is client in verbose mode? More...
 
void watchDevice (const char *deviceName)
 Add a device to the watch list. More...
 
void watchDevice (const char *deviceName, const std::function< void(BaseDevice)> &callback)
 
void watchProperty (const char *deviceName, const char *propertyName)
 watchProperties Add a property to the watch list. When communicating with INDI server. More...
 
void connectDevice (const char *deviceName)
 Disconnect INDI driver. More...
 
void disconnectDevice (const char *deviceName)
 Disconnect INDI driver. More...
 
INDI::BaseDevice getDevice (const char *deviceName)
 
std::vector< INDI::BaseDevicegetDevices () const
 
bool getDevices (std::vector< INDI::BaseDevice > &deviceList, uint16_t driverInterface)
 getDevices Returns list of devices that belong to a particular DRIVER_INTERFACE class. More...
 
void setBLOBMode (BLOBHandling blobH, const char *dev, const char *prop=nullptr)
 Set Binary Large Object policy mode. More...
 
BLOBHandling getBLOBMode (const char *dev, const char *prop=nullptr)
 getBLOBMode Get Binary Large Object policy mode IF set previously by setBLOBMode More...
 
void sendNewProperty (INDI::Property pp)
 Send new Property command to server. More...
 
void sendNewText (INDI::Property pp)
 Send new Text command to server. More...
 
void sendNewText (const char *deviceName, const char *propertyName, const char *elementName, const char *text)
 Send new Text command to server. More...
 
void sendNewNumber (INDI::Property pp)
 Send new Number command to server. More...
 
void sendNewNumber (const char *deviceName, const char *propertyName, const char *elementName, double value)
 Send new Number command to server. More...
 
void sendNewSwitch (INDI::Property pp)
 Send new Switch command to server. More...
 
void sendNewSwitch (const char *deviceName, const char *propertyName, const char *elementName)
 Send new Switch command to server. More...
 
void startBlob (const char *devName, const char *propName, const char *timestamp)
 Send opening tag for BLOB command to server. More...
 
void sendOneBlob (IBLOB *bp)
 Send ONE blob content to server. The BLOB data in raw binary format and will be converted to base64 and sent to server. More...
 
void sendOneBlob (INDI::WidgetViewBlob *blob)
 
void sendOneBlob (const char *blobName, unsigned int blobSize, const char *blobFormat, void *blobBuffer)
 Send ONE blob content to server. The BLOB data in raw binary format and will be converted to base64 and sent to server. More...
 
void finishBlob ()
 Send closing tag for BLOB command to server. More...
 
void sendPingRequest (const char *uid)
 Send one ping request, the server will answer back with the same uuid. More...
 
void sendPingReply (const char *uid)
 Send a ping reply for the given uuid. More...
 
- Public Member Functions inherited from INDI::BaseMediator
virtual ~BaseMediator ()=default
 
virtual void newDevice (INDI::BaseDevice baseDevice)
 Emmited when a new device is created from INDI server. More...
 
virtual void removeDevice (INDI::BaseDevice baseDevice)
 Emmited when a device is deleted from INDI server. More...
 
virtual void newProperty (INDI::Property property)
 Emmited when a new property is created for an INDI driver. More...
 
virtual void updateProperty (INDI::Property property)
 Emmited when a new property value arrives from INDI server. More...
 
virtual void removeProperty (INDI::Property property)
 Emmited when a property is deleted for an INDI driver. More...
 
virtual void newMessage (INDI::BaseDevice baseDevice, int messageID)
 Emmited when a new message arrives from INDI server. More...
 
virtual void serverConnected ()
 Emmited when the server is connected. More...
 
virtual void serverDisconnected (int exit_code)
 Emmited when the server gets disconnected. More...
 
virtual void newDevice (INDI::BaseDevice *dp)
 Emmited when a new device is created from INDI server. More...
 
virtual void removeDevice (INDI::BaseDevice *dp)
 Emmited when a device is deleted from INDI server. More...
 
virtual void newProperty (INDI::Property *property)
 Emmited when a new property is created for an INDI driver. More...
 
virtual void removeProperty (INDI::Property *property)
 Emmited when a property is deleted for an INDI driver. More...
 
virtual void newSwitch (ISwitchVectorProperty *svp)
 Emmited when a new switch value arrives from INDI server. More...
 
virtual void newNumber (INumberVectorProperty *nvp)
 Emmited when a new number value arrives from INDI server. More...
 
virtual void newText (ITextVectorProperty *tvp)
 Emmited when a new text value arrives from INDI server. More...
 
virtual void newLight (ILightVectorProperty *lvp)
 Emmited when a new light value arrives from INDI server. More...
 
virtual void newBLOB (IBLOB *bp)
 Emmited when a new property value arrives from INDI server. More...
 
virtual void newMessage (INDI::BaseDevice *dp, int messageID)
 Emmited when a new message arrives from INDI server. More...
 

Protected Member Functions

virtual void newPingReply (std::string uid)
 pingReply are sent by the server on response to pingReply (see above). More...
 
virtual void newUniversalMessage (std::string message)
 newUniversalMessage Universal messages are sent from INDI server without a specific device. It is addressed to the client overall. More...
 
 AbstractBaseClient (std::unique_ptr< AbstractBaseClientPrivate > &&dd)
 

Protected Attributes

std::unique_ptr< AbstractBaseClientPrivated_ptr_indi
 

Friends

class BaseClientPrivate
 
class BaseClientQtPrivate
 

Detailed Description

Definition at line 37 of file abstractbaseclient.h.

Constructor & Destructor Documentation

◆ AbstractBaseClient() [1/2]

INDI::AbstractBaseClient::AbstractBaseClient ( )
delete

◆ ~AbstractBaseClient()

INDI::AbstractBaseClient::~AbstractBaseClient ( )
virtual

Definition at line 317 of file abstractbaseclient.cpp.

◆ AbstractBaseClient() [2/2]

INDI::AbstractBaseClient::AbstractBaseClient ( std::unique_ptr< AbstractBaseClientPrivate > &&  dd)
protected

Definition at line 313 of file abstractbaseclient.cpp.

Member Function Documentation

◆ connectDevice()

void INDI::AbstractBaseClient::connectDevice ( const char *  deviceName)

Disconnect INDI driver.

Parameters
deviceNameName of the device to disconnect.
Examples
tutorial_client.cpp.

Definition at line 382 of file abstractbaseclient.cpp.

◆ connectServer()

virtual bool INDI::AbstractBaseClient::connectServer ( )
pure virtual

Connect to INDI server.

Returns
True if the connection is successful, false otherwise.
Note
This function blocks until connection is either successull or unsuccessful.

Implemented in INDI::BaseClientQt, and INDI::BaseClient.

◆ disconnectDevice()

void INDI::AbstractBaseClient::disconnectDevice ( const char *  deviceName)

Disconnect INDI driver.

Parameters
deviceNameName of the device to disconnect.

Definition at line 388 of file abstractbaseclient.cpp.

◆ disconnectServer()

virtual bool INDI::AbstractBaseClient::disconnectServer ( int  exit_code = 0)
pure virtual

Disconnect from INDI server. Any devices previously created will be deleted and memory cleared.

Returns
True if disconnection is successful, false otherwise.

Implemented in INDI::BaseClientQt, and INDI::BaseClient.

◆ finishBlob()

void INDI::AbstractBaseClient::finishBlob ( )

Send closing tag for BLOB command to server.

Definition at line 595 of file abstractbaseclient.cpp.

◆ getBLOBMode()

BLOBHandling INDI::AbstractBaseClient::getBLOBMode ( const char *  dev,
const char *  prop = nullptr 
)

getBLOBMode Get Binary Large Object policy mode IF set previously by setBLOBMode

Parameters
devname of device.
propproperty name, can be NULL to return overall device policy if it exists.
Returns
BLOB Policy, if not found, it always returns B_ALSO

Definition at line 447 of file abstractbaseclient.cpp.

◆ getDevice()

BaseDevice INDI::AbstractBaseClient::getDevice ( const char *  deviceName)
Parameters
deviceNameName of device to search for in the list of devices owned by INDI server,
Returns
If deviceName exists, it returns an instance of the device. Otherwise, it returns NULL.

Definition at line 394 of file abstractbaseclient.cpp.

◆ getDevices() [1/2]

std::vector< BaseDevice > INDI::AbstractBaseClient::getDevices ( ) const
Returns
Returns a vector of all devices created in the client.

Definition at line 400 of file abstractbaseclient.cpp.

◆ getDevices() [2/2]

bool INDI::AbstractBaseClient::getDevices ( std::vector< INDI::BaseDevice > &  deviceList,
uint16_t  driverInterface 
)

getDevices Returns list of devices that belong to a particular DRIVER_INTERFACE class.

For example, to get a list of guide cameras:

std::vector<INDI::BaseDevice *> guideCameras;
getDevices(guideCameras, CCD_INTERFACE | GUIDER_INTERFACE);
for (INDI::BaseDevice *device : guideCameras)
cout << "Guide Camera Name: " << device->getDeviceName();
hid_device * device
std::vector< INDI::BaseDevice > getDevices() const
Class to provide basic INDI device functionality.
Definition: basedevice.h:52
Parameters
deviceListSupply device list to be filled by the function.
driverInterfaceORed DRIVER_INTERFACE values to select the desired class of devices.
Returns
True if one or more devices are found for the supplied driverInterface, false if no matching devices found.

◆ getHost()

const char * INDI::AbstractBaseClient::getHost ( ) const

Get the server host name.

Definition at line 327 of file abstractbaseclient.cpp.

◆ getPort()

int INDI::AbstractBaseClient::getPort ( ) const

Get the port number.

Definition at line 333 of file abstractbaseclient.cpp.

◆ isServerConnected()

bool INDI::AbstractBaseClient::isServerConnected ( ) const

Get status of the connection.

Definition at line 339 of file abstractbaseclient.cpp.

◆ isVerbose()

bool INDI::AbstractBaseClient::isVerbose ( ) const

isVerbose Is client in verbose mode?

Returns
Is client in verbose mode?

Definition at line 358 of file abstractbaseclient.cpp.

◆ newPingReply()

void INDI::AbstractBaseClient::newPingReply ( std::string  uid)
protectedvirtual

pingReply are sent by the server on response to pingReply (see above).

Definition at line 613 of file abstractbaseclient.cpp.

◆ newUniversalMessage()

void INDI::AbstractBaseClient::newUniversalMessage ( std::string  message)
protectedvirtual

newUniversalMessage Universal messages are sent from INDI server without a specific device. It is addressed to the client overall.

Parameters
messagecontent of message.
Note
The default implementation simply logs the message to stderr. Override to handle the message.

Definition at line 618 of file abstractbaseclient.cpp.

◆ sendNewNumber() [1/2]

void INDI::AbstractBaseClient::sendNewNumber ( const char *  deviceName,
const char *  propertyName,
const char *  elementName,
double  value 
)

Send new Number command to server.

Definition at line 523 of file abstractbaseclient.cpp.

◆ sendNewNumber() [2/2]

void INDI::AbstractBaseClient::sendNewNumber ( INDI::Property  pp)

Send new Number command to server.

Definition at line 515 of file abstractbaseclient.cpp.

◆ sendNewProperty()

void INDI::AbstractBaseClient::sendNewProperty ( INDI::Property  pp)

Send new Property command to server.

Examples
tutorial_client.cpp.

Definition at line 460 of file abstractbaseclient.cpp.

◆ sendNewSwitch() [1/2]

void INDI::AbstractBaseClient::sendNewSwitch ( const char *  deviceName,
const char *  propertyName,
const char *  elementName 
)

Send new Switch command to server.

Definition at line 548 of file abstractbaseclient.cpp.

◆ sendNewSwitch() [2/2]

void INDI::AbstractBaseClient::sendNewSwitch ( INDI::Property  pp)

Send new Switch command to server.

Definition at line 541 of file abstractbaseclient.cpp.

◆ sendNewText() [1/2]

void INDI::AbstractBaseClient::sendNewText ( const char *  deviceName,
const char *  propertyName,
const char *  elementName,
const char *  text 
)

Send new Text command to server.

Definition at line 497 of file abstractbaseclient.cpp.

◆ sendNewText() [2/2]

void INDI::AbstractBaseClient::sendNewText ( INDI::Property  pp)

Send new Text command to server.

Definition at line 488 of file abstractbaseclient.cpp.

◆ sendOneBlob() [1/3]

void INDI::AbstractBaseClient::sendOneBlob ( const char *  blobName,
unsigned int  blobSize,
const char *  blobFormat,
void *  blobBuffer 
)

Send ONE blob content to server. The BLOB data in raw binary format and will be converted to base64 and sent to server.

Definition at line 585 of file abstractbaseclient.cpp.

◆ sendOneBlob() [2/3]

void INDI::AbstractBaseClient::sendOneBlob ( IBLOB bp)

Send ONE blob content to server. The BLOB data in raw binary format and will be converted to base64 and sent to server.

Definition at line 580 of file abstractbaseclient.cpp.

◆ sendOneBlob() [3/3]

void INDI::AbstractBaseClient::sendOneBlob ( INDI::WidgetViewBlob blob)

Definition at line 571 of file abstractbaseclient.cpp.

◆ sendPingReply()

void INDI::AbstractBaseClient::sendPingReply ( const char *  uid)

Send a ping reply for the given uuid.

Note
This should not be called directly, as it is already handled by baseclient

Definition at line 607 of file abstractbaseclient.cpp.

◆ sendPingRequest()

void INDI::AbstractBaseClient::sendPingRequest ( const char *  uid)

Send one ping request, the server will answer back with the same uuid.

Parameters
uidThis string will server as identifier for the reply
Note
reply will be dispatched to newPingReply

Definition at line 601 of file abstractbaseclient.cpp.

◆ setBLOBMode()

void INDI::AbstractBaseClient::setBLOBMode ( BLOBHandling  blobH,
const char *  dev,
const char *  prop = nullptr 
)

Set Binary Large Object policy mode.

Set the BLOB handling mode for the client. The client may either receive:

  • Only BLOBS
  • BLOBs mixed with normal messages
  • Normal messages only, no BLOBs

If dev and prop are supplied, then the BLOB handling policy is set for this particular device and property. if prop is NULL, then the BLOB policy applies to the whole device.

Parameters
blobHBLOB handling policy
devname of device, required.
propname of property, optional.
Examples
tutorial_client.cpp.

Definition at line 419 of file abstractbaseclient.cpp.

◆ setConnectionTimeout()

void INDI::AbstractBaseClient::setConnectionTimeout ( uint32_t  seconds,
uint32_t  microseconds 
)

setConnectionTimeout Set connection timeout. By default it is 3 seconds.

Parameters
secondsseconds
microsecondsmicroseconds

Definition at line 345 of file abstractbaseclient.cpp.

◆ setServer()

void INDI::AbstractBaseClient::setServer ( const char *  hostname,
unsigned int  port 
)

Set the server host name and port.

Parameters
hostnameINDI server host name or IP address.
portINDI server port.
Examples
tutorial_client.cpp.

Definition at line 320 of file abstractbaseclient.cpp.

◆ setVerbose()

void INDI::AbstractBaseClient::setVerbose ( bool  enable)

setVerbose Set verbose mode

Parameters
enableIf true, enable FULL verbose output. Any XML message received, including BLOBs, are printed on standard output. Only use this for debugging purposes.

Definition at line 352 of file abstractbaseclient.cpp.

◆ startBlob()

void INDI::AbstractBaseClient::startBlob ( const char *  devName,
const char *  propName,
const char *  timestamp 
)

Send opening tag for BLOB command to server.

Definition at line 565 of file abstractbaseclient.cpp.

◆ watchDevice() [1/2]

void INDI::AbstractBaseClient::watchDevice ( const char *  deviceName)

Add a device to the watch list.

A client may select to receive notifications of only a specific device or a set of devices. If the client encounters any of the devices set via this function, it will create a corresponding INDI::BaseDevice object to handle them. If no devices are watched, then all devices owned by INDI server will be created and handled.

Examples
tutorial_client.cpp.

Definition at line 364 of file abstractbaseclient.cpp.

◆ watchDevice() [2/2]

void INDI::AbstractBaseClient::watchDevice ( const char *  deviceName,
const std::function< void(BaseDevice)> &  callback 
)

Definition at line 370 of file abstractbaseclient.cpp.

◆ watchProperty()

void INDI::AbstractBaseClient::watchProperty ( const char *  deviceName,
const char *  propertyName 
)

watchProperties Add a property to the watch list. When communicating with INDI server.

The client calls <getProperties device=deviceName property=propertyName/>> so that only a particular property (or list of properties if more than one) are defined back to the client. This function will call watchDevice(deviceName) as well to limit the traffic to this device.

Parameters
propertyNameProperty to watch for.

Definition at line 376 of file abstractbaseclient.cpp.

Friends And Related Function Documentation

◆ BaseClientPrivate

friend class BaseClientPrivate
friend

Definition at line 226 of file abstractbaseclient.h.

◆ BaseClientQtPrivate

friend class BaseClientQtPrivate
friend

Definition at line 227 of file abstractbaseclient.h.

Member Data Documentation

◆ d_ptr_indi

std::unique_ptr<AbstractBaseClientPrivate> INDI::AbstractBaseClient::d_ptr_indi
protected

Definition at line 233 of file abstractbaseclient.h.


The documentation for this class was generated from the following files: