| 1 | #ifndef INDIDEFAULTDRIVER_H
|
|---|
| 2 | #define INDIDEFAULTDRIVER_H
|
|---|
| 3 |
|
|---|
| 4 | #include "basedriver.h"
|
|---|
| 5 | #include "indidriver.h"
|
|---|
| 6 |
|
|---|
| 7 | /**
|
|---|
| 8 | * \class INDI::DefaultDriver
|
|---|
| 9 | \brief Class to provide extended functionary for drivers in addition
|
|---|
| 10 | to the functionality provided by INDI::BaseDriver. This class should \e only be subclassed by
|
|---|
| 11 | drivers directly as it is linked with main(). Virtual drivers cannot employ INDI::DefaultDriver.
|
|---|
| 12 |
|
|---|
| 13 | INDI::DefaultDriver provides capability to add Debug, Simulation, and Configuration controls. These controls (switches) are
|
|---|
| 14 | defined to the client. Configuration options permit saving and loading of AS-IS property values.
|
|---|
| 15 |
|
|---|
| 16 | \see <a href='tutorial__four_8h_source.html'>Tutorial Four</a>
|
|---|
| 17 | \author Jasem Mutlaq
|
|---|
| 18 | */
|
|---|
| 19 | class INDI::DefaultDriver : public INDI::BaseDriver
|
|---|
| 20 | {
|
|---|
| 21 | public:
|
|---|
| 22 | DefaultDriver();
|
|---|
| 23 | virtual ~DefaultDriver() {}
|
|---|
| 24 |
|
|---|
| 25 | /** \brief Add Debug, Simulation, and Configuration options to the driver */
|
|---|
| 26 | void addAuxControls();
|
|---|
| 27 |
|
|---|
| 28 | /** \brief Set all properties to IDLE state */
|
|---|
| 29 | void resetProperties();
|
|---|
| 30 |
|
|---|
| 31 | protected:
|
|---|
| 32 |
|
|---|
| 33 | /** \brief define the driver's properties to the client.
|
|---|
| 34 | \param dev name of the device
|
|---|
| 35 | \note This function is called by the INDI framework, do not call it directly.
|
|---|
| 36 | */
|
|---|
| 37 | virtual void ISGetProperties (const char *dev);
|
|---|
| 38 |
|
|---|
| 39 | /** \brief Process the client newSwitch command
|
|---|
| 40 | \note This function is called by the INDI framework, do not call it directly.
|
|---|
| 41 | \returns True if any property was successfully processed, false otherwise.
|
|---|
| 42 | */
|
|---|
| 43 | virtual bool ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n);
|
|---|
| 44 |
|
|---|
| 45 | /** \brief Process the client newNumber command
|
|---|
| 46 | \note This function is called by the INDI framework, do not call it directly.
|
|---|
| 47 | \returns True if any property was successfully processed, false otherwise.
|
|---|
| 48 | */
|
|---|
| 49 | virtual bool ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n) {return false;}
|
|---|
| 50 |
|
|---|
| 51 | /** \brief Process the client newSwitch command
|
|---|
| 52 | \note This function is called by the INDI framework, do not call it directly.
|
|---|
| 53 | \returns True if any property was successfully processed, false otherwise.
|
|---|
| 54 | */
|
|---|
| 55 | virtual bool ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n) {return false;}
|
|---|
| 56 |
|
|---|
| 57 | // Configuration
|
|---|
| 58 |
|
|---|
| 59 | /** \brief Load the last saved configuration file
|
|---|
| 60 | \return True if successful, false otherwise.
|
|---|
| 61 | */
|
|---|
| 62 | bool loadConfig();
|
|---|
| 63 |
|
|---|
| 64 | /** \brief Save the current properties in a configuration file
|
|---|
| 65 | \return True if successful, false otherwise.
|
|---|
| 66 | */
|
|---|
| 67 | bool saveConfig();
|
|---|
| 68 |
|
|---|
| 69 | /** \brief Load the default configuration file
|
|---|
| 70 | \return True if successful, false otherwise.
|
|---|
| 71 | */
|
|---|
| 72 | bool loadDefaultConfig();
|
|---|
| 73 |
|
|---|
| 74 | // Simulatin & Debug
|
|---|
| 75 |
|
|---|
| 76 | /** \brief Toggle driver debug status
|
|---|
| 77 |
|
|---|
| 78 | A driver can be more verbose if Debug option is enabled by the client.
|
|---|
| 79 |
|
|---|
| 80 | \param enable If true, the Debug option is set to ON.
|
|---|
| 81 | */
|
|---|
| 82 | void setDebug(bool enable);
|
|---|
| 83 |
|
|---|
| 84 | /** \brief Toggle driver simulation status
|
|---|
| 85 |
|
|---|
| 86 | A driver can run in simulation mode if Simulation option is enabled by the client.
|
|---|
| 87 |
|
|---|
| 88 | \param enable If true, the Simulation option is set to ON.
|
|---|
| 89 | */
|
|---|
| 90 | void setSimulation(bool enable);
|
|---|
| 91 |
|
|---|
| 92 | /** \return True if Debug is on, False otherwise. */
|
|---|
| 93 | bool isDebug();
|
|---|
| 94 |
|
|---|
| 95 | /** \return True if Simulation is on, False otherwise. */
|
|---|
| 96 | bool isSimulation();
|
|---|
| 97 |
|
|---|
| 98 | private:
|
|---|
| 99 |
|
|---|
| 100 | bool pDebug;
|
|---|
| 101 | bool pSimulation;
|
|---|
| 102 |
|
|---|
| 103 | ISwitch DebugS[2];
|
|---|
| 104 | ISwitch SimulationS[2];
|
|---|
| 105 | ISwitch ConfigProcessS[3];
|
|---|
| 106 |
|
|---|
| 107 | ISwitchVectorProperty *DebugSP;
|
|---|
| 108 | ISwitchVectorProperty *SimulationSP;
|
|---|
| 109 | ISwitchVectorProperty *ConfigProcessSP;
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 | };
|
|---|
| 113 |
|
|---|
| 114 | #endif // INDIDEFAULTDRIVER_H
|
|---|