if(layout.has_driver())
layout.get_driver().signal_locomotive_detected.connect(sigc::mem_fun(this, &Engineer::locomotive_detected));
layout.signal_train_added.connect(sigc::mem_fun(this, &Engineer::train_added));
- layout.signal_emergency.connect(sigc::mem_fun(this, &Engineer::set_status));
+ layout.signal_emergency.connect(sigc::mem_fun(this, &Engineer::emergency));
const set<Block *> &blocks = layout.get_all<Block>();
for(set<Block *>::const_iterator i=blocks.begin(); i!=blocks.end(); ++i)
if(TrackCircuit *tc = (*i)->get_sensor())
return layout.pick<Track>(Ray(start, Vector(ray)));
}
+void Engineer::emergency(Block *, const string &msg)
+{
+ set_status(msg);
+}
+
void Engineer::locomotive_detected(const Driver::DetectedLocomotive &loco)
{
if(!import_active)
void button_press(unsigned);
void axis_motion(unsigned, float, float);
void view_all();
- void sensor_event(unsigned, bool);
- void block_reserved(const R2C2::Block &, const R2C2::Train *);
R2C2::Object *pick_object(const R2C2::Vector &);
+ void emergency(R2C2::Block *, const std::string &);
void locomotive_detected(const R2C2::Driver::DetectedLocomotive &);
void import_finished(int);
void train_added(R2C2::Train &);
reserve_more();
}
else if(!is_block_current(*block))
- train.get_layout().emergency("Sensor for "+train.get_name()+" triggered out of order");
+ train.get_layout().emergency(block, "Sensor for "+train.get_name()+" triggered out of order");
}
else if(state==Sensor::INACTIVE)
advance_back();
i->second->tick(dt);
}
-void Layout::emergency(const string &msg)
+void Layout::emergency(Block *block, const string &msg)
{
if(driver)
driver->halt(true);
- IO::print("Emergency: %s\n", msg);
- signal_emergency.emit(msg);
+ if(block)
+ IO::print("Emergency at %s: %s\n", block->get_name(), msg);
+ else
+ IO::print("Emergency: %s\n", msg);
+ signal_emergency.emit(block, msg);
}
void Layout::save(const string &fn) const
{
Block *block = sensor.get_block();
if(block && !block->get_train())
- emergency(format("Unreserved sensor %d triggered", sensor.get_address()));
+ emergency(block, "Unreserved sensor triggered");
}
}
sigc::signal<void, Train &> signal_train_removed;
sigc::signal<void, Block &, Train *> signal_block_reserved;
sigc::signal<void, Sensor &, Sensor::State> signal_sensor_state_changed;
- sigc::signal<void, const std::string &> signal_emergency;
+ sigc::signal<void, Block *, const std::string &> signal_emergency;
private:
Catalogue &catalogue;
void remove_train(Train &);
void tick();
- void emergency(const std::string &);
+ void emergency(Block *, const std::string &);
void save(const std::string &) const;
void save_dynamic(const std::string &) const;
if(id==turnout_id)
{
path_changing = false;
- layout.emergency(format("Turnout %d failed", turnout_addr));
+ layout.emergency(block, "Turnout failed");
}
}
Vehicle &vehicle = *(reverse ? vehicles.back() : vehicles.front());
float d = speed*(dt/Time::sec);
- if(allocator.is_block_current(vehicle.get_placement().get_position(reverse ? VehiclePlacement::BACK_AXLE : VehiclePlacement::FRONT_AXLE)->get_block()))
+ Block &block = vehicle.get_placement().get_position(reverse ? VehiclePlacement::BACK_AXLE : VehiclePlacement::FRONT_AXLE)->get_block();
+ if(allocator.is_block_current(block))
{
SetFlag setf(advancing);
vehicle.advance(reverse ? -d : d);
overshoot_dist += d;
if(overshoot_dist>40*layout.get_catalogue().get_scale())
{
- layout.emergency(name+" has not arrived at sensor");
+ layout.emergency(&block, name+" has not arrived at sensor");
accurate_position = false;
}
}
send(pkt);
}
-void Server::emergency(const string &msg)
+void Server::emergency(Block *, const string &msg)
{
EmergencyPacket pkt;
pkt.message = msg;
void incoming_connection();
void driver_state_changed();
- void emergency(const std::string &);
+ void emergency(Block *, const std::string &);
void train_added(Train &);
void train_control_changed(const Train &, const std::string &, float);
void train_function_changed(const Train &, unsigned, bool);