layout.add_train(*this);
- layout.get_driver().add_loco(address, protocol, loco_type);
+ loco_id = layout.get_driver().add_loco(address, protocol, loco_type);
layout.get_driver().signal_loco_speed.connect(sigc::mem_fun(this, &Train::loco_speed_event));
layout.get_driver().signal_loco_function.connect(sigc::mem_fun(this, &Train::loco_func_event));
{
if(!loco_type.get_functions().count(func))
throw invalid_argument("Train::set_function");
- layout.get_driver().set_loco_function(address, func, state);
+ layout.get_driver().set_loco_function(loco_id, func, state);
}
float Train::get_control(const string &ctrl) const
dist += i->get_path_length(i.entry());
- if(i->get_sensor_id())
+ if(i->get_sensor_address())
sensor_seen = true;
}
bool r = reverse;
if(loco_type.get_swap_direction())
r = !r;
- driver.set_loco_reverse(address, r);
+ driver.set_loco_reverse(loco_id, r);
allocator.reverse();
last_entry_block = BlockIter();
if(speed_step!=current_speed_step && !speed_changing && !driver.is_halted() && driver.get_power())
{
speed_changing = true;
- driver.set_loco_speed(address, speed_step);
+ driver.set_loco_speed(loco_id, speed_step);
pure_speed = false;
}
signal_control_changed.emit(ctrl.name, ctrl.value);
}
-void Train::loco_speed_event(unsigned addr, unsigned speed, bool rev)
+void Train::loco_speed_event(unsigned id, unsigned speed, bool rev)
{
- if(addr==address)
+ if(id==loco_id)
{
current_speed_step = speed;
bool r = reverse;
if(loco_type.get_swap_direction())
r = !r;
if(rev!=r)
- layout.get_driver().set_loco_reverse(address, r);
+ layout.get_driver().set_loco_reverse(loco_id, r);
speed_changing = false;
pure_speed = false;
}
}
-void Train::loco_func_event(unsigned addr, unsigned func, bool state)
+void Train::loco_func_event(unsigned id, unsigned func, bool state)
{
- if(addr==address)
+ if(id==loco_id)
{
if(state)
functions |= 1<<func;
if(last_entry_block && &*last_entry_block!=block)
{
for(BlockIter i=last_entry_block.next(); (i && &*i!=block); i=i.next())
- if(i->get_train()!=this || i->get_sensor_id())
+ if(i->get_train()!=this || i->get_sensor_address())
return;
}