Vanetza
Loading...
Searching...
No Matches
fully_meshed_state_machine.hpp
1
#ifndef FULLY_MESHED_STATE_MACHINE_HPP_YPE958OH
2
#define FULLY_MESHED_STATE_MACHINE_HPP_YPE958OH
3
4
#include <vanetza/common/clock.hpp>
5
#include <vanetza/dcc/channel_load.hpp>
6
#include <vanetza/dcc/state_machine.hpp>
7
#include <boost/circular_buffer.hpp>
8
#include <boost/optional.hpp>
9
10
namespace
vanetza
11
{
12
namespace
dcc
13
{
14
15
// constants
16
static
constexpr
Clock::duration NDL_minDccSampling = std::chrono::milliseconds(100);
17
18
19
class
State
20
{
21
public
:
22
virtual
Clock::duration transmission_interval()
const
= 0;
23
virtual
const
char
* name()
const
= 0;
24
virtual
~State
() {}
25
};
26
27
class
Relaxed
:
public
State
28
{
29
public
:
30
Clock::duration transmission_interval()
const override
;
31
const
char
* name()
const override
;
32
};
33
34
class
Active :
public
State
35
{
36
public
:
37
Active();
38
void
update(
double
min,
double
max);
39
Clock::duration transmission_interval()
const override
;
40
const
char
* name()
const override
;
41
42
private
:
43
static
const
std::size_t sc_substates;
44
std::size_t m_substate;
45
};
46
47
class
Restrictive
:
public
State
48
{
49
public
:
50
Clock::duration transmission_interval()
const override
;
51
const
char
* name()
const override
;
52
};
53
54
/**
55
* Fully meshed TRC state machine as per TS 102 687 v1.1.1
56
*
57
* States are modelled according to C2C-CC DCC Whitepaper / BSP v1.2
58
* State transitions are deferred internally for ramping up and cooling down over time.
59
*/
60
class
FullyMeshedStateMachine :
public
StateMachine
61
{
62
public
:
63
FullyMeshedStateMachine();
64
~FullyMeshedStateMachine();
65
66
/**
67
* Notify state machine about current channel load.
68
* This method expects to be called in regular intervals
69
* of NDL_minDccSampling length.
70
*/
71
void
update
(
ChannelLoad
channel_load);
72
73
/**
74
* Get currently allowed maximum message rate depending on state
75
* \return messages per second
76
*/
77
double
message_rate
()
const
;
78
79
/**
80
* Get advised transmission interval between consecutive messages
81
* \return message transmission interval
82
*/
83
Clock::duration
transmission_interval
()
const
;
84
85
/**
86
* Get state machine's active state
87
*/
88
const
State
&
state
()
const
;
89
90
private
:
91
double
max_channel_load()
const
;
92
double
min_channel_load()
const
;
93
94
Relaxed
m_relaxed;
95
Active
m_active;
96
Restrictive
m_restrictive;
97
State
* m_state;
98
boost::circular_buffer<ChannelLoad> m_channel_loads;
99
};
100
101
}
// namespace dcc
102
}
// namespace vanetza
103
104
#endif
/* FULLY_MESHED_STATE_MACHINE_HPP_YPE958OH */
105
vanetza::dcc::Active
Definition
fully_meshed_state_machine.hpp:35
vanetza::dcc::ChannelLoad
Definition
channel_load.hpp:12
vanetza::dcc::FullyMeshedStateMachine::message_rate
double message_rate() const
Definition
fully_meshed_state_machine.cpp:129
vanetza::dcc::FullyMeshedStateMachine::update
void update(ChannelLoad channel_load)
Definition
fully_meshed_state_machine.cpp:103
vanetza::dcc::FullyMeshedStateMachine::transmission_interval
Clock::duration transmission_interval() const
Definition
fully_meshed_state_machine.cpp:135
vanetza::dcc::FullyMeshedStateMachine::state
const State & state() const
Definition
fully_meshed_state_machine.cpp:140
vanetza::dcc::Relaxed
Definition
fully_meshed_state_machine.hpp:28
vanetza::dcc::Restrictive
Definition
fully_meshed_state_machine.hpp:48
vanetza::dcc::StateMachine
Definition
state_machine.hpp:16
vanetza::dcc::State
Definition
fully_meshed_state_machine.hpp:20
vanetza
dcc
fully_meshed_state_machine.hpp
Generated on
for Vanetza by
1.14.0