chiark / gitweb /
relay train on decel_done (untested)
authorian <ian>
Sat, 26 Jul 2008 23:13:52 +0000 (23:13 +0000)
committerian <ian>
Sat, 26 Jul 2008 23:13:52 +0000 (23:13 +0000)
hostside/TODO
hostside/speed.c

index 41666de34b2b959d9a9764415fbaadff83ec2de6..3955051a14c4947e7e3f62c2b7ed74c2747e9493 100644 (file)
@@ -7,12 +7,12 @@ allegedly fixed, but untested
                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)
                and nothing else.  command speed 126 then 0
 
+bugs
        resolution algorithm is fundamentally incorrect as it
                depends on always detecting both ends of the train
                also apparently on detecting all of the middle ?!
index 716f7cd06950dec7bf5acd15ddd0a5ce31f045a0..06e57c9b5a164edae9ad380946ce61ac80e8454c 100644 (file)
@@ -19,9 +19,17 @@ static void xmit(Train *tra) {
 
 static void decel_done(TimeoutEvent *toev) {
   Train *tra= (void*)((char*)toev - offsetof(Train, speed.decel));
+  struct timeval tnow;
+  ErrorCode ec;
+  
   tra->speed.speed= tra->speedcurve[tra->speed.step];
+
   DPRINTF(speed,core, "decel_done %s step %d speed %f\n",
          tra->pname, tra->speed.step, tra->speed.speed);
+  mgettimeofday(&tnow);
+
+  ec= predict(tra,tnow, PREDF_OLDPLAN, 0,0, 0, 0,(char*)"deceleration done");
+  assert(!ec);
 }
 
 static const SpeedRange *stop_info(Train *tra, double speed) {
@@ -48,8 +56,8 @@ static double current_speed(Train *tra, const struct timeval tnow) {
 
   if (left_to_go <= 0) {
     DPRINTF(speed,query, "current?  decel-done\n");
-    toev_stop(&tra->speed.decel);
-    decel_done(&tra->speed.decel);
+    /* we don't cancel the timeout because we need the callback to lay out
+     * the train again at the lower speed */
     return tra->speed.speed;
   }