-
Notifications
You must be signed in to change notification settings - Fork 132
/
lora-tx-current-model.cc
178 lines (150 loc) · 4.37 KB
/
lora-tx-current-model.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/*
* Copyright (c) 2017 University of Padova
*
* SPDX-License-Identifier: GPL-2.0-only
*
* Author: Romagnolo Stefano <[email protected]>
*/
#include "lora-tx-current-model.h"
#include "lora-utils.h"
#include "ns3/double.h"
#include "ns3/log.h"
namespace ns3
{
namespace lorawan
{
NS_LOG_COMPONENT_DEFINE("LoraTxCurrentModel");
NS_OBJECT_ENSURE_REGISTERED(LoraTxCurrentModel);
TypeId
LoraTxCurrentModel::GetTypeId()
{
static TypeId tid = TypeId("ns3::LoraTxCurrentModel").SetParent<Object>().SetGroupName("Lora");
return tid;
}
LoraTxCurrentModel::LoraTxCurrentModel()
{
}
LoraTxCurrentModel::~LoraTxCurrentModel()
{
}
// Similarly to the wifi case
NS_OBJECT_ENSURE_REGISTERED(LinearLoraTxCurrentModel);
TypeId
LinearLoraTxCurrentModel::GetTypeId()
{
static TypeId tid =
TypeId("ns3::LinearLoraTxCurrentModel")
.SetParent<LoraTxCurrentModel>()
.SetGroupName("Lora")
.AddConstructor<LinearLoraTxCurrentModel>()
.AddAttribute("Eta",
"The efficiency of the power amplifier.",
DoubleValue(0.10),
MakeDoubleAccessor(&LinearLoraTxCurrentModel::SetEta,
&LinearLoraTxCurrentModel::GetEta),
MakeDoubleChecker<double>())
.AddAttribute("Voltage",
"The supply voltage (in Volts).",
DoubleValue(3.3),
MakeDoubleAccessor(&LinearLoraTxCurrentModel::SetVoltage,
&LinearLoraTxCurrentModel::GetVoltage),
MakeDoubleChecker<double>())
.AddAttribute("StandbyCurrent",
"The current in the STANDBY state (in Watts).",
DoubleValue(0.0014), // idle mode = 1.4mA
MakeDoubleAccessor(&LinearLoraTxCurrentModel::SetStandbyCurrent,
&LinearLoraTxCurrentModel::GetStandbyCurrent),
MakeDoubleChecker<double>());
return tid;
}
LinearLoraTxCurrentModel::LinearLoraTxCurrentModel()
{
NS_LOG_FUNCTION(this);
}
LinearLoraTxCurrentModel::~LinearLoraTxCurrentModel()
{
NS_LOG_FUNCTION(this);
}
void
LinearLoraTxCurrentModel::SetEta(double eta)
{
NS_LOG_FUNCTION(this << eta);
m_eta = eta;
}
void
LinearLoraTxCurrentModel::SetVoltage(double voltage)
{
NS_LOG_FUNCTION(this << voltage);
m_voltage = voltage;
}
void
LinearLoraTxCurrentModel::SetStandbyCurrent(double idleCurrent)
{
NS_LOG_FUNCTION(this << idleCurrent);
m_idleCurrent = idleCurrent;
}
double
LinearLoraTxCurrentModel::GetEta() const
{
return m_eta;
}
double
LinearLoraTxCurrentModel::GetVoltage() const
{
return m_voltage;
}
double
LinearLoraTxCurrentModel::GetStandbyCurrent() const
{
return m_idleCurrent;
}
double
LinearLoraTxCurrentModel::CalcTxCurrent(double txPowerDbm) const
{
NS_LOG_FUNCTION(this << txPowerDbm);
return DbmToW(txPowerDbm) / (m_voltage * m_eta) + m_idleCurrent;
}
NS_OBJECT_ENSURE_REGISTERED(ConstantLoraTxCurrentModel);
TypeId
ConstantLoraTxCurrentModel::GetTypeId()
{
static TypeId tid =
TypeId("ns3::ConstantLoraTxCurrentModel")
.SetParent<LoraTxCurrentModel>()
.SetGroupName("Lora")
.AddConstructor<ConstantLoraTxCurrentModel>()
.AddAttribute("TxCurrent",
"The radio Tx current in Ampere.",
DoubleValue(0.028), // transmit at 0dBm = 28mA
MakeDoubleAccessor(&ConstantLoraTxCurrentModel::SetTxCurrent,
&ConstantLoraTxCurrentModel::GetTxCurrent),
MakeDoubleChecker<double>());
return tid;
}
ConstantLoraTxCurrentModel::ConstantLoraTxCurrentModel()
{
NS_LOG_FUNCTION(this);
}
ConstantLoraTxCurrentModel::~ConstantLoraTxCurrentModel()
{
NS_LOG_FUNCTION(this);
}
void
ConstantLoraTxCurrentModel::SetTxCurrent(double txCurrent)
{
NS_LOG_FUNCTION(this << txCurrent);
m_txCurrent = txCurrent;
}
double
ConstantLoraTxCurrentModel::GetTxCurrent() const
{
return m_txCurrent;
}
double
ConstantLoraTxCurrentModel::CalcTxCurrent(double txPowerDbm) const
{
NS_LOG_FUNCTION(this << txPowerDbm);
return m_txCurrent;
}
} // namespace lorawan
} // namespace ns3