]> git.tdb.fi Git - r2c2.git/commitdiff
Mark train positions as inaccurate on halt
authorMikko Rasa <tdb@tdb.fi>
Fri, 23 Apr 2010 17:11:35 +0000 (17:11 +0000)
committerMikko Rasa <tdb@tdb.fi>
Fri, 23 Apr 2010 17:11:35 +0000 (17:11 +0000)
source/libmarklin/train.cpp
source/libmarklin/train.h

index ed57dd7ee143c7f1ec8eb1a5b1081f85d9ad4881..973cc07e8c5a234c9d0e11094b810585ba693344 100644 (file)
@@ -60,6 +60,8 @@ Train::Train(Layout &l, const LocoType &t, unsigned a):
        layout.get_driver().signal_sensor.connect(sigc::mem_fun(this, &Train::sensor_event));
        layout.get_driver().signal_turnout.connect(sigc::mem_fun(this, &Train::turnout_event));
 
+       layout.get_driver().signal_halt.connect(sigc::mem_fun(this, &Train::halt_event));
+
        control->signal_control_changed.connect(signal_control_changed);
 }
 
@@ -362,7 +364,10 @@ void Train::tick(const Time::TimeStamp &t, const Time::TimeDelta &dt)
                {
                        overshoot_dist += d;
                        if(overshoot_dist>40*layout.get_catalogue().get_scale())
+                       {
                                layout.emergency(name+" has not arrived at sensor");
+                               accurate_position = false;
+                       }
                }
        }
        else if(end_of_route)
@@ -557,6 +562,12 @@ void Train::turnout_event(unsigned addr, bool)
        }
 }
 
+void Train::halt_event(bool h)
+{
+       if(h)
+               accurate_position = false;
+}
+
 void Train::block_reserved(const Block &block, const Train *train)
 {
        if(&block==pending_block && !train)
index 866454164ee1592b9cb794f8413cc9509c3571a5..18ad6a1e1407d807330aedd359e686eb30d2e70a 100644 (file)
@@ -136,6 +136,7 @@ private:
        void loco_func_event(unsigned, unsigned, bool);
        void sensor_event(unsigned, bool);
        void turnout_event(unsigned, bool);
+       void halt_event(bool);
        void block_reserved(const Block &, const Train *);
        unsigned reserve_more();
        float get_real_speed(unsigned) const;