void Dummy::set_turnout(unsigned addr, bool state)
{
- turnouts[addr] = state;
- signal_turnout.emit(addr, state);
+ if(turnouts[addr]!=state)
+ {
+ turnouts[addr] = state;
+ signal_turnout.emit(addr, state);
+ }
}
bool Dummy::get_turnout(unsigned addr) const
return false;
}
+void Dummy::set_loco_speed(unsigned addr, unsigned speed)
+{
+ LocoState &loco = locos[addr];
+ loco.speed = speed;
+ signal_loco_speed.emit(addr, speed, loco.reverse);
+}
+
+void Dummy::set_loco_reverse(unsigned addr, bool rev)
+{
+ LocoState &loco = locos[addr];
+ loco.reverse = rev;
+ signal_loco_speed.emit(addr, loco.speed, rev);
+}
+
+void Dummy::set_loco_function(unsigned addr, unsigned func, bool state)
+{
+ signal_loco_function.emit(addr, func, state);
+}
+
} // namespace Marklin
class Dummy: public Driver
{
private:
+ struct LocoState
+ {
+ unsigned speed;
+ bool reverse;
+ };
+
bool power;
std::map<unsigned, bool> turnouts;
+ std::map<unsigned, LocoState> locos;
public:
Dummy();
virtual bool get_power() const { return power; }
virtual void add_loco(unsigned) { }
- virtual void set_loco_speed(unsigned, unsigned) { }
- virtual void set_loco_reverse(unsigned, bool) { }
- virtual void set_loco_function(unsigned, unsigned, bool) { }
+ virtual void set_loco_speed(unsigned, unsigned);
+ virtual void set_loco_reverse(unsigned, bool);
+ virtual void set_loco_function(unsigned, unsigned, bool);
virtual void add_turnout(unsigned);
virtual void set_turnout(unsigned, bool);