#include <msp/core/maputils.h>
+#include <msp/time/utils.h>
#include "catalogue.h"
#include "layout.h"
#include "route.h"
TrainRoutePlanner::TrainRoutePlanner(Layout &layout):
goal(0),
+ timeout(10*Time::sec),
result(PENDING),
thread(0)
{
}
}
+void TrainRoutePlanner::set_timeout(const Time::TimeDelta &t)
+{
+ timeout = t;
+}
+
TrainRoutePlanner::Result TrainRoutePlanner::plan()
{
prepare_plan();
void TrainRoutePlanner::create_plan()
{
+ Time::TimeStamp timeout_stamp = Time::now()+timeout;
+ unsigned count = 0;
while(!queue.empty())
{
const RoutingStep &step = get_step();
}
add_steps(step);
+
+ if(++count>=1000)
+ {
+ if(Time::now()>timeout_stamp)
+ break;
+ count = 0;
+ }
}
result = FAILED;
std::list<RoutingStep> steps;
std::list<RoutingStep> queue;
const RoutingStep *goal;
+ Msp::Time::TimeDelta timeout;
Result result;
PlanningThread *thread;
TrainRoutePlanner(Layout &);
~TrainRoutePlanner();
+ void set_timeout(const Msp::Time::TimeDelta &);
Result plan();
void plan_async();
Result check();