/* $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
*/
namespace Marklin {
-class Locomotive;
+class LocoType;
class Route;
-class Sensor;
-class TrafficManager;
-class Turnout;
class Train: public sigc::trackable
{
sigc::signal<void, const std::string &> signal_name_changed;
sigc::signal<void, unsigned> signal_target_speed_changed;
+ sigc::signal<void, unsigned> signal_speed_changed;
+ sigc::signal<void, bool> signal_reverse_changed;
+ sigc::signal<void, unsigned, bool> signal_function_changed;
sigc::signal<void, const Route *> signal_route_changed;
sigc::signal<void, const std::string &> signal_status_changed;
void add(float, float);
};
- TrafficManager &trfc_mgr;
+ Layout &layout;
+ const LocoType &loco_type;
+ unsigned address;
std::string name;
- Locomotive &loco;
std::list<BlockRef> cur_blocks;
std::list<BlockRef> rsv_blocks;
Block *pending_block;
unsigned target_speed;
+ unsigned current_speed;
+ bool reverse;
+ Msp::Time::TimeStamp stop_timeout;
+ unsigned functions;
const Route *route;
std::string status;
Point pos;
public:
- Train(TrafficManager &, Locomotive &);
+ Train(Layout &, const LocoType &, unsigned);
+ ~Train();
+ const LocoType &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; }
+
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; }
+ void set_function(unsigned, bool);
unsigned get_target_speed() const { return target_speed; }
+ unsigned get_speed() const { return current_speed; }
+ bool get_reverse() const { return reverse; }
+ bool get_function(unsigned) const;
+ unsigned get_functions() const { return functions; }
+
+ void set_route(const Route *);
const Route *get_route() const { return route; }
- const std::string &get_status() const { return status; }
- const Point &get_position() const { return pos; }
void place(Block &, unsigned);
bool is_placed() const { return !cur_blocks.empty(); }
bool free_block(Block &);
int get_entry_to_block(Block &) const;
+
+ const std::string &get_status() const { return status; }
+ const Point &get_position() const { return pos; }
+
void tick(const Msp::Time::TimeStamp &, const Msp::Time::TimeDelta &);
+
void save(std::list<Msp::DataFile::Statement> &) 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 block_reserved(const Block &, const Train *);
unsigned reserve_more();
void update_speed();