X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftrain.h;h=dff9aae666fa3f301b02bf21203024c578a677dc;hb=ecd7af790bd3ab7c7e768f68968379e1feea56a9;hp=03b8b66d3e1e929869431c0ec472853d823dbdaf;hpb=dda1e6c8716b6ac70d63a3f6ff95474a8b8b7336;p=r2c2.git diff --git a/source/libr2c2/train.h b/source/libr2c2/train.h index 03b8b66..dff9aae 100644 --- a/source/libr2c2/train.h +++ b/source/libr2c2/train.h @@ -4,15 +4,16 @@ #include #include #include -#include -#include "block.h" +#include #include "blockallocator.h" #include "controller.h" +#include "sensor.h" #include "trainai.h" namespace R2C2 { class ArticleNumber; +class Block; class SpeedQuantizer; class Vehicle; class VehicleType; @@ -35,7 +36,7 @@ public: void quantized_speed(); void router(); void timetable(); - void vehicle(ArticleNumber); + void vehicle(const std::string &); }; sigc::signal signal_name_changed; @@ -43,12 +44,16 @@ public: sigc::signal signal_function_changed; sigc::signal signal_ai_event; sigc::signal signal_advanced; + sigc::signal signal_rear_advanced; + sigc::signal signal_vehicle_added; + sigc::signal signal_vehicle_removed; private: Layout &layout; const VehicleType &loco_type; unsigned address; std::string protocol; + unsigned loco_id; std::string name; const Train *preceding_train; std::vector vehicles; @@ -56,15 +61,14 @@ private: bool advancing; Controller *controller; std::list ais; - bool active; unsigned current_speed_step; bool speed_changing; bool reverse; - Msp::Time::TimeStamp stop_timeout; + Msp::Time::TimeDelta stop_timeout; unsigned functions; BlockIter last_entry_block; - Msp::Time::TimeStamp last_entry_time; + Msp::Time::TimeDelta travel_time; bool pure_speed; SpeedQuantizer *speed_quantizer; bool accurate_position; @@ -90,13 +94,12 @@ public: 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; float get_speed() const; float get_quantized_speed() const; unsigned get_speed_step() const { return current_speed_step; } - bool is_active() const { return active; } + float get_maximum_speed() const; bool get_function(unsigned) const; unsigned get_functions() const { return functions; } @@ -113,27 +116,30 @@ public: return 0; } - void place(const BlockIter &); + bool place(const BlockIter &); void unplace(); bool is_placed() const { return !allocator.empty(); } void stop_at(Block *); - bool free_block(Block &); - void free_noncritical_blocks(); - void reserve_more(); + bool is_block_critical(const Block &) const; + BlockIter get_last_critical_block() const; +private: + BlockIter check_critical_blocks(const Block *) const; +public: + void refresh_blocks_from(Block &); const BlockAllocator &get_block_allocator() const { return allocator; } float get_reserved_distance() const; - void tick(const Msp::Time::TimeStamp &, const Msp::Time::TimeDelta &); + void tick(const Msp::Time::TimeDelta &); 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 block_state_changed(Block &, Block::State); + void advanced(Block &, Sensor *); void halt_event(bool); void block_reserved(const Block &, const Train *); - float get_reserved_distance_until(const Block *, bool) const; + float get_reserved_distance_until(const Block *) const; }; } // namespace R2C2