/usr/include/libindi/defaultdriver.h is in libindi-dev 0.8-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | #ifndef INDIDEFAULTDRIVER_H
#define INDIDEFAULTDRIVER_H
#include "basedriver.h"
#include "indidriver.h"
/**
* \class INDI::DefaultDriver
\brief Class to provide extended functionary for drivers in addition
to the functionality provided by INDI::BaseDriver. This class should \e only be subclassed by
drivers directly as it is linked with main(). Virtual drivers cannot employ INDI::DefaultDriver.
INDI::DefaultDriver 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 <a href='tutorial__four_8h_source.html'>Tutorial Four</a>
\author Jasem Mutlaq
*/
class INDI::DefaultDriver : public INDI::BaseDriver
{
public:
DefaultDriver();
virtual ~DefaultDriver() {}
/** \brief Add Debug, Simulation, and Configuration options to the driver */
void addAuxControls();
/** \brief Add Debug control to the driver */
void addDebugControl();
/** \brief Add Simulation control to the driver */
void addSimulationControl();
/** \brief Add Configuration control to the driver */
void addConfigurationControl();
/** \brief Set all properties to IDLE state */
void resetProperties();
/** \brief 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.
\param nvp The number vector property to be defined
*/
void defineNumber(INumberVectorProperty *nvp);
/** \brief 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.
\param tvp The text vector property to be defined
*/
void defineText(ITextVectorProperty *tvp);
/** \brief 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.
\param svp The switch vector property to be defined
*/
void defineSwitch(ISwitchVectorProperty *svp);
/** \brief 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.
\param lvp The light vector property to be defined
*/
void defineLight(ILightVectorProperty *lvp);
/** \brief 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.
\param bvp The BLOB vector property to be defined
*/
void defineBLOB(IBLOBVectorProperty *bvp);
/** \brief Delete a property and unregister it. It will also be deleted from all clients.
\param propertyName name of property to be deleted.
*/
virtual bool deleteProperty(const char *propertyName);
/** \brief Connect or Disconnect a device.
\param status If true, the driver will attempt to connect to the device (CONNECT=ON). If false, it will attempt
to disconnect the device.
\param msg A message to be sent along with connect/disconnect command.
*/
virtual void setConnected(bool status, IPState state=IPS_OK, const char *msg = NULL);
int SetTimer(int);
void RemoveTimer(int);
virtual void TimerHit();
protected:
/** \brief define the driver's properties to the client.
\param dev name of the device
\note This function is called by the INDI framework, do not call it directly.
*/
virtual void ISGetProperties (const char *dev);
/** \brief 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.
*/
virtual bool ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n);
/** \brief 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.
*/
virtual bool ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n) {return false;}
/** \brief 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.
*/
virtual bool ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n) {return false;}
// Configuration
/** \brief Load the last saved configuration file
\return True if successful, false otherwise.
*/
bool loadConfig();
/** \brief Save the current properties in a configuration file
\return True if successful, false otherwise.
*/
bool saveConfig();
/** \brief Load the default configuration file
\return True if successful, false otherwise.
*/
bool loadDefaultConfig();
// Simulatin & Debug
/** \brief Toggle driver debug status
A driver can be more verbose if Debug option is enabled by the client.
\param enable If true, the Debug option is set to ON.
*/
void setDebug(bool enable);
/** \brief Toggle driver simulation status
A driver can run in simulation mode if Simulation option is enabled by the client.
\param enable If true, the Simulation option is set to ON.
*/
void setSimulation(bool enable);
/** \return True if Debug is on, False otherwise. */
bool isDebug();
/** \return True if Simulation is on, False otherwise. */
bool isSimulation();
// These are the properties we define, that are generic to pretty much all devices
// They are public to make them available to all dervied classes and thier children
ISwitchVectorProperty *ConnectionSP;
ISwitch ConnectionS[2];
/** \brief Initilize properties initial state and value. The child class must implement this function.
\return True if initilization is successful, false otherwise.
*/
virtual bool initProperties();
/** \brief 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.
\return True if update is successful, false otherwise.
*/
virtual bool updateProperties();
/** \brief Connect to a device. Child classes must implement this function and perform the connection
routine in the function.
\return True if connection to device is successful, false otherwise.
*/
virtual bool Connect()=0;
/** \brief Disconnect from a device. Child classes must implement this function and perform the disconnection
routine in the function.
\return True if disconnection from a device is successful, false otherwise.
*/
virtual bool Disconnect()=0;
/** \return Default name of the device. */
virtual const char *getDefaultName()=0;
private:
bool pDebug;
bool pSimulation;
ISwitch DebugS[2];
ISwitch SimulationS[2];
ISwitch ConfigProcessS[3];
ISwitchVectorProperty *DebugSP;
ISwitchVectorProperty *SimulationSP;
ISwitchVectorProperty *ConfigProcessSP;
};
#endif // INDIDEFAULTDRIVER_H
|