X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fintellibox.cpp;h=732e164c01b42660122d89fa15058b36fb94efc6;hb=a20b8421d002629a9f4d97c0c378e9f9cb29e292;hp=7702ed6b1bdde49b9309c2da9ef72f54fd3e2ae6;hpb=85362cce505281c1d281c959e135c9f8fa12bd5c;p=r2c2.git diff --git a/source/libr2c2/intellibox.cpp b/source/libr2c2/intellibox.cpp index 7702ed6..732e164 100644 --- a/source/libr2c2/intellibox.cpp +++ b/source/libr2c2/intellibox.cpp @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of R²C² -Copyright © 2010 Mikkosoft Productions, Mikko Rasa -Distributed under the GPL -*/ - #include #include #include @@ -242,7 +235,7 @@ void Intellibox::set_turnout(unsigned addr, unsigned state) { Turnout &turnout = turnouts[addr]; unsigned mask = (1<::iterator i=queue.begin(); i!=queue.end(); ++i) { write(serial_fd, i->data, i->length); @@ -601,6 +593,8 @@ void Intellibox::process_reply(const Time::TimeStamp &t) turnout.pending = turnout.state; signal_turnout.emit(addr, turnout.state); } + + turnout.synced = true; } else error(cmd, err); @@ -620,24 +614,22 @@ void Intellibox::process_reply(const Time::TimeStamp &t) unsigned speed = (data[0]<=1 ? 0 : data[0]*2/19+1); bool reverse = !(data[1]&0x20); - if(speed!=loco.speed || reverse!=loco.reverse) - { - loco.speed = speed; - loco.reverse = reverse; - signal_loco_speed.emit(addr, loco.speed, loco.reverse); - } + bool speed_changed = (speed!=loco.speed || reverse!=loco.reverse); + + loco.speed = speed; + loco.reverse = reverse; unsigned funcs = (data[1]&0xF)<<1; if(data[1]&0x10) funcs |= 1; - if(funcs!=loco.funcs) - { - unsigned changed = loco.funcs^funcs; - loco.funcs = funcs; - for(unsigned i=0; i<5; ++i) - if(changed&(1<