return next_model->get_speed();
}
+bool AIControl::get_reverse() const
+{
+ if(float ns = next_model->get_speed())
+ return ns<0;
+ else
+ return target_speed.value<0;
+}
+
float AIControl::get_braking_distance() const
{
return next_model->get_braking_distance();
virtual const TrainControl &get_control(const std::string &) const;
virtual float get_speed() const;
+ virtual bool get_reverse() const;
virtual float get_braking_distance() const;
virtual void tick(const Msp::Time::TimeDelta &);
virtual const TrainControl &get_control(const std::string &) const = 0;
virtual float get_speed() const = 0;
+ virtual bool get_reverse() const = 0;
virtual float get_braking_distance() const = 0;
virtual void tick(const Msp::Time::TimeDelta &) = 0;
virtual const TrainControl &get_control(const std::string &) const;
virtual float get_speed() const { return speed; }
+ virtual bool get_reverse() const { return speed<0; }
virtual float get_braking_distance() const;
virtual void tick(const Msp::Time::TimeDelta &);
float speed = control->get_speed();
unsigned speed_notch = find_speed(abs(speed));
- if(speed && (speed<0)!=reverse)
+ if(control->get_reverse()!=reverse)
{
- driver.set_loco_reverse(address, speed<0);
- reverse = speed<0;
+ reverse = control->get_reverse();
+ driver.set_loco_reverse(address, reverse);
release_blocks(rsv_blocks);
reverse_blocks(cur_blocks);