From 25e0897bcedbb6885930fa1a897c7a582d3baf1c Mon Sep 17 00:00:00 2001 From: ian Date: Sat, 17 May 2008 18:19:13 +0000 Subject: [PATCH] do not always use current position when predicting; do do so when reporting initially --- hostside/safety.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/hostside/safety.c b/hostside/safety.c index d014f39..ca5886b 100644 --- a/hostside/safety.c +++ b/hostside/safety.c @@ -247,7 +247,7 @@ typedef struct { need_polarise:1, /* when we commit */ train_polarity_inverted:1, /* right now, or if know_best, the best */ know_best_polarity:1, /* longest-lasting into the future */ - alwaysusemotions:1; /* for report_train_ownerships only */ + alwaysusemotions:1; /* for report_train_ownerships only */ TrackLocation nose, fdet, tail; TrackAdvanceContext nosec, tailc, fdetc; TimeInterval elapsed; /* from now, minimum */ @@ -356,7 +356,9 @@ static int pred_getmovpos(TrackLocation *t, TrackAdvanceContext *c, MovPosComb *use_io) { PredictUserContext *u= c->u; if (u->usecurrentposn) return 0; - if (t->seg->motion) *use_io= movpos_change_intent(t->seg->motion); + if (t->seg->motion) + if (t->seg->moving || t->seg->pred_vacated || u->alwaysusemotions) + *use_io= movpos_change_intent(t->seg->motion); if (*use_io<0) safety_panic(u->train, t->seg, "track route unexpectedly not known"); return 0; @@ -541,11 +543,11 @@ static int fdet_nextseg(TrackLocation *t, TrackAdvanceContext *c, } /* Now we have advanced the nose and have recorded any appropriate - * motion(s). But we advancing the nose has updated the segment's + * motion(s). Advancing the nose has updated the segment's * notion of the motion but not trackloc_advance's cached version of - * the movposcomb in *mpc_io. That doesn't matter because we don't - * actually use it ourselves and trackloc_advance will call - * getmovpos. */ + * the movposcomb in *mpc_io - but trackloc_advance will call + * pred_getmovpos right after we return so we do not need to worry. + */ /* Check polarity */ @@ -664,8 +666,8 @@ ErrorCode predict(Train *tra, int accelerate, struct timeval tnow, assert(foredet); u.walk_compute_polarise= 1; - u.train_polarity_inverted= foredet->seg_inverted ^ foredet->tr_backwards; u.usecurrentposn= 1; + u.train_polarity_inverted= foredet->seg_inverted ^ foredet->tr_backwards; /*----- find the train's foredetect (rearmost possibility) -----*/ /* @@ -709,6 +711,7 @@ ErrorCode predict(Train *tra, int accelerate, struct timeval tnow, /*----- find the train's nose (rearmost possibility) -----*/ + u.usecurrentposn= 0; u.nosec.u= &u; u.nosec.getmovpos= pred_getmovpos; u.nosec.nextseg= nose_nextseg; -- 2.30.2