+ if(type.is_turnout())
+ throw InvalidState("Can't set sensor on a turnout");
+
+ sensor_id = i;
+ layout.create_blocks(*this);
+ if(layout.has_driver() && sensor_id)
+ layout.get_driver().add_sensor(sensor_id);
+}
+
+void Track::set_active_path(unsigned p)
+{
+ if(!turnout_id)
+ throw InvalidState("Not a turnout");
+ if(!(type.get_paths()&(1<<p)))
+ throw InvalidParameterValue("Invalid path");
+
+ layout.get_driver().set_turnout(turnout_id, p&1);
+ if(type.is_double_address())
+ layout.get_driver().set_turnout(turnout_id+1, p&2);
+ else if(type.get_n_paths()>2)
+ active_path = (active_path&1) | (p&2);