A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
lora-radio-energy-model-helper.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2017 University of Padova
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Romagnolo Stefano <romagnolostefano93@gmail.com>
7
*/
8
9
#include "
lora-radio-energy-model-helper.h
"
10
11
#include "ns3/lora-net-device.h"
12
#include "ns3/lora-radio-energy-model.h"
13
14
namespace
ns3
15
{
16
namespace
lorawan
17
{
18
19
LoraRadioEnergyModelHelper::LoraRadioEnergyModelHelper
()
20
{
21
m_radioEnergy
.SetTypeId(
"ns3::LoraRadioEnergyModel"
);
22
}
23
24
LoraRadioEnergyModelHelper::~LoraRadioEnergyModelHelper
()
25
{
26
}
27
28
void
29
LoraRadioEnergyModelHelper::Set
(std::string name,
const
AttributeValue
&
v
)
30
{
31
m_radioEnergy
.Set(name,
v
);
32
}
33
34
void
35
LoraRadioEnergyModelHelper::SetTxCurrentModel
(std::string name,
36
std::string n0,
37
const
AttributeValue
& v0,
38
std::string n1,
39
const
AttributeValue
& v1,
40
std::string n2,
41
const
AttributeValue
& v2,
42
std::string n3,
43
const
AttributeValue
& v3,
44
std::string n4,
45
const
AttributeValue
& v4,
46
std::string n5,
47
const
AttributeValue
& v5,
48
std::string n6,
49
const
AttributeValue
& v6,
50
std::string n7,
51
const
AttributeValue
& v7)
52
{
53
ObjectFactory
factory;
54
factory.
SetTypeId
(name);
55
factory.
Set
(n0, v0);
56
factory.
Set
(n1, v1);
57
factory.
Set
(n2, v2);
58
factory.
Set
(n3, v3);
59
factory.
Set
(n4, v4);
60
factory.
Set
(n5, v5);
61
factory.
Set
(n6, v6);
62
factory.
Set
(n7, v7);
63
m_txCurrentModel
= factory;
64
}
65
66
/*
67
* Private function starts here.
68
*/
69
70
Ptr<energy::DeviceEnergyModel>
71
LoraRadioEnergyModelHelper::DoInstall
(
Ptr<NetDevice>
device,
Ptr<energy::EnergySource>
source)
const
72
{
73
NS_ASSERT
(device);
74
NS_ASSERT
(source);
75
// check if device is LoraNetDevice
76
std::string deviceName = device->GetInstanceTypeId().GetName();
77
if
(deviceName !=
"ns3::LoraNetDevice"
)
78
{
79
NS_FATAL_ERROR
(
"NetDevice type is not LoraNetDevice!"
);
80
}
81
Ptr<Node>
node = device->GetNode();
82
Ptr<LoraRadioEnergyModel>
model =
m_radioEnergy
.Create<
LoraRadioEnergyModel
>();
83
NS_ASSERT
(model);
84
// set energy source pointer
85
model->SetEnergySource(source);
86
87
// set energy depletion callback
88
// if none is specified, make a callback to EndDeviceLoraPhy::SetSleepMode
89
Ptr<LoraNetDevice>
loraDevice =
DynamicCast<LoraNetDevice>
(device);
90
Ptr<EndDeviceLoraPhy>
loraPhy =
DynamicCast<EndDeviceLoraPhy>
(loraDevice->GetPhy());
91
// add model to device model list in energy source
92
source->AppendDeviceEnergyModel(model);
93
// create and register energy model phy listener
94
loraPhy->RegisterListener(model->GetPhyListener());
95
96
if
(
m_txCurrentModel
.GetTypeId().GetUid())
97
{
98
Ptr<LoraTxCurrentModel>
txcurrent =
m_txCurrentModel
.Create<
LoraTxCurrentModel
>();
99
model->SetTxCurrentModel(txcurrent);
100
}
101
return
model;
102
}
103
104
}
// namespace lorawan
105
}
// namespace ns3
v
uint32_t v
Definition
cairo-wideint.c:749
ns3::AttributeValue
Hold a value for an Attribute.
Definition
attribute.h:59
ns3::ObjectFactory
Instantiate subclasses of ns3::Object.
Definition
object-factory.h:37
ns3::ObjectFactory::Set
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
Definition
object-factory.h:215
ns3::ObjectFactory::SetTypeId
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Definition
object-factory.cc:29
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
ptr.h:70
ns3::lorawan::LoraRadioEnergyModelHelper::m_radioEnergy
ObjectFactory m_radioEnergy
radio energy
Definition
lora-radio-energy-model-helper.h:91
ns3::lorawan::LoraRadioEnergyModelHelper::Set
void Set(std::string name, const AttributeValue &v) override
Definition
lora-radio-energy-model-helper.cc:29
ns3::lorawan::LoraRadioEnergyModelHelper::m_txCurrentModel
ObjectFactory m_txCurrentModel
transmit current model
Definition
lora-radio-energy-model-helper.h:92
ns3::lorawan::LoraRadioEnergyModelHelper::~LoraRadioEnergyModelHelper
~LoraRadioEnergyModelHelper() override
Destructor.
Definition
lora-radio-energy-model-helper.cc:24
ns3::lorawan::LoraRadioEnergyModelHelper::SetTxCurrentModel
void SetTxCurrentModel(std::string name, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
Definition
lora-radio-energy-model-helper.cc:35
ns3::lorawan::LoraRadioEnergyModelHelper::DoInstall
Ptr< energy::DeviceEnergyModel > DoInstall(Ptr< NetDevice > device, Ptr< energy::EnergySource > source) const override
Definition
lora-radio-energy-model-helper.cc:71
ns3::lorawan::LoraRadioEnergyModelHelper::LoraRadioEnergyModelHelper
LoraRadioEnergyModelHelper()
Default constructor.
Definition
lora-radio-energy-model-helper.cc:19
ns3::lorawan::LoraRadioEnergyModel
A LoRa radio energy model.
Definition
lora-radio-energy-model.h:121
ns3::lorawan::LoraTxCurrentModel
Model the transmit current as a function of the transmit power and mode.
Definition
lora-tx-current-model.h:27
NS_ASSERT
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition
assert.h:55
NS_FATAL_ERROR
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition
fatal-error.h:186
lora-radio-energy-model-helper.h
ns3::lorawan
Definition
forwarder-helper.cc:19
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::DynamicCast
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition
ptr.h:605
src
lorawan
helper
lora-radio-energy-model-helper.cc
Generated on
for ns-3 by
1.15.0