From: Mikko Rasa Date: Tue, 1 Apr 2014 18:35:31 +0000 (+0300) Subject: Use current monitoring to detect failed turnouts X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=5bc94d60a17039dfd5d46caaa292d3667fa87fb3;p=r2c2.git Use current monitoring to detect failed turnouts The turnout solenoid takes quite a bit of current, which is easy to detect. If there's no current spike after activating a solenoid, it may have a broken microswitch that prevents operation. --- diff --git a/source/libr2c2/arducontrol.cpp b/source/libr2c2/arducontrol.cpp index dbe3013..fa95a69 100644 --- a/source/libr2c2/arducontrol.cpp +++ b/source/libr2c2/arducontrol.cpp @@ -405,6 +405,8 @@ void ArduControl::tick() acc.state.set(acc.state^lowest_bit); PendingCommand cmd(acc, Accessory::ACTIVATE, i); command_queue.push(cmd); + + monitor.reset_peak(); } else accessory_queue.pop_front(); @@ -415,8 +417,23 @@ void ArduControl::tick() Time::TimeStamp t = Time::now(); if(t>off_timeout) { + Accessory &acc = *active_accessory; + + if(acc.kind==Accessory::TURNOUT && monitor.get_peak()<0.5f) + { + unsigned bit = 1< state; + unsigned uncertain; unsigned target; Msp::Time::TimeDelta active_time;