From: Mikko Rasa Date: Wed, 21 Apr 2010 23:08:10 +0000 (+0000) Subject: Add a separate double_address flag to TrackType X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=e990eb02d42cc4b9ff679b947a6911f79472f8f5;p=r2c2.git Add a separate double_address flag to TrackType --- diff --git a/source/libmarklin/track.cpp b/source/libmarklin/track.cpp index 208d40f..05f9f2f 100644 --- a/source/libmarklin/track.cpp +++ b/source/libmarklin/track.cpp @@ -130,8 +130,10 @@ void Track::set_active_path(unsigned p) throw InvalidParameterValue("Invalid path"); layout.get_driver().set_turnout(turnout_id, p&1); - if(type.get_n_paths()>2) + if(type.is_double_address()) layout.get_driver().set_turnout(turnout_id+1, p&2); + else if(type.get_n_paths()>2) + active_path = (active_path&1) | (p&2); } int Track::get_endpoint_by_link(const Track &other) const diff --git a/source/libmarklin/tracktype.cpp b/source/libmarklin/tracktype.cpp index 19b0c6b..d869779 100644 --- a/source/libmarklin/tracktype.cpp +++ b/source/libmarklin/tracktype.cpp @@ -14,7 +14,8 @@ using namespace Msp; namespace Marklin { TrackType::TrackType(unsigned a): - art_nr(a) + art_nr(a), + double_address(false) { } float TrackType::get_total_length() const @@ -52,11 +53,6 @@ bool TrackType::is_turnout() const return endpoints.size()>2; } -bool TrackType::is_double_address() const -{ - return get_n_paths()>2; -} - TrackPoint TrackType::get_point(unsigned epi, unsigned path, float d) const { if(epi>=endpoints.size()) @@ -158,6 +154,7 @@ TrackType::Loader::Loader(TrackType &t): Msp::DataFile::BasicLoader(t) { add("description", &TrackType::description); + add("double_address", &TrackType::double_address); add("part", &Loader::part); } diff --git a/source/libmarklin/tracktype.h b/source/libmarklin/tracktype.h index 14c9866..582f77a 100644 --- a/source/libmarklin/tracktype.h +++ b/source/libmarklin/tracktype.h @@ -32,6 +32,7 @@ private: std::string description; std::vector parts; std::vector endpoints; + bool double_address; public: TrackType(unsigned); @@ -43,7 +44,7 @@ public: unsigned get_paths() const; unsigned get_n_paths() const; bool is_turnout() const; - bool is_double_address() const; + bool is_double_address() const { return double_address; } const std::vector &get_parts() const { return parts; } const std::vector &get_endpoints() const { return endpoints; } TrackPoint get_point(unsigned, unsigned, float) const; diff --git a/tracks.dat b/tracks.dat index dafc85b..7a2c07a 100644 --- a/tracks.dat +++ b/tracks.dat @@ -308,6 +308,7 @@ track 24612 track 24630 { description "Turnout, 3-way"; + double_address true; part { length 188.3;