From f7238194310b77f21385286150295b284127b887 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 1 Apr 2014 21:28:36 +0300 Subject: [PATCH] Basic support for failed turnout detection --- source/libr2c2/driver.h | 1 + source/libr2c2/track.cpp | 11 +++++++++++ source/libr2c2/track.h | 1 + 3 files changed, 13 insertions(+) diff --git a/source/libr2c2/driver.h b/source/libr2c2/driver.h index 1222540..a0e5cc4 100644 --- a/source/libr2c2/driver.h +++ b/source/libr2c2/driver.h @@ -52,6 +52,7 @@ public: sigc::signal signal_loco_speed; sigc::signal signal_loco_function; sigc::signal signal_turnout; + sigc::signal signal_turnout_failed; sigc::signal signal_signal; sigc::signal signal_sensor; diff --git a/source/libr2c2/track.cpp b/source/libr2c2/track.cpp index 030d428..2ad3b53 100644 --- a/source/libr2c2/track.cpp +++ b/source/libr2c2/track.cpp @@ -1,5 +1,6 @@ #include #include +#include #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(t) diff --git a/source/libr2c2/track.h b/source/libr2c2/track.h index ad4ad21..bac4712 100644 --- a/source/libr2c2/track.h +++ b/source/libr2c2/track.h @@ -106,6 +106,7 @@ public: void save(std::list &) const; private: void turnout_event(unsigned, unsigned); + void turnout_failed(unsigned); }; } // namespace R2C2 -- 2.45.2