3 This file is part of the MSP Märklin suite
4 Copyright © 2006-2008 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
8 #ifndef LIBMARKLIN_CONTROL_H_
9 #define LIBMARKLIN_CONTROL_H_
13 #include <msp/time/timer.h>
14 #include <msp/time/timestamp.h>
15 #include "constants.h"
17 #include "locomotive.h"
30 std::list<Command> queue;
31 std::map<unsigned, Turnout *> turnouts;
32 std::map<unsigned, Locomotive *> locomotives;
33 std::map<unsigned, Sensor *> sensors;
34 Msp::Time::TimeStamp next_event_query;
37 Msp::Time::Timer timer;
40 sigc::signal<void, bool> signal_power_event;
41 sigc::signal<void, unsigned, bool> signal_turnout_event;
42 sigc::signal<void, unsigned, bool> signal_sensor_event;
48 bool get_power() const { return power; }
50 const std::map<unsigned, Sensor *> &get_sensors() const { return sensors; }
51 unsigned get_queue_length() const { return queue.size(); }
52 void open(const std::string &);
53 Command &command(Cmd);
54 Command &command(Cmd, unsigned char);
55 Command &command(Cmd, const unsigned char *, unsigned);
57 void add_turnout(Turnout &);
58 Turnout &get_turnout(unsigned) const;
59 void add_locomotive(Locomotive &);
60 Locomotive &get_locomotive(unsigned) const;
61 void add_sensor(Sensor &);
62 Sensor &get_sensor(unsigned) const;
65 Msp::Time::Timer::Slot &set_timer(const Msp::Time::TimeDelta &);
67 void read_all(int, char *, int);
68 std::string read_reply(Cmd);
69 void status_done(const Reply &);
70 void event_query_done(const Reply &);
71 void turnout_event_done(const Reply &);
72 void sensor_event_done(const Reply &);
75 } // namespace Marklin