From: ian Date: Sun, 4 May 2008 21:00:30 +0000 (+0000) Subject: seems to be able to polarise X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=8c42d2669be274aa6e814a7e24bc70a5e39b6a1a;p=trains.git seems to be able to polarise --- diff --git a/hostside/safety.c b/hostside/safety.c index 58bb085..69774f9 100644 --- a/hostside/safety.c +++ b/hostside/safety.c @@ -345,7 +345,8 @@ static int initpresent_nextseg(TrackLocation *t, TrackAdvanceContext *c, PredictUserContext *u= c->u; t->seg->now_present= t->seg->pred_present= t->seg->will_polarise= 1; t->seg->until= 0; - u->noninv_tally[!t->backwards]++; /* ! since going backwards along train */ + if (!t->seg->i->invertible) + u->noninv_tally[!t->backwards]++; /* ! since going backwards along train */ return 0; } @@ -455,7 +456,8 @@ static int tail_nextseg(TrackLocation *t, TrackAdvanceContext *c, pred_callback_debug(" tail_nextseg",t,c); - u->noninv_tally[leaving->tr_backwards]--; + if (!t->seg->i->invertible) + u->noninv_tally[leaving->tr_backwards]--; if (t->seg->pred_vacated) return 0; /* only vacate once */ t->seg->pred_present= 0; @@ -599,21 +601,20 @@ static int report_nextseg(TrackLocation *t, struct TrackAdvanceContext *c, if (t->seg->det_expected) strcat(flags,"*"); + if (t->seg->det_ignore) + strcat(flags,"."); if (t->seg == u->train->foredetect) { strcat(flags,"!"); u->usecurrentposn=u->forceusemotions; } - if (t->seg->det_ignore) - strcat(flags,"@"); - if (t->seg->tr_backwards) - strcat(flags,"-"); - oprintf(UPO," %s%s",flags,t->seg->i->pname); + oprintf(UPO," %s%s", t->seg->tr_backwards?"-":"", t->seg->i->pname); if (t->seg->i->n_poscombs > 1) { r= pred_getmovpos(t,c,mpc); assert(!r); assert(*mpc>=0); oprintf(UPO,"/%s", t->seg->i->poscombs[*mpc].pname); } + oprintf(UPO,"%s",flags); return 0; } @@ -738,10 +739,25 @@ ErrorCode predict(Train *tra, int accelerate, /*----- commit to the plan -----*/ - if (u.need_polarise) + oprintf(DUPO("safety") " predict committing\n"); + + if (u.need_polarise) { + oprintf(DUPO("safety") " predict polarising train_polarity=%d\n", + u.train_polarity_inverted), actual_inversions_start(); + } + oprintf(DUPO("safety") " predict "); FOR_SEG { + oprintf(UPO, + " %s%s%s%c%c%c%c", + seg->tr_backwards?"-":"", seg->i->pname, + seg->owner == tra ? "#" : "=", + "-N"[ seg->now_present ], + "-P"[ seg->pred_present ], + "-V"[ seg->pred_vacated ], + "-#"[ seg->will_polarise ]); + if (seg->owner == tra) { seg->det_ignore= 0; seg->owner= 0; @@ -757,14 +773,14 @@ ErrorCode predict(Train *tra, int accelerate, ec= movpos_change(seg, target, -1, reservation); assert(!ec); } - if (u.need_polarise) { - if (seg->will_polarise) - seg->seg_inverted= seg->tr_backwards ^ u.train_polarity_inverted; + if (u.need_polarise && seg->will_polarise) { + seg->seg_inverted= seg->tr_backwards ^ u.train_polarity_inverted; actual_inversions_segment(seg); } seg->now_present= seg->pred_present= seg->pred_vacated= seg->will_polarise= 0; } + oprintf(UPO,"\n"); if (u.need_polarise) actual_inversions_done();