]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/train.h
Make the simulation independent of wall clock time
[r2c2.git] / source / libr2c2 / train.h
index 6b384f8220b9eece5e5873ead9ab07283d601755..c0eb52e850006cd4ca48f41f1ad35dd77da227f3 100644 (file)
@@ -4,15 +4,16 @@
 #include <sigc++/signal.h>
 #include <sigc++/trackable.h>
 #include <msp/datafile/objectloader.h>
-#include <msp/time/timestamp.h>
-#include "block.h"
+#include <msp/time/timedelta.h>
 #include "blockallocator.h"
 #include "controller.h"
+#include "sensor.h"
 #include "trainai.h"
 
 namespace R2C2 {
 
 class ArticleNumber;
+class Block;
 class SpeedQuantizer;
 class Vehicle;
 class VehicleType;
@@ -34,7 +35,6 @@ public:
                void name(const std::string &);
                void quantized_speed();
                void router();
-               void timetable();
                void vehicle(ArticleNumber);
        };
 
@@ -60,11 +60,11 @@ private:
        unsigned current_speed_step;
        bool speed_changing;
        bool reverse;
-       Msp::Time::TimeStamp stop_timeout;
+       Msp::Time::TimeDelta stop_timeout;
        unsigned functions;
 
-       Msp::Time::TimeStamp last_entry_time;
-       float travel_dist;
+       BlockIter last_entry_block;
+       Msp::Time::TimeDelta travel_time;
        bool pure_speed;
        SpeedQuantizer *speed_quantizer;
        bool accurate_position;
@@ -123,17 +123,17 @@ public:
        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<Msp::DataFile::Statement> &) 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 sensor_state_changed(Sensor &, Sensor::State);
        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