chiark / gitweb /
Change default for predit to PREDF_NEWPLAN -
authorian <ian>
Sat, 26 Jul 2008 15:05:44 +0000 (15:05 +0000)
committerian <ian>
Sat, 26 Jul 2008 15:05:44 +0000 (15:05 +0000)
part 1, change PREDF_ values and add PREDF_OLDPLAN

hostside/safety.c
hostside/safety.h
hostside/speed.c

index 5b1ecd996c887a17852063328d338a1a8a6867ba..2de2e73333bafb16943dac27b942137ba8c5fb10 100644 (file)
@@ -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;
index 1a74fe084c708b02fa4bd6746ebd674f137b752e..df63cf04255bc8d391fbb8d0af0ac7135fc9bc00 100644 (file)
@@ -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,
index a405b29a450acaa49977a3fdd29dfab9ae237a79..fe55d3237190cb4d8ef805003b34d600165a69bf 100644 (file)
@@ -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;
   }