]> git.tdb.fi Git - r2c2.git/commitdiff
Add a flag to Track to indicate that its path is changing
authorMikko Rasa <tdb@tdb.fi>
Tue, 12 Feb 2013 12:40:07 +0000 (14:40 +0200)
committerMikko Rasa <tdb@tdb.fi>
Tue, 12 Feb 2013 12:40:07 +0000 (14:40 +0200)
source/libr2c2/track.cpp
source/libr2c2/track.h

index 540c24743d05136f121816cba463a92c8f395c7f..d4e9d12d8ef7b08682f0f9c97d5f4cb36a3cce38 100644 (file)
@@ -21,7 +21,8 @@ Track::Track(Layout &l, const TrackType &t):
        turnout_id(0),
        sensor_id(0),
        links(type.get_endpoints().size()),
-       active_path(0)
+       active_path(0),
+       path_changing(false)
 {
        if(type.is_turnout())
                turnout_id = layout.allocate_turnout_id();
@@ -143,6 +144,7 @@ void Track::set_active_path(unsigned p)
        if(!(type.get_paths()&(1<<p)))
                throw invalid_argument("Track::set_active_path");
 
+       path_changing = true;
        layout.get_driver().set_turnout(turnout_id, p);
 }
 
@@ -373,6 +375,7 @@ void Track::turnout_event(unsigned addr, unsigned state)
        if(addr==turnout_id)
        {
                active_path = state;
+               path_changing = false;
                signal_path_changed.emit(active_path);
        }
 }
index 3ae5d602295dcd1fdcbf074b8d47880e8d5e45c8..4dbfa2db87eabd56c12616f759adebdef1f4ca2c 100644 (file)
@@ -41,6 +41,7 @@ private:
        unsigned sensor_id;
        std::vector<Track *> links;
        unsigned active_path;
+       bool path_changing;
 
        Track(const Track &);
        Track &operator=(const Track &);
@@ -69,6 +70,7 @@ public:
        unsigned get_sensor_id() const { return sensor_id; }
        void set_active_path(unsigned);
        unsigned get_active_path() const { return active_path; }
+       bool is_path_changing() const { return path_changing; }
 
        int get_endpoint_by_link(Track &) const;
        Vector get_endpoint_position(unsigned) const;