#include "layout.h"
#include "sensor.h"
+using namespace std;
using namespace Msp;
namespace R2C2 {
{
if(state_confirm_timeout)
{
- state_confirm_timeout -= dt;
+ state_confirm_timeout = max(state_confirm_timeout-dt, Time::zero);
if(state_confirm_timeout<=Time::zero)
{
if(state==MAYBE_INACTIVE)
state = INACTIVE;
else if(state==MAYBE_ACTIVE)
state = ACTIVE;
- state_confirm_timeout = Time::zero;
signal_state_changed.emit(state);
}
}
{
float secs = dt/Time::sec;
if(speed<target_speed.value)
- {
- speed += secs*accel;
- if(speed>target_speed.value)
- speed = target_speed.value;
- }
+ speed = min(speed+secs*accel, target_speed.value);
else if(speed>target_speed.value)
- {
- speed -= secs*accel;
- if(speed<target_speed.value)
- speed = target_speed.value;
- }
+ speed = max(speed-secs*accel, target_speed.value);
}
} // namespace R2C2
{
if(stop_timeout)
{
- stop_timeout -= dt;
+ stop_timeout = max(stop_timeout-dt, Time::zero);
if(stop_timeout<=Time::zero)
- {
allocator.set_active(false);
- stop_timeout = Time::TimeDelta();
- }
}
travel_time += dt;