]> git.tdb.fi Git - r2c2.git/blob - source/libmarklin/turnout.h
c7a603c78e53db9224b75951aa3474d107c62338
[r2c2.git] / source / libmarklin / turnout.h
1 /* $Id$
2
3 This file is part of the MSP Märklin suite
4 Copyright © 2006-2009 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
6 */
7
8 #ifndef LIBMARKLIN_TURNOUT_H_
9 #define LIBMARKLIN_TURNOUT_H_
10
11 #include <list>
12 #include <map>
13 #include <string>
14 #include <sigc++/sigc++.h>
15 #include "constants.h"
16
17 namespace Marklin {
18
19 class Control;
20 class Reply;
21
22 class Turnout
23 {
24 public:
25         sigc::signal<void, unsigned> signal_path_changing;
26         sigc::signal<void, unsigned> signal_path_changed;
27
28 private:
29         Control &control;
30         unsigned addr;
31         unsigned char path;
32         unsigned char pending_path;
33         unsigned char pending_cmds;
34         bool dual;
35         bool on;
36
37 public:
38         Turnout(Control &, unsigned, bool =false);
39
40         void set_path(unsigned char);
41         unsigned get_address() const { return addr; }
42         unsigned char get_path() const { return path; }
43 private:
44         void command(unsigned char);
45         void command_reply(const Reply &, unsigned char);
46         void status_reply(const Reply &, unsigned char);
47         void turnout_event(unsigned, bool);
48 };
49
50 } // namespace Marklin
51
52 #endif