layout.add_train(*this);
- layout.get_driver().add_loco(address, protocol);
+ 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 InvalidParameterValue("Invalid function");
- if(func<5)
- layout.get_driver().set_loco_function(address, func, state);
- else
- layout.get_driver().set_loco_function(address+1, func-4, state);
+ layout.get_driver().set_loco_function(address, func, state);
}
float Train::get_control(const string &ctrl) const
signal_control_changed.emit(ctrl.name, ctrl.value);
}
-void Train::loco_speed_event(unsigned addr, unsigned speed, bool)
+void Train::loco_speed_event(unsigned addr, unsigned speed, bool rev)
{
if(addr==address)
{
current_speed_step = speed;
+ if(rev!=reverse)
+ layout.get_driver().set_loco_reverse(address, reverse);
speed_changing = false;
pure_speed = false;
}
void Train::loco_func_event(unsigned addr, unsigned func, bool state)
{
- if(addr==address || (addr==address+1 && loco_type.get_max_function()>4))
+ if(addr==address)
{
- if(addr==address+1)
- func += 4;
if(state)
functions |= 1<<func;
else
if(!block || block->get_endpoints().size()<2)
{
if(!blocking_train)
+ {
good_end = blocks.end();
+ end_of_route = true;
+ }
break;
}
contested_blocks.push_back(block);
continue;
}
- else if(divert_track && (entry_conflict || exit_conflict))
+ else if(divert_track && (entry_conflict || exit_conflict || !other_train->is_active()))
// We are blocked, but there's a diversion possibility
try_divert = true;