]> git.tdb.fi Git - r2c2.git/blobdiff - source/libmarklin/dummy.cpp
Add a set_sensor function to the Driver interface
[r2c2.git] / source / libmarklin / dummy.cpp
index 99e97933879accb2eacf4e3994451d66914a89ee..b8478a2fe95c10e7f27843a531f658f26df72c04 100644 (file)
@@ -62,4 +62,21 @@ void Dummy::set_loco_function(unsigned addr, unsigned func, bool state)
        signal_loco_function.emit(addr, func, state);
 }
 
+void Dummy::set_sensor(unsigned addr, bool state)
+{
+       if(sensors[addr]!=state)
+       {
+               sensors[addr] = state;
+               signal_sensor.emit(addr, state);
+       }
+}
+
+bool Dummy::get_sensor(unsigned addr) const
+{
+       map<unsigned, bool>::const_iterator i = sensors.find(addr);
+       if(i!=sensors.end())
+               return i->second;
+       return false;
+}
+
 } // namespace Marklin