3 This file is part of the MSP Märklin suite
4 Copyright © 2006-2009 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"
28 sigc::signal<void, bool> signal_power_event;
29 sigc::signal<void, unsigned, bool> signal_turnout_event;
30 sigc::signal<void, unsigned, bool> signal_sensor_event;
35 std::list<Command> queue;
36 std::map<unsigned, Turnout *> turnouts;
37 std::map<unsigned, Locomotive *> locomotives;
38 std::map<unsigned, Sensor *> sensors;
39 Msp::Time::TimeStamp next_event_query;
42 Msp::Time::Timer timer;
48 void open(const std::string &);
51 bool get_power() const { return power; }
52 Command &command(Cmd);
53 Command &command(Cmd, unsigned char);
54 Command &command(Cmd, const unsigned char *, unsigned);
55 unsigned get_queue_length() const { return queue.size(); }
58 void add_turnout(Turnout &);
59 Turnout &get_turnout(unsigned) const;
60 const std::map<unsigned, Turnout *> &get_turnouts() const { return turnouts; }
61 void add_locomotive(Locomotive &);
62 Locomotive &get_locomotive(unsigned) const;
63 const std::map<unsigned, Locomotive *> &get_locomotives() const { return locomotives; }
64 void add_sensor(Sensor &);
65 Sensor &get_sensor(unsigned) const;
66 const std::map<unsigned, Sensor *> &get_sensors() const { return sensors; }
69 Msp::Time::Timer::Slot &set_timer(const Msp::Time::TimeDelta &);
71 void status_done(const Reply &);
72 void event_query_done(const Reply &);
73 void turnout_event_done(const Reply &);
74 void sensor_event_done(const Reply &);
77 } // namespace Marklin