*/
};
-static const char *posnpname(Segment *move, MovPosComb poscomb) {
+const char *movpos_pname(Segment *move, MovPosComb poscomb) {
return poscomb<0 ? "?" : move->i->poscombs[poscomb].pname;
}
static void ouposn_moving(Change *chg) {
Segment *move= chg->move;
oprintf(UPO, "movpos %s position %s moving\n",
- move->i->pname, posnpname(move, chg->actual));
+ move->i->pname, movpos_pname(move, chg->actual));
}
static void motion_done(Segment *move, MovPosComb actual) {
move->motion= 0;
move->movposcomb= actual;
oprintf(UPO, "movpos %s position %s stable\n",
- move->i->pname, posnpname(move, move->movposcomb));
+ move->i->pname, movpos_pname(move, move->movposcomb));
}
static void ignore_all_abandon(Method *m) { }
continue;
}
oprintf(UPO, "%s/%s[%d@t+%d]", whichr->h.move->i->pname,
- posnpname(whichr->h.move, whichr->h.intent),
+ movpos_pname(whichr->h.move, whichr->h.intent),
whichr->n_motions, whichwhen);
if (future > whichwhen) {
oprintf(UPO,"!...bad\n");
const MovFeatInfo *feati;
MovFeatKind kind;
- oprintf(DUPO("movpos/eval") "%s/%s <-%s\n",
- move->i->pname, posnpname(move,target), posnpname(move,startpoint));
+ oprintf(DUPO("movpos/eval") "%s/%s <-%s\n", move->i->pname,
+ movpos_pname(move,target), movpos_pname(move,startpoint));
if (startpoint<0) {
startpoint= movpos_poscomb_actual(move);
oprintf(DUPO("movpos/eval") " actual <-%s\n",
- posnpname(move,startpoint));
+ movpos_pname(move,startpoint));
}
for (feat=0, feati=movei->movfeats, tchanges=0, kind= mfk_none;
}
oprintf(DUPO("movpos/change") "%s/%s maxdelay=%dms actual=%s\n",
- move->i->pname, posnpname(move,target),
- maxdelay_ms, posnpname(move, actual));
+ move->i->pname, movpos_pname(move,target),
+ maxdelay_ms, movpos_pname(move, actual));
if (chg) oprintf(DUPO("movpos/change") " chg=%s:%s/%s\n",
chg->meth->pname, chg->move->i->pname,
- posnpname(chg->move, chg->intent));
+ movpos_pname(chg->move, chg->intent));
{ /* provide horizon for visibility of motions[] */
int n_motions=0;
int nchanges;
oprintf(DUPO("movpos/reserve") "%s/%s maxdelay=%dms startpoint=%s\n",
- move->i->pname, posnpname(move,target),
- maxdelay_ms, posnpname(move,startpoint));
+ move->i->pname, movpos_pname(move,target),
+ maxdelay_ms, movpos_pname(move,startpoint));
nchanges= evaluate_target(move,target,startpoint,&kind);
if (nchanges==-1) return EC_MovFeatKindsCombination;
if (!res) return;
oprintf(DUPO("movpos/unreserve") "%s:%s/%s\n",
res->meth->pname, res->move->i->pname,
- posnpname(res->move, res->intent));
+ movpos_pname(res->move, res->intent));
res->meth->destroy(res->meth, res);
}
* now_present
* | pred_present
* |/ vacated
- * ||/ motion &&
- * ||| !moving
- * NPV until means
+ * ||/
+ * |||
+ * NPV until
*
* has never been here as far as we know --- undef
- * here now, prediction has it still here NP- arrival = 0 old, defer
- * here now, but predicted to have departed N-V departure old, defer
- * pred. to have arrived here -P- arrival to do now
- * pred. to have arrived and departed --V departure to do now
- * here now, pred. to have dep'd and ret'd NPV re-arrival new, defer
- * now absent, pred. to have arr, dep & ret'd -PV re-arrival forbidden
+ * here now, prediction has it still here NP- arrival = 0
+ * here now, but predicted to have departed N-V departure
+ * pred. to have arrived here -P- arrival
+ * pred. to have arrived and departed --V departure
+ * here now, pred. to have dep'd and ret'd NPV re-arrival
+ * now absent, pred. to have arr, dep & ret'd -PV re-arrival
*
* seg->tr_backwards records the sense of the _first_ passage of the train.
*
* invalid/impossible combination:
* train here now but never in prediction N--
*
- * `old' means a motion reservation which is part of the path we
- * committed to in an earlier prediction but which we have not yet
- * reached in this prediction.
+ * Meanings of moving, motion and motion_newplan:
+ * For segments NPV==000, no plan made yet:
+ *
+ * moving motion _newplan
+ * 0 0 0 segment is entirely stable
+ * 0 non-0 0 existing plan has deferred motion
+ * 1 non-0 0 currently moving - as planned if owned
+ *
+ * 1 0 ? always forbidden
+ * ? ? non-0 forbidden for not-yet-planned segments
+ *
+ * For segments with NPV!=0, some kind of planning done:
+ *
+ * moving motion _newplan new plan involves
+ * 0 0 0 no motion, segment is entirely stable
+ * 0 non-0 0 abandoning planned deferred motion
+ * 0 0 non-0 new motion, perhaps deferred
+ * any non-0 =motion same motion as before
+ * any non-0 !=motion different motion
+ *
+ * 1 0 ? always forbidden
+ * 1 non-0 0 forbidden: need explicit motion to cancel
*
* (These are the values when not in the middle of nose_nextseg.)
*/
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, uses ->motion */
TrackLocation nose, fdet, tail;
TrackAdvanceContext nosec, tailc, fdetc;
TimeInterval elapsed; /* from now, minimum */
return ec;
}
+static const char *motion_pname(Segment *seg, MovPosChange *motion) {
+ if (!motion) return "";
+ return movpos_pname(seg, movpos_change_intent(motion));
+}
+
static void pred_callback_debug(const char *what, TrackLocation *t,
struct TrackAdvanceContext *c,
const TrackLocation *before) {
oprintf(DUPO("safety") " predict %s"
" %c%s dist=%-4d until=%-4ld %c%c%c.%c (was %s%s..%d dist=%-4d)"
- " %c%c%c.%c%c%c%c"
- " elapsed=%ld nit=%d,%d\n",
+ " %c%c%c.%c%c%c%c elapsed=%ld"
+ " %s/%s %c%s >%s"
+ " nit=%d,%d\n",
what,
" -"[t->backwards],
"-n"[ u->need_polarise ],
"-i"[ u->train_polarity_inverted ],
"-b"[ u->know_best_polarity ],
-
(long)u->elapsed,
+
+ t->seg->i->pname,
+ movpos_pname(t->seg, t->seg->movposcomb),
+ "!~"[ t->seg->moving ],
+ motion_pname(t->seg, t->seg->motion),
+ motion_pname(t->seg, t->seg->motion_newplan),
+
u->noninv_tally[0], u->noninv_tally[1]);
}
MovPosComb *use_io) {
PredictUserContext *u= c->u;
if (u->usecurrentposn) return 0;
- if (t->seg->motion)
- if (t->seg->moving || t->seg->pred_vacated || u->alwaysusemotions)
+ if (u->alwaysusemotions) {
+ if (t->seg->motion)
*use_io= movpos_change_intent(t->seg->motion);
+ } else if (t->seg->moving || t->seg->pred_vacated) {
+ if (t->seg->motion_newplan)
+ *use_io= movpos_change_intent(t->seg->motion_newplan);
+ }
if (*use_io<0) safety_panic(u->train, t->seg,
"track route unexpectedly not known");
return 0;
pred_callback_debug("optunwind_nextseg",t,c,before);
if (t->seg == u->furthest ||
- t->seg->motion)
+ t->seg->motion_newplan)
return EC_SignallingHorizonReached;
t->seg->pred_present= 0;