A Discrete-Event Network Simulator
API
wifi-tx-current-model.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014 Universita' degli Studi di Napoli "Federico II"
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Stefano Avallone <stefano.avallone@unina.it>
19  */
20 
21 #include "wifi-tx-current-model.h"
22 #include "ns3/log.h"
23 #include "ns3/boolean.h"
24 #include "ns3/double.h"
25 #include "ns3/string.h"
26 #include "ns3/pointer.h"
27 #include <cmath>
28 
29 namespace ns3 {
30 
31 NS_LOG_COMPONENT_DEFINE ("WifiTxCurrentModel");
32 
33 // ------------------------------------------------------------------------- //
34 
35 NS_OBJECT_ENSURE_REGISTERED (WifiTxCurrentModel);
36 
37 TypeId
39 {
40  static TypeId tid = TypeId ("ns3::WifiTxCurrentModel")
41  .SetParent<Object> ()
42  .SetGroupName ("Energy")
43  ;
44  return tid;
45 }
46 
48 {
49 }
50 
52 {
53 }
54 
55 double
57 {
58  double mW = std::pow (10.0, dbm / 10.0);
59  return mW / 1000.0;
60 }
61 
62 // ------------------------------------------------------------------------- //
63 
65 
66 TypeId
68 {
69  static TypeId tid = TypeId ("ns3::LinearWifiTxCurrentModel")
71  .AddConstructor<LinearWifiTxCurrentModel> ()
72  .AddAttribute ("Eta", "The efficiency of the power amplifier.",
73  DoubleValue (0.10),
76  MakeDoubleChecker<double> ())
77  .AddAttribute ("Voltage", "The supply voltage (in Volts).",
78  DoubleValue (3.0),
81  MakeDoubleChecker<double> ())
82  .AddAttribute ("IdleCurrent", "The current in the IDLE state (in Watts).",
83  DoubleValue (0.273333),
86  MakeDoubleChecker<double> ())
87  ;
88  return tid;
89 }
90 
92 {
93 }
94 
96 {
97 }
98 
99 void
101 {
102  m_eta = eta;
103 }
104 
105 void
107 {
108  m_voltage = voltage;
109 }
110 
111 void
113 {
114  m_idleCurrent = idleCurrent;
115 }
116 
117 double
119 {
120  return m_eta;
121 }
122 
123 double
125 {
126  return m_voltage;
127 }
128 
129 double
131 {
132  return m_idleCurrent;
133 }
134 
135 double
137 {
138  return DbmToW (txPowerDbm) / (m_voltage * m_eta) + m_idleCurrent;
139 }
140 
141 // ------------------------------------------------------------------------- //
142 
143 } // namespace ns3
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
static TypeId GetTypeId(void)
double CalcTxCurrent(double txPowerDbm) const
a linear model of the Wifi transmit current
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: double.h:42
void SetIdleCurrent(double idleCurrent)
A base class which provides memory management and object aggregation.
Definition: object.h:87
Modelize the transmit current as a function of the transmit power and mode.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Definition: double.h:41
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:826
static double DbmToW(double dbm)
Convert from dBm to Watts.