]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/intellibox.cpp
Refer to things in the driver with abstract ids instead of addresses
[r2c2.git] / source / libr2c2 / intellibox.cpp
index 338aed2544127844dff4de200cf7bbffc90f2a2a..975c143fe46baf904d00db9b19a3777c68d627a1 100644 (file)
@@ -93,7 +93,7 @@ unsigned Intellibox::get_protocol_speed_steps(const string &proto_name) const
        return 0;
 }
 
-void Intellibox::add_loco(unsigned addr, const string &proto_name, const VehicleType &type)
+unsigned Intellibox::add_loco(unsigned addr, const string &proto_name, const VehicleType &type)
 {
        Protocol proto = map_protocol(proto_name);
 
@@ -112,6 +112,8 @@ void Intellibox::add_loco(unsigned addr, const string &proto_name, const Vehicle
                data[1] = (addr>>8)&0xFF;
                command(CMD_LOK_STATUS, addr, data, 2);
        }
+
+       return addr;
 }
 
 void Intellibox::remove_loco(unsigned addr)
@@ -197,9 +199,9 @@ void Intellibox::set_loco_function(unsigned addr, unsigned func, bool state)
        signal_loco_function.emit(addr, func, state);
 }
 
-void Intellibox::add_turnout(unsigned addr, const TrackType &type)
+unsigned Intellibox::add_turnout(unsigned addr, const TrackType &type)
 {
-       add_turnout(addr, type.get_state_bits(), false);
+       return add_turnout(addr, type.get_state_bits(), false);
 }
 
 void Intellibox::remove_turnout(unsigned addr)
@@ -207,7 +209,7 @@ void Intellibox::remove_turnout(unsigned addr)
        turnouts.erase(addr);
 }
 
-void Intellibox::add_turnout(unsigned addr, unsigned bits, bool signal)
+unsigned Intellibox::add_turnout(unsigned addr, unsigned bits, bool signal)
 {
        if(!turnouts.count(addr))
        {
@@ -229,6 +231,8 @@ void Intellibox::add_turnout(unsigned addr, unsigned bits, bool signal)
                        command(CMD_TURNOUT_STATUS, addr+i, data, 2);
                }
        }
+
+       return addr;
 }
 
 void Intellibox::turnout_state_changed(unsigned addr, const Turnout &turnout) const
@@ -269,9 +273,9 @@ unsigned Intellibox::get_turnout(unsigned addr) const
        return 0;
 }
 
-void Intellibox::add_signal(unsigned addr, const SignalType &)
+unsigned Intellibox::add_signal(unsigned addr, const SignalType &)
 {
-       add_turnout(addr, 1, true);
+       return add_turnout(addr, 1, true);
 }
 
 void Intellibox::remove_signal(unsigned addr)
@@ -289,13 +293,15 @@ unsigned Intellibox::get_signal(unsigned addr) const
        return get_turnout(addr);
 }
 
-void Intellibox::add_sensor(unsigned addr)
+unsigned Intellibox::add_sensor(unsigned addr)
 {
        if(!sensors.count(addr))
        {
                sensors[addr];
                update_sensors = true;
        }
+
+       return addr;
 }
 
 void Intellibox::remove_sensor(unsigned addr)