From: ian Date: Sat, 26 Jul 2008 15:05:44 +0000 (+0000) Subject: Change default for predit to PREDF_NEWPLAN - X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=a0ecb9ea54202c732c3bfd9ebb71569fd1c282ba;p=trains.git Change default for predit to PREDF_NEWPLAN - part 1, change PREDF_ values and add PREDF_OLDPLAN --- diff --git a/hostside/safety.c b/hostside/safety.c index 5b1ecd9..2de2e73 100644 --- a/hostside/safety.c +++ b/hostside/safety.c @@ -705,9 +705,9 @@ ErrorCode predict(Train *tra, struct timeval tnow, unsigned flags, u.train= tra; u.problem_callback= ppc; u.problem_callback_u= ppcu; - u.neednewplan= !!(flags & PREDF_NEWPLAN); + u.neednewplan= !(flags & PREDF_OLDPLAN); u.maxspeed= speedmanager_speed_maxestimate(u.train, tnow); - u.stopping= !(flags & PREDF_NEWPLAN) && speedmanager_stopping(u.train); + u.stopping= (flags & PREDF_OLDPLAN) && speedmanager_stopping(u.train); u.stopping_distance= speedmanager_stoppingdistance(u.train, tnow); u.desire_move= desire_move; @@ -721,7 +721,7 @@ ErrorCode predict(Train *tra, struct timeval tnow, unsigned flags, tra->speed.decel.running ? " decel" : "", u.stopping_distance, "-j"[ !!(flags & PREDF_JUSTDET) ], - "-n"[ !!(flags & PREDF_NEWPLAN) ], + "no"[ !!(flags & PREDF_OLDPLAN) ], u.stopping ? " stopping" : "", u.desire_move ? u.desire_move->i->pname : "", u.desire_move ? u.desire_move->i->poscombs[u.desire_movposcomb] @@ -1151,7 +1151,7 @@ ErrorCode safety_setdirection(Train *tra, int backwards, tra->backwards ^= 1; newfdet.seg->tr_backwards ^= 1; /* in case it's the same as oldfdet */ - ec2= predict(tra,tnow, 0,0,0, 0,(char*)"abandon reverse"); + ec2= predict(tra,tnow, PREDF_OLDPLAN,0,0, 0,(char*)"abandon reverse"); assert(!ec2); return ec; @@ -1203,7 +1203,8 @@ void safety_notify_detection(Segment *seg) { tra->plan_lookahead_nsegs--; report_train_position(tra); - ec= predict(tra,tnow, PREDF_JUSTDET,0,0, detection_report_problem,0); + ec= predict(tra,tnow, PREDF_JUSTDET|PREDF_OLDPLAN,0,0, + detection_report_problem,0); if (!ec) return; assert(ec == EC_SignallingPredictedProblem); @@ -1213,7 +1214,8 @@ void safety_notify_detection(Segment *seg) { report_train_position(tra); speedmanager_safety_stop(tra,tnow); - ec= predict(tra,tnow, PREDF_JUSTDET,0,0, 0,(char*)"safety commanding stop"); + ec= predict(tra,tnow, PREDF_JUSTDET|PREDF_OLDPLAN,0,0, + 0,(char*)"safety commanding stop"); assert(!ec); } @@ -1241,7 +1243,8 @@ ErrorCode safety_movposchange(Segment *seg, MovPosComb comb, ec= predict(seg->owner,tnow, PREDF_NEWPLAN,seg,comb, ppc,ppcu); if (!ec) return 0; - ec2= predict(seg->owner,tnow,0, 0,0, 0,(char*)"abandon movposchange"); + ec2= predict(seg->owner,tnow, PREDF_OLDPLAN, 0,0, + 0,(char*)"abandon movposchange"); assert(!ec2); return ec; diff --git a/hostside/safety.h b/hostside/safety.h index 1a74fe0..df63cf0 100644 --- a/hostside/safety.h +++ b/hostside/safety.h @@ -126,9 +126,10 @@ ErrorCode safety_setdirection(Train *tra, int backwards, #define PREDF_JUSTDET 001u /* we have just detected the train entering its foredetect so we * can subtract the uncertainty from the stopping distance */ -#define PREDF_NEWPLAN 002u - /* the existing plan is not necessarily sufficient as - * we are intending to accelerate or change a movpos */ +#define PREDF_OLDPLAN 002u + /* the old plan is necessarily sufficient as we are not intending + * to accelerate, change a movpos, etc. */ +#define PREDF_NEWPLAN 000u /* now the default */ ErrorCode predict(Train *tra, struct timeval tnow, unsigned flags, Segment *desire_move, int desire_movposcomb, diff --git a/hostside/speed.c b/hostside/speed.c index a405b29..fe55d32 100644 --- a/hostside/speed.c +++ b/hostside/speed.c @@ -127,7 +127,8 @@ static ErrorCode request_core(Train *tra, int step, struct timeval tnow, toev_start(&tra->speed.decel); tra->speed.speed= vnow; if (ppc || ppcu) { - ec= predict(tra,tnow, 0,0,0, 0,(char*)"deceleration forbidden"); + ec= predict(tra,tnow, PREDF_OLDPLAN,0,0, + 0,(char*)"deceleration forbidden"); assert(!ec); } xmit(tra); @@ -139,7 +140,8 @@ static ErrorCode request_core(Train *tra, int step, struct timeval tnow, if (ec) { tra->speed.try_speed= -1; - ec2= predict(tra,tnow, 0,0,0, 0,(char*)"abandoned acceleration"); + ec2= predict(tra,tnow, PREDF_OLDPLAN,0,0, + 0,(char*)"abandoned acceleration"); assert(!ec2); return ec; }