TwiceAsNice
2019-02-18
|
Class to provide basic client functionality based on Qt5 toolkit and is therefore suitable for cross-platform development. More...
#include <baseclientqt.h>
Classes | |
struct | BLOBMode |
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... | |
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::BaseDevice * | getDevice (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. More... | |
void | sendOneBlob (const char *blobName, unsigned int blobSize, const char *blobFormat, void *blobBuffer) |
Send ONE blob content 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. More... | |
![]() | |
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 () |
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::BaseDevice * | findDev (const char *devName, char *errmsg) |
Find and return a particular device. More... | |
INDI::BaseDevice * | addDevice (XMLEle *dep, char *errmsg) |
Add a new device. More... | |
INDI::BaseDevice * | findDev (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) |
Process messages. More... | |
Private Slots | |
void | listenINDI () |
void | processSocketError (QAbstractSocket::SocketError socketError) |
Private Member Functions | |
BLOBMode * | findBLOBMode (const std::string &device, const std::string &property) |
void | setDriverConnection (bool status, const char *deviceName) |
Connect/Disconnect to INDI driver. More... | |
void | clear () |
clear Clear devices and blob modes More... | |
Private Attributes | |
QTcpSocket | client_socket |
std::vector< INDI::BaseDevice * > | cDevices |
std::vector< std::string > | cDeviceNames |
std::vector< BLOBMode * > | blobModes |
std::string | cServer |
unsigned int | cPort |
bool | sConnected |
bool | verbose |
LilXML * | lillp |
uint32_t | timeout_sec |
uint32_t | timeout_us |
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.
INDI::BaseClientQt::BaseClientQt | ( | QObject * | parent = Q_NULLPTR | ) |
|
virtual |
|
protected |
Add a new device.
|
private |
clear Clear devices and blob modes
void INDI::BaseClientQt::connectDevice | ( | const char * | deviceName | ) |
Connect to INDI driver.
deviceName | Name of the device to connect to. |
bool INDI::BaseClientQt::connectServer | ( | ) |
Connect to INDI server.
|
protected |
Remove device.
|
protected |
Delete property command.
void INDI::BaseClientQt::disconnectDevice | ( | const char * | deviceName | ) |
Disconnect INDI driver.
deviceName | Name of the device to disconnect. |
bool INDI::BaseClientQt::disconnectServer | ( | ) |
|
protected |
Dispatch command received from INDI server to respective devices handled by the client.
|
private |
|
protected |
Find and return a particular device.
|
protected |
Find a device, and if it doesn't exist, create it if create is set to 1.
void INDI::BaseClientQt::finishBlob | ( | ) |
Send closing tag for BLOB command to server.
BLOBHandling INDI::BaseClientQt::getBLOBMode | ( | const char * | dev, |
const char * | prop = NULL |
||
) |
getBLOBMode Get Binary Large Object policy mode IF set previously by setBLOBMode
dev | name of device. |
prop | property name, can be NULL to return overall device policy if it exists. |
INDI::BaseDevice * INDI::BaseClientQt::getDevice | ( | const char * | deviceName | ) |
deviceName | Name of device to search for in the list of devices owned by INDI server, |
|
inline |
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:
deviceList | Supply device list to be filled by the function. |
driverInterface | ORed DRIVER_INTERFACE values to select the desired class of devices. |
|
inline |
|
inline |
bool INDI::BaseClientQt::isServerConnected | ( | ) | const |
|
inline |
isVerbose Is client in verbose mode?
|
static |
|
privateslot |
|
protected |
Process messages.
|
privateslot |
void INDI::BaseClientQt::sendNewNumber | ( | INumberVectorProperty * | pp | ) |
Send new Number command to server.
void INDI::BaseClientQt::sendNewNumber | ( | const char * | deviceName, |
const char * | propertyName, | ||
const char * | elementName, | ||
double | value | ||
) |
Send new Number command to server.
void INDI::BaseClientQt::sendNewSwitch | ( | ISwitchVectorProperty * | pp | ) |
Send new Switch command to server.
void INDI::BaseClientQt::sendNewSwitch | ( | const char * | deviceName, |
const char * | propertyName, | ||
const char * | elementName | ||
) |
Send new Switch command to server.
void INDI::BaseClientQt::sendNewText | ( | ITextVectorProperty * | pp | ) |
Send new Text command to server.
void INDI::BaseClientQt::sendNewText | ( | const char * | deviceName, |
const char * | propertyName, | ||
const char * | elementName, | ||
const char * | text | ||
) |
Send new Text command to server.
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
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
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:
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.
blobH | BLOB handling policy |
dev | name of device, required. |
prop | name of property, optional. |
setConnectionTimeout Set connection timeout.
By default it is 3 seconds.
seconds | seconds |
microseconds | microseconds |
Connect/Disconnect to INDI driver.
status | If true, the client will attempt to turn on CONNECTION property within the driver (i.e. turn on the device). Otherwise, CONNECTION will be turned off. |
deviceName | Name of the device to connect to. |
void INDI::BaseClientQt::setServer | ( | const char * | hostname, |
unsigned int | port | ||
) |
|
inline |
setVerbose Set verbose mode
enable | If true, enable FULL verbose output. Any XML message received, including BLOBs, are printed on standard output. Only use this for debugging purposes. |
void INDI::BaseClientQt::startBlob | ( | const char * | devName, |
const char * | propName, | ||
const char * | timestamp | ||
) |
Send opening tag for BLOB command to server.
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.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |