]> git.tdb.fi Git - r2c2.git/commitdiff
Fix problems with turnouts
authorMikko Rasa <tdb@tdb.fi>
Fri, 23 Apr 2010 17:11:04 +0000 (17:11 +0000)
committerMikko Rasa <tdb@tdb.fi>
Fri, 23 Apr 2010 17:11:04 +0000 (17:11 +0000)
source/libmarklin/intellibox.cpp

index 70372f4f10dae20b930f091affe7cc80416249a4..6efe8750a188e7dce26efeb4585d46fd438c1ba9 100644 (file)
@@ -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)
 { }