chiark / gitweb /
correct tail positioning, and detection processing, during resolution; rename predict...
authorian <ian>
Thu, 1 May 2008 23:02:34 +0000 (23:02 +0000)
committerian <ian>
Thu, 1 May 2008 23:02:34 +0000 (23:02 +0000)
hostside/README.commands
hostside/resolve.c
hostside/safety.c
hostside/safety.h
hostside/speed.c

index d26aa9782d4e952414a289633fd2ab06122088f2..4d35a5a2861faef4260f389530e8b1d438d9a919 100644 (file)
@@ -34,7 +34,7 @@ POSSIBLY-ASYNCHRONOUS REPORTING OF MESSAGES TO/FROM (MASTER) PIC
  U< resolving <some message about resolution algorithm>
 
  U< resolution inexplicable <segment>
- U< resolution mispositioned <train> <crush-ending-segment> <distance>
+ U< resolution mispositioned head|tail <train> <crush-ending-seg> <distance>
  U< resolution movpos-change-failed <segment>/<poscombname>
  U< resolution problems <number-of-problems>
 
index 7845fc89b21d39f2b41b191582b54568929dbc81..ab4addadd03e5d14083833e2a7c1c94c7c1aef4e 100644 (file)
@@ -371,8 +371,8 @@ static int segdist(Segment *seg) {
 static void ends_callback_debug(const char *what, TrackLocation *t,
                                struct TrackAdvanceContext *c) {
   oprintf(DUPO("resolving") " ends   %s"
-         " %s%s det=%d ours=%d done=%d owner=%s home=%s\n",
-         what, t->backwards?"-":"", t->seg->i->pname,
+         " %s%s dist=%d det=%d ours=%d done=%d owner=%s home=%s\n",
+         what, t->backwards?"-":"", t->seg->i->pname, c->distance,
          t->seg->res_detect,
          t->seg->resfin_ours,
          t->seg->resfin_done,
@@ -464,13 +464,17 @@ static int resolve_complete_ends_train(Train *tra) {
          segdist(tra->foredetect));
 
   tra->maxinto= segdist(tra->foredetect) - u.extraspace;
-  if (tra->maxinto < 0) tra->maxinto= 0;
+  if (tra->maxinto < 0) {
+    oprintf(UPO, "resolution mispositioned head %s %s -%d\n",
+           tra->pname, tra->foredetect->i->pname, -tra->maxinto);
+    return 1;
+  }
   tra->uncertainty= tra->maxinto;
 
   FOR_SEG seg->resfin_done= 0;
 
   t.seg= tra->foredetect;
-  t.remain= segdist(tra->foredetect) - u.extraspace;
+  t.remain= 0;
   t.backwards= !tra->foredetect->tr_backwards;
   
   tc.distance= tra->detectable + tra->tail + MARGIN_NOSE;
@@ -486,7 +490,7 @@ static int resolve_complete_ends_train(Train *tra) {
   if (tc.distance) {
     tra->uncertainty -= tc.distance;
     if (tra->uncertainty < 0) {
-      oprintf(UPO, "resolution mispositioned %s %s -%d\n",
+      oprintf(UPO, "resolution mispositioned tail %s %s -%d\n",
              tra->pname, t.seg->i->pname, -tra->uncertainty);
       return 1;
     }
index aa5f78205a0a9e5b9109e3d84a62a958932a4271..27ecd175c760014f5f891e2f173f2b8e612a21da 100644 (file)
@@ -607,8 +607,8 @@ void report_train_ownerships(Train *tra, Segment *furthest,
 
 /*---------- prediction entrypoint ----------*/
 
-ErrorCode predict_confirm(Train *tra, int accelerate,
-                         PredictionProblemCallback *ppc, void *ppcu) {
+ErrorCode predict(Train *tra, int accelerate,
+                 PredictionProblemCallback *ppc, void *ppcu) {
   PredictUserContext u;
   Segment *foredet;
   SEG_IV;
@@ -759,7 +759,7 @@ void safety_notify_detection(Segment *seg) {
 
   report_train_position(tra);
 
-  ec= predict_confirm(tra, 0, detection_report_problem, 0);
+  ec= predict(tra, 0, detection_report_problem, 0);
   if (!ec) return;
 
   assert(ec == EC_SignallingPredictedProblem);
index eb9bec584ca07ffa11c1e4c1cad1f04dc60e7d12..458494dda14cf9ce45b6b834a31a998b1e14510c 100644 (file)
@@ -107,8 +107,8 @@ ErrorCode safety_check_movposchange(Segment *seg,
                            PredictionProblemCallback *ppc, void *ppcu);
   /* If this check success, caller may call movpos_change */
 
-ErrorCode predict_confirm(Train *tra, int accelerate,
-                         PredictionProblemCallback *ppc, void *ppcu);
+ErrorCode predict(Train *tra, int accelerate,
+                 PredictionProblemCallback *ppc, void *ppcu);
   /* Lower-level interface for speedmanager etc.
    * Caller must call this with different situations until it succeeds!
    * Caller may pass ppc=0 and ppcu=(char*)"some context" to
index e0e932b03b1904c40e2bf0279d012243a52c8d21..56abfac7b157b8dd7ba27fab1b3fad8930179fcf 100644 (file)
@@ -102,18 +102,18 @@ ErrorCode speedmanager_speedchange_request(Train *tra, int step,
     tra->speed.decel.duration= stop_info(tra,vnow)->ts;
     toev_start(&tra->speed.decel);
     tra->speed.speed= vnow;
-    ec= predict_confirm(tra,0, 0,(char*)"deceleration forbidden");
+    ec= predict(tra,0, 0,(char*)"deceleration forbidden");
     assert(!ec);
     xmit(tra);
     return 0;
   }
 
   tra->speed.try_speed= vtarg;
-  ec= predict_confirm(tra,1, ppc,ppcu);
+  ec= predict(tra,1, ppc,ppcu);
 
   if (ec) {
     tra->speed.try_speed= -1;
-    ec2= predict_confirm(tra,1, 0,(char*)"abandoned acceleration");
+    ec2= predict(tra,1, 0,(char*)"abandoned acceleration");
     assert(!ec2);
     return ec;
   }