From: Mikko Rasa Date: Fri, 23 Apr 2010 17:11:35 +0000 (+0000) Subject: Mark train positions as inaccurate on halt X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=c5b6976004967e9e0a3c43ad025ebfa096894f3f;p=r2c2.git Mark train positions as inaccurate on halt --- diff --git a/source/libmarklin/train.cpp b/source/libmarklin/train.cpp index ed57dd7..973cc07 100644 --- a/source/libmarklin/train.cpp +++ b/source/libmarklin/train.cpp @@ -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) diff --git a/source/libmarklin/train.h b/source/libmarklin/train.h index 8664541..18ad6a1 100644 --- a/source/libmarklin/train.h +++ b/source/libmarklin/train.h @@ -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;