From: ian Date: Thu, 1 May 2008 23:02:34 +0000 (+0000) Subject: correct tail positioning, and detection processing, during resolution; rename predict... X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=4e5e9663b079a6e3451463e278243e3407628e39;p=trains.git correct tail positioning, and detection processing, during resolution; rename predict_confirm to predict --- diff --git a/hostside/README.commands b/hostside/README.commands index d26aa97..4d35a5a 100644 --- a/hostside/README.commands +++ b/hostside/README.commands @@ -34,7 +34,7 @@ POSSIBLY-ASYNCHRONOUS REPORTING OF MESSAGES TO/FROM (MASTER) PIC U< resolving U< resolution inexplicable - U< resolution mispositioned + U< resolution mispositioned head|tail U< resolution movpos-change-failed / U< resolution problems diff --git a/hostside/resolve.c b/hostside/resolve.c index 7845fc8..ab4adda 100644 --- a/hostside/resolve.c +++ b/hostside/resolve.c @@ -371,8 +371,8 @@ static int segdist(Segment *seg) { static void ends_callback_debug(const char *what, TrackLocation *t, struct TrackAdvanceContext *c) { oprintf(DUPO("resolving") " ends %s" - " %s%s det=%d ours=%d done=%d owner=%s home=%s\n", - what, t->backwards?"-":"", t->seg->i->pname, + " %s%s dist=%d det=%d ours=%d done=%d owner=%s home=%s\n", + what, t->backwards?"-":"", t->seg->i->pname, c->distance, t->seg->res_detect, t->seg->resfin_ours, t->seg->resfin_done, @@ -464,13 +464,17 @@ static int resolve_complete_ends_train(Train *tra) { segdist(tra->foredetect)); tra->maxinto= segdist(tra->foredetect) - u.extraspace; - if (tra->maxinto < 0) tra->maxinto= 0; + if (tra->maxinto < 0) { + oprintf(UPO, "resolution mispositioned head %s %s -%d\n", + tra->pname, tra->foredetect->i->pname, -tra->maxinto); + return 1; + } tra->uncertainty= tra->maxinto; FOR_SEG seg->resfin_done= 0; t.seg= tra->foredetect; - t.remain= segdist(tra->foredetect) - u.extraspace; + t.remain= 0; t.backwards= !tra->foredetect->tr_backwards; tc.distance= tra->detectable + tra->tail + MARGIN_NOSE; @@ -486,7 +490,7 @@ static int resolve_complete_ends_train(Train *tra) { if (tc.distance) { tra->uncertainty -= tc.distance; if (tra->uncertainty < 0) { - oprintf(UPO, "resolution mispositioned %s %s -%d\n", + oprintf(UPO, "resolution mispositioned tail %s %s -%d\n", tra->pname, t.seg->i->pname, -tra->uncertainty); return 1; } diff --git a/hostside/safety.c b/hostside/safety.c index aa5f782..27ecd17 100644 --- a/hostside/safety.c +++ b/hostside/safety.c @@ -607,8 +607,8 @@ void report_train_ownerships(Train *tra, Segment *furthest, /*---------- prediction entrypoint ----------*/ -ErrorCode predict_confirm(Train *tra, int accelerate, - PredictionProblemCallback *ppc, void *ppcu) { +ErrorCode predict(Train *tra, int accelerate, + PredictionProblemCallback *ppc, void *ppcu) { PredictUserContext u; Segment *foredet; SEG_IV; @@ -759,7 +759,7 @@ void safety_notify_detection(Segment *seg) { report_train_position(tra); - ec= predict_confirm(tra, 0, detection_report_problem, 0); + ec= predict(tra, 0, detection_report_problem, 0); if (!ec) return; assert(ec == EC_SignallingPredictedProblem); diff --git a/hostside/safety.h b/hostside/safety.h index eb9bec5..458494d 100644 --- a/hostside/safety.h +++ b/hostside/safety.h @@ -107,8 +107,8 @@ ErrorCode safety_check_movposchange(Segment *seg, PredictionProblemCallback *ppc, void *ppcu); /* If this check success, caller may call movpos_change */ -ErrorCode predict_confirm(Train *tra, int accelerate, - PredictionProblemCallback *ppc, void *ppcu); +ErrorCode predict(Train *tra, int accelerate, + PredictionProblemCallback *ppc, void *ppcu); /* Lower-level interface for speedmanager etc. * Caller must call this with different situations until it succeeds! * Caller may pass ppc=0 and ppcu=(char*)"some context" to diff --git a/hostside/speed.c b/hostside/speed.c index e0e932b..56abfac 100644 --- a/hostside/speed.c +++ b/hostside/speed.c @@ -102,18 +102,18 @@ ErrorCode speedmanager_speedchange_request(Train *tra, int step, tra->speed.decel.duration= stop_info(tra,vnow)->ts; toev_start(&tra->speed.decel); tra->speed.speed= vnow; - ec= predict_confirm(tra,0, 0,(char*)"deceleration forbidden"); + ec= predict(tra,0, 0,(char*)"deceleration forbidden"); assert(!ec); xmit(tra); return 0; } tra->speed.try_speed= vtarg; - ec= predict_confirm(tra,1, ppc,ppcu); + ec= predict(tra,1, ppc,ppcu); if (ec) { tra->speed.try_speed= -1; - ec2= predict_confirm(tra,1, 0,(char*)"abandoned acceleration"); + ec2= predict(tra,1, 0,(char*)"abandoned acceleration"); assert(!ec2); return ec; }