A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
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
NS_LOG_COMPONENT_DEFINE
(
"ParabolicAntennaModel"
);
31
32
namespace
ns3 {
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
.AddConstructor<ParabolicAntennaModel> ()
43
.AddAttribute (
"Beamwidth"
,
44
"The 3dB beamwidth (degrees)"
,
45
DoubleValue
(60),
46
MakeDoubleAccessor (&
ParabolicAntennaModel::SetBeamwidth
,
47
&
ParabolicAntennaModel::GetBeamwidth
),
48
MakeDoubleChecker<double> (0, 180))
49
.AddAttribute (
"Orientation"
,
50
"The angle (degrees) that expresses the orientation of the antenna on the x-y plane relative to the x axis"
,
51
DoubleValue
(0.0),
52
MakeDoubleAccessor (&
ParabolicAntennaModel::SetOrientation
,
53
&
ParabolicAntennaModel::GetOrientation
),
54
MakeDoubleChecker<double> (-360, 360))
55
.AddAttribute (
"MaxAttenuation"
,
56
"The maximum attenuation (dB) of the antenna radiation pattern."
,
57
DoubleValue
(20.0),
58
MakeDoubleAccessor (&
ParabolicAntennaModel::m_maxAttenuation
),
59
MakeDoubleChecker<double> ())
60
;
61
return
tid;
62
}
63
64
void
65
ParabolicAntennaModel::SetBeamwidth
(
double
beamwidthDegrees)
66
{
67
NS_LOG_FUNCTION
(
this
<< beamwidthDegrees);
68
m_beamwidthRadians
=
DegreesToRadians
(beamwidthDegrees);
69
}
70
71
double
72
ParabolicAntennaModel::GetBeamwidth
()
const
73
{
74
return
RadiansToDegrees
(
m_beamwidthRadians
);
75
}
76
77
void
78
ParabolicAntennaModel::SetOrientation
(
double
orientationDegrees)
79
{
80
NS_LOG_FUNCTION
(
this
<< orientationDegrees);
81
m_orientationRadians
=
DegreesToRadians
(orientationDegrees);
82
}
83
84
double
85
ParabolicAntennaModel::GetOrientation
()
const
86
{
87
return
RadiansToDegrees
(
m_orientationRadians
);
88
}
89
90
double
91
ParabolicAntennaModel::GetGainDb
(
Angles
a)
92
{
93
NS_LOG_FUNCTION
(
this
<< a);
94
// azimuth angle w.r.t. the reference system of the antenna
95
double
phi = a.
phi
-
m_orientationRadians
;
96
97
// make sure phi is in (-pi, pi]
98
while
(phi <= -M_PI)
99
{
100
phi += M_PI+M_PI;
101
}
102
while
(phi > M_PI)
103
{
104
phi -= M_PI+M_PI;
105
}
106
107
NS_LOG_LOGIC
(
"phi = "
<< phi );
108
109
double
gainDb = -std::min (12 * pow (phi /
m_beamwidthRadians
, 2),
m_maxAttenuation
);
110
111
NS_LOG_LOGIC
(
"gain = "
<< gainDb);
112
return
gainDb;
113
}
114
115
116
}
117
src
antenna
model
parabolic-antenna-model.cc
Generated on Tue Oct 9 2012 16:45:32 for ns-3 by
1.8.1.2