#include <msp/time/units.h>
#include <msp/time/utils.h>
#include "aicontrol.h"
+#include "block.h"
#include "catalogue.h"
#include "driver.h"
#include "layout.h"
#include "simplecontroller.h"
#include "speedquantizer.h"
#include "timetable.h"
+#include "trackcircuit.h"
#include "trackiter.h"
#include "tracktype.h"
#include "train.h"
layout.get_driver().signal_loco_speed.connect(sigc::mem_fun(this, &Train::loco_speed_event));
layout.get_driver().signal_loco_function.connect(sigc::mem_fun(this, &Train::loco_func_event));
- layout.signal_block_state_changed.connect(sigc::mem_fun(this, &Train::block_state_changed));
+ layout.signal_sensor_state_changed.connect(sigc::mem_fun(this, &Train::sensor_state_changed));
layout.get_driver().signal_halt.connect(sigc::mem_fun(this, &Train::halt_event));
}
}
-void Train::block_state_changed(Block &block, Block::State state)
+void Train::sensor_state_changed(Sensor &sensor, Sensor::State state)
{
- if(block.get_train()==this && state==Block::MAYBE_ACTIVE)
+ Block *block = 0;
+ if(TrackCircuit *tc = dynamic_cast<TrackCircuit *>(&sensor))
+ block = &tc->get_block();
+ else
+ return;
+
+ if(block->get_train()==this && state==Sensor::MAYBE_ACTIVE)
{
if(last_entry_block)
{
if(pure_speed && speed_quantizer && current_speed_step>0)
travel_distance = 0;
- for(BlockIter i=last_entry_block; &*i!=█ i=i.next())
+ for(BlockIter i=last_entry_block; &*i!=block; i=i.next())
{
if(i->get_sensor_id())
return;
}
}
- last_entry_block = allocator.iter_for(block);
+ last_entry_block = allocator.iter_for(*block);
last_entry_time = Time::now();
pure_speed = true;
accurate_position = true;