brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 1 | #ifndef AOS_INPUT_SENSOR_INPUT_H_ |
| 2 | #define AOS_INPUT_SENSOR_INPUT_H_ |
| 3 | |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 4 | #ifdef __VXWORKS__ |
| 5 | #include <vector> |
| 6 | #include <semLib.h> |
| 7 | #endif |
| 8 | |
| 9 | namespace aos { |
| 10 | |
| 11 | // Class for implementing code that takes information from a sensor struct and |
| 12 | // places it into queues. Subclasses should be compiled for both the atom and |
| 13 | // the crio to support crio control loops. |
| 14 | template<class Values> class SensorInput { |
| 15 | protected: |
| 16 | virtual void RunIteration(Values &values) = 0; |
| 17 | public: |
| 18 | // Enters an infinite loop that reads values and calls RunIteration. |
| 19 | void Run(); |
| 20 | |
| 21 | #ifdef __VXWORKS__ |
| 22 | // Calls RunIteration on all instances with values. |
| 23 | static void RunIterationAll(Values &values); |
| 24 | private: |
| 25 | static SEM_ID lock_; |
| 26 | static std::vector<SensorInput *> running_; |
| 27 | #endif |
| 28 | }; |
| 29 | |
| 30 | } // namespace aos |
| 31 | |
| 32 | #include "SensorInput-tmpl.h" |
| 33 | |
| 34 | #endif |
| 35 | |