]> git.tdb.fi Git - r2c2.git/commitdiff
Rename turnout/sensor_id fields in Track and Block to *_addr
authorMikko Rasa <tdb@tdb.fi>
Thu, 7 Nov 2013 20:31:50 +0000 (22:31 +0200)
committerMikko Rasa <tdb@tdb.fi>
Thu, 7 Nov 2013 20:31:50 +0000 (22:31 +0200)
That's what they really are.  The *_id names would get in the way of what
I'm going to do next.

18 files changed:
source/designer/designer.cpp
source/designer/trackproperties.cpp
source/designer/trackproperties.h
source/engineer/engineer.cpp
source/libr2c2/block.cpp
source/libr2c2/block.h
source/libr2c2/blockallocator.cpp
source/libr2c2/blockiter.cpp
source/libr2c2/layout.cpp
source/libr2c2/layout.h
source/libr2c2/route.cpp
source/libr2c2/signal.cpp
source/libr2c2/track.cpp
source/libr2c2/track.h
source/libr2c2/trackcircuit.cpp
source/libr2c2/train.cpp
source/libr2c2/trainrouter.cpp
source/libr2c2/vehicle.cpp

index 30b022f8597e12e8e539d6b247d8e38d92728b9c..6706db6f4856755ab4a1e3a72e0140412a488c48 100644 (file)
@@ -516,17 +516,17 @@ void Designer::update_track_icon(Track3D &track)
        if(track.get_track().get_flex())
                overlay->add_graphic(track, "flex");
 
-       if(unsigned sid = track.get_track().get_sensor_id())
+       if(unsigned saddr = track.get_track().get_sensor_address())
        {
                overlay->add_graphic(track, "sensor");
-               overlay->set_label(track, lexical_cast<string>(sid));
+               overlay->set_label(track, lexical_cast<string>(saddr));
        }
-       else if(unsigned tid = track.get_track().get_turnout_id())
+       else if(unsigned taddr = track.get_track().get_turnout_address())
        {
-               if(tid<0x800)
+               if(taddr<0x800)
                {
                        overlay->add_graphic(track, "turnout");
-                       overlay->set_label(track, lexical_cast<string>(tid));
+                       overlay->set_label(track, lexical_cast<string>(taddr));
                }
        }
 }
@@ -566,10 +566,10 @@ string Designer::tooltip(int x, int y)
                {
                        if(mode!=CATALOGUE && abs(track->get_tilt()).radians()>1e-4)
                                info += format(" (slope %.1f%%)", abs(tan(track->get_tilt())*100));
-                       if(track->get_turnout_id())
-                               info += format(" (turnout %d)", track->get_turnout_id());
-                       else if(track->get_sensor_id())
-                               info += format(" (sensor %d)", track->get_sensor_id());
+                       if(track->get_turnout_address())
+                               info += format(" (turnout %d)", track->get_turnout_address());
+                       else if(track->get_sensor_address())
+                               info += format(" (sensor %d)", track->get_sensor_address());
                }
                return info;
        }
@@ -594,8 +594,8 @@ void Designer::show_route(const Route &route)
                Track3D &t3d = layout_3d->get_3d(**i);
                Path3D *path = new Path3D(t3d);
                path->set_color(GL::Color(0.5, 0.8, 1.0));
-               if(unsigned tid = (*i)->get_turnout_id())
-                       path->set_path(route.get_turnout(tid));
+               if(unsigned taddr = (*i)->get_turnout_address())
+                       path->set_path(route.get_turnout(taddr));
        }
 }
 
index c95ad02887f24d3bd99868aa7a6a6a83afe73253..59ce75111c25a0c5e001f77d1da7c38711b63f5a 100644 (file)
@@ -24,17 +24,17 @@ TrackProperties::TrackProperties(const Selection &s):
 
        {
                GLtk::Row row(*layout);
-               add(*(lbl1 = new GLtk::Label("Turnout ID")));
-               add(*(ent_turnout_id = new GLtk::Entry));
-               ent_turnout_id->set_edit_size(5, 1);
+               add(*(lbl1 = new GLtk::Label("Turnout address")));
+               add(*(ent_turnout_addr = new GLtk::Entry));
+               ent_turnout_addr->set_edit_size(5, 1);
        }
 
        {
                GLtk::Row row(*layout);
-               add(*(lbl2 = new GLtk::Label("Sensor ID")));
+               add(*(lbl2 = new GLtk::Label("Sensor address")));
                layout->add_constraint(*lbl1, GLtk::Layout::COPY_WIDTH, *lbl2);
-               add(*(ent_sensor_id = new GLtk::Entry));
-               ent_sensor_id->set_edit_size(5, 1);
+               add(*(ent_sensor_addr = new GLtk::Entry));
+               ent_sensor_addr->set_edit_size(5, 1);
        }
 
        GLtk::Button *btn;
@@ -51,25 +51,25 @@ TrackProperties::TrackProperties(const Selection &s):
 
        if(selection.size()==1)
        {
-               if(unsigned tid = selection.get_object<Track>()->get_turnout_id())
-                       ent_turnout_id->set_text(lexical_cast<string>(tid));
+               if(unsigned taddr = selection.get_object<Track>()->get_turnout_address())
+                       ent_turnout_addr->set_text(lexical_cast<string>(taddr));
        }
 
        const set<Track *> &tracks = selection.get_objects<Track>();
-       int sensor_id = -1;
+       int sensor_addr = -1;
        for(set<Track *>::const_iterator i=tracks.begin(); i!=tracks.end(); ++i)
        {
-               if(static_cast<int>((*i)->get_sensor_id())!=sensor_id)
+               if(static_cast<int>((*i)->get_sensor_address())!=sensor_addr)
                {
-                       if(sensor_id==-1)
-                               sensor_id = (*i)->get_sensor_id();
+                       if(sensor_addr==-1)
+                               sensor_addr = (*i)->get_sensor_address();
                        else
-                               sensor_id = -2;
+                               sensor_addr = -2;
                }
        }
 
-       if(sensor_id>=0)
-               ent_sensor_id->set_text(lexical_cast<string>(sensor_id));
+       if(sensor_addr>=0)
+               ent_sensor_addr->set_text(lexical_cast<string>(sensor_addr));
 }
 
 void TrackProperties::on_response(int code)
@@ -80,17 +80,17 @@ void TrackProperties::on_response(int code)
                {
                        Track *track = selection.get_object<Track>();
                        if(track->get_type().is_turnout())
-                               track->set_turnout_id(lexical_cast<unsigned>(ent_turnout_id->get_text()));
+                               track->set_turnout_address(lexical_cast<unsigned>(ent_turnout_addr->get_text()));
                }
 
-               string sensor_id_text = ent_sensor_id->get_text();
-               if(!sensor_id_text.empty())
+               string sensor_addr_text = ent_sensor_addr->get_text();
+               if(!sensor_addr_text.empty())
                {
-                       unsigned sensor_id = lexical_cast<unsigned>(sensor_id_text);
+                       unsigned sensor_addr = lexical_cast<unsigned>(sensor_addr_text);
                        const set<Track *> &tracks = selection.get_objects<Track>();
                        for(set<Track *>::const_iterator i=tracks.begin(); i!=tracks.end(); ++i)
                                if(!(*i)->get_type().is_turnout())
-                                       (*i)->set_sensor_id(sensor_id);
+                                       (*i)->set_sensor_address(sensor_addr);
                }
        }
 }
index 1e319511e574c006b34711c5311b3cd7422a4594..7c2946483df2590861ea4d4b665cf4e3e1d3b6c4 100644 (file)
@@ -10,8 +10,8 @@ class TrackProperties: public Msp::GLtk::Dialog
 {
 private:
        const Selection &selection;
-       Msp::GLtk::Entry *ent_turnout_id;
-       Msp::GLtk::Entry *ent_sensor_id;
+       Msp::GLtk::Entry *ent_turnout_addr;
+       Msp::GLtk::Entry *ent_sensor_addr;
 
 public:
        TrackProperties(const Selection &);
index c88bae8e24648cd09f8566d09c1dbf3ddbcb2607..87e3dda10003c7fd917dec1a94b619f2911ffb93 100644 (file)
@@ -193,7 +193,7 @@ void Engineer::button_press(unsigned btn)
                Object *obj = pick_object(pointer);
                if(Track *track = dynamic_cast<Track *>(obj))
                {
-                       if(track->get_turnout_id())
+                       if(track->get_turnout_address())
                        {
                                Block &block = track->get_block();
                                if(block.get_train() && block.get_train()->is_block_critical(block))
@@ -210,14 +210,14 @@ void Engineer::button_press(unsigned btn)
                                                        ++i;
                                        }
                                        track->set_active_path(i);
-                                       set_status(format("Turnout %d", track->get_turnout_id()));
+                                       set_status(format("Turnout %d", track->get_turnout_address()));
                                }
                        }
-                       if(unsigned sid = track->get_sensor_id())
+                       if(unsigned saddr = track->get_sensor_address())
                        {
                                if(options.simulate)
-                                       layout.get_driver().set_sensor(sid, !layout.get_driver().get_sensor(sid));
-                               set_status(format("Sensor %d", sid));
+                                       layout.get_driver().set_sensor(saddr, !layout.get_driver().get_sensor(saddr));
+                               set_status(format("Sensor %d", saddr));
                        }
                }
                else if(Vehicle *veh = dynamic_cast<Vehicle *>(obj))
index 33627f8a7cf354afd006ace1b18436090d979441..59ad3a3c990965ac67b9e0ccad5602aff5c35abb 100644 (file)
@@ -16,8 +16,8 @@ namespace R2C2 {
 Block::Block(Layout &l, Track &start):
        TrackChain(l),
        id(0),
-       sensor_id(start.get_sensor_id()),
-       turnout_id(start.get_turnout_id()),
+       sensor_addr(start.get_sensor_address()),
+       turnout_addr(start.get_turnout_address()),
        conflict(false),
        sensor(0),
        train(0)
@@ -49,7 +49,7 @@ Block::Block(Layout &l, Track &start):
        for(set<Block *>::const_iterator i=blocks.begin(); (!conflict && i!=blocks.end()); ++i)
                conflict = (id==(*i)->get_id());
 
-       if(!conflict && sensor_id)
+       if(!conflict && sensor_addr)
                sensor = new TrackCircuit(layout, *this);
 
        layout.add(*this);
@@ -81,7 +81,7 @@ void Block::on_track_added(Track &track)
 
 TrackChain::Validity Block::check_validity(Track &track) const
 {
-       if(track.get_sensor_id()!=sensor_id || track.get_turnout_id()!=turnout_id)
+       if(track.get_sensor_address()!=sensor_addr || track.get_turnout_address()!=turnout_addr)
                return INCOMPATIBLE;
 
        return TrackChain::check_validity(track);
@@ -174,10 +174,10 @@ bool Block::reserve(Train *t)
 
 void Block::determine_id()
 {
-       if(sensor_id)
-               id = 0x1000|sensor_id;
-       else if(turnout_id)
-               id = 0x2000|turnout_id;
+       if(sensor_addr)
+               id = 0x1000|sensor_addr;
+       else if(turnout_addr)
+               id = 0x2000|turnout_addr;
        else if(endpoints.size()==2)
        {
                unsigned id1 = endpoints[0].link ? endpoints[0].link->get_id() : 1;
index c3b7c8742fe8faa247b5af2948c885eea7c522a7..2f898b0992af7e14799fc576532265f8b808bff8 100644 (file)
@@ -32,8 +32,8 @@ public:
 
 private:
        unsigned id;
-       unsigned sensor_id;
-       unsigned turnout_id;
+       unsigned sensor_addr;
+       unsigned turnout_addr;
        bool conflict;
        TrackCircuit *sensor;
        std::vector<Endpoint> endpoints;
@@ -49,8 +49,8 @@ private:
 
 public:
        unsigned get_id() const { return id; }
-       unsigned get_sensor_id() const { return sensor_id; }
-       unsigned get_turnout_id() const { return turnout_id; }
+       unsigned get_sensor_address() const { return sensor_addr; }
+       unsigned get_turnout_address() const { return turnout_addr; }
        TrackCircuit *get_sensor() const { return sensor; }
        const std::vector<Endpoint> &get_endpoints() const { return endpoints; }
        const Endpoint &get_endpoint(unsigned) const;
index e28558a7e0cd9e715e32722900dae39e544729b3..2c92ddc647a5178672200f3cb49ffc5b62f18715 100644 (file)
@@ -42,7 +42,7 @@ BlockAllocator::BlockAllocator(Train &t):
 
        const set<Track *> &tracks = layout.get_all<Track>();
        for(set<Track *>::const_iterator i=tracks.begin(); i!=tracks.end(); ++i)
-               if((*i)->get_turnout_id())
+               if((*i)->get_turnout_address())
                {
                        (*i)->signal_path_changing.connect(sigc::hide(sigc::bind(sigc::mem_fun(this, &BlockAllocator::turnout_path_changing), sigc::ref(**i))));
                        (*i)->signal_path_changed.connect(sigc::hide(sigc::bind(sigc::mem_fun(this, &BlockAllocator::turnout_path_changed), sigc::ref(**i))));
@@ -207,7 +207,7 @@ void BlockAllocator::reserve_more()
        float dist = 0;
        for(BlockList::const_iterator i=cur_blocks_end; i!=blocks.end(); ++i)
        {
-               if((*i)->get_sensor_id())
+               if((*i)->get_sensor_address())
                        ++nsens;
                if(nsens>0)
                        dist += (*i)->get_path_length(i->entry());
@@ -228,7 +228,7 @@ void BlockAllocator::reserve_more()
                        // The track ends here
                        break;
 
-               if(block->get_turnout_id() && !prev->get_turnout_id())
+               if(block->get_turnout_address() && !prev->get_turnout_address())
                {
                        /* We are arriving at a turnout.  See if we have enough blocks and
                        distance reserved. */
@@ -279,7 +279,7 @@ void BlockAllocator::reserve_more()
                if(&*block==stop_at_block)
                        break;
 
-               if(block->get_sensor_id())
+               if(block->get_sensor_address())
                        ++nsens;
                if(nsens>0)
                        dist += block->get_path_length(block.entry());
@@ -611,8 +611,8 @@ void BlockAllocator::Loader::block(unsigned id)
        obj.blocks.push_back(BlockIter(blk, entry));
        blk->reserve(&obj.train);
 
-       if(blk->get_sensor_id())
-               obj.train.get_layout().get_driver().set_sensor(blk->get_sensor_id(), true);
+       if(blk->get_sensor_address())
+               obj.train.get_layout().get_driver().set_sensor(blk->get_sensor_address(), true);
 
        prev_block = blk;
 }
index a3f6d876a8b40000472283ca276c586bcfc1c482..9dcca6c68672a9392883ff4ccb4803358588a7f1 100644 (file)
@@ -40,7 +40,7 @@ const Block::Endpoint &BlockIter::endpoint() const
 int BlockIter::get_exit(const Route *route) const
 {
        const vector<Block::Endpoint> &eps = _block->get_endpoints();
-       if(_block->get_turnout_id())
+       if(_block->get_turnout_address())
        {
                /* The endpoints of a turnout block exactly correspond to the endpoints
                of the track. */
index c2de1c599a08712ec1893602e527d96972d2a246..c23ad38fb1d39969c2463ebab919ea165a3b0895 100644 (file)
@@ -39,7 +39,7 @@ namespace R2C2 {
 Layout::Layout(Catalogue &c, Driver *d):
        catalogue(c),
        driver(d),
-       next_turnout_id(0x800)
+       next_turnout_addr(0x800)
 {
        clock.set_rate(60);
 }
@@ -227,18 +227,18 @@ void Layout::remove(BeamGate &g)
        remove(static_cast<Sensor &>(g));
 }
 
-unsigned Layout::allocate_turnout_id()
+unsigned Layout::allocate_turnout_address()
 {
-       set<unsigned> used_ids;
+       set<unsigned> used_addrs;
        const set<Track *> &tracks = objects.get<Track>();
        for(set<Track *>::const_iterator i=tracks.begin(); i!=tracks.end(); ++i)
-               if((*i)->get_turnout_id())
-                       used_ids.insert((*i)->get_turnout_id());
+               if((*i)->get_turnout_address())
+                       used_addrs.insert((*i)->get_turnout_address());
 
-       unsigned result = next_turnout_id;
-       while(used_ids.count(result))
+       unsigned result = next_turnout_addr;
+       while(used_addrs.count(result))
                ++result;
-       next_turnout_id = result+1;
+       next_turnout_addr = result+1;
 
        return result;
 }
@@ -449,8 +449,8 @@ void Layout::save_dynamic(const string &fn) const
 
        const set<Track *> &tracks = objects.get<Track>();
        for(set<Track *>::const_iterator i=tracks.begin(); i!=tracks.end(); ++i)
-               if(unsigned tid = (*i)->get_turnout_id())
-                       writer.write((DataFile::Statement("turnout"), tid, (*i)->get_active_path()));
+               if(unsigned taddr = (*i)->get_turnout_address())
+                       writer.write((DataFile::Statement("turnout"), taddr, (*i)->get_active_path()));
 
        for(map<unsigned, Train *>::const_iterator i=trains.begin(); i!=trains.end(); ++i)
        {
index 59eae083d05253b6d8c7d5a5e80ad0498d136c94..d1428cf70100070972a8758ee9ad0782e5d8b9fd 100644 (file)
@@ -88,7 +88,7 @@ private:
        Storage<Sensor> sensors;
        std::map<unsigned, Train *> trains;
        Msp::Time::TimeStamp last_tick;
-       unsigned next_turnout_id;
+       unsigned next_turnout_addr;
 
 public:
        Layout(Catalogue &, Driver * = 0);
@@ -119,7 +119,7 @@ public:
        void remove(Sensor &);
        void remove(BeamGate &);
 
-       unsigned allocate_turnout_id();
+       unsigned allocate_turnout_address();
 
        Block &get_block(unsigned) const;
        void create_blocks();
index c8f1ed3539881856a7026f30324de456c334dc2c..b3dc474d81d4cbdfeb68bf13d162646cd4262691 100644 (file)
@@ -157,7 +157,7 @@ void Route::update_turnouts()
        for(set<Track *>::const_iterator i=tracks.begin(); i!=tracks.end(); ++i)
                if((*i)->get_type().is_turnout())
                {
-                       found.insert((*i)->get_turnout_id());
+                       found.insert((*i)->get_turnout_address());
                        update_turnout(**i);
                }
 
@@ -186,7 +186,7 @@ void Route::update_turnout(Track &track)
                if(link->get_type().is_turnout())
                {
                        const TrackType::Endpoint &link_ep = link->get_type().get_endpoint(link->get_link_slot(track));
-                       int p = get_turnout(link->get_turnout_id());
+                       int p = get_turnout(link->get_turnout_address());
                        if(p>=0 && !link_ep.has_path(p))
                                // The linked track is a turnout and has a path which is incompatible with this endpoint
                                ep_mask = ~ep_mask;
@@ -195,17 +195,17 @@ void Route::update_turnout(Track &track)
                mask &= ep_mask;
        }
 
-       unsigned tid = track.get_turnout_id();
+       unsigned taddr = track.get_turnout_address();
        if(mask && !(mask&(mask-1)))
        {
                // Exactly one possible choice, set the path accordingly
                unsigned path = 0;
                for(; (mask && !(mask&1)); mask>>=1, ++path) ;
-               turnouts[tid] = path;
+               turnouts[taddr] = path;
        }
-       else if(!turnouts.count(tid))
+       else if(!turnouts.count(taddr))
                // More than one possible choice, and no existing entry - set as undecided
-               turnouts[tid] = -1;
+               turnouts[taddr] = -1;
 }
 
 int Route::get_turnout(unsigned id) const
@@ -218,9 +218,9 @@ int Route::get_turnout(unsigned id) const
 
 unsigned Route::get_path(Track &trk) const
 {
-       if(unsigned tid = trk.get_turnout_id())
+       if(unsigned taddr = trk.get_turnout_address())
        {
-               map<unsigned, int>::const_iterator i = turnouts.find(tid);
+               map<unsigned, int>::const_iterator i = turnouts.find(taddr);
                if(i!=turnouts.end())
                        return i->second;
        }
@@ -295,7 +295,7 @@ void Route::Loader::finish()
        for(set<Track *>::const_iterator i=ltracks.begin(); i!=ltracks.end(); ++i)
                if((*i)->get_type().is_turnout())
                {
-                       TurnoutMap::iterator j = turnouts.find((*i)->get_turnout_id());
+                       TurnoutMap::iterator j = turnouts.find((*i)->get_turnout_address());
                        if(j!=turnouts.end())
                                turnout_tracks[*i] = j->second;
                }
index 73563b6e815d1d6b7d3c8fd6ca957a4120ca8cca..72b35a737015f0d74349380cde8ac3a81c92b9bf 100644 (file)
@@ -110,7 +110,7 @@ void Signal::tick(const Time::TimeDelta &)
                BlockIter iter = block.next();
                while(iter && iter->get_train()==train)
                {
-                       if(iter->get_sensor_id())
+                       if(iter->get_sensor_address())
                                ++n_blocks;
                        iter=iter.next();
                }
@@ -160,7 +160,7 @@ void Signal::train_advanced(Block &b)
 {
        if(&b==block.block())
                passing = true;
-       else if(passing && b.get_sensor_id())
+       else if(passing && b.get_sensor_address())
        {
                layout.get_driver().set_signal(address, type.get_indications().back().aspect);
                reset();
index 25159863917ab266de87bd44b5472f01702242d0..44d992ba07290bef90ded2471b99c36c029db89c 100644 (file)
@@ -33,20 +33,20 @@ Track::Track(Layout &l, const TrackType &t):
        block(0),
        slope(0),
        flex(false),
-       turnout_id(0),
-       sensor_id(0),
+       turnout_addr(0),
+       sensor_addr(0),
        links(type.get_endpoints().size()),
        active_path(0),
        path_changing(false)
 {
        if(type.is_turnout())
        {
-               turnout_id = layout.allocate_turnout_id();
+               turnout_addr = layout.allocate_turnout_address();
 
                if(layout.has_driver())
                {
                        Driver &driver = layout.get_driver();
-                       driver.add_turnout(turnout_id, type);
+                       driver.add_turnout(turnout_addr, type);
                        driver.signal_turnout.connect(sigc::mem_fun(this, &Track::turnout_event));
                }
        }
@@ -60,8 +60,8 @@ Track::Track(Layout &l, const TrackType &t):
 Track::~Track()
 {
        break_links();
-       if(layout.has_driver() && turnout_id)
-               layout.get_driver().remove_turnout(turnout_id);
+       if(layout.has_driver() && turnout_addr)
+               layout.get_driver().remove_turnout(turnout_addr);
        layout.remove(*this);
 }
 
@@ -157,43 +157,43 @@ void Track::check_slope()
        signal_moved.emit();
 }
 
-void Track::set_turnout_id(unsigned i)
+void Track::set_turnout_address(unsigned a)
 {
        if(!type.is_turnout())
                throw logic_error("not a turnout");
-       if(!i)
+       if(!a)
                throw invalid_argument("Track::set_turnout_id");
 
        Driver *driver = (layout.has_driver() ? &layout.get_driver() : 0);
 
-       if(driver && turnout_id)
-               driver->remove_turnout(turnout_id);
-       turnout_id = i;
+       if(driver && turnout_addr)
+               driver->remove_turnout(turnout_addr);
+       turnout_addr = a;
        layout.create_blocks(*this);
        layout.update_routes();
-       if(driver && turnout_id)
-               driver->add_turnout(turnout_id, type);
+       if(driver && turnout_addr)
+               driver->add_turnout(turnout_addr, type);
 }
 
-void Track::set_sensor_id(unsigned i)
+void Track::set_sensor_address(unsigned a)
 {
        if(type.is_turnout())
                throw logic_error("is a turnout");
 
-       sensor_id = i;
+       sensor_addr = a;
        layout.create_blocks(*this);
 }
 
 void Track::set_active_path(unsigned p)
 {
-       if(!turnout_id)
+       if(!turnout_addr)
                throw logic_error("not a turnout");
        if(!(type.get_paths()&(1<<p)))
                throw invalid_argument("Track::set_active_path");
 
        signal_path_changing(p);
        path_changing = true;
-       layout.get_driver().set_turnout(turnout_id, p);
+       layout.get_driver().set_turnout(turnout_addr, p);
 }
 
 float Track::get_path_length(int p) const
@@ -398,17 +398,17 @@ void Track::save(list<DataFile::Statement> &st) const
        st.push_back((DataFile::Statement("position"), position.x, position.y, position.z));
        st.push_back((DataFile::Statement("rotation"), rotation.radians()));
        st.push_back((DataFile::Statement("tilt"), tilt.radians()));
-       if(turnout_id)
-               st.push_back((DataFile::Statement("turnout_id"), turnout_id));
-       if(sensor_id)
-               st.push_back((DataFile::Statement("sensor_id"), sensor_id));
+       if(turnout_addr)
+               st.push_back((DataFile::Statement("turnout_address"), turnout_addr));
+       if(sensor_addr)
+               st.push_back((DataFile::Statement("sensor_address"), sensor_addr));
        if(flex)
                st.push_back((DataFile::Statement("flex"), true));
 }
 
 void Track::turnout_event(unsigned addr, unsigned state)
 {
-       if(addr==turnout_id)
+       if(addr==turnout_addr)
        {
                active_path = state;
                path_changing = false;
@@ -423,8 +423,10 @@ Track::Loader::Loader(Track &t):
        add("position",   &Loader::position);
        add("rotation",   &Loader::rotation);
        add("tilt",       &Loader::tilt);
-       add("turnout_id", &Loader::turnout_id);
-       add("sensor_id",  &Loader::sensor_id);
+       add("turnout_id", &Loader::turnout_address);
+       add("turnout_address", &Loader::turnout_address);
+       add("sensor_id",  &Loader::sensor_address);
+       add("sensor_address",  &Loader::sensor_address);
        add("flex",       &Track::flex);
 
        // deprecated
@@ -441,9 +443,9 @@ void Track::Loader::rotation(float r)
        obj.set_rotation(Angle::from_radians(r));
 }
 
-void Track::Loader::sensor_id(unsigned id)
+void Track::Loader::sensor_address(unsigned addr)
 {
-       obj.set_sensor_id(id);
+       obj.set_sensor_address(addr);
 }
 
 void Track::Loader::slope(float s)
@@ -456,9 +458,9 @@ void Track::Loader::tilt(float t)
        obj.set_tilt(Angle::from_radians(t));
 }
 
-void Track::Loader::turnout_id(unsigned id)
+void Track::Loader::turnout_address(unsigned addr)
 {
-       obj.set_turnout_id(id);
+       obj.set_turnout_address(addr);
 }
 
 } // namespace R2C2
index 79365afbcceb04c8d1e291ab7b37fee54d85c9a9..1d8cd714bf279a50dd726abf1852bc85955585c7 100644 (file)
@@ -25,10 +25,10 @@ public:
        private:
                void position(float, float, float);
                void rotation(float);
-               void sensor_id(unsigned);
+               void sensor_address(unsigned);
                void slope(float);
                void tilt(float);
-               void turnout_id(unsigned);
+               void turnout_address(unsigned);
        };
 
        typedef std::list<TrackAttachment *> AttachmentList;
@@ -42,8 +42,8 @@ private:
        Block *block;
        float slope;
        bool flex;
-       unsigned turnout_id;
-       unsigned sensor_id;
+       unsigned turnout_addr;
+       unsigned sensor_addr;
        std::vector<Track *> links;
        unsigned active_path;
        bool path_changing;
@@ -70,10 +70,10 @@ private:
        void check_slope();
 
 public:
-       void set_turnout_id(unsigned);
-       void set_sensor_id(unsigned);
-       unsigned get_turnout_id() const { return turnout_id; }
-       unsigned get_sensor_id() const { return sensor_id; }
+       void set_turnout_address(unsigned);
+       void set_sensor_address(unsigned);
+       unsigned get_turnout_address() const { return turnout_addr; }
+       unsigned get_sensor_address() const { return sensor_addr; }
        void set_active_path(unsigned);
        unsigned get_active_path() const { return active_path; }
        bool is_path_changing() const { return path_changing; }
index 7efe4d094cae020a88e7e154e2ecd38f105f2b09..851a2ba0669c595d42a05d35f0fedd804c14737c 100644 (file)
@@ -10,7 +10,7 @@ TrackCircuit::TrackCircuit(Layout &l, Block &b):
        Sensor(l),
        block(b)
 {
-       Sensor::set_address(block.get_sensor_id());
+       Sensor::set_address(block.get_sensor_address());
 }
 
 void TrackCircuit::set_address(unsigned)
index b1664633bc75e06dbb13fbcb92b1fadcea8945f5..50ad137723d42ec2a8c10775767a3de92c91d745 100644 (file)
@@ -255,7 +255,7 @@ BlockIter Train::get_first_noncritical_block() const
 
                dist += i->get_path_length(i.entry());
 
-               if(i->get_sensor_id())
+               if(i->get_sensor_address())
                        sensor_seen = true;
        }
 
@@ -444,7 +444,7 @@ void Train::sensor_state_changed(Sensor &sensor, Sensor::State state)
        if(last_entry_block && &*last_entry_block!=block)
        {
                for(BlockIter i=last_entry_block.next(); (i && &*i!=block); i=i.next())
-                       if(i->get_train()!=this || i->get_sensor_id())
+                       if(i->get_train()!=this || i->get_sensor_address())
                                return;
        }
 
index 100842b6001fc44ebbf32a06e08ed0331f346189..b5a5bef11f674f3301a36c1304558bc63b2bc8fa 100644 (file)
@@ -183,9 +183,9 @@ void TrainRouter::block_reserved(Block &block, Train *t)
        if(advance_route(route, block))
        {
                // Check if the block is a turnout and set it to proper path
-               if(unsigned tid = block.get_turnout_id())
+               if(unsigned taddr = block.get_turnout_address())
                {
-                       int path = (*route)->get_turnout(tid);
+                       int path = (*route)->get_turnout(taddr);
                        if(path>=0)
                                b_iter.track_iter()->set_active_path(path);
                }
index 02fb1afce6d4c719367560d3dbf677e208b1c795..099644a1301ca8360101d894fec8c9d5c74a4fc3 100644 (file)
@@ -247,7 +247,7 @@ void Vehicle::propagate_backward()
 
 void Vehicle::check_sensor(const TrackOffsetIter &t, unsigned &sensor, bool release)
 {
-       unsigned s = t->get_sensor_id();
+       unsigned s = t->get_sensor_address();
        if(s!=sensor)
        {
                unsigned old = sensor;