]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/intellibox.h
Simplify some interfaces by using track and block iterators
[r2c2.git] / source / libr2c2 / intellibox.h
index a4eed30d4bcf0cda32e28c80ee2748c786d7872a..4740a1ec6d6f2ccb611a5b5d2b4913eaaca5c37e 100644 (file)
@@ -1,14 +1,8 @@
-/* $Id$
-
-This file is part of R²C²
-Copyright © 2010  Mikkosoft Productions, Mikko Rasa
-Distributed under the GPL
-*/
-
 #ifndef LIBR2C2_INTELLIBOX_H_
 #define LIBR2C2_INTELLIBOX_H_
 
 #include <map>
+#include <msp/io/serial.h>
 #include <msp/time/timestamp.h>
 #include "driver.h"
 
@@ -68,7 +62,7 @@ private:
                ERR_NO_I2C_SPACE,
                ERR_LOW_TURNOUT_SPACE=0x40,
                ERR_LOK_HALTED,
-               ERR_LOK_POWER_OFF,
+               ERR_LOK_POWER_OFF
        };
 
        enum Protocol
@@ -91,13 +85,16 @@ private:
                Locomotive();
        };
 
+       // These are used for signals as well, but Intellibox calls them turnouts.
        struct Turnout
        {
                unsigned bits;
                unsigned state;
                bool active;
+               bool synced;
                unsigned pending;
                Msp::Time::TimeStamp off_timeout;
+               bool signal;
 
                Turnout();
        };
@@ -118,7 +115,7 @@ private:
                unsigned length;
        };
 
-       int serial_fd;
+       Msp::IO::Serial serial;
        bool power;
        bool halted;
        std::map<unsigned, Locomotive> locos;
@@ -145,9 +142,18 @@ public:
        virtual void set_loco_function(unsigned, unsigned, bool);
 
        virtual void add_turnout(unsigned, const TrackType &);
+private:
+       void add_turnout(unsigned, unsigned, bool);
+       void turnout_state_changed(unsigned, const Turnout &) const;
+public:
        virtual void set_turnout(unsigned, unsigned);
        virtual unsigned get_turnout(unsigned) const;
 
+       virtual void add_signal(unsigned, const SignalType &);
+       virtual void set_signal(unsigned, unsigned);
+       virtual unsigned get_signal(unsigned) const;
+
+public:
        virtual void add_sensor(unsigned);
        virtual void set_sensor(unsigned, bool) { }
        virtual bool get_sensor(unsigned) const;