Throttler.cpp
Go to the documentation of this file.
1
#include "
Throttler.h
"
2
3
#include "
ArmarXCore/core/time/DateTime.h
"
4
5
namespace
armarx
6
{
7
Throttler::Throttler
(
const
float
frequency) :
8
delay(
Duration
::MicroSeconds(1 / frequency * 1
'000'
000))
9
{
10
}
11
12
bool
13
Throttler::check
(
const
armarx::DateTime
&
timestamp
) noexcept
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
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:13
armarx::Throttler::Throttler
Throttler(float frequency)
Construct a new Throttler object.
Definition:
Throttler.cpp:7
timestamp
std::string timestamp()
Definition:
CartographerAdapter.cpp:85
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:16
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition:
ArmarXTimeserver.cpp:27
ArmarXCore
core
util
Throttler.cpp
Generated by
1.8.17