Instrument Neutral Distributed Interface INDI  1.5.0
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 ()
 
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...
 
bool connectServer ()
 Connect to INDI server. More...
 
bool disconnectServer ()
 Disconnect from INDI server. More...
 
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=NULL)
 Set Binary Large Object policy mode. More...
 
BLOBHandling getBLOBMode (const char *dev, const char *prop=NULL)
 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 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...
 
virtual ~BaseMediator ()
 

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)
 

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

Constructor & Destructor Documentation

INDI::BaseClientQt::BaseClientQt ( )

Definition at line 42 of file baseclientqt.cpp.

INDI::BaseClientQt::~BaseClientQt ( )
virtual

Definition at line 58 of file baseclientqt.cpp.

Member Function Documentation

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

Add a new device.

Definition at line 381 of file baseclientqt.cpp.

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

Connect to INDI driver.

Parameters
deviceNameName of the device to connect to.

Definition at line 151 of file baseclientqt.cpp.

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 84 of file baseclientqt.cpp.

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

Remove device.

Definition at line 345 of file baseclientqt.cpp.

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

Delete property command.

Definition at line 317 of file baseclientqt.cpp.

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

Disconnect INDI driver.

Parameters
deviceNameName of the device to disconnect.

Definition at line 156 of file baseclientqt.cpp.

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 130 of file baseclientqt.cpp.

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 276 of file baseclientqt.cpp.

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

Find and return a particular device.

Definition at line 366 of file baseclientqt.cpp.

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 409 of file baseclientqt.cpp.

void INDI::BaseClientQt::finishBlob ( )

Send closing tag for BLOB command to server.

Definition at line 698 of file baseclientqt.cpp.

BLOBHandling INDI::BaseClientQt::getBLOBMode ( const char *  dev,
const char *  prop = NULL 
)

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 750 of file baseclientqt.cpp.

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 206 of file baseclientqt.cpp.

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

Definition at line 104 of file baseclientqt.h.

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 | GUIDE_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 788 of file baseclientqt.cpp.

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

Definition at line 152 of file baseclientqt.h.

int INDI::BaseClientQt::getPort ( )
inline

Definition at line 153 of file baseclientqt.h.

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

isVerbose Is client in verbose mode?

Returns
Is client in verbose mode?

Definition at line 188 of file baseclientqt.h.

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

Definition at line 216 of file baseclientqt.cpp.

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

Process messages

Definition at line 447 of file baseclientqt.cpp.

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

Send new Number command to server.

Definition at line 504 of file baseclientqt.cpp.

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

Send new Number command to server.

Definition at line 528 of file baseclientqt.cpp.

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

Send new Switch command to server.

Definition at line 551 of file baseclientqt.cpp.

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

Send new Switch command to server.

Definition at line 586 of file baseclientqt.cpp.

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

Send new Text command to server.

Definition at line 457 of file baseclientqt.cpp.

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 481 of file baseclientqt.cpp.

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 620 of file baseclientqt.cpp.

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 658 of file baseclientqt.cpp.

void INDI::BaseClientQt::setBLOBMode ( BLOBHandling  blobH,
const char *  dev,
const char *  prop = NULL 
)

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 703 of file baseclientqt.cpp.

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

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 73 of file baseclientqt.cpp.

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

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

Send opening tag for BLOB command to server.

Definition at line 608 of file baseclientqt.cpp.

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 79 of file baseclientqt.cpp.


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