current_row(0),
executing(true),
pending_block(0),
- pending_train(0)
+ pending_train(0),
+ arrived(false)
{
train.signal_arrived.connect(sigc::mem_fun(this, &Timetable::train_arrived));
train.get_layout().get_driver().signal_sensor.connect(sigc::mem_fun(this, &Timetable::sensor_event));
switch(row.type)
{
case GOTO_SENSOR:
+ arrived = false;
if(!train.go_to(get_sensor(row.get_param<unsigned>(0))))
set_enabled(false);
break;
case GOTO_ZONE:
+ arrived = false;
if(!train.go_to(get_zone(row.get_param<string>(0))))
set_enabled(false);
break;
executing = false;
break;
case ARRIVE:
- executing = false;
+ if(!arrived)
+ executing = false;
+ arrived = false;
break;
case SPEED:
- train.set_control("speed", row.get_param<unsigned>(0)/3.6*train.get_layout().get_catalogue().get_scale());
+ if(!arrived)
+ train.set_control("speed", row.get_param<unsigned>(0)/3.6*train.get_layout().get_catalogue().get_scale());
break;
case REVERSE:
train.set_control("reverse", !train.get_control("reverse"));
current_row = (current_row+1)%rows.size();
executing = true;
}
+ else
+ arrived = true;
}
case GOTO_ZONE:
return "set route to "+get_param<string>(0);
case TRAVEL:
- return "travel to "+get_param<string>(0);
+ return format("travel to sensor %d", get_param<unsigned>(0));
case WAIT_TIME:
return format("wait for %d seconds", get_param<unsigned>(0));
case WAIT_UNTIL:
case GOTO_ZONE:
return DataFile::Statement("goto_zone"), get_param<string>(0);
case TRAVEL:
- return DataFile::Statement("travel"), get_param<string>(0);
+ return DataFile::Statement("travel"), get_param<unsigned>(0);
case WAIT_TIME:
return DataFile::Statement("wait"), get_param<unsigned>(0);
case WAIT_UNTIL:
obj.rows.push_back(Row(SPEED, s));
}
-void Timetable::Loader::travel(const string &t)
+void Timetable::Loader::travel(unsigned s)
{
- obj.rows.push_back(Row(TRAVEL, t));
+ obj.rows.push_back(Row(TRAVEL, s));
}
void Timetable::Loader::wait(unsigned t)
void route(const std::string &);
void reverse();
void speed(unsigned);
- void travel(const std::string &);
+ void travel(unsigned);
void wait(unsigned);
void wait_train(unsigned, unsigned);
void wait_until(unsigned, unsigned);
Block *pending_block;
Train *pending_train;
Msp::Time::TimeStamp wait_timeout;
+ bool arrived;
public:
Timetable(Train &);