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