Layout::Layout(Catalogue &c, Driver *d):
catalogue(c),
driver(d)
-{ }
+{
+ if(driver)
+ driver->signal_sensor.connect(sigc::mem_fun(this, &Layout::sensor_event));
+}
Layout::~Layout()
{
i->second->tick(t, dt);
}
+void Layout::emergency(const string &msg)
+{
+ if(driver)
+ driver->halt(true);
+ signal_emergency.emit(msg);
+}
+
void Layout::save(const string &fn)
{
IO::BufferedFile out(fn, IO::M_WRITE);
}
}
+void Layout::sensor_event(unsigned addr, bool state)
+{
+ if(state)
+ {
+ for(set<Block *>::iterator i=blocks.begin(); i!=blocks.end(); ++i)
+ if((*i)->get_sensor_id()==addr)
+ {
+ if(!(*i)->get_train())
+ emergency("Unreserved sensor triggered");
+ break;
+ }
+ }
+}
+
Layout::Loader::Loader(Layout &l):
DataFile::BasicLoader<Layout>(l),