X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibmarklin%2Ftrain.h;h=02d1d52de1b8751d411bc5aa063300f46d2fb110;hb=29b131b59ba562f996a338a453745e5a4dfad5b7;hp=4289d3c0dd9b5b77e13224b8c8a01eb616771def;hpb=9ddcd066e37e4c72685817c042c30897786ece05;p=r2c2.git diff --git a/source/libmarklin/train.h b/source/libmarklin/train.h index 4289d3c..02d1d52 100644 --- a/source/libmarklin/train.h +++ b/source/libmarklin/train.h @@ -12,13 +12,14 @@ Distributed under the GPL #include #include #include "block.h" +#include "controller.h" namespace Marklin { -class ControlModel; -class LocoType; class Route; +class Timetable; class Vehicle; +class VehicleType; class Train: public sigc::trackable { @@ -27,15 +28,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 signal_name_changed; @@ -65,14 +70,19 @@ private: }; Layout &layout; - const LocoType &loco_type; + const VehicleType &loco_type; unsigned address; std::string name; + int priority; + const Train *yielding_to; std::vector vehicles; std::list cur_blocks; std::list rsv_blocks; Block *pending_block; - ControlModel *control; + bool reserving; + bool advancing; + Controller *controller; + Timetable *timetable; bool active; unsigned current_speed; bool speed_changing; @@ -88,18 +98,26 @@ private: float travel_dist; bool pure_speed; std::vector 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); + void yield_to(const Train &); + int get_priority() const { return priority; } + Controller &get_controller() const { return *controller; } + + void add_vehicle(const VehicleType &); + void remove_vehicle(unsigned); + unsigned get_n_vehicles() const; Vehicle &get_vehicle(unsigned); const Vehicle &get_vehicle(unsigned) const; @@ -107,14 +125,19 @@ 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; } void place(Block &, unsigned); + void unplace(); bool is_placed() const { return !cur_blocks.empty(); } bool free_block(Block &); int get_entry_to_block(Block &) const; @@ -126,12 +149,15 @@ public: void save(std::list &) const; private: + void control_changed(const Controller::Control &); 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_reserved_distance_until(const Block *, bool) const; float get_real_speed(unsigned) const; unsigned find_speed(float) const; float get_travel_speed() const;