A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
src
antenna
model
parabolic-antenna-model.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2012 CTTC
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: Nicola Baldo <nbaldo@cttc.es>
19
*/
20
21
22
#include <ns3/log.h>
23
#include <ns3/double.h>
24
#include <cmath>
25
26
#include "
antenna-model.h
"
27
#include "
parabolic-antenna-model.h
"
28
29
30
namespace
ns3
{
31
32
NS_LOG_COMPONENT_DEFINE
(
"ParabolicAntennaModel"
);
33
34
NS_OBJECT_ENSURE_REGISTERED
(ParabolicAntennaModel);
35
36
37
TypeId
38
ParabolicAntennaModel::GetTypeId
()
39
{
40
static
TypeId
tid =
TypeId
(
"ns3::ParabolicAntennaModel"
)
41
.
SetParent
<
AntennaModel
> ()
42
.SetGroupName(
"Antenna"
)
43
.AddConstructor<
ParabolicAntennaModel
> ()
44
.AddAttribute (
"Beamwidth"
,
45
"The 3dB beamwidth (degrees)"
,
46
DoubleValue
(60),
47
MakeDoubleAccessor
(&
ParabolicAntennaModel::SetBeamwidth
,
48
&
ParabolicAntennaModel::GetBeamwidth
),
49
MakeDoubleChecker<double> (0, 180))
50
.AddAttribute (
"Orientation"
,
51
"The angle (degrees) that expresses the orientation of the antenna on the x-y plane relative to the x axis"
,
52
DoubleValue
(0.0),
53
MakeDoubleAccessor
(&
ParabolicAntennaModel::SetOrientation
,
54
&
ParabolicAntennaModel::GetOrientation
),
55
MakeDoubleChecker<double> (-360, 360))
56
.AddAttribute (
"MaxAttenuation"
,
57
"The maximum attenuation (dB) of the antenna radiation pattern."
,
58
DoubleValue
(20.0),
59
MakeDoubleAccessor
(&
ParabolicAntennaModel::m_maxAttenuation
),
60
MakeDoubleChecker<double> ())
61
;
62
return
tid;
63
}
64
65
void
66
ParabolicAntennaModel::SetBeamwidth
(
double
beamwidthDegrees)
67
{
68
NS_LOG_FUNCTION
(
this
<< beamwidthDegrees);
69
m_beamwidthRadians
=
DegreesToRadians
(beamwidthDegrees);
70
}
71
72
double
73
ParabolicAntennaModel::GetBeamwidth
()
const
74
{
75
return
RadiansToDegrees
(
m_beamwidthRadians
);
76
}
77
78
void
79
ParabolicAntennaModel::SetOrientation
(
double
orientationDegrees)
80
{
81
NS_LOG_FUNCTION
(
this
<< orientationDegrees);
82
m_orientationRadians
=
DegreesToRadians
(orientationDegrees);
83
}
84
85
double
86
ParabolicAntennaModel::GetOrientation
()
const
87
{
88
return
RadiansToDegrees
(
m_orientationRadians
);
89
}
90
91
double
92
ParabolicAntennaModel::GetGainDb
(
Angles
a)
93
{
94
NS_LOG_FUNCTION
(
this
<< a);
95
// azimuth angle w.r.t. the reference system of the antenna
96
double
phi = a.
phi
-
m_orientationRadians
;
97
98
// make sure phi is in (-pi, pi]
99
while
(phi <= -M_PI)
100
{
101
phi += M_PI+M_PI;
102
}
103
while
(phi > M_PI)
104
{
105
phi -= M_PI+M_PI;
106
}
107
108
NS_LOG_LOGIC
(
"phi = "
<< phi );
109
110
double
gainDb = -
std::min
(12 * pow (phi /
m_beamwidthRadians
, 2),
m_maxAttenuation
);
111
112
NS_LOG_LOGIC
(
"gain = "
<< gainDb);
113
return
gainDb;
114
}
115
116
117
}
118
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Definition:
log-macros-enabled.h:213
ns3::ParabolicAntennaModel::SetOrientation
void SetOrientation(double orientationDegrees)
Definition:
parabolic-antenna-model.cc:79
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:45
min
#define min(a, b)
Definition:
80211b.c:42
ns3::DegreesToRadians
double DegreesToRadians(double degrees)
converts degrees to radians
Definition:
angles.cc:31
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
ns3::ParabolicAntennaModel::m_orientationRadians
double m_orientationRadians
Definition:
parabolic-antenna-model.h:66
ns3::ParabolicAntennaModel::SetBeamwidth
void SetBeamwidth(double beamwidthDegrees)
Definition:
parabolic-antenna-model.cc:66
ns3::ParabolicAntennaModel::GetGainDb
virtual double GetGainDb(Angles a)
this method is expected to be re-implemented by each antenna model
Definition:
parabolic-antenna-model.cc:92
parabolic-antenna-model.h
ns3::ParabolicAntennaModel::GetTypeId
static TypeId GetTypeId()
Definition:
parabolic-antenna-model.cc:38
ns3::ParabolicAntennaModel
Antenna model based on a parabolic approximation of the main lobe radiation pattern.
Definition:
parabolic-antenna-model.h:45
ns3::ParabolicAntennaModel::m_maxAttenuation
double m_maxAttenuation
Definition:
parabolic-antenna-model.h:68
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
NS_LOG_LOGIC
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
ns3::RadiansToDegrees
double RadiansToDegrees(double radians)
converts radians to degrees
Definition:
angles.cc:37
ns3::MakeDoubleAccessor
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
ns3::ParabolicAntennaModel::GetBeamwidth
double GetBeamwidth() const
Definition:
parabolic-antenna-model.cc:73
antenna-model.h
ns3::Angles::phi
double phi
the azimuth angle in radians
Definition:
angles.h:111
ns3::Angles
struct holding the azimuth and inclination angles of spherical coordinates.
Definition:
angles.h:71
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Definition:
double.h:41
ns3::ParabolicAntennaModel::m_beamwidthRadians
double m_beamwidthRadians
Definition:
parabolic-antenna-model.h:64
ns3::AntennaModel
interface for antenna radiation pattern models
Definition:
antenna-model.h:44
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:58
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:915
ns3::ParabolicAntennaModel::GetOrientation
double GetOrientation() const
Definition:
parabolic-antenna-model.cc:86
Generated on Wed Nov 7 2018 10:01:47 for ns-3 by
1.8.14