A Discrete-Event Network Simulator
API
 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"
28 
29 
30 NS_LOG_COMPONENT_DEFINE ("ParabolicAntennaModel");
31 
32 namespace ns3 {
33 
34 NS_OBJECT_ENSURE_REGISTERED (ParabolicAntennaModel);
35 
36 
37 TypeId
39 {
40  static TypeId tid = TypeId ("ns3::ParabolicAntennaModel")
42  .AddConstructor<ParabolicAntennaModel> ()
43  .AddAttribute ("Beamwidth",
44  "The 3dB beamwidth (degrees)",
45  DoubleValue (60),
46  MakeDoubleAccessor (&ParabolicAntennaModel::SetBeamwidth,
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,
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
73 {
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
86 {
88 }
89 
90 double
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 
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetOrientation(double orientationDegrees)
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition: object-base.h:38
double DegreesToRadians(double degrees)
converts degrees to radians
Definition: angles.cc:32
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
void SetBeamwidth(double beamwidthDegrees)
virtual double GetGainDb(Angles a)
this method is expected to be re-implemented by each antenna model
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:233
double RadiansToDegrees(double radians)
converts radians to degrees
Definition: angles.cc:38
double phi
the azimuth angle in radians
Definition: angles.h:111
struct holding the azimuth and inclination angles of spherical coordinates.
Definition: angles.h:71
Hold a floating point type.
Definition: double.h:41
interface for antenna radiation pattern models
Definition: antenna-model.h:44
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:610