layout.signal_emergency.connect(sigc::mem_fun(this, &Engineer::set_status));
const set<Block *> &blocks = layout.get_all<Block>();
for(set<Block *>::const_iterator i=blocks.begin(); i!=blocks.end(); ++i)
- (*i)->get_sensor().signal_state_changed.connect(sigc::hide(sigc::bind(sigc::mem_fun(this, &Engineer::reset_block_color), sigc::ref(**i))));
+ if(Sensor *sensor = (*i)->get_sensor())
+ sensor->signal_state_changed.connect(sigc::hide(sigc::bind(sigc::mem_fun(this, &Engineer::reset_block_color), sigc::ref(**i))));
if(FS::exists(options.state_fn))
DataFile::load(layout, options.state_fn);
void Engineer::reset_block_color(const Block &block)
{
- bool active = block.get_sensor().get_state()>Sensor::INACTIVE;
+ bool active = false;
+ if(Sensor *sensor = block.get_sensor())
+ active = sensor->get_state()>Sensor::INACTIVE;
if(block.get_train())
{
id(0),
sensor_id(start.get_sensor_id()),
turnout_id(start.get_turnout_id()),
+ sensor(0),
train(0)
{
add_track(start);
determine_id();
- sensor = new TrackCircuit(layout, *this);
+ if(sensor_id)
+ sensor = new TrackCircuit(layout, *this);
layout.add(*this);
}
unsigned get_id() const { return id; }
unsigned get_sensor_id() const { return sensor_id; }
unsigned get_turnout_id() const { return turnout_id; }
- TrackCircuit &get_sensor() const { return *sensor; }
+ TrackCircuit *get_sensor() const { return sensor; }
const std::vector<Endpoint> &get_endpoints() const { return endpoints; }
const Endpoint &get_endpoint(unsigned) const;
int get_endpoint_by_link(Block &) const;