chiark / gitweb /
MARGIN_TRAINLENGTH
authorian <ian>
Sun, 27 Jul 2008 22:54:30 +0000 (22:54 +0000)
committerian <ian>
Sun, 27 Jul 2008 22:54:30 +0000 (22:54 +0000)
hostside/resolve.c
hostside/safety.c
hostside/safety.h

index 34f7b00d46c90cfd19981ea5f465b2b344beff96..c9a42665db3a442573cf2a3f5d36d7f281c4d709 100644 (file)
@@ -506,8 +506,8 @@ static void end_constraints(FindEndUserContext *u) {
     cons->min= lim.min;
     cons->max= lim.max;
   } else {
-    cons->max= -lim.min + tra->detectable;
-    cons->min= -lim.max + tra->detectable;
+    cons->max= -lim.min + ceil(tra->detectable * MARGIN_TRAINLENGTH);
+    cons->min= -lim.max + ceil(tra->detectable * MARGIN_TRAINLENGTH);
   }
   cons->lastdetect= u->lastdetect;
   cons->hardend= u->t.seg;
index 1de397038d402513299558cf8caf0fad94b8abf9..21e1d9e324942b24fdeab22e27e449bd28db575c 100644 (file)
@@ -772,7 +772,8 @@ ErrorCode predict(Train *tra, struct timeval tnow, unsigned flags,
    * so we must instead extend our idea of the length of the train.
    */
 
-  int tail_walkback= MARGIN_NOSE + tail_length(tra) + tra->detectable;
+  int tail_walkback= MARGIN_NOSE + tail_length(tra) +
+    ceil(tra->detectable * MARGIN_TRAINLENGTH);
   int tail_advance_delaydist= MARGIN_TAIL;
 
   int effective_into_fdet= tra->maxinto - tra->uncertainty;
@@ -1145,7 +1146,7 @@ ErrorCode safety_setdirection(Train *tra, int backwards,
   newfdet.remain= tra->maxinto;
   newfdet.backwards= !tra->foredetect->tr_backwards;
 
-  c.distance= tra->detectable + tra->uncertainty;
+  c.distance= ceil(tra->detectable * MARGIN_TRAINLENGTH) + tra->uncertainty;
   c.nextseg= reverse_nextseg;
   c.getmovpos= 0;
   c.trackend= reverse_trackend;
index 6f918a5129b5b835ec47ef68d9d27a007fbfd3a9..263e219dbb6b1452c11ef2d12e9255849908ff48 100644 (file)
@@ -48,7 +48,7 @@ struct Train {
      * foremost reference possibility, plus ->head, plus MARGIN_NOSE
      * (and if it is not stationary it may own more).  It owns the
      * track backwards from the rearmost reference possibility for
-     * ->detectable plus ->tail plus MARGIN_NOSE.
+     * ceil(->detectable * MARGIN_TRAINLENGTH) + ->tail + MARGIN_NOSE.
      */
   unsigned
     backwards:1, /* train is moving backwards wrt its own front and back */
@@ -402,6 +402,7 @@ int trackloc_set_exactinto(TrackLocation *t, TrackAdvanceContext *c,
 #define MARGIN_SPEED 1.2 /*ratio*/
 #define MARGIN_AUTOPOINTTIME 500 /*ms*/
 #define UNMARGIN_ROUNDING 1e-4 /* mm/ms; for 1s, leads to max err of 100um */
+#define MARGIN_TRAINLENGTH 1.05
 
 #define MARGIN_STOPTIME 240 /*ms*/
 #define MARGIN_POLARISETIME 120 /*ms*/