Instrument Neutral Distributed Interface INDI  0.9.9
Public Member Functions | Protected Member Functions | List of all members
INDI::BaseClient Class Reference

Class to provide basic client functionality. More...

#include <baseclient.h>

Inheritance diagram for INDI::BaseClient:
INDI::BaseMediator

Public Member Functions

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 vector< INDI::BaseDevice * > & getDevices () const
 
void setBLOBMode (BLOBHandling blobH, const char *dev, const char *prop=NULL)
 Set Binary Large Object policy mode. More...
 
void sendNewText (ITextVectorProperty *pp)
 Send new Text command to server.
 
void sendNewText (const char *deviceName, const char *propertyName, const char *elementName, const char *text)
 Send new Text command to server.
 
void sendNewNumber (INumberVectorProperty *pp)
 Send new Number command to server.
 
void sendNewNumber (const char *deviceName, const char *propertyName, const char *elementName, double value)
 Send new Number command to server.
 
void sendNewSwitch (ISwitchVectorProperty *pp)
 Send new Switch command to server.
 
void sendNewSwitch (const char *deviceName, const char *propertyName, const char *elementName)
 Send new Switch command to server.
 
void startBlob (const char *devName, const char *propName, const char *timestamp)
 Send opening tag for BLOB command to server.
 
void sendOneBlob (const char *blobName, unsigned int blobSize, const char *blobFormat, void *blobBuffer)
 Send ONE blob content to server.
 
void finishBlob ()
 Send closing tag for BLOB command to server.
 
- 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 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.
 
virtual void serverDisconnected (int exit_code)=0
 Emmited when the server gets disconnected. More...
 

Protected Member Functions

int dispatchCommand (XMLEle *root, char *errmsg)
 Dispatch command received from INDI server to respective devices handled by the client.
 
int removeDevice (const char *devName, char *errmsg)
 Remove device.
 
int delPropertyCmd (XMLEle *root, char *errmsg)
 Delete property command.
 
INDI::BaseDevicefindDev (const char *devName, char *errmsg)
 Find and return a particular device.
 
INDI::BaseDeviceaddDevice (XMLEle *dep, char *errmsg)
 Add a new device.
 
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.
 
int messageCmd (XMLEle *root, char *errmsg)
 

Detailed Description

Class to provide basic client functionality.

BaseClient enables accelerated development of INDI Clients by providing a framework that facilitates communication, device handling, and event notification. By subclassing BaseClient, 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
Examples:
tutorial_client.h.

Definition at line 54 of file baseclient.h.

Member Function Documentation

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

Connect to INDI driver.

Parameters
deviceNameName of the device to connect to.

Definition at line 159 of file baseclient.cpp.

bool INDI::BaseClient::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 68 of file baseclient.cpp.

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

Disconnect INDI driver.

Parameters
deviceNameName of the device to disconnect.

Definition at line 164 of file baseclient.cpp.

bool INDI::BaseClient::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 135 of file baseclient.cpp.

INDI::BaseDevice * INDI::BaseClient::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 217 of file baseclient.cpp.

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

Definition at line 110 of file baseclient.h.

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

Process messages

Definition at line 512 of file baseclient.cpp.

void INDI::BaseClient::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 698 of file baseclient.cpp.

void INDI::BaseClient::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 56 of file baseclient.cpp.

void INDI::BaseClient::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 63 of file baseclient.cpp.


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