From 896b0e2a1a8955753201e0f6ce405b37116a04c7 Mon Sep 17 00:00:00 2001 From: ian Date: Sat, 26 Jul 2008 23:13:52 +0000 Subject: [PATCH] relay train on decel_done (untested) --- hostside/TODO | 2 +- hostside/speed.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/hostside/TODO b/hostside/TODO index 41666de..3955051 100644 --- a/hostside/TODO +++ b/hostside/TODO @@ -7,12 +7,12 @@ allegedly fixed, but untested and nothing else. command speed 1 then speed 0 should now own X12 too but does not -bugs on decel done, should replan train location to release future segments no longer required to reproduce: put shinkansen nose car at A6 (home location) and nothing else. command speed 126 then 0 +bugs resolution algorithm is fundamentally incorrect as it depends on always detecting both ends of the train also apparently on detecting all of the middle ?! diff --git a/hostside/speed.c b/hostside/speed.c index 716f7cd..06e57c9 100644 --- a/hostside/speed.c +++ b/hostside/speed.c @@ -19,9 +19,17 @@ static void xmit(Train *tra) { static void decel_done(TimeoutEvent *toev) { Train *tra= (void*)((char*)toev - offsetof(Train, speed.decel)); + struct timeval tnow; + ErrorCode ec; + tra->speed.speed= tra->speedcurve[tra->speed.step]; + DPRINTF(speed,core, "decel_done %s step %d speed %f\n", tra->pname, tra->speed.step, tra->speed.speed); + mgettimeofday(&tnow); + + ec= predict(tra,tnow, PREDF_OLDPLAN, 0,0, 0, 0,(char*)"deceleration done"); + assert(!ec); } static const SpeedRange *stop_info(Train *tra, double speed) { @@ -48,8 +56,8 @@ static double current_speed(Train *tra, const struct timeval tnow) { if (left_to_go <= 0) { DPRINTF(speed,query, "current? decel-done\n"); - toev_stop(&tra->speed.decel); - decel_done(&tra->speed.decel); + /* we don't cancel the timeout because we need the callback to lay out + * the train again at the lower speed */ return tra->speed.speed; } -- 2.30.2