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-tx-current-model.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-tx-current-model.h
"
10
11
#include "
lora-utils.h
"
12
13
#include "ns3/double.h"
14
15
namespace
ns3
16
{
17
namespace
lorawan
18
{
19
20
NS_LOG_COMPONENT_DEFINE
(
"LoraTxCurrentModel"
);
21
22
NS_OBJECT_ENSURE_REGISTERED
(
LoraTxCurrentModel
);
23
24
TypeId
25
LoraTxCurrentModel::GetTypeId
()
26
{
27
static
TypeId
tid =
TypeId
(
"ns3::LoraTxCurrentModel"
).
SetParent
<
Object
>().SetGroupName(
"Lora"
);
28
return
tid;
29
}
30
31
LoraTxCurrentModel::LoraTxCurrentModel
()
32
{
33
}
34
35
LoraTxCurrentModel::~LoraTxCurrentModel
()
36
{
37
}
38
39
// Similarly to the wifi case
40
NS_OBJECT_ENSURE_REGISTERED
(
LinearLoraTxCurrentModel
);
41
42
TypeId
43
LinearLoraTxCurrentModel::GetTypeId
()
44
{
45
static
TypeId
tid =
46
TypeId
(
"ns3::LinearLoraTxCurrentModel"
)
47
.
SetParent
<
LoraTxCurrentModel
>()
48
.SetGroupName(
"Lora"
)
49
.AddConstructor<
LinearLoraTxCurrentModel
>()
50
.AddAttribute(
"Eta"
,
51
"The efficiency of the power amplifier."
,
52
DoubleValue
(0.10),
53
MakeDoubleAccessor
(&
LinearLoraTxCurrentModel::SetEta
,
54
&
LinearLoraTxCurrentModel::GetEta
),
55
MakeDoubleChecker<double>
())
56
.AddAttribute(
"Voltage"
,
57
"The supply voltage (in Volts)."
,
58
DoubleValue
(3.3),
59
MakeDoubleAccessor
(&
LinearLoraTxCurrentModel::SetVoltage
,
60
&
LinearLoraTxCurrentModel::GetVoltage
),
61
MakeDoubleChecker<double>
())
62
.AddAttribute(
"StandbyCurrent"
,
63
"The current in the STANDBY state (in Watts)."
,
64
DoubleValue
(0.0014),
// idle mode = 1.4mA
65
MakeDoubleAccessor
(&
LinearLoraTxCurrentModel::SetStandbyCurrent
,
66
&
LinearLoraTxCurrentModel::GetStandbyCurrent
),
67
MakeDoubleChecker<double>
());
68
return
tid;
69
}
70
71
LinearLoraTxCurrentModel::LinearLoraTxCurrentModel
()
72
{
73
NS_LOG_FUNCTION
(
this
);
74
}
75
76
LinearLoraTxCurrentModel::~LinearLoraTxCurrentModel
()
77
{
78
NS_LOG_FUNCTION
(
this
);
79
}
80
81
void
82
LinearLoraTxCurrentModel::SetEta
(
double
eta)
83
{
84
NS_LOG_FUNCTION
(
this
<< eta);
85
m_eta
= eta;
86
}
87
88
void
89
LinearLoraTxCurrentModel::SetVoltage
(
double
voltage)
90
{
91
NS_LOG_FUNCTION
(
this
<< voltage);
92
m_voltage
= voltage;
93
}
94
95
void
96
LinearLoraTxCurrentModel::SetStandbyCurrent
(
double
idleCurrent)
97
{
98
NS_LOG_FUNCTION
(
this
<< idleCurrent);
99
m_idleCurrent
= idleCurrent;
100
}
101
102
double
103
LinearLoraTxCurrentModel::GetEta
()
const
104
{
105
return
m_eta
;
106
}
107
108
double
109
LinearLoraTxCurrentModel::GetVoltage
()
const
110
{
111
return
m_voltage
;
112
}
113
114
double
115
LinearLoraTxCurrentModel::GetStandbyCurrent
()
const
116
{
117
return
m_idleCurrent
;
118
}
119
120
double
121
LinearLoraTxCurrentModel::CalcTxCurrent
(
double
txPowerDbm)
const
122
{
123
NS_LOG_FUNCTION
(
this
<< txPowerDbm);
124
return
DbmToW
(txPowerDbm) / (
m_voltage
*
m_eta
) +
m_idleCurrent
;
125
}
126
127
NS_OBJECT_ENSURE_REGISTERED
(
ConstantLoraTxCurrentModel
);
128
129
TypeId
130
ConstantLoraTxCurrentModel::GetTypeId
()
131
{
132
static
TypeId
tid =
133
TypeId
(
"ns3::ConstantLoraTxCurrentModel"
)
134
.
SetParent
<
LoraTxCurrentModel
>()
135
.SetGroupName(
"Lora"
)
136
.AddConstructor<
ConstantLoraTxCurrentModel
>()
137
.AddAttribute(
"TxCurrent"
,
138
"The radio Tx current in Ampere."
,
139
DoubleValue
(0.028),
// transmit at 0dBm = 28mA
140
MakeDoubleAccessor
(&
ConstantLoraTxCurrentModel::SetTxCurrent
,
141
&
ConstantLoraTxCurrentModel::GetTxCurrent
),
142
MakeDoubleChecker<double>
());
143
return
tid;
144
}
145
146
ConstantLoraTxCurrentModel::ConstantLoraTxCurrentModel
()
147
{
148
NS_LOG_FUNCTION
(
this
);
149
}
150
151
ConstantLoraTxCurrentModel::~ConstantLoraTxCurrentModel
()
152
{
153
NS_LOG_FUNCTION
(
this
);
154
}
155
156
void
157
ConstantLoraTxCurrentModel::SetTxCurrent
(
double
txCurrent)
158
{
159
NS_LOG_FUNCTION
(
this
<< txCurrent);
160
m_txCurrent
= txCurrent;
161
}
162
163
double
164
ConstantLoraTxCurrentModel::GetTxCurrent
()
const
165
{
166
return
m_txCurrent
;
167
}
168
169
double
170
ConstantLoraTxCurrentModel::CalcTxCurrent
(
double
txPowerDbm)
const
171
{
172
NS_LOG_FUNCTION
(
this
<< txPowerDbm);
173
return
m_txCurrent
;
174
}
175
176
}
// namespace lorawan
177
}
// namespace ns3
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition
double.h:31
ns3::Object::Object
Object()
Caller graph was not generated because of its size.
Definition
object.cc:93
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:50
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:999
ns3::lorawan::ConstantLoraTxCurrentModel
A constant model of the transmission current for a LoRa device, always yielding the same current inde...
Definition
lora-tx-current-model.h:122
ns3::lorawan::ConstantLoraTxCurrentModel::m_txCurrent
double m_txCurrent
The transmission current [Ampere].
Definition
lora-tx-current-model.h:150
ns3::lorawan::ConstantLoraTxCurrentModel::CalcTxCurrent
double CalcTxCurrent(double txPowerDbm) const override
Get the current for transmission at this power.
Definition
lora-tx-current-model.cc:170
ns3::lorawan::ConstantLoraTxCurrentModel::SetTxCurrent
void SetTxCurrent(double txCurrent)
Set the current in the TX state.
Definition
lora-tx-current-model.cc:157
ns3::lorawan::ConstantLoraTxCurrentModel::~ConstantLoraTxCurrentModel
~ConstantLoraTxCurrentModel() override
Destructor.
Definition
lora-tx-current-model.cc:151
ns3::lorawan::ConstantLoraTxCurrentModel::ConstantLoraTxCurrentModel
ConstantLoraTxCurrentModel()
Default constructor.
Definition
lora-tx-current-model.cc:146
ns3::lorawan::ConstantLoraTxCurrentModel::GetTypeId
static TypeId GetTypeId()
Register this type.
Definition
lora-tx-current-model.cc:130
ns3::lorawan::ConstantLoraTxCurrentModel::GetTxCurrent
double GetTxCurrent() const
Get the current of the TX state.
Definition
lora-tx-current-model.cc:164
ns3::lorawan::LinearLoraTxCurrentModel
A linear model of the transmission current for a LoRa device, based on the WiFi model.
Definition
lora-tx-current-model.h:54
ns3::lorawan::LinearLoraTxCurrentModel::GetStandbyCurrent
double GetStandbyCurrent() const
Get the current in the STANDBY state.
Definition
lora-tx-current-model.cc:115
ns3::lorawan::LinearLoraTxCurrentModel::m_idleCurrent
double m_idleCurrent
Standby current.
Definition
lora-tx-current-model.h:112
ns3::lorawan::LinearLoraTxCurrentModel::SetStandbyCurrent
void SetStandbyCurrent(double idleCurrent)
Set the current in the STANDBY state.
Definition
lora-tx-current-model.cc:96
ns3::lorawan::LinearLoraTxCurrentModel::GetTypeId
static TypeId GetTypeId()
Register this type.
Definition
lora-tx-current-model.cc:43
ns3::lorawan::LinearLoraTxCurrentModel::m_voltage
double m_voltage
Voltage.
Definition
lora-tx-current-model.h:111
ns3::lorawan::LinearLoraTxCurrentModel::LinearLoraTxCurrentModel
LinearLoraTxCurrentModel()
Default constructor.
Definition
lora-tx-current-model.cc:71
ns3::lorawan::LinearLoraTxCurrentModel::GetEta
double GetEta() const
Get the power amplifier efficiency.
Definition
lora-tx-current-model.cc:103
ns3::lorawan::LinearLoraTxCurrentModel::SetVoltage
void SetVoltage(double voltage)
Set the supply voltage.
Definition
lora-tx-current-model.cc:89
ns3::lorawan::LinearLoraTxCurrentModel::m_eta
double m_eta
ETA.
Definition
lora-tx-current-model.h:110
ns3::lorawan::LinearLoraTxCurrentModel::~LinearLoraTxCurrentModel
~LinearLoraTxCurrentModel() override
Destructor.
Definition
lora-tx-current-model.cc:76
ns3::lorawan::LinearLoraTxCurrentModel::GetVoltage
double GetVoltage() const
Get the supply voltage.
Definition
lora-tx-current-model.cc:109
ns3::lorawan::LinearLoraTxCurrentModel::CalcTxCurrent
double CalcTxCurrent(double txPowerDbm) const override
Get the current for transmission at this power.
Definition
lora-tx-current-model.cc:121
ns3::lorawan::LinearLoraTxCurrentModel::SetEta
void SetEta(double eta)
Set the power amplifier efficiency.
Definition
lora-tx-current-model.cc:82
ns3::lorawan::LoraTxCurrentModel
Model the transmit current as a function of the transmit power and mode.
Definition
lora-tx-current-model.h:27
ns3::lorawan::LoraTxCurrentModel::LoraTxCurrentModel
LoraTxCurrentModel()
Default constructor.
Definition
lora-tx-current-model.cc:31
ns3::lorawan::LoraTxCurrentModel::GetTypeId
static TypeId GetTypeId()
Register this type.
Definition
lora-tx-current-model.cc:25
ns3::lorawan::LoraTxCurrentModel::~LoraTxCurrentModel
~LoraTxCurrentModel() override
Destructor.
Definition
lora-tx-current-model.cc:35
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:194
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition
log-macros-enabled.h:231
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
lora-tx-current-model.h
lora-utils.h
ns3::lorawan
Definition
forwarder-helper.cc:19
ns3::lorawan::DbmToW
double DbmToW(double dBm)
Convert from dBm to Watts.
Definition
lora-utils.cc:26
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::MakeDoubleChecker
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition
double.h:82
ns3::MakeDoubleAccessor
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition
double.h:32
src
lorawan
model
lora-tx-current-model.cc
Generated on
for ns-3 by
1.15.0