]> git.tdb.fi Git - r2c2.git/blobdiff - source/libmarklin/train.h
Change the control system to separate speed and reverse
[r2c2.git] / source / libmarklin / train.h
index 5960c27d16b78164da022a40e0c79e7529647244..f9ea6f17ae0001b39432e8cd83b57ac8fb4cf9ce 100644 (file)
@@ -16,10 +16,11 @@ Distributed under the GPL
 namespace Marklin {
 
 class ControlModel;
-class LocoType;
 class Route;
 class Timetable;
 class Vehicle;
+class VehicleType;
+struct TrainControl;
 
 class Train: public sigc::trackable
 {
@@ -28,16 +29,19 @@ public:
        {
        private:
                Block *prev_block;
+               bool blocks_valid;
 
        public:
                Loader(Train &);
        private:
+               virtual void finish();
                void block(unsigned);
                void block_hint(unsigned);
                void name(const std::string &);
                void real_speed(unsigned, float, float);
                void route(const std::string &);
                void timetable();
+               void vehicle(unsigned);
        };
 
        sigc::signal<void, const std::string &> signal_name_changed;
@@ -67,9 +71,10 @@ private:
        };
 
        Layout &layout;
-       const LocoType &loco_type;
+       const VehicleType &loco_type;
        unsigned address;
        std::string name;
+       int priority;
        std::vector<Vehicle *> vehicles;
        std::list<BlockRef> cur_blocks;
        std::list<BlockRef> rsv_blocks;
@@ -91,18 +96,25 @@ private:
        float travel_dist;
        bool pure_speed;
        std::vector<RealSpeed> real_speed;
+       bool accurate_position;
+       float overshoot_dist;
 
 public:
-       Train(Layout &, const LocoType &, unsigned);
+       Train(Layout &, const VehicleType &, unsigned);
        ~Train();
 
        Layout &get_layout() const { return layout; }
-       const LocoType &get_locomotive_type() const { return loco_type; }
+       const VehicleType &get_locomotive_type() const { return loco_type; }
        unsigned get_address() const { return address; }
        void set_name(const std::string &);
        const std::string &get_name() const { return name; }
-       ControlModel &get_control() const { return *control; }
+       void set_priority(int);
+       int get_priority() const { return priority; }
+       ControlModel &get_control_model() const { return *control; }
 
+       void add_vehicle(const VehicleType &);
+       void remove_vehicle(unsigned);
+       unsigned get_n_vehicles() const;
        Vehicle &get_vehicle(unsigned);
        const Vehicle &get_vehicle(unsigned) const;
 
@@ -110,10 +122,14 @@ public:
        void set_active(bool);
        void set_function(unsigned, bool);
        float get_control(const std::string &) const;
+       float get_speed() const;
        bool is_active() const { return active; }
        bool get_function(unsigned) const;
        unsigned get_functions() const { return functions; }
 
+       void set_timetable(Timetable *);
+       Timetable *get_timetable() { return timetable; }
+
        void set_route(const Route *);
        void go_to(const Track &);
        const Route *get_route() const { return route; }
@@ -129,10 +145,12 @@ public:
 
        void save(std::list<Msp::DataFile::Statement> &) const;
 private:
+       void control_changed(const TrainControl &);
        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 halt_event(bool);
        void block_reserved(const Block &, const Train *);
        unsigned reserve_more();
        float get_real_speed(unsigned) const;