]> git.tdb.fi Git - r2c2.git/blobdiff - source/libmarklin/control.h
Add state loading and saving to engineer
[r2c2.git] / source / libmarklin / control.h
index 4729695d7dbeb10d00e40f13578877a9f8493f61..0ec3d5ba53022a6f3d2bde7614547d1c24703ee0 100644 (file)
@@ -1,3 +1,10 @@
+/* $Id$
+
+This file is part of the MSP Märklin suite
+Copyright © 2006-2008 Mikkosoft Productions, Mikko Rasa
+Distributed under the GPL
+*/
+
 #ifndef LIBMARKLIN_CONTROL_H_
 #define LIBMARKLIN_CONTROL_H_
 
 namespace Marklin {
 
 class Command;
+class Reply;
 
 class Control
 {
 private:
        int  serial_fd;
-       bool p50_enabled;
        bool power;
        std::list<Command> queue;
        std::map<unsigned, Turnout *> turnouts;
@@ -30,33 +37,39 @@ private:
        Msp::Time::Timer timer;
 
 public:
+       sigc::signal<void, bool> signal_power_event;
        sigc::signal<void, unsigned, bool> signal_turnout_event;
        sigc::signal<void, unsigned, bool> signal_sensor_event;
 
        Control();
+       ~Control();
+
        void       set_power(bool);
        bool       get_power() const { return power; }
-       void       set_debug(bool d) { debug=d; }
-       //const TurnoutMap &get_turnouts() const { return turnouts; }
+       void       set_debug(bool);
        const std::map<unsigned, Sensor *> &get_sensors() const { return sensors; }
        unsigned   get_queue_length() const { return queue.size(); }
        void       open(const std::string &);
-       Command    &command(const std::string &);
+       Command    &command(Cmd);
+       Command    &command(Cmd, unsigned char);
+       Command    &command(Cmd, const unsigned char *, unsigned);
+
        void       add_turnout(Turnout &);
        Turnout    &get_turnout(unsigned) const;
        void       add_locomotive(Locomotive &);
        Locomotive &get_locomotive(unsigned) const;
        void       add_sensor(Sensor &);
        Sensor     &get_sensor(unsigned) const;
+
        void       tick();
        Msp::Time::Timer::Slot &set_timer(const Msp::Time::TimeDelta &);
-       ~Control();
 private:
        void read_all(int, char *, int);
        std::string read_reply(Cmd);
-       void event_query_done(Error, const std::string &);
-       void turnout_event_done(Error, const std::string &);
-       void sensor_event_done(Error, const std::string &);
+       void status_done(const Reply &);
+       void event_query_done(const Reply &);
+       void turnout_event_done(const Reply &);
+       void sensor_event_done(const Reply &);
 };
 
 } // namespace Marklin