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)
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);
};
bool power;
+ bool halted;
std::map<unsigned, TurnoutState> turnouts;
std::map<unsigned, LocoState> locos;
std::map<unsigned, bool> sensors;
virtual void set_power(bool);
virtual bool get_power() const { return power; }
- virtual void halt(bool) { }
- virtual bool is_halted() const { return false; }
+ virtual void halt(bool);
+ virtual bool is_halted() const { return halted; }
virtual const char *enumerate_protocols(unsigned) const;
virtual unsigned get_protocol_speed_steps(const std::string &) const;