OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2012 CTTC | 3 * Copyright (c) 2012 CTTC |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "parabolic-antenna-model.h" | 27 #include "parabolic-antenna-model.h" |
28 | 28 |
29 | 29 |
30 namespace ns3 { | 30 namespace ns3 { |
31 | 31 |
32 NS_LOG_COMPONENT_DEFINE ("ParabolicAntennaModel"); | 32 NS_LOG_COMPONENT_DEFINE ("ParabolicAntennaModel"); |
33 | 33 |
34 NS_OBJECT_ENSURE_REGISTERED (ParabolicAntennaModel); | 34 NS_OBJECT_ENSURE_REGISTERED (ParabolicAntennaModel); |
35 | 35 |
36 | 36 |
37 TypeId | 37 TypeId |
38 ParabolicAntennaModel::GetTypeId () | 38 ParabolicAntennaModel::GetTypeId () |
39 { | 39 { |
40 static TypeId tid = TypeId ("ns3::ParabolicAntennaModel") | 40 static TypeId tid = TypeId ("ns3::ParabolicAntennaModel") |
41 .SetParent<AntennaModel> () | 41 .SetParent<AntennaModel> () |
42 .SetGroupName("Antenna") | 42 .SetGroupName ("Antenna") |
43 .AddConstructor<ParabolicAntennaModel> () | 43 .AddConstructor<ParabolicAntennaModel> () |
44 .AddAttribute ("Beamwidth", | 44 .AddAttribute ("Beamwidth", |
45 "The 3dB beamwidth (degrees)", | 45 "The 3dB beamwidth (degrees)", |
46 DoubleValue (60), | 46 DoubleValue (60), |
47 MakeDoubleAccessor (&ParabolicAntennaModel::SetBeamwidth, | 47 MakeDoubleAccessor (&ParabolicAntennaModel::SetBeamwidth, |
48 &ParabolicAntennaModel::GetBeamwidth), | 48 &ParabolicAntennaModel::GetBeamwidth), |
49 MakeDoubleChecker<double> (0, 180)) | 49 MakeDoubleChecker<double> (0, 180)) |
50 .AddAttribute ("Orientation", | 50 .AddAttribute ("Orientation", |
51 "The angle (degrees) that expresses the orientation of the an
tenna on the x-y plane relative to the x axis", | 51 "The angle (degrees) that expresses the orientation of the an
tenna on the x-y plane relative to the x axis", |
52 DoubleValue (0.0), | 52 DoubleValue (0.0), |
53 MakeDoubleAccessor (&ParabolicAntennaModel::SetOrientation, | 53 MakeDoubleAccessor (&ParabolicAntennaModel::SetOrientation, |
54 &ParabolicAntennaModel::GetOrientation), | 54 &ParabolicAntennaModel::GetOrientation), |
55 MakeDoubleChecker<double> (-360, 360)) | 55 MakeDoubleChecker<double> (-360, 360)) |
56 .AddAttribute ("MaxAttenuation", | 56 .AddAttribute ("MaxAttenuation", |
57 "The maximum attenuation (dB) of the antenna radiation patter
n.", | 57 "The maximum attenuation (dB) of the antenna radiation patter
n.", |
58 DoubleValue (20.0), | 58 DoubleValue (20.0), |
59 MakeDoubleAccessor (&ParabolicAntennaModel::m_maxAttenuation)
, | 59 MakeDoubleAccessor (&ParabolicAntennaModel::m_maxAttenuation)
, |
60 MakeDoubleChecker<double> ()) | 60 MakeDoubleChecker<double> ()) |
61 ; | 61 ; |
62 return tid; | 62 return tid; |
63 } | 63 } |
64 | 64 |
65 void | 65 void |
66 ParabolicAntennaModel::SetBeamwidth (double beamwidthDegrees) | 66 ParabolicAntennaModel::SetBeamwidth (double beamwidthDegrees) |
67 { | 67 { |
68 NS_LOG_FUNCTION (this << beamwidthDegrees); | 68 NS_LOG_FUNCTION (this << beamwidthDegrees); |
69 m_beamwidthRadians = DegreesToRadians (beamwidthDegrees); | 69 m_beamwidthRadians = DegreesToRadians (beamwidthDegrees); |
70 } | 70 } |
71 | 71 |
72 double | 72 double |
73 ParabolicAntennaModel::GetBeamwidth () const | 73 ParabolicAntennaModel::GetBeamwidth () const |
74 { | 74 { |
75 return RadiansToDegrees (m_beamwidthRadians); | 75 return RadiansToDegrees (m_beamwidthRadians); |
76 } | 76 } |
77 | 77 |
78 void | 78 void |
79 ParabolicAntennaModel::SetOrientation (double orientationDegrees) | 79 ParabolicAntennaModel::SetOrientation (double orientationDegrees) |
80 { | 80 { |
81 NS_LOG_FUNCTION (this << orientationDegrees); | 81 NS_LOG_FUNCTION (this << orientationDegrees); |
82 m_orientationRadians = DegreesToRadians (orientationDegrees); | 82 m_orientationRadians = DegreesToRadians (orientationDegrees); |
83 } | 83 } |
84 | 84 |
85 double | 85 double |
86 ParabolicAntennaModel::GetOrientation () const | 86 ParabolicAntennaModel::GetOrientation () const |
87 { | 87 { |
88 return RadiansToDegrees (m_orientationRadians); | 88 return RadiansToDegrees (m_orientationRadians); |
89 } | 89 } |
90 | 90 |
91 double | 91 double |
92 ParabolicAntennaModel::GetGainDb (Angles a) | 92 ParabolicAntennaModel::GetGainDb (Angles a) |
93 { | 93 { |
94 NS_LOG_FUNCTION (this << a); | 94 NS_LOG_FUNCTION (this << a); |
95 // azimuth angle w.r.t. the reference system of the antenna | 95 // azimuth angle w.r.t. the reference system of the antenna |
96 double phi = a.phi - m_orientationRadians; | 96 double phi = a.phi - m_orientationRadians; |
97 | 97 |
98 // make sure phi is in (-pi, pi] | 98 // make sure phi is in (-pi, pi] |
99 while (phi <= -M_PI) | 99 while (phi <= -M_PI) |
100 { | 100 { |
101 phi += M_PI+M_PI; | 101 phi += M_PI + M_PI; |
102 } | 102 } |
103 while (phi > M_PI) | 103 while (phi > M_PI) |
104 { | 104 { |
105 phi -= M_PI+M_PI; | 105 phi -= M_PI + M_PI; |
106 } | 106 } |
107 | 107 |
108 NS_LOG_LOGIC ("phi = " << phi ); | 108 NS_LOG_LOGIC ("phi = " << phi ); |
109 | 109 |
110 double gainDb = -std::min (12 * pow (phi / m_beamwidthRadians, 2), m_maxAttenu
ation); | 110 double gainDb = -std::min (12 * pow (phi / m_beamwidthRadians, 2), m_maxAttenu
ation); |
111 | 111 |
112 NS_LOG_LOGIC ("gain = " << gainDb); | 112 NS_LOG_LOGIC ("gain = " << gainDb); |
113 return gainDb; | 113 return gainDb; |
114 } | 114 } |
115 | 115 |
116 | 116 |
117 } | 117 } |
118 | 118 |
OLD | NEW |