]> git.tdb.fi Git - r2c2.git/blob - source/libmarklin/locomotive.h
Initial revision
[r2c2.git] / source / libmarklin / locomotive.h
1 #ifndef LIBMARKLIN_LOCOMOTIVE_H_
2 #define LIBMARKLIN_LOCOMOTIVE_H_
3
4 #include <list>
5 #include <string>
6 #include "constants.h"
7
8 namespace Marklin {
9
10 class Control;
11
12 class Locomotive
13 {
14 public:
15         Locomotive(Control &, unsigned);
16         void     set_speed(unsigned);
17         void     set_reverse(bool);
18         void     set_function(unsigned, bool);
19         unsigned get_address() const   { return addr; }
20         unsigned get_speed() const     { return speed; }
21         bool     get_reverse() const   { return reverse; }
22         bool     get_function(unsigned f) const { return (funcs>>f)&1; }
23         void     refresh_status();
24 private:
25         Control  &control;
26         unsigned addr;
27         unsigned speed;
28         bool     reverse;
29         unsigned funcs;
30
31         void     send_command(bool);
32         void     status_reply(Error, const std::string &);
33         bool     reverse_timeout();
34 };
35 typedef std::list<Locomotive *> LocomotiveSeq;
36
37 } // namespace Marklin
38
39 #endif