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