]> git.tdb.fi Git - r2c2.git/blob - source/libmarklin/sensor.h
45749ea28c142fe338436c378681b94a41fd0735
[r2c2.git] / source / libmarklin / sensor.h
1 /* $Id$
2
3 This file is part of the MSP Märklin suite
4 Copyright © 2007-2008  Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
6 */
7
8 #ifndef LIBMARKLIN_SENSOR_H_
9 #define LIBMARKLIN_SENSOR_H_
10
11 #include <list>
12 #include <map>
13 #include <sigc++/signal.h>
14 #include <msp/time/timestamp.h>
15
16 namespace Marklin {
17
18 class Control;
19
20 class Sensor
21 {
22 public:
23         sigc::signal<void, bool> signal_state_changed;
24
25 private:
26         Control &control;
27         unsigned addr;
28         bool state;
29         Msp::Time::TimeStamp off_timeout;
30
31 public:
32         Sensor(Control &, unsigned);
33
34         unsigned get_address() const { return addr; }
35         bool get_state() const { return state; }
36         void tick();
37 private:
38         void sensor_event(unsigned, bool);
39 };
40
41 } // namespace Marklin
42
43 #endif