]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/dummy.h
Simulate a delay for switching turnouts in the Dummy driver
[r2c2.git] / source / libr2c2 / dummy.h
index 469b7f2f7b9ade735bfe951d1fba0740a527f608..2c6f992c64d05ee5ca7cba8456093abdebe6d0db 100644 (file)
@@ -2,6 +2,8 @@
 #define LIBR2C2_DUMMY_H_
 
 #include <map>
+#include <msp/time/timedelta.h>
+#include <msp/time/timestamp.h>
 #include "driver.h"
 
 namespace R2C2 {
@@ -9,6 +11,13 @@ namespace R2C2 {
 class Dummy: public Driver
 {
 private:
+       struct TurnoutState
+       {
+               unsigned state;
+               unsigned pending;
+               Msp::Time::TimeStamp timeout;
+       };
+
        struct LocoState
        {
                unsigned speed;
@@ -16,12 +25,13 @@ private:
        };
 
        bool power;
-       std::map<unsigned, unsigned> turnouts;
+       std::map<unsigned, TurnoutState> turnouts;
        std::map<unsigned, LocoState> locos;
        std::map<unsigned, bool> sensors;
+       Msp::Time::TimeDelta turnout_delay;
 
 public:
-       Dummy();
+       Dummy(const std::string &);
 
        virtual void set_power(bool);
        virtual bool get_power() const { return power; }
@@ -47,7 +57,7 @@ public:
        virtual void set_sensor(unsigned, bool);
        virtual bool get_sensor(unsigned) const;
 
-       virtual void tick() { }
+       virtual void tick();
        virtual void flush() { }
 };