Throttler.cpp
Go to the documentation of this file.
1#include "Throttler.h"
2
4
5namespace armarx
6{
7 Throttler::Throttler(const float frequency) :
8 delay(Duration::MicroSeconds(1 / frequency * 1'000'000))
9 {
10 }
11
12 bool
14 {
15 const core::time::Duration timeSinceLastTrue = timestamp - lastTimeTrue;
16
17 if (timeSinceLastTrue >= delay)
18 {
19 lastTimeTrue = timestamp;
20 return true;
21 }
22
23 return false;
24 }
25
26} // namespace armarx
std::string timestamp()
Throttler(float frequency)
Construct a new Throttler object.
Definition Throttler.cpp:7
bool check(const armarx::DateTime &timestamp) noexcept
Check if enough time has passed since this function last returned true.
Definition Throttler.cpp:13
Represents a point in time.
Definition DateTime.h:25
Represents a duration.
Definition Duration.h:17
This file offers overloads of toIce() and fromIce() functions for STL container types.