]> git.tdb.fi Git - r2c2.git/blobdiff - source/libmarklin/train.h
Framework for supporting multiple control protocols in a single driver
[r2c2.git] / source / libmarklin / train.h
index 8418d899c5d37980188d12bcc87c38d8dd4ff908..a13c422a9d8c2d35f989d2704e11447152d908f5 100644 (file)
@@ -75,19 +75,21 @@ private:
        Layout &layout;
        const VehicleType &loco_type;
        unsigned address;
+       std::string protocol;
        std::string name;
        int priority;
        const Train *yielding_to;
        std::vector<Vehicle *> vehicles;
-       BlockList cur_blocks;
-       BlockList rsv_blocks;
+       BlockList blocks;
+       BlockList::iterator cur_blocks_end;
+       BlockList::iterator clear_blocks_end;
        Block *pending_block;
        bool reserving;
        bool advancing;
        Controller *controller;
        Timetable *timetable;
        bool active;
-       unsigned current_speed;
+       unsigned current_speed_step;
        bool speed_changing;
        bool reverse;
        Msp::Time::TimeStamp stop_timeout;
@@ -104,12 +106,13 @@ private:
        float overshoot_dist;
 
 public:
-       Train(Layout &, const VehicleType &, unsigned);
+       Train(Layout &, const VehicleType &, unsigned, const std::string &);
        ~Train();
 
        Layout &get_layout() const { return layout; }
        const VehicleType &get_locomotive_type() const { return loco_type; }
        unsigned get_address() const { return address; }
+       const std::string &get_protocol() const { return protocol; }
        void set_name(const std::string &);
        const std::string &get_name() const { return name; }
        void set_priority(int);
@@ -141,7 +144,7 @@ public:
        const Route *get_route() const;
        void place(Block &, unsigned);
        void unplace();
-       bool is_placed() const { return !cur_blocks.empty(); }
+       bool is_placed() const { return !blocks.empty(); }
        bool free_block(Block &);
        void free_noncritical_blocks();
        int get_entry_to_block(Block &) const;
@@ -157,21 +160,22 @@ private:
        void loco_speed_event(unsigned, unsigned, bool);
        void loco_func_event(unsigned, unsigned, bool);
        void sensor_event(unsigned, bool);
-       void turnout_event(unsigned, bool);
+       void turnout_path_changed(Track &);
        void halt_event(bool);
        void block_reserved(const Block &, const Train *);
-       unsigned reserve_more();
+       void reserve_more();
+       void check_turnout_paths(bool);
        float get_reserved_distance_until(const Block *, bool) const;
        float get_real_speed(unsigned) const;
-       unsigned find_speed(float) const;
+       unsigned find_speed_step(float) const;
        float get_travel_speed() const;
        void set_status(const std::string &);
-       void release_blocks(BlockList &);
-       void release_blocks(BlockList &, BlockList::iterator, BlockList::iterator);
+       void release_blocks();
+       void release_blocks(BlockList::iterator, BlockList::iterator);
        void reverse_blocks(BlockList &) const;
        bool advance_route(std::list<RouteRef>::iterator &, Track &);
        Route *create_lead_route(Route *, const Route *);
-       bool is_valid_diversion(const Route &, Track &, unsigned);
+       bool is_valid_diversion(const Route &, const TrackIter &);
 };
 
 } // namespace Marklin