A simple WIP that logs data from a Grove sensor, and can send and receive information over USB and SMS.
Dependencies: DHT DS_1337 SDFileSystem USBDevice mbed
Handlers/AbstractHandler.h@0:2df78a4443cd, 2016-04-10 (annotated)
- Committer:
- Joseph Radford
- Date:
- Sun Apr 10 15:47:33 2016 +1000
- Revision:
- 0:2df78a4443cd
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Joseph Radford |
0:2df78a4443cd | 1 | #ifndef __ABSTRACT_HANDLER_H__ |
Joseph Radford |
0:2df78a4443cd | 2 | #define __ABSTRACT_HANDLER_H__ |
Joseph Radford |
0:2df78a4443cd | 3 | |
Joseph Radford |
0:2df78a4443cd | 4 | #include "../timers.h" |
Joseph Radford |
0:2df78a4443cd | 5 | |
Joseph Radford |
0:2df78a4443cd | 6 | /*! |
Joseph Radford |
0:2df78a4443cd | 7 | * \brief The AbstractHandler class is inherited by all handlers. It forms the basis of any handler, by having |
Joseph Radford |
0:2df78a4443cd | 8 | * a simple \a run function, called in main.cpp, and a \a setRequest function which is used to set a request |
Joseph Radford |
0:2df78a4443cd | 9 | * specific to the reimplemented class. |
Joseph Radford |
0:2df78a4443cd | 10 | */ |
Joseph Radford |
0:2df78a4443cd | 11 | class AbstractHandler |
Joseph Radford |
0:2df78a4443cd | 12 | { |
Joseph Radford |
0:2df78a4443cd | 13 | public: |
Joseph Radford |
0:2df78a4443cd | 14 | AbstractHandler(MyTimers *_timer) : m_timer(_timer) {} |
Joseph Radford |
0:2df78a4443cd | 15 | ~AbstractHandler() {} |
Joseph Radford |
0:2df78a4443cd | 16 | |
Joseph Radford |
0:2df78a4443cd | 17 | /*! |
Joseph Radford |
0:2df78a4443cd | 18 | * \brief run is inherited by each Handler class. It is called from the main while loop in main.cpp. |
Joseph Radford |
0:2df78a4443cd | 19 | * It runs through the state machine, specific to each Handler class. |
Joseph Radford |
0:2df78a4443cd | 20 | */ |
Joseph Radford |
0:2df78a4443cd | 21 | virtual void run() = 0; // run the handler |
Joseph Radford |
0:2df78a4443cd | 22 | |
Joseph Radford |
0:2df78a4443cd | 23 | /*! |
Joseph Radford |
0:2df78a4443cd | 24 | * \brief setRequest sets a request that the handler will complete when it is able to |
Joseph Radford |
0:2df78a4443cd | 25 | * \param request unique to the reimplemented class (an enum) that will be completed in the state machine |
Joseph Radford |
0:2df78a4443cd | 26 | * \param message an optional array of information relevant to the \a request |
Joseph Radford |
0:2df78a4443cd | 27 | */ |
Joseph Radford |
0:2df78a4443cd | 28 | virtual void setRequest(int request, void *data = 0) = 0; |
Joseph Radford |
0:2df78a4443cd | 29 | |
Joseph Radford |
0:2df78a4443cd | 30 | protected: |
Joseph Radford |
0:2df78a4443cd | 31 | MyTimers *m_timer; ///< Handler classes use timers to pause in the state machine, and continue after delay has finished |
Joseph Radford |
0:2df78a4443cd | 32 | }; |
Joseph Radford |
0:2df78a4443cd | 33 | |
Joseph Radford |
0:2df78a4443cd | 34 | #endif // __ABSTRACT_HANDLER_H__ |