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#include "ns3/log.h"
15
16namespace ns3
17{
18namespace lorawan
19{
20
21NS_LOG_COMPONENT_DEFINE("LoraTxCurrentModel");
22
23NS_OBJECT_ENSURE_REGISTERED(LoraTxCurrentModel);
24
25TypeId
27{
28 static TypeId tid = TypeId("ns3::LoraTxCurrentModel").SetParent<Object>().SetGroupName("Lora");
29 return tid;
30}
31
35
39
40// Similarly to the wifi case
42
45{
46 static TypeId tid =
47 TypeId("ns3::LinearLoraTxCurrentModel")
49 .SetGroupName("Lora")
50 .AddConstructor<LinearLoraTxCurrentModel>()
51 .AddAttribute("Eta",
52 "The efficiency of the power amplifier.",
53 DoubleValue(0.10),
57 .AddAttribute("Voltage",
58 "The supply voltage (in Volts).",
59 DoubleValue(3.3),
63 .AddAttribute("StandbyCurrent",
64 "The current in the STANDBY state (in Watts).",
65 DoubleValue(0.0014), // idle mode = 1.4mA
69 return tid;
70}
71
76
81
82void
84{
85 NS_LOG_FUNCTION(this << eta);
86 m_eta = eta;
87}
88
89void
91{
92 NS_LOG_FUNCTION(this << voltage);
93 m_voltage = voltage;
94}
95
96void
98{
99 NS_LOG_FUNCTION(this << idleCurrent);
100 m_idleCurrent = idleCurrent;
101}
102
103double
105{
106 return m_eta;
107}
108
109double
114
115double
120
121double
123{
124 NS_LOG_FUNCTION(this << txPowerDbm);
125 return DbmToW(txPowerDbm) / (m_voltage * m_eta) + m_idleCurrent;
126}
127
129
130TypeId
132{
133 static TypeId tid =
134 TypeId("ns3::ConstantLoraTxCurrentModel")
136 .SetGroupName("Lora")
137 .AddConstructor<ConstantLoraTxCurrentModel>()
138 .AddAttribute("TxCurrent",
139 "The radio Tx current in Ampere.",
140 DoubleValue(0.028), // transmit at 0dBm = 28mA
144 return tid;
145}
146
151
156
157void
159{
160 NS_LOG_FUNCTION(this << txCurrent);
161 m_txCurrent = txCurrent;
162}
163
164double
169
170double
172{
173 NS_LOG_FUNCTION(this << txPowerDbm);
174 return m_txCurrent;
175}
176
177} // namespace lorawan
178} // namespace ns3
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
A base class which provides memory management and object aggregation.
Definition object.h:78
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
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:191
#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