Instrument Neutral Distributed Interface INDI  1.9.2
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
INDI::BaseClientQt Class Reference

Class to provide basic client functionality based on Qt5 toolkit and is therefore suitable for cross-platform development. More...

#include <baseclientqt.h>

Inheritance diagram for INDI::BaseClientQt:
INDI::BaseMediator

Public Member Functions

 BaseClientQt (QObject *parent=Q_NULLPTR)
 
virtual ~BaseClientQt ()
 
void setServer (const char *hostname, unsigned int port)
 Set the server host name and port. More...
 
void watchDevice (const char *deviceName)
 Add a device to the watch list. More...
 
void watchProperty (const char *deviceName, const char *propertyName)
 watchProperties Add a property to the watch list. When communicating with INDI server. Thi 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. More...
 
bool connectServer ()
 Connect to INDI server. More...
 
bool disconnectServer ()
 Disconnect from INDI server. More...
 
bool isServerConnected () const
 
void connectDevice (const char *deviceName)
 Connect to INDI driver. More...
 
void disconnectDevice (const char *deviceName)
 Disconnect INDI driver. More...
 
INDI::BaseDevicegetDevice (const char *deviceName)
 
const std::vector< INDI::BaseDevice * > & getDevices () 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...
 
const char * getHost ()
 
int getPort ()
 
void sendNewText (ITextVectorProperty *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 (INumberVectorProperty *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 (ISwitchVectorProperty *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 (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 setVerbose (bool enable)
 setVerbose Set verbose mode More...
 
bool isVerbose () const
 isVerbose Is client in verbose mode? More...
 
void setConnectionTimeout (uint32_t seconds, uint32_t microseconds)
 setConnectionTimeout Set connection timeout. By default it is 3 seconds. More...
 
- Public Member Functions inherited from INDI::BaseMediator
virtual ~BaseMediator ()=default
 
virtual void newDevice (INDI::BaseDevice *dp)=0
 Emmited when a new device is created from INDI server. More...
 
virtual void removeDevice (INDI::BaseDevice *dp)=0
 Emmited when a device is deleted from INDI server. More...
 
virtual void newProperty (INDI::Property *property)=0
 Emmited when a new property is created for an INDI driver. More...
 
virtual void removeProperty (INDI::Property *property)=0
 Emmited when a property is deleted for an INDI driver. More...
 
virtual void newBLOB (IBLOB *bp)=0
 Emmited when a new BLOB value arrives from INDI server. More...
 
virtual void newSwitch (ISwitchVectorProperty *svp)=0
 Emmited when a new switch value arrives from INDI server. More...
 
virtual void newNumber (INumberVectorProperty *nvp)=0
 Emmited when a new number value arrives from INDI server. More...
 
virtual void newText (ITextVectorProperty *tvp)=0
 Emmited when a new text value arrives from INDI server. More...
 
virtual void newLight (ILightVectorProperty *lvp)=0
 Emmited when a new light value arrives from INDI server. More...
 
virtual void newMessage (INDI::BaseDevice *dp, int messageID)=0
 Emmited when a new message arrives from INDI server. More...
 
virtual void serverConnected ()=0
 Emmited when the server is connected. More...
 
virtual void serverDisconnected (int exit_code)=0
 Emmited when the server gets disconnected. More...
 

Static Public Member Functions

static void * listenHelper (void *context)
 

Protected Member Functions

int dispatchCommand (XMLEle *root, char *errmsg)
 Dispatch command received from INDI server to respective devices handled by the client. More...
 
int deleteDevice (const char *devName, char *errmsg)
 Remove device. More...
 
int delPropertyCmd (XMLEle *root, char *errmsg)
 Delete property command. More...
 
INDI::BaseDevicefindDev (const char *devName, char *errmsg)
 Find and return a particular device. More...
 
INDI::BaseDeviceaddDevice (XMLEle *dep, char *errmsg)
 Add a new device. More...
 
INDI::BaseDevicefindDev (XMLEle *root, int create, char *errmsg)
 Find a device, and if it doesn't exist, create it if create is set to 1. More...
 
int messageCmd (XMLEle *root, char *errmsg)
 
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...
 

Detailed Description

Class to provide basic client functionality based on Qt5 toolkit and is therefore suitable for cross-platform development.

BaseClientQt enables accelerated development of INDI Clients by providing a framework that facilitates communication, device handling, and event notification. By subclassing BaseClientQt, clients can quickly connect to an INDI server, and query for a set of INDI::BaseDevice devices, and read and write properties seamlessly. Event driven programming is possible due to notifications upon reception of new devices or properties.

Attention
All notifications functions defined in INDI::BaseMediator must be implemented in the client class even if they are not used because these are pure virtual functions.
See also
INDI Client Tutorial for more details.
Author
Jasem Mutlaq

Definition at line 57 of file baseclientqt.h.

Constructor & Destructor Documentation

◆ BaseClientQt()

INDI::BaseClientQt::BaseClientQt ( QObject *  parent = Q_NULLPTR)

Definition at line 48 of file baseclientqt.cpp.

◆ ~BaseClientQt()

INDI::BaseClientQt::~BaseClientQt ( )
virtual

Definition at line 76 of file baseclientqt.cpp.

Member Function Documentation

◆ addDevice()

INDI::BaseDevice * INDI::BaseClientQt::addDevice ( XMLEle dep,
char *  errmsg 
)
protected

Add a new device.

Definition at line 441 of file baseclientqt.cpp.

◆ connectDevice()

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

Connect to INDI driver.

Parameters
deviceNameName of the device to connect to.

Definition at line 182 of file baseclientqt.cpp.

◆ connectServer()

bool INDI::BaseClientQt::connectServer ( )

Connect to INDI server.

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

Definition at line 119 of file baseclientqt.cpp.

◆ deleteDevice()

int INDI::BaseClientQt::deleteDevice ( const char *  devName,
char *  errmsg 
)
protected

Remove device.

Definition at line 405 of file baseclientqt.cpp.

◆ delPropertyCmd()

int INDI::BaseClientQt::delPropertyCmd ( XMLEle root,
char *  errmsg 
)
protected

Delete property command.

Definition at line 371 of file baseclientqt.cpp.

◆ disconnectDevice()

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

Disconnect INDI driver.

Parameters
deviceNameName of the device to disconnect.

Definition at line 187 of file baseclientqt.cpp.

◆ disconnectServer()

bool INDI::BaseClientQt::disconnectServer ( )

Disconnect from INDI server.

Disconnects from INDI servers. Any devices previously created will be deleted and memory cleared.

Returns
True if disconnection is successful, false otherwise.

Definition at line 159 of file baseclientqt.cpp.

◆ dispatchCommand()

int INDI::BaseClientQt::dispatchCommand ( XMLEle root,
char *  errmsg 
)
protected

Dispatch command received from INDI server to respective devices handled by the client.

Definition at line 306 of file baseclientqt.cpp.

◆ findDev() [1/2]

INDI::BaseDevice * INDI::BaseClientQt::findDev ( const char *  devName,
char *  errmsg 
)
protected

Find and return a particular device.

Definition at line 426 of file baseclientqt.cpp.

◆ findDev() [2/2]

INDI::BaseDevice * INDI::BaseClientQt::findDev ( XMLEle root,
int  create,
char *  errmsg 
)
protected

Find a device, and if it doesn't exist, create it if create is set to 1.

Definition at line 469 of file baseclientqt.cpp.

◆ finishBlob()

void INDI::BaseClientQt::finishBlob ( )

Send closing tag for BLOB command to server.

Definition at line 634 of file baseclientqt.cpp.

◆ getBLOBMode()

BLOBHandling INDI::BaseClientQt::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 665 of file baseclientqt.cpp.

◆ getDevice()

INDI::BaseDevice * INDI::BaseClientQt::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 237 of file baseclientqt.cpp.

◆ getDevices() [1/2]

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

Definition at line 123 of file baseclientqt.h.

◆ getDevices() [2/2]

bool INDI::BaseClientQt::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();
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.

Definition at line 703 of file baseclientqt.cpp.

◆ getHost()

const char* INDI::BaseClientQt::getHost ( )
inline

Definition at line 174 of file baseclientqt.h.

◆ getPort()

int INDI::BaseClientQt::getPort ( )
inline

Definition at line 178 of file baseclientqt.h.

◆ isServerConnected()

bool INDI::BaseClientQt::isServerConnected ( ) const

Definition at line 714 of file baseclientqt.cpp.

◆ isVerbose()

bool INDI::BaseClientQt::isVerbose ( ) const
inline

isVerbose Is client in verbose mode?

Returns
Is client in verbose mode?

Definition at line 219 of file baseclientqt.h.

◆ listenHelper()

void * INDI::BaseClientQt::listenHelper ( void *  context)
static

Definition at line 247 of file baseclientqt.cpp.

◆ messageCmd()

int INDI::BaseClientQt::messageCmd ( XMLEle root,
char *  errmsg 
)
protected

Process messages

Definition at line 507 of file baseclientqt.cpp.

◆ newUniversalMessage()

void INDI::BaseClientQt::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 517 of file baseclientqt.cpp.

◆ sendNewNumber() [1/2]

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

Send new Number command to server.

Definition at line 561 of file baseclientqt.cpp.

◆ sendNewNumber() [2/2]

void INDI::BaseClientQt::sendNewNumber ( INumberVectorProperty pp)

Send new Number command to server.

Definition at line 553 of file baseclientqt.cpp.

◆ sendNewSwitch() [1/2]

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

Send new Switch command to server.

Definition at line 590 of file baseclientqt.cpp.

◆ sendNewSwitch() [2/2]

void INDI::BaseClientQt::sendNewSwitch ( ISwitchVectorProperty pp)

Send new Switch command to server.

Definition at line 584 of file baseclientqt.cpp.

◆ sendNewText() [1/2]

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

Send new Text command to server.

Definition at line 530 of file baseclientqt.cpp.

◆ sendNewText() [2/2]

void INDI::BaseClientQt::sendNewText ( ITextVectorProperty pp)

Send new Text command to server.

Definition at line 522 of file baseclientqt.cpp.

◆ sendOneBlob() [1/2]

void INDI::BaseClientQt::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 625 of file baseclientqt.cpp.

◆ sendOneBlob() [2/2]

void INDI::BaseClientQt::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 617 of file baseclientqt.cpp.

◆ setBLOBMode()

void INDI::BaseClientQt::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.

Definition at line 639 of file baseclientqt.cpp.

◆ setConnectionTimeout()

void INDI::BaseClientQt::setConnectionTimeout ( uint32_t  seconds,
uint32_t  microseconds 
)
inline

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

Parameters
secondsseconds
microsecondsmicroseconds

Definition at line 229 of file baseclientqt.h.

◆ setServer()

void INDI::BaseClientQt::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.

Definition at line 97 of file baseclientqt.cpp.

◆ setVerbose()

void INDI::BaseClientQt::setVerbose ( bool  enable)
inline

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 210 of file baseclientqt.h.

◆ startBlob()

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

Send opening tag for BLOB command to server.

Definition at line 612 of file baseclientqt.cpp.

◆ watchDevice()

void INDI::BaseClientQt::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.

Definition at line 103 of file baseclientqt.cpp.

◆ watchProperty()

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

watchProperties Add a property to the watch list. When communicating with INDI server. Thi 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 113 of file baseclientqt.cpp.


The documentation for this class was generated from the following files:
INDI::BaseClientQt::getDevices
const std::vector< INDI::BaseDevice * > & getDevices() const
Definition: baseclientqt.h:123
device
hid_device * device
Definition: activefocuser_utils.cpp:92
INDI::BaseDevice
Class to provide basic INDI device functionality.
Definition: basedevice.h:45