F´ Flight Software - C/C++ Documentation
NASA-v2.0.1
A framework for building embedded system applications to NASA flight quality standards.
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
Functions
a
b
c
d
g
h
i
m
r
s
t
v
w
Variables
Typedefs
Enumerations
Enumerator
a
b
f
h
i
n
o
p
s
v
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
~
Functions
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
~
Variables
b
d
e
f
g
h
i
l
m
n
p
q
s
t
u
v
w
Typedefs
Enumerations
Enumerator
a
b
c
d
e
f
g
h
l
m
n
o
p
q
r
s
t
w
Related Functions
Files
File List
File Members
All
_
a
b
c
d
f
g
h
i
k
l
m
n
p
r
s
t
u
v
Functions
f
i
m
s
u
Variables
Typedefs
Enumerations
Enumerator
c
d
f
m
p
r
s
t
Macros
a
c
d
f
g
h
i
k
l
m
n
p
r
s
t
u
v
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
TokenBucket.hpp
Go to the documentation of this file.
1
// ======================================================================
2
// \title TokenBucket.hpp
3
// \author vwong
4
// \brief hpp file for a rate limiter utility class
5
//
6
// \copyright
7
//
8
// Copyright (C) 2009-2020 California Institute of Technology.
9
//
10
// ALL RIGHTS RESERVED. United States Government Sponsorship
11
// acknowledged.
12
// ======================================================================
13
14
#ifndef TokenBucket_HPP
15
#define TokenBucket_HPP
16
17
#include <
Fw/Types/BasicTypes.hpp
>
18
#include <
Fw/Time/Time.hpp
>
19
20
#define MAX_TOKEN_BUCKET_TOKENS 1000
21
22
namespace
Utils
{
23
24
class
TokenBucket
25
{
26
27
public
:
28
29
// Full constructor
30
//
31
// replenishInterval is in microseconds
32
//
33
TokenBucket
(U32 replenishInterval, U32 maxTokens, U32 replenishRate, U32 startTokens,
Fw::Time
startTime);
34
35
// replenishRate=1, startTokens=maxTokens, startTime=0
36
TokenBucket
(U32 replenishInterval, U32 maxTokens);
37
38
public
:
39
40
// Adjust settings at runtime
41
void
setMaxTokens
(U32 maxTokens);
42
void
setReplenishInterval
(U32 replenishInterval);
43
void
setReplenishRate
(U32 replenishRate);
44
45
U32
getMaxTokens
()
const
;
46
U32
getReplenishInterval
()
const
;
47
U32
getReplenishRate
()
const
;
48
U32
getTokens
()
const
;
49
50
// Manual replenish
51
void
replenish
();
52
53
// Main point of entry
54
//
55
// Evaluates time since last trigger to determine number of tokens to
56
// replenish. If time moved backwards, always returns false.
57
//
58
// If number of tokens is not zero, consumes one and returns true.
59
// Otherwise, returns false.
60
//
61
bool
trigger
(
const
Fw::Time
time);
62
63
private
:
64
65
// parameters
66
U32 m_replenishInterval;
67
U32 m_maxTokens;
68
U32 m_replenishRate;
69
70
// state
71
U32 m_tokens;
72
Fw::Time
m_time;
73
};
74
75
}
// end namespace Utils
76
77
#endif
Fw::Time
Definition:
Time.hpp:10
Utils::TokenBucket::setReplenishInterval
void setReplenishInterval(U32 replenishInterval)
Definition:
TokenBucket.cpp:49
Utils::TokenBucket
Definition:
TokenBucket.hpp:24
Utils::TokenBucket::setReplenishRate
void setReplenishRate(U32 replenishRate)
Definition:
TokenBucket.cpp:65
Utils
Definition:
CRCChecker.cpp:20
Utils::TokenBucket::getReplenishRate
U32 getReplenishRate() const
Definition:
TokenBucket.cpp:93
Utils::TokenBucket::TokenBucket
TokenBucket(U32 replenishInterval, U32 maxTokens, U32 replenishRate, U32 startTokens, Fw::Time startTime)
Definition:
TokenBucket.cpp:19
Utils::TokenBucket::getTokens
U32 getTokens() const
Definition:
TokenBucket.cpp:99
Utils::TokenBucket::getMaxTokens
U32 getMaxTokens() const
Definition:
TokenBucket.cpp:87
Utils::TokenBucket::setMaxTokens
void setMaxTokens(U32 maxTokens)
Definition:
TokenBucket.cpp:57
Utils::TokenBucket::replenish
void replenish()
Definition:
TokenBucket.cpp:73
Utils::TokenBucket::getReplenishInterval
U32 getReplenishInterval() const
Definition:
TokenBucket.cpp:81
BasicTypes.hpp
Declares ISF basic types.
Time.hpp
Utils::TokenBucket::trigger
bool trigger(const Fw::Time time)
Definition:
TokenBucket.cpp:105
Utils
TokenBucket.hpp
Generated by
1.8.17