chiark / gitweb /
adjust (maximise) maxinto when we accelerate (untested)
authorian <ian>
Sat, 26 Jul 2008 22:59:22 +0000 (22:59 +0000)
committerian <ian>
Sat, 26 Jul 2008 22:59:22 +0000 (22:59 +0000)
hostside/TODO
hostside/speed.c

index 2b5bb62bb3cec66af17b20f69b5367a767f59acd..41666de34b2b959d9a9764415fbaadff83ec2de6 100644 (file)
@@ -1,4 +1,4 @@
-bugs
+allegedly fixed, but untested
        if train was abutting section boundary and is told to go,
                maxinto is not updated properly, so if it is then
                told to stop it stops owning the segment it may have
@@ -7,6 +7,7 @@ bugs
                and nothing else.  command speed 1 then speed 0
                should now own X12 too but does not
 
+bugs
        on decel done, should replan train location to release future
                segments no longer required
        to reproduce: put shinkansen nose car at A6 (home location)
index e365f6f5119d2f0d114c07b1a2ab2cc75755820b..c2f4daab9e9781406a536ec5892116101b3e7ebe 100644 (file)
@@ -104,6 +104,7 @@ static ErrorCode request_core(Train *tra, int step, struct timeval tnow,
   double vnow, vtarg;
   SpeedInfo try;
   const SpeedRange *regime;
+  Distance oldmaxinto;
 
   DPRINTF(speed,core, "request %s%s step %d\n",
          tra->backwards?"-":"",tra->pname,
@@ -114,6 +115,7 @@ static ErrorCode request_core(Train *tra, int step, struct timeval tnow,
 
   vnow= current_speed(tra,tnow);
   vtarg= tra->speedcurve[step];
+  oldmaxinto= tra->maxinto;
   
   DPRINTF(speed,core, " request  vnow=%f vtarg=%f\n", vnow,vtarg);
 
@@ -123,10 +125,19 @@ static ErrorCode request_core(Train *tra, int step, struct timeval tnow,
                                          try.max_speed_estimate);
   try.stopping= !step;
 
+  if (!try.stopping) {
+    Segment *fdet= tra->foredetect;
+    tra->maxinto= fdet->i->poscombs[fdet->movposcomb].dist;
+    assert(tra->maxinto >= oldmaxinto);
+    tra->uncertainty += tra->maxinto - oldmaxinto;
+  }
+
   ec= predict(tra,tnow,
              step <= tra->speed.step ? PREDF_OLDPLAN : 0,
              0,0, &try, ppc,ppcu);
   if (ec) {
+    tra->uncertainty -= tra->maxinto - oldmaxinto;
+    tra->maxinto= oldmaxinto;
     ec2= predict(tra,tnow, PREDF_OLDPLAN,0,0, 0,
                 0,(char*)"abandoned acceleration");
     assert(!ec2);
@@ -141,6 +152,7 @@ static ErrorCode request_core(Train *tra, int step, struct timeval tnow,
     tra->speed.decel.duration= regime->ts;
     toev_start(&tra->speed.decel);
   }
+  report_train_position(tra);
   xmit(tra);
   return 0;
 }