From 416c47be77ca6a0a66745709d6d512c9615ca253 Mon Sep 17 00:00:00 2001 From: ian Date: Sat, 26 Jul 2008 22:59:22 +0000 Subject: [PATCH] adjust (maximise) maxinto when we accelerate (untested) --- hostside/TODO | 3 ++- hostside/speed.c | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/hostside/TODO b/hostside/TODO index 2b5bb62..41666de 100644 --- a/hostside/TODO +++ b/hostside/TODO @@ -1,4 +1,4 @@ -bugs +allegedly fixed, but untested if train was abutting section boundary and is told to go, maxinto is not updated properly, so if it is then told to stop it stops owning the segment it may have @@ -7,6 +7,7 @@ bugs 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) diff --git a/hostside/speed.c b/hostside/speed.c index e365f6f..c2f4daa 100644 --- a/hostside/speed.c +++ b/hostside/speed.c @@ -104,6 +104,7 @@ static ErrorCode request_core(Train *tra, int step, struct timeval tnow, double vnow, vtarg; SpeedInfo try; const SpeedRange *regime; + Distance oldmaxinto; DPRINTF(speed,core, "request %s%s step %d\n", tra->backwards?"-":"",tra->pname, @@ -114,6 +115,7 @@ static ErrorCode request_core(Train *tra, int step, struct timeval tnow, vnow= current_speed(tra,tnow); vtarg= tra->speedcurve[step]; + oldmaxinto= tra->maxinto; DPRINTF(speed,core, " request vnow=%f vtarg=%f\n", vnow,vtarg); @@ -123,10 +125,19 @@ static ErrorCode request_core(Train *tra, int step, struct timeval tnow, try.max_speed_estimate); try.stopping= !step; + if (!try.stopping) { + Segment *fdet= tra->foredetect; + tra->maxinto= fdet->i->poscombs[fdet->movposcomb].dist; + assert(tra->maxinto >= oldmaxinto); + tra->uncertainty += tra->maxinto - oldmaxinto; + } + ec= predict(tra,tnow, step <= tra->speed.step ? PREDF_OLDPLAN : 0, 0,0, &try, ppc,ppcu); if (ec) { + tra->uncertainty -= tra->maxinto - oldmaxinto; + tra->maxinto= oldmaxinto; ec2= predict(tra,tnow, PREDF_OLDPLAN,0,0, 0, 0,(char*)"abandoned acceleration"); assert(!ec2); @@ -141,6 +152,7 @@ static ErrorCode request_core(Train *tra, int step, struct timeval tnow, tra->speed.decel.duration= regime->ts; toev_start(&tra->speed.decel); } + report_train_position(tra); xmit(tra); return 0; } -- 2.30.2