X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibmarklin%2Ftrain.cpp;h=d87d3768a7e0a482db808d934cd5f5211f389197;hb=59e4c75da550e96ae74162a5ed70e8b1999721d8;hp=93470997133a6e534736f6f6d71b256e0533bc13;hpb=77f8c0e033b9b5e7085de5d22a62128a996a5b2a;p=r2c2.git diff --git a/source/libmarklin/train.cpp b/source/libmarklin/train.cpp index 9347099..d87d376 100644 --- a/source/libmarklin/train.cpp +++ b/source/libmarklin/train.cpp @@ -14,7 +14,7 @@ Distributed under the GPL #include "driver.h" #include "layout.h" #include "route.h" -#include "simplephysics.h" +#include "simplecontroller.h" #include "timetable.h" #include "tracktype.h" #include "train.h" @@ -32,7 +32,7 @@ Train::Train(Layout &l, const VehicleType &t, unsigned a): address(a), priority(0), pending_block(0), - control(new AIControl(*this, new SimplePhysics)), + controller(new AIControl(*this, new SimpleController)), timetable(0), active(false), current_speed(0), @@ -66,12 +66,12 @@ Train::Train(Layout &l, const VehicleType &t, unsigned a): layout.get_driver().signal_halt.connect(sigc::mem_fun(this, &Train::halt_event)); - control->signal_control_changed.connect(sigc::mem_fun(this, &Train::control_changed)); + controller->signal_control_changed.connect(sigc::mem_fun(this, &Train::control_changed)); } Train::~Train() { - delete control; + delete controller; delete timetable; for(vector::iterator i=vehicles.begin(); i!=vehicles.end(); ++i) delete *i; @@ -130,14 +130,14 @@ const Vehicle &Train::get_vehicle(unsigned i) const void Train::set_control(const string &n, float v) { - control->set_control(n, v); + controller->set_control(n, v); } void Train::set_active(bool a) { if(a==active) return; - if(!a && control->get_speed()) + if(!a && controller->get_speed()) throw InvalidState("Can't deactivate while moving"); active = a; @@ -165,12 +165,12 @@ void Train::set_function(unsigned func, bool state) float Train::get_control(const string &ctrl) const { - return control->get_control(ctrl).value; + return controller->get_control(ctrl).value; } float Train::get_speed() const { - return control->get_speed(); + return controller->get_speed(); } bool Train::get_function(unsigned func) const @@ -245,7 +245,7 @@ void Train::go_to(const Track &to) void Train::place(Block &block, unsigned entry) { - if(control->get_speed()) + if(controller->get_speed()) throw InvalidState("Must be stopped before placing"); release_blocks(rsv_blocks); @@ -366,13 +366,13 @@ void Train::tick(const Time::TimeStamp &t, const Time::TimeDelta &dt) if(timetable) timetable->tick(t); - control->tick(dt); - float speed = control->get_speed(); + controller->tick(dt); + float speed = controller->get_speed(); unsigned speed_notch = find_speed(speed); - if(control->get_reverse()!=reverse) + if(controller->get_reverse()!=reverse) { - reverse = control->get_reverse(); + reverse = controller->get_reverse(); driver.set_loco_reverse(address, reverse); release_blocks(rsv_blocks); @@ -514,7 +514,7 @@ void Train::save(list &st) const } } -void Train::control_changed(const TrainControl &ctrl) +void Train::control_changed(const Controller::Control &ctrl) { signal_control_changed.emit(ctrl.name, ctrl.value); }