Vanetza
Loading...
Searching...
No Matches
dcc_information_sharing.cpp
1#include <vanetza/common/runtime.hpp>
2#include <vanetza/geonet/dcc_information_sharing.hpp>
3#include <vanetza/geonet/location_table.hpp>
4
5namespace vanetza
6{
7namespace geonet
8{
9
11 m_runtime(rt), m_location_table(lt), m_cbr_target(target), m_tx_power(0),
15{
16 Clock::duration initial = m_trigger_interval;
17 initial *= delay.value();
18 m_runtime.schedule(initial, [this](const Clock::time_point&) { trigger(); });
19}
20
21DccInformationSharing::DccInformationSharing(Runtime& rt, const LocationTable& lt, dcc::ChannelLoad target) :
23{
24}
25
26DccField DccInformationSharing::generate_dcc_field()
27{
28 DccMcoField dcc_mco;
29 dcc_mco.local_cbr(m_aggregator.get_local_cbr());
30 dcc_mco.neighbour_cbr(m_aggregator.get_one_hop_cbr());
31 dcc_mco.output_power(m_tx_power);
32 return dcc_mco;
33}
34
36{
37 m_cbr_local = local_cbr;
38}
39
40void DccInformationSharing::set_tx_power(unsigned tx_power)
41{
42 m_tx_power = tx_power;
43}
44
45void DccInformationSharing::trigger()
46{
47 m_aggregator.aggregate(m_cbr_local, m_location_table, m_last_aggregation, m_cbr_target);
48 m_last_aggregation = m_runtime.now();
49 m_update_hook(static_cast<const CbrAggregator&>(m_aggregator));
50 m_runtime.schedule(m_trigger_interval, [this](const Clock::time_point&) { trigger(); });
51}
52
53} // namespace geonet
54} // namespace vanetza
DccInformationSharing(Runtime &rt, const LocationTable &lt, dcc::ChannelLoad target, UnitInterval delay)
void output_power(unsigned dbm)