+void Train::set_function(unsigned func, bool state)
+{
+ 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);
+}
+
+bool Train::get_function(unsigned func) const
+{
+ return (functions>>func)&1;
+}
+
+void Train::set_route(const Route *r)
+{
+ route = r;
+ signal_route_changed.emit(route);
+}
+
+void Train::place(Block &block, unsigned entry)
+{
+ if(target_speed)
+ set_speed(0);
+
+ release_blocks(rsv_blocks);
+ release_blocks(cur_blocks);
+
+ if(!block.reserve(this))