]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/dummy.cpp
Implement halt in the dummy driver
[r2c2.git] / source / libr2c2 / dummy.cpp
index cfee07417b3105b75c2eba5a1029f3056ead320a..c28a3e16e9ae9c3a25d3a87c8b560b62c7e28c51 100644 (file)
@@ -18,6 +18,18 @@ void Dummy::set_power(bool p)
        signal_power.emit(power);
 }
 
+void Dummy::halt(bool h)
+{
+       halted = h;
+       if(halted)
+       {
+               for(map<unsigned, LocoState>::iterator i=locos.begin(); i!=locos.end(); ++i)
+                       if(i->second.speed)
+                               set_loco_speed(i->first, 0);
+       }
+       signal_halt.emit(halted);
+}
+
 const char *Dummy::enumerate_protocols(unsigned i) const
 {
        if(i==0)
@@ -65,6 +77,9 @@ unsigned Dummy::get_turnout(unsigned addr) const
 
 void Dummy::set_loco_speed(unsigned addr, unsigned speed)
 {
+       if(speed && halted)
+               return;
+
        LocoState &loco = locos[addr];
        loco.speed = speed;
        signal_loco_speed.emit(addr, speed, loco.reverse);