]> git.tdb.fi Git - r2c2.git/commitdiff
Basic support for failed turnout detection
authorMikko Rasa <tdb@tdb.fi>
Tue, 1 Apr 2014 18:28:36 +0000 (21:28 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 1 Apr 2014 18:28:36 +0000 (21:28 +0300)
source/libr2c2/driver.h
source/libr2c2/track.cpp
source/libr2c2/track.h

index 1222540c0b81e19bff985870c730124d2ea16b2f..a0e5cc434405a194e56099bd5e3f63dd7512e8b4 100644 (file)
@@ -52,6 +52,7 @@ public:
        sigc::signal<void, unsigned, unsigned, bool> signal_loco_speed;
        sigc::signal<void, unsigned, unsigned, bool> signal_loco_function;
        sigc::signal<void, unsigned, unsigned> signal_turnout;
+       sigc::signal<void, unsigned> signal_turnout_failed;
        sigc::signal<void, unsigned, unsigned> signal_signal;
        sigc::signal<void, unsigned, bool> signal_sensor;
 
index 030d428f18068dd6f8b7e7d08773c1a2d7155f83..2ad3b53dcffe2779d611aa43b4f5a6acab2a3482 100644 (file)
@@ -1,5 +1,6 @@
 #include <cmath>
 #include <msp/core/maputils.h>
+#include <msp/strings/format.h>
 #include "block.h"
 #include "catalogue.h"
 #include "driver.h"
@@ -48,6 +49,7 @@ Track::Track(Layout &l, const TrackType &t):
                        Driver &driver = layout.get_driver();
                        turnout_id = driver.add_turnout(turnout_addr, type);
                        driver.signal_turnout.connect(sigc::mem_fun(this, &Track::turnout_event));
+                       driver.signal_turnout_failed.connect(sigc::mem_fun(this, &Track::turnout_failed));
                }
        }
 
@@ -421,6 +423,15 @@ void Track::turnout_event(unsigned id, unsigned state)
        }
 }
 
+void Track::turnout_failed(unsigned id)
+{
+       if(id==turnout_id)
+       {
+               path_changing = false;
+               layout.emergency(format("Turnout %d failed", turnout_addr));
+       }
+}
+
 
 Track::Loader::Loader(Track &t):
        DataFile::ObjectLoader<Track>(t)
index ad4ad21066b9dfc9fe7f18985bf6795c6d94c7c5..bac4712322ba38ed46f2416fd3276d3e450c1902 100644 (file)
@@ -106,6 +106,7 @@ public:
        void save(std::list<Msp::DataFile::Statement> &) const;
 private:
        void turnout_event(unsigned, unsigned);
+       void turnout_failed(unsigned);
 };
 
 } // namespace R2C2