]> git.tdb.fi Git - r2c2.git/blobdiff - source/libmarklin/train.h
Allow setting sensor ID for multiple tracks at once
[r2c2.git] / source / libmarklin / train.h
index 363fb5572c9184dde7a64e339815f3fbe4f28983..43ee84dc5cd6c590e7d7a69a16dfe0eb0f3cf982 100644 (file)
@@ -1,44 +1,66 @@
+/* $Id$
+
+This file is part of the MSP Märklin suite
+Copyright © 2006-2009 Mikkosoft Productions, Mikko Rasa
+Distributed under the GPL
+*/
+
 #ifndef LIBMARKLIN_TRAIN_H_
 #define LIBMARKLIN_TRAIN_H_
 
+#include <sigc++/signal.h>
 #include <sigc++/trackable.h>
-#include "section.h"
+#include <msp/time/timestamp.h>
+#include "block.h"
 
 namespace Marklin {
 
 class Locomotive;
+class Sensor;
 class TrafficManager;
 
 class Train: public sigc::trackable
 {
-public:
-       Train(TrafficManager &, Locomotive &);
-       const std::string &get_name() const { return name; }
-       void set_speed(unsigned);
-       void place(Section *, const Section::Endpoint *);
-       bool free_section(Section *);
-       void tick();
 private:
-       struct SectionRef
+       struct BlockRef
        {
-               Section *section;
-               const Section::Endpoint *entry;
+               Block *block;
+               unsigned entry;
 
-               SectionRef(Section *s, const Section::Endpoint *e): section(s), entry(e) { }
+               BlockRef(Block *s, unsigned e): block(s), entry(e) { }
        };
-       typedef std::list<SectionRef> SectRefSeq;
 
        TrafficManager &trfc_mgr;
        std::string name;
        Locomotive &loco;
-       SectRefSeq cur_sections;
-       SectRefSeq rsv_sections;
+       std::list<BlockRef> cur_blocks;
+       std::list<BlockRef> rsv_blocks;
        unsigned target_speed;
+       Msp::Time::TimeStamp try_reserve;
+       std::string status;
+       Msp::Time::TimeStamp last_entry_time;
+       float travel_dist;
+       unsigned real_speed;
 
-       void sensor_event(unsigned, bool);
-       bool reserve_more();
+public:
+       sigc::signal<void, const std::string &> signal_name_changed;
+       sigc::signal<void, const std::string &> signal_status_changed;
+
+       Train(TrafficManager &, Locomotive &);
+
+       void set_name(const std::string &);
+       void set_speed(unsigned);
+       const std::string &get_name() const { return name; }
+       Locomotive &get_locomotive() const { return loco; }
+       const std::string &get_status() const { return status; }
+       void place(Block *, unsigned);
+       bool free_block(Block *);
+       void tick(const Msp::Time::TimeStamp &);
+private:
+       void sensor_event(bool, Sensor *);
+       unsigned reserve_more();
+       void set_status(const std::string &);
 };
-typedef std::list<Train *> TrainSeq;
 
 } // namespace Marklin