#include "driver.h"
#include "layout.h"
#include "timetable.h"
+#include "trackcircuit.h"
#include "train.h"
using namespace std;
train.signal_advanced.connect(sigc::mem_fun(this, &Timetable::train_advanced));
train.signal_ai_event.connect(sigc::mem_fun(this, &Timetable::event));
Layout &layout = train.get_layout();
- layout.signal_block_state_changed.connect(sigc::mem_fun(this, &Timetable::block_state_changed));
+ layout.signal_sensor_state_changed.connect(sigc::mem_fun(this, &Timetable::sensor_state_changed));
layout.signal_block_reserved.connect(sigc::mem_fun(this, &Timetable::block_reserved));
}
case TRAVEL_TO:
{
Block *block = &get_sensor(row.get_param<unsigned>(0));
- if(block->get_train()!=&train || block->get_state()<Block::MAYBE_ACTIVE)
+ if(block->get_train()!=&train || block->get_sensor().get_state()<Sensor::MAYBE_ACTIVE)
{
pending_block = block;
pending_train = &train;
{
Train *other_train = &train.get_layout().get_train(row.get_param<unsigned>(0));
Block *block = &get_sensor(row.get_param<unsigned>(1));
- if(block->get_train()!=other_train || block->get_state()<Block::MAYBE_ACTIVE)
+ if(block->get_train()!=other_train || block->get_sensor().get_state()<Sensor::MAYBE_ACTIVE)
{
pending_train = other_train;
pending_block = block;
return train.get_layout().get_zone(name.substr(0, space), number);
}
-void Timetable::block_state_changed(Block &block, Block::State state)
+void Timetable::sensor_state_changed(Sensor &sensor, Sensor::State state)
{
if(rows.empty() || !enabled)
return;
- if(&block==pending_block && block.get_train()==pending_train && state>=Block::MAYBE_ACTIVE)
+ Block *block = 0;
+ if(TrackCircuit *tc = dynamic_cast<TrackCircuit *>(&sensor))
+ block = &tc->get_block();
+ else
+ return;
+
+ if(block==pending_block && block->get_train()==pending_train && state>=Sensor::MAYBE_ACTIVE)
{
pending_block = 0;
current_row = (current_row+1)%rows.size();