From: Mikko Rasa Date: Fri, 23 Apr 2010 17:11:04 +0000 (+0000) Subject: Fix problems with turnouts X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=52c1f07901c422ddfff93a6b4d6852b974383469;p=r2c2.git Fix problems with turnouts --- diff --git a/source/libmarklin/intellibox.cpp b/source/libmarklin/intellibox.cpp index 70372f4..6efe875 100644 --- a/source/libmarklin/intellibox.cpp +++ b/source/libmarklin/intellibox.cpp @@ -161,6 +161,7 @@ void Intellibox::set_turnout(unsigned addr, bool state) turnout.pending = state; turnout.active = true; + turnout.off_timeout = Time::TimeStamp(); turnout_command(addr, state, true); } @@ -376,7 +377,10 @@ void Intellibox::process_reply(const Time::TimeStamp &t) read_all(data, 2); unsigned addr = data[0]+((data[1]&7)<<8); - signal_turnout.emit(addr, (data[1]&0x80)!=0); + Turnout &turnout = turnouts[addr]; + turnout.state = (data[1]&0x80)!=0; + turnout.pending = turnout.state; + signal_turnout.emit(addr, turnout.state); } } else if(cmd==CMD_EVENT_SENSOR) @@ -461,6 +465,7 @@ void Intellibox::process_reply(const Time::TimeStamp &t) if(state!=turnout.state) { turnout.state = state; + turnout.pending = state; signal_turnout.emit(addr, turnout.state); } } @@ -540,7 +545,8 @@ Intellibox::Locomotive::Locomotive(): Intellibox::Turnout::Turnout(): state(false), - active(false) + active(false), + pending(false) { }