blob: fa99bab9dfbc57dcc6a6481dd8a0da5eacb477cd [file] [log] [blame]
brians343bc112013-02-10 01:53:46 +00001#ifndef AOS_INPUT_SENSOR_INPUT_H_
2#define AOS_INPUT_SENSOR_INPUT_H_
3
brians343bc112013-02-10 01:53:46 +00004#ifdef __VXWORKS__
5#include <vector>
6#include <semLib.h>
7#endif
8
9namespace 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.
14template<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