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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Romagnolo Stefano <romagnolostefano93@gmail.com>
7 */
8
10
11#include "lora-utils.h"
12
13#include "ns3/double.h"
14
15namespace ns3
16{
17namespace lorawan
18{
19
20NS_LOG_COMPONENT_DEFINE("LoraTxCurrentModel");
21
23
24TypeId
26{
27 static TypeId tid = TypeId("ns3::LoraTxCurrentModel").SetParent<Object>().SetGroupName("Lora");
28 return tid;
29}
30
34
38
39// Similarly to the wifi case
41
44{
45 static TypeId tid =
46 TypeId("ns3::LinearLoraTxCurrentModel")
48 .SetGroupName("Lora")
49 .AddConstructor<LinearLoraTxCurrentModel>()
50 .AddAttribute("Eta",
51 "The efficiency of the power amplifier.",
52 DoubleValue(0.10),
56 .AddAttribute("Voltage",
57 "The supply voltage (in Volts).",
58 DoubleValue(3.3),
62 .AddAttribute("StandbyCurrent",
63 "The current in the STANDBY state (in Watts).",
64 DoubleValue(0.0014), // idle mode = 1.4mA
68 return tid;
69}
70
75
80
81void
83{
84 NS_LOG_FUNCTION(this << eta);
85 m_eta = eta;
86}
87
88void
90{
91 NS_LOG_FUNCTION(this << voltage);
92 m_voltage = voltage;
93}
94
95void
97{
98 NS_LOG_FUNCTION(this << idleCurrent);
99 m_idleCurrent = idleCurrent;
100}
101
102double
104{
105 return m_eta;
106}
107
108double
113
114double
119
120double
122{
123 NS_LOG_FUNCTION(this << txPowerDbm);
124 return DbmToW(txPowerDbm) / (m_voltage * m_eta) + m_idleCurrent;
125}
126
128
129TypeId
131{
132 static TypeId tid =
133 TypeId("ns3::ConstantLoraTxCurrentModel")
135 .SetGroupName("Lora")
136 .AddConstructor<ConstantLoraTxCurrentModel>()
137 .AddAttribute("TxCurrent",
138 "The radio Tx current in Ampere.",
139 DoubleValue(0.028), // transmit at 0dBm = 28mA
143 return tid;
144}
145
150
155
156void
158{
159 NS_LOG_FUNCTION(this << txCurrent);
160 m_txCurrent = txCurrent;
161}
162
163double
168
169double
171{
172 NS_LOG_FUNCTION(this << txPowerDbm);
173 return m_txCurrent;
174}
175
176} // namespace lorawan
177} // namespace ns3
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
Object()
Caller graph was not generated because of its size.
Definition object.cc:93
a unique identifier for an interface.
Definition type-id.h:50
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:999
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:194
#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:35
double DbmToW(double dBm)
Convert from dBm to Watts.
Definition lora-utils.cc:26
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition double.h:82
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition double.h:32