X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibmarklin%2Ftrain.h;h=ccfcbec1058f0dd6c12ab5409ad66415e4c27298;hb=cf52013784607dc4d307bd1244c5346ee88336a4;hp=bacb246f4dfd5f68a4dee346aa92abf5a85bebcf;hpb=a6a65f32fdf1b0eae00bfcafa70dbca5391cb09e;p=r2c2.git diff --git a/source/libmarklin/train.h b/source/libmarklin/train.h index bacb246..ccfcbec 100644 --- a/source/libmarklin/train.h +++ b/source/libmarklin/train.h @@ -1,7 +1,7 @@ /* $Id$ This file is part of the MSP Märklin suite -Copyright © 2006-2009 Mikkosoft Productions, Mikko Rasa +Copyright © 2006-2010 Mikkosoft Productions, Mikko Rasa Distributed under the GPL */ @@ -15,26 +15,37 @@ Distributed under the GPL namespace Marklin { -class Locomotive; +class ControlModel; +class LocoType; class Route; -class Sensor; -class TrafficManager; -class Turnout; +class Timetable; +class Vehicle; class Train: public sigc::trackable { public: class Loader: public Msp::DataFile::BasicLoader { + private: + Block *prev_block; + public: Loader(Train &); private: + 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; - sigc::signal signal_target_speed_changed; + sigc::signal signal_control_changed; + sigc::signal signal_function_changed; sigc::signal signal_route_changed; + sigc::signal signal_arrived; sigc::signal signal_status_changed; private: @@ -43,7 +54,8 @@ private: Block *block; unsigned entry; - BlockRef(Block *s, unsigned e): block(s), entry(e) { } + BlockRef(Block *, unsigned); + BlockRef next() const; }; struct RealSpeed @@ -55,57 +67,91 @@ private: void add(float, float); }; - TrafficManager &trfc_mgr; + Layout &layout; + const LocoType &loco_type; + unsigned address; std::string name; - Locomotive &loco; + int priority; + std::vector vehicles; std::list cur_blocks; std::list rsv_blocks; Block *pending_block; - unsigned target_speed; + ControlModel *control; + Timetable *timetable; + bool active; + unsigned current_speed; + bool speed_changing; + bool reverse; + Msp::Time::TimeStamp stop_timeout; + unsigned functions; const Route *route; - Msp::Time::TimeStamp try_reserve; + const Route *next_route; + bool end_of_route; std::string status; Msp::Time::TimeStamp last_entry_time; float travel_dist; - unsigned travel_speed; bool pure_speed; std::vector real_speed; - - Track *cur_track; - unsigned cur_track_ep; - float offset; - Point pos; + bool accurate_position; + float overshoot_dist; public: - Train(TrafficManager &, Locomotive &); + Train(Layout &, const LocoType &, unsigned); + ~Train(); + Layout &get_layout() const { return layout; } + const LocoType &get_locomotive_type() const { return loco_type; } + unsigned get_address() const { return address; } void set_name(const std::string &); - void set_speed(unsigned); - void set_reverse(bool); - void set_route(const Route *); const std::string &get_name() const { return name; } - Locomotive &get_locomotive() const { return loco; } - unsigned get_target_speed() const { return target_speed; } + void set_priority(int); + int get_priority() const { return priority; } + ControlModel &get_control() const { return *control; } + + Vehicle &get_vehicle(unsigned); + const Vehicle &get_vehicle(unsigned) const; + + void set_control(const std::string &, float); + void set_active(bool); + void set_function(unsigned, bool); + float get_control(const std::string &) 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); + bool is_placed() const { return !cur_blocks.empty(); } + bool free_block(Block &); + int get_entry_to_block(Block &) const; + float get_reserved_distance() const; + const std::string &get_status() const { return status; } - const Point &get_position() const { return pos; } - void place(Block *, unsigned); - bool free_block(Block *); + void tick(const Msp::Time::TimeStamp &, const Msp::Time::TimeDelta &); + void save(std::list &) const; private: - void locomotive_reverse_changed(bool); - void sensor_event(bool, Sensor *); - void turnout_path_changing(unsigned, Turnout *); - void turnout_path_changed(unsigned, Turnout *); + 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(); - void update_speed(); float get_real_speed(unsigned) const; unsigned find_speed(float) const; + float get_travel_speed() const; void set_status(const std::string &); - void set_position(const Block::Endpoint &); - void release_reserved_blocks(); + void release_blocks(std::list &); + void release_blocks(std::list &, std::list::iterator, std::list::iterator); + void reverse_blocks(std::list &) const; }; } // namespace Marklin