]> git.tdb.fi Git - r2c2.git/blob - source/libr2c2/sensor.h
849f899a9687d1be8d3e6a3f12992753917e8c08
[r2c2.git] / source / libr2c2 / sensor.h
1 #ifndef LIBR2C2_SENSOR_H_
2 #define LIBR2C2_SENSOR_H_
3
4 #include <sigc++/signal.h>
5 #include <msp/time/timedelta.h>
6
7 namespace R2C2 {
8
9 class Layout;
10
11 class Sensor: public sigc::trackable
12 {
13 public:
14         enum State
15         {
16                 INACTIVE,
17                 MAYBE_INACTIVE,
18                 MAYBE_ACTIVE,
19                 ACTIVE
20         };
21
22         sigc::signal<void, State> signal_state_changed;
23
24 protected:
25         Layout &layout;
26         unsigned address;
27         State state;
28         Msp::Time::TimeDelta state_confirm_timeout;
29
30         Sensor(Layout &);
31 public:
32         virtual ~Sensor();
33
34         unsigned get_address() const { return address; }
35         State get_state() const { return state; }
36
37         void tick(const Msp::Time::TimeDelta &);
38
39 private:
40         void event(unsigned, bool);
41 };
42
43 } // namespace R2C2
44
45 #endif