Instrument Neutral Distributed Interface INDI  1.4.1
Public Member Functions | Protected Member Functions | List of all members
INDI::DefaultDevice Class Referenceabstract

Class to provide extended functionality for devices in addition to the functionality provided by INDI::BaseDevice. This class should only be subclassed by drivers directly as it is linked with main(). Virtual drivers cannot employ INDI::DefaultDevice. More...

#include <defaultdevice.h>

Inheritance diagram for INDI::DefaultDevice:
INDI::BaseDevice INDI::CCD INDI::Dome INDI::FilterWheel INDI::Focuser INDI::GPS INDI::Telescope INDI::Weather

Public Member Functions

void addAuxControls ()
 Add Debug, Simulation, and Configuration options to the driver.
 
void addDebugControl ()
 Add Debug control to the driver.
 
void addSimulationControl ()
 Add Simulation control to the driver.
 
void addConfigurationControl ()
 Add Configuration control to the driver.
 
void resetProperties ()
 Set all properties to IDLE state.
 
void defineNumber (INumberVectorProperty *nvp)
 Define number vector to client & register it. Alternatively, IDDefNumber can be used but the property will not get registered and the driver will not be able to save configuration files. More...
 
void defineText (ITextVectorProperty *tvp)
 Define text vector to client & register it. Alternatively, IDDefText can be used but the property will not get registered and the driver will not be able to save configuration files. More...
 
void defineSwitch (ISwitchVectorProperty *svp)
 Define switch vector to client & register it. Alternatively, IDDefswitch can be used but the property will not get registered and the driver will not be able to save configuration files. More...
 
void defineLight (ILightVectorProperty *lvp)
 Define light vector to client & register it. Alternatively, IDDeflight can be used but the property will not get registered and the driver will not be able to save configuration files. More...
 
void defineBLOB (IBLOBVectorProperty *bvp)
 Define BLOB vector to client & register it. Alternatively, IDDefBLOB can be used but the property will not get registered and the driver will not be able to save configuration files. More...
 
virtual bool deleteProperty (const char *propertyName)
 Delete a property and unregister it. It will also be deleted from all clients. More...
 
virtual void setConnected (bool status, IPState state=IPS_OK, const char *msg=NULL)
 Set connection switch status in the client. More...
 
int SetTimer (int ms)
 Set a timer to call the function TimerHit after ms milliseconds. More...
 
void RemoveTimer (int id)
 Remove timer added with SetTimer. More...
 
virtual void TimerHit ()
 Callback function to be called once SetTimer duration elapses.
 
virtual const char * getDriverExec ()
 
virtual const char * getDriverName ()
 
void setVersion (uint16_t vMajor, uint16_t vMinor)
 Set driver version information to be defined in DRIVER_INFO property as vMajor.vMinor. More...
 
uint16_t getMajorVersion ()
 
uint16_t getMinorVersion ()
 
virtual void ISGetProperties (const char *dev)
 define the driver's properties to the client. Usually, only a minimum set of properties are defined to the client in this function if the device is in disconnected state. Those properties should be enough to enable the client to establish a connection to the device. In addition to CONNECT/DISCONNECT, such properties may include port name, IP address, etc... You should check if the device is already connected, and if this is true, then you must define the remainder of the the properties to the client in this function. Otherwise, the remainder of the driver's properties are defined to the client in updateProperties() function which is called when a client connects/disconnects from a device. More...
 
virtual bool ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n)
 Process the client newSwitch command. More...
 
virtual bool ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
 Process the client newNumber command. More...
 
virtual bool ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n)
 Process the client newSwitch command. More...
 
virtual bool ISNewBLOB (const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n)
 Process the client newBLOB command. More...
 
virtual bool ISSnoopDevice (XMLEle *root)
 Process a snoop event from INDI server. This function is called when a snooped property is updated in a snooped driver. More...
 
virtual uint16_t getDriverInterface ()
 
void setDriverInterface (uint16_t value)
 setInterface Set driver interface. By default the driver interface is set to GENERAL_DEVICE. You may send an ORed list of DeviceInterface values. More...
 
- Public Member Functions inherited from INDI::BaseDevice
INumberVectorPropertygetNumber (const char *name)
 
ITextVectorPropertygetText (const char *name)
 
ISwitchVectorPropertygetSwitch (const char *name)
 
ILightVectorPropertygetLight (const char *name)
 
IBLOBVectorPropertygetBLOB (const char *name)
 
IPState getPropertyState (const char *name)
 
IPerm getPropertyPermission (const char *name)
 
int removeProperty (const char *name, char *errmsg)
 Remove a property. More...
 
void * getRawProperty (const char *name, INDI_PROPERTY_TYPE type=INDI_UNKNOWN)
 Return a property and its type given its name. More...
 
INDI::PropertygetProperty (const char *name, INDI_PROPERTY_TYPE type=INDI_UNKNOWN)
 Return a property and its type given its name. More...
 
std::vector< INDI::Property * > * getProperties ()
 Return a list of all properties in the device.
 
bool buildSkeleton (const char *filename)
 Build driver properties from a skeleton file. More...
 
bool isConnected ()
 
void setDeviceName (const char *dev)
 Set the device name. More...
 
const char * getDeviceName ()
 
void addMessage (std::string msg)
 Add message to the driver's message queue. More...
 
std::string messageQueue (int index) const
 
std::string lastMessage ()
 
void setMediator (INDI::BaseMediator *med)
 Set the driver's mediator to receive notification of news devices and updated property values.
 
INDI::BaseMediatorgetMediator ()
 
const char * getDriverName ()
 
const char * getDriverExec ()
 
const char * getDriverVersion ()
 

Protected Member Functions

virtual bool loadConfig (bool silent=false, const char *property=NULL)
 Load the last saved configuration file. More...
 
virtual bool saveConfig (bool silent=false)
 Save the current properties in a configuration file. More...
 
virtual bool saveConfigItems (FILE *fp)
 saveConfigItems Save specific properties in the provide config file handler. Child class usually override this function to save their own properties and the base class saveConfigItems(fp) must be explicitly called by each child class. The Default Device saveConfigItems(fp) only save Debug properties options in the config file. More...
 
virtual bool saveAllConfigItems (FILE *fp)
 saveAllConfigItems Save all the drivers' properties in the configuration file More...
 
virtual bool loadDefaultConfig ()
 Load the default configuration file. More...
 
void setDebug (bool enable)
 Toggle driver debug status. More...
 
void setSimulation (bool enable)
 Toggle driver simulation status. More...
 
virtual void debugTriggered (bool enable)
 Inform driver that the debug option was triggered. More...
 
virtual void simulationTriggered (bool enable)
 Inform driver that the simulation option was triggered. More...
 
bool isDebug ()
 
bool isSimulation ()
 
virtual bool initProperties ()
 Initilize properties initial state and value. The child class must implement this function. More...
 
virtual bool updateProperties ()
 updateProperties is called whenever there is a change in the CONNECTION status of the driver. This will enable the driver to react to changes of switching ON/OFF a device. For example, a driver may only define a set of properties after a device is connected, but not before. More...
 
virtual bool Connect ()=0
 Connect to a device. Child classes must implement this function and perform the connection routine in the function. More...
 
virtual bool Disconnect ()=0
 Disconnect from a device. Child classes must implement this function and perform the disconnection routine in the function. More...
 
virtual const char * getDefaultName ()=0
 
- Protected Member Functions inherited from INDI::BaseDevice
int buildProp (XMLEle *root, char *errmsg)
 Build a property given the supplied XML element (defXXX) More...
 
int setValue (XMLEle *root, char *errmsg)
 handle SetXXX commands from client
 
int setBLOB (IBLOBVectorProperty *pp, XMLEle *root, char *errmsg)
 Parse and store BLOB in the respective vector.
 

Additional Inherited Members

- Public Types inherited from INDI::BaseDevice

Detailed Description

Class to provide extended functionality for devices in addition to the functionality provided by INDI::BaseDevice. This class should only be subclassed by drivers directly as it is linked with main(). Virtual drivers cannot employ INDI::DefaultDevice.

INDI::DefaultDevice provides capability to add Debug, Simulation, and Configuration controls. These controls (switches) are defined to the client. Configuration options permit saving and loading of AS-IS property values.

See also
Tutorial Four
Author
Jasem Mutlaq
Examples:
dome.h, raindetector.h, simpledevice.h, and simpleskeleton.h.

Definition at line 93 of file defaultdevice.h.

Member Function Documentation

virtual bool INDI::DefaultDevice::Connect ( )
protectedpure virtual

Connect to a device. Child classes must implement this function and perform the connection routine in the function.

Returns
True if connection to device is successful, false otherwise.

Implemented in INDI::Telescope.

Examples:
dome.h, raindetector.h, simpleccd.h, simpledevice.h, and simpleskeleton.h.
void INDI::DefaultDevice::debugTriggered ( bool  enable)
protectedvirtual

Inform driver that the debug option was triggered.

This function is called after setDebug is triggered by the client. Reimplement this function if your driver needs to take specific action after debug is enabled/disabled. Otherwise, you can use isDebug() to check if simulation is enabled or disabled.

Parameters
enableIf true, the debug option is set to ON.

Definition at line 451 of file defaultdevice.cpp.

void INDI::DefaultDevice::defineBLOB ( IBLOBVectorProperty bvp)

Define BLOB vector to client & register it. Alternatively, IDDefBLOB can be used but the property will not get registered and the driver will not be able to save configuration files.

Parameters
bvpThe BLOB vector property to be defined

Definition at line 721 of file defaultdevice.cpp.

void INDI::DefaultDevice::defineLight ( ILightVectorProperty lvp)

Define light vector to client & register it. Alternatively, IDDeflight can be used but the property will not get registered and the driver will not be able to save configuration files.

Parameters
lvpThe light vector property to be defined

Definition at line 715 of file defaultdevice.cpp.

void INDI::DefaultDevice::defineNumber ( INumberVectorProperty nvp)

Define number vector to client & register it. Alternatively, IDDefNumber can be used but the property will not get registered and the driver will not be able to save configuration files.

Parameters
nvpThe number vector property to be defined

Definition at line 697 of file defaultdevice.cpp.

void INDI::DefaultDevice::defineSwitch ( ISwitchVectorProperty svp)

Define switch vector to client & register it. Alternatively, IDDefswitch can be used but the property will not get registered and the driver will not be able to save configuration files.

Parameters
svpThe switch vector property to be defined

Definition at line 709 of file defaultdevice.cpp.

void INDI::DefaultDevice::defineText ( ITextVectorProperty tvp)

Define text vector to client & register it. Alternatively, IDDefText can be used but the property will not get registered and the driver will not be able to save configuration files.

Parameters
tvpThe text vector property to be defined

Definition at line 703 of file defaultdevice.cpp.

bool INDI::DefaultDevice::deleteProperty ( const char *  propertyName)
virtual

Delete a property and unregister it. It will also be deleted from all clients.

Parameters
propertyNamename of property to be deleted.

Definition at line 677 of file defaultdevice.cpp.

virtual bool INDI::DefaultDevice::Disconnect ( )
protectedpure virtual

Disconnect from a device. Child classes must implement this function and perform the disconnection routine in the function.

Returns
True if disconnection from a device is successful, false otherwise.

Implemented in INDI::Telescope.

Examples:
dome.h, raindetector.h, simpleccd.h, simpledevice.h, and simpleskeleton.h.
virtual const char* INDI::DefaultDevice::getDefaultName ( )
protectedpure virtual
Returns
Default name of the device.
Examples:
dome.h, raindetector.h, simpleccd.h, simpledevice.h, simplescope.h, and simpleskeleton.h.
virtual const char* INDI::DefaultDevice::getDriverExec ( )
inlinevirtual
Returns
driver executable filename

Definition at line 177 of file defaultdevice.h.

uint16_t INDI::DefaultDevice::getDriverInterface ( )
virtual
Returns
getInterface Return the interface declared by the driver.

Reimplemented from INDI::BaseDevice.

Definition at line 620 of file defaultdevice.cpp.

virtual const char* INDI::DefaultDevice::getDriverName ( )
inlinevirtual
Returns
driver name

Definition at line 180 of file defaultdevice.h.

uint16_t INDI::DefaultDevice::getMajorVersion ( )
inline
Returns
Major driver version number.

Definition at line 189 of file defaultdevice.h.

uint16_t INDI::DefaultDevice::getMinorVersion ( )
inline
Returns
Minor driver version number.

Definition at line 192 of file defaultdevice.h.

bool INDI::DefaultDevice::initProperties ( )
protectedvirtual

Initilize properties initial state and value. The child class must implement this function.

Returns
True if initilization is successful, false otherwise.

Reimplemented in INDI::CCD, INDI::Dome, INDI::Telescope, INDI::Weather, INDI::GPS, INDI::FilterWheel, and INDI::Focuser.

Examples:
dome.cpp, dome.h, raindetector.h, and simpleskeleton.h.

Definition at line 634 of file defaultdevice.cpp.

bool INDI::DefaultDevice::isDebug ( )
protected
Returns
True if Debug is on, False otherwise.

Definition at line 441 of file defaultdevice.cpp.

void INDI::DefaultDevice::ISGetProperties ( const char *  dev)
virtual

define the driver's properties to the client. Usually, only a minimum set of properties are defined to the client in this function if the device is in disconnected state. Those properties should be enough to enable the client to establish a connection to the device. In addition to CONNECT/DISCONNECT, such properties may include port name, IP address, etc... You should check if the device is already connected, and if this is true, then you must define the remainder of the the properties to the client in this function. Otherwise, the remainder of the driver's properties are defined to the client in updateProperties() function which is called when a client connects/disconnects from a device.

Parameters
devname of the device
Note
This function is called by the INDI framework, do not call it directly. See LX200 Generic driver for an example implementation

Reimplemented in INDI::CCD, INDI::Dome, INDI::Telescope, INDI::FilterWheel, and INDI::Focuser.

Examples:
simpleskeleton.cpp, and simpleskeleton.h.

Definition at line 461 of file defaultdevice.cpp.

virtual bool INDI::DefaultDevice::ISNewBLOB ( const char *  dev,
const char *  name,
int  sizes[],
int  blobsizes[],
char *  blobs[],
char *  formats[],
char *  names[],
int  n 
)
inlinevirtual

Process the client newBLOB command.

Note
This function is called by the INDI framework, do not call it directly.
Returns
True if any property was successfully processed, false otherwise.
Examples:
simpleskeleton.h.

Definition at line 228 of file defaultdevice.h.

virtual bool INDI::DefaultDevice::ISNewNumber ( const char *  dev,
const char *  name,
double  values[],
char *  names[],
int  n 
)
inlinevirtual

Process the client newNumber command.

Note
This function is called by the INDI framework, do not call it directly.
Returns
True if any property was successfully processed, false otherwise.

Reimplemented in INDI::CCD, INDI::Dome, INDI::Telescope, INDI::Weather, INDI::FilterWheel, and INDI::Focuser.

Examples:
simpleskeleton.h.

Definition at line 216 of file defaultdevice.h.

bool INDI::DefaultDevice::ISNewSwitch ( const char *  dev,
const char *  name,
ISState states,
char *  names[],
int  n 
)
virtual

Process the client newSwitch command.

Note
This function is called by the INDI framework, do not call it directly.
Returns
True if any property was successfully processed, false otherwise.

Reimplemented in INDI::CCD, INDI::Dome, INDI::Telescope, INDI::Weather, INDI::GPS, INDI::FilterWheel, and INDI::Focuser.

Examples:
dome.cpp, dome.h, raindetector.h, simpleskeleton.cpp, and simpleskeleton.h.

Definition at line 200 of file defaultdevice.cpp.

virtual bool INDI::DefaultDevice::ISNewText ( const char *  dev,
const char *  name,
char *  texts[],
char *  names[],
int  n 
)
inlinevirtual

Process the client newSwitch command.

Note
This function is called by the INDI framework, do not call it directly.
Returns
True if any property was successfully processed, false otherwise.

Reimplemented in INDI::CCD, INDI::Dome, INDI::Telescope, INDI::FilterWheel, and INDI::Focuser.

Examples:
simpleskeleton.h.

Definition at line 222 of file defaultdevice.h.

bool INDI::DefaultDevice::isSimulation ( )
protected
Returns
True if Simulation is on, False otherwise.

Definition at line 446 of file defaultdevice.cpp.

virtual bool INDI::DefaultDevice::ISSnoopDevice ( XMLEle *  root)
inlinevirtual

Process a snoop event from INDI server. This function is called when a snooped property is updated in a snooped driver.

Note
This function is called by the INDI framework, do not call it directly.
Returns
True if any property was successfully processed, false otherwise.

Reimplemented in INDI::CCD, INDI::Dome, INDI::Telescope, INDI::Weather, INDI::Focuser, and INDI::FilterWheel.

Examples:
dome.h.

Definition at line 234 of file defaultdevice.h.

bool INDI::DefaultDevice::loadConfig ( bool  silent = false,
const char *  property = NULL 
)
protectedvirtual

Load the last saved configuration file.

Parameters
silentif true, don't report any error or notification messages.
propertyName of property to load configuration for. If NULL, all properties in the configuration file are loaded which is the default behavior.
Returns
True if successful, false otherwise.

Definition at line 70 of file defaultdevice.cpp.

bool INDI::DefaultDevice::loadDefaultConfig ( )
protectedvirtual

Load the default configuration file.

Returns
True if successful, false otherwise.

Definition at line 176 of file defaultdevice.cpp.

void INDI::DefaultDevice::RemoveTimer ( int  id)

Remove timer added with SetTimer.

Parameters
idID of the timer as returned from SetTimer

Definition at line 599 of file defaultdevice.cpp.

bool INDI::DefaultDevice::saveAllConfigItems ( FILE *  fp)
protectedvirtual

saveAllConfigItems Save all the drivers' properties in the configuration file

Parameters
fppointer to config file handler
Returns
True if successful, false otherwise.

Definition at line 100 of file defaultdevice.cpp.

bool INDI::DefaultDevice::saveConfig ( bool  silent = false)
protectedvirtual

Save the current properties in a configuration file.

Parameters
silentif true, don't report any error or notification messages.
Returns
True if successful, false otherwise.

Definition at line 145 of file defaultdevice.cpp.

bool INDI::DefaultDevice::saveConfigItems ( FILE *  fp)
protectedvirtual

saveConfigItems Save specific properties in the provide config file handler. Child class usually override this function to save their own properties and the base class saveConfigItems(fp) must be explicitly called by each child class. The Default Device saveConfigItems(fp) only save Debug properties options in the config file.

Parameters
fpPointer to config file handler
Returns
True if successful, false otherwise.

Reimplemented in INDI::CCD, INDI::Dome, INDI::Telescope, INDI::Weather, INDI::Focuser, and INDI::FilterWheel.

Definition at line 92 of file defaultdevice.cpp.

void INDI::DefaultDevice::setConnected ( bool  status,
IPState  state = IPS_OK,
const char *  msg = NULL 
)
virtual

Set connection switch status in the client.

Parameters
statusIf true, the driver will attempt to connect to the device (CONNECT=ON). If false, it will attempt to disconnect the device.
statusTrue to set CONNECT on, false to set DISCONNECT on.
stateState of CONNECTION properti, by default IPS_OK.
msgA message to be sent along with connect/disconnect command, by default NULL.

Definition at line 560 of file defaultdevice.cpp.

void INDI::DefaultDevice::setDebug ( bool  enable)
protected

Toggle driver debug status.

A driver can be more verbose if Debug option is enabled by the client.

Parameters
enableIf true, the Debug option is set to ON.

Definition at line 361 of file defaultdevice.cpp.

void INDI::DefaultDevice::setDriverInterface ( uint16_t  value)

setInterface Set driver interface. By default the driver interface is set to GENERAL_DEVICE. You may send an ORed list of DeviceInterface values.

Parameters
valueORed list of DeviceInterface values.

Definition at line 625 of file defaultdevice.cpp.

void INDI::DefaultDevice::setSimulation ( bool  enable)
protected

Toggle driver simulation status.

A driver can run in simulation mode if Simulation option is enabled by the client.

Parameters
enableIf true, the Simulation option is set to ON.

Definition at line 403 of file defaultdevice.cpp.

int INDI::DefaultDevice::SetTimer ( int  ms)

Set a timer to call the function TimerHit after ms milliseconds.

Parameters
mstimer duration in milliseconds.
Returns
id of the timer to be used with RemoveTimer

Definition at line 593 of file defaultdevice.cpp.

void INDI::DefaultDevice::setVersion ( uint16_t  vMajor,
uint16_t  vMinor 
)
inline

Set driver version information to be defined in DRIVER_INFO property as vMajor.vMinor.

Parameters
vMajormajor revision number
vMinorminor revision number

Definition at line 186 of file defaultdevice.h.

void INDI::DefaultDevice::simulationTriggered ( bool  enable)
protectedvirtual

Inform driver that the simulation option was triggered.

This function is called after setSimulation is triggered by the client. Reimplement this function if your driver needs to take specific action after simulation is enabled/disabled. Otherwise, you can use isSimulation() to check if simulation is enabled or disabled.

Parameters
enableIf true, the simulation option is set to ON.

Definition at line 456 of file defaultdevice.cpp.

bool INDI::DefaultDevice::updateProperties ( )
protectedvirtual

updateProperties is called whenever there is a change in the CONNECTION status of the driver. This will enable the driver to react to changes of switching ON/OFF a device. For example, a driver may only define a set of properties after a device is connected, but not before.

Returns
True if update is successful, false otherwise.

Reimplemented in INDI::CCD, INDI::Dome, INDI::Telescope, INDI::Weather, INDI::GPS, INDI::FilterWheel, and INDI::Focuser.

Examples:
dome.cpp, dome.h, and raindetector.h.

Definition at line 614 of file defaultdevice.cpp.


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