A Discrete-Event Network Simulator
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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Romagnolo Stefano <romagnolostefano93@gmail.com>
18 */
19
21
22#include "lora-utils.h"
23
24#include "ns3/double.h"
25#include "ns3/log.h"
26
27namespace ns3
28{
29namespace lorawan
30{
31
32NS_LOG_COMPONENT_DEFINE("LoraTxCurrentModel");
33
34NS_OBJECT_ENSURE_REGISTERED(LoraTxCurrentModel);
35
36TypeId
38{
39 static TypeId tid = TypeId("ns3::LoraTxCurrentModel").SetParent<Object>().SetGroupName("Lora");
40 return tid;
41}
42
44{
45}
46
48{
49}
50
51// Similarly to the wifi case
53
56{
57 static TypeId tid =
58 TypeId("ns3::LinearLoraTxCurrentModel")
60 .SetGroupName("Lora")
61 .AddConstructor<LinearLoraTxCurrentModel>()
62 .AddAttribute("Eta",
63 "The efficiency of the power amplifier.",
64 DoubleValue(0.10),
67 MakeDoubleChecker<double>())
68 .AddAttribute("Voltage",
69 "The supply voltage (in Volts).",
70 DoubleValue(3.3),
73 MakeDoubleChecker<double>())
74 .AddAttribute("StandbyCurrent",
75 "The current in the STANDBY state (in Watts).",
76 DoubleValue(0.0014), // idle mode = 1.4mA
79 MakeDoubleChecker<double>());
80 return tid;
81}
82
84{
85 NS_LOG_FUNCTION(this);
86}
87
89{
90 NS_LOG_FUNCTION(this);
91}
92
93void
95{
96 NS_LOG_FUNCTION(this << eta);
97 m_eta = eta;
98}
99
100void
102{
103 NS_LOG_FUNCTION(this << voltage);
104 m_voltage = voltage;
105}
106
107void
109{
110 NS_LOG_FUNCTION(this << idleCurrent);
111 m_idleCurrent = idleCurrent;
112}
113
114double
116{
117 return m_eta;
118}
119
120double
122{
123 return m_voltage;
124}
125
126double
128{
129 return m_idleCurrent;
130}
131
132double
134{
135 NS_LOG_FUNCTION(this << txPowerDbm);
136 return DbmToW(txPowerDbm) / (m_voltage * m_eta) + m_idleCurrent;
137}
138
140
141TypeId
143{
144 static TypeId tid =
145 TypeId("ns3::ConstantLoraTxCurrentModel")
147 .SetGroupName("Lora")
148 .AddConstructor<ConstantLoraTxCurrentModel>()
149 .AddAttribute("TxCurrent",
150 "The radio Tx current in Ampere.",
151 DoubleValue(0.028), // transmit at 0dBm = 28mA
154 MakeDoubleChecker<double>());
155 return tid;
156}
157
159{
160 NS_LOG_FUNCTION(this);
161}
162
164{
165 NS_LOG_FUNCTION(this);
166}
167
168void
170{
171 NS_LOG_FUNCTION(this << txCurrent);
172 m_txCurrent = txCurrent;
173}
174
175double
177{
178 return m_txCurrent;
179}
180
181double
183{
184 NS_LOG_FUNCTION(this << txPowerDbm);
185 return m_txCurrent;
186}
187
188} // namespace lorawan
189} // namespace ns3
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
A base class which provides memory management and object aggregation.
Definition: object.h:89
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
A constant model of the transmission current for a LoRa device, always yielding the same current inde...
double m_txCurrent
The transmission current [Ampere].
double CalcTxCurrent(double txPowerDbm) const override
Get the current for transmission at this power.
void SetTxCurrent(double txCurrent)
Set the current in the TX state.
static TypeId GetTypeId()
Register this type.
double GetTxCurrent() const
Get the current of the TX state.
A linear model of the transmission current for a LoRa device, based on the WiFi model.
double GetStandbyCurrent() const
Get the current in the STANDBY state.
void SetStandbyCurrent(double idleCurrent)
Set the current in the STANDBY state.
static TypeId GetTypeId()
Register this type.
double GetEta() const
Get the power amplifier efficiency.
void SetVoltage(double voltage)
Set the supply voltage.
double GetVoltage() const
Get the supply voltage.
double CalcTxCurrent(double txPowerDbm) const override
Get the current for transmission at this power.
void SetEta(double eta)
Set the power amplifier efficiency.
Model the transmit current as a function of the transmit power and mode.
static TypeId GetTypeId()
Register this type.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
double DbmToW(double dBm)
Convert from dBm to Watts.
Definition: lora-utils.cc:37
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:43