wait_timeout = t+row.get_param<unsigned>(0)*Time::sec;
executing = false;
break;
+ case WAIT_UNTIL:
+ {
+ unsigned unixtime = t.to_unixtime();
+ unsigned mod = row.get_param<unsigned>(1);
+ unsigned secs = ((mod+row.get_param<unsigned>(0))-(unixtime%mod))%mod;
+ wait_timeout = t+secs*Time::sec;
+ executing = false;
+ }
+ break;
case WAIT_TRAIN:
pending_train = &train.get_layout().get_train(row.get_param<unsigned>(0));
pending_block = &get_sensor(row.get_param<unsigned>(1)).get_block();
return "travel to "+get_param<string>(0);
case WAIT_TIME:
return format("wait for %d seconds", get_param<unsigned>(0));
+ case WAIT_UNTIL:
+ return format("wait until %d mod %d seconds", get_param<unsigned>(0), get_param<unsigned>(1));
case WAIT_TRAIN:
return format("wait for train %d at %s", get_param<unsigned>(0), get_param<string>(1));
case ARRIVE:
return DataFile::Statement("travel"), get_param<string>(0);
case WAIT_TIME:
return DataFile::Statement("wait"), get_param<unsigned>(0);
+ case WAIT_UNTIL:
+ return DataFile::Statement("wait_until"), get_param<unsigned>(0), get_param<unsigned>(1);
case WAIT_TRAIN:
return DataFile::Statement("wait_train"), get_param<unsigned>(0), get_param<unsigned>(1);
case ARRIVE:
}
}
}
+ else if(!s.compare(0, 11, "wait until "))
+ {
+ string::size_type mod = s.find(" mod ", 11);
+ unsigned nondigit = (mod!=string::npos ? mod+5 : 11);
+ while(nondigit<s.size() && isdigit(s[nondigit]))
+ ++nondigit;
+ if(mod!=string::npos)
+ {
+ unsigned time = lexical_cast<unsigned>(s.substr(11, mod-11));
+ Row row(WAIT_UNTIL, time);
+ row.params.push_back(lexical_cast<unsigned>(s.substr(mod+5, nondigit-mod-5)));
+ return row;
+ }
+ else
+ {
+ unsigned time = lexical_cast<unsigned>(s.substr(11, nondigit-11));
+ Row row(WAIT_UNTIL, time);
+ row.params.push_back(3600);
+ return row;
+ }
+ }
else if(!s.compare(0, 10, "set speed "))
{
unsigned nondigit = 11;
add("travel", &Loader::travel);
add("wait", &Loader::wait);
add("wait_train", &Loader::wait_train);
+ add("wait_until", &Loader::wait_until);
// Deprecated alias
add("goto", static_cast<void (Loader::*)(const string &)>(&Loader::goto_sensor));
obj.rows.push_back(row);
}
+void Timetable::Loader::wait_until(unsigned t, unsigned m)
+{
+ Row row(WAIT_UNTIL, t);
+ row.params.push_back(m);
+ obj.rows.push_back(row);
+}
+
} // namespace R2C2