Implements an object that calculates average speed from its measurement data. More...
#include <kanzi/core.ui/util/speed_measurer.hpp>
Public Member Functions | |
SpeedMeasurer (size_t maxMeasurements, chrono::milliseconds minMeasurementWindow, chrono::milliseconds maxMeasurementWindow) | |
Creates a speed measurer with the given properties. More... | |
void | reset () |
Resets measurement data. More... | |
void | addMeasurement (chrono::milliseconds timestamp, float value) |
Adds a new measurement to the measurer. More... | |
optional< float > | getSpeed (chrono::milliseconds measurementTime) const |
Calculates average speed from measurements in units / second. More... | |
Implements an object that calculates average speed from its measurement data.
|
explicit |
Creates a speed measurer with the given properties.
void kanzi::SpeedMeasurer::reset | ( | ) |
Resets measurement data.
void kanzi::SpeedMeasurer::addMeasurement | ( | chrono::milliseconds | timestamp, |
float | value | ||
) |
Adds a new measurement to the measurer.
optional<float> kanzi::SpeedMeasurer::getSpeed | ( | chrono::milliseconds | measurementTime | ) | const |
Calculates average speed from measurements in units / second.
Returns nullopt if there were not enough measurements.