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(const std::string &);
55 void add_turnout(Turnout &);
56 Turnout &get_turnout(unsigned) const;
57 void add_locomotive(Locomotive &);
58 Locomotive &get_locomotive(unsigned) const;
59 void add_sensor(Sensor &);
60 Sensor &get_sensor(unsigned) const;
63 Msp::Time::Timer::Slot &set_timer(const Msp::Time::TimeDelta &);
65 void read_all(int, char *, int);
66 std::string read_reply(Cmd);
67 void status_done(Error, const std::string &);
68 void event_query_done(Error, const std::string &);
69 void turnout_event_done(Error, const std::string &);
70 void sensor_event_done(Error, const std::string &);
73 } // namespace Marklin