author | Nicola Baldo <nbaldo@cttc.es> |
Tue, 04 Oct 2011 18:40:50 +0200 | |
changeset 7553 | 2b93d333dea6 |
parent 7142 | 89a701fec3a1 |
child 7836 | 9cf68ee51869 |
permissions | -rw-r--r-- |
6349 | 1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* Copyright (c) 2010 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 |
#include "ns3/propagation-delay-model.h" |
|
21 |
#include "ns3/spectrum-propagation-loss-model.h" |
|
22 |
#include "ns3/mobility-model.h" |
|
23 |
#include "ns3/log.h" |
|
24 |
#include "ns3/config.h" |
|
25 |
#include "ns3/simulator.h" |
|
26 |
#include "ns3/names.h" |
|
27 |
#include "ns3/spectrum-channel.h" |
|
28 |
#include "ns3/waveform-generator.h" |
|
29 |
#include "ns3/non-communicating-net-device.h" |
|
30 |
#include "waveform-generator-helper.h" |
|
31 |
||
32 |
||
33 |
||
34 |
||
35 |
NS_LOG_COMPONENT_DEFINE ("WaveformGeneratorHelper"); |
|
36 |
||
37 |
namespace ns3 { |
|
38 |
||
39 |
||
40 |
WaveformGeneratorHelper::WaveformGeneratorHelper () |
|
41 |
{ |
|
42 |
m_phy.SetTypeId ("ns3::WaveformGenerator"); |
|
43 |
m_device.SetTypeId ("ns3::NonCommunicatingNetDevice"); |
|
44 |
} |
|
45 |
||
46 |
WaveformGeneratorHelper::~WaveformGeneratorHelper () |
|
47 |
{ |
|
48 |
} |
|
49 |
||
50 |
void |
|
51 |
WaveformGeneratorHelper::SetChannel (Ptr<SpectrumChannel> channel) |
|
52 |
{ |
|
53 |
m_channel = channel; |
|
54 |
} |
|
55 |
||
56 |
void |
|
57 |
WaveformGeneratorHelper::SetChannel (std::string channelName) |
|
58 |
{ |
|
59 |
Ptr<SpectrumChannel> channel = Names::Find<SpectrumChannel> (channelName); |
|
60 |
m_channel = channel; |
|
61 |
} |
|
62 |
||
63 |
void |
|
64 |
WaveformGeneratorHelper::SetTxPowerSpectralDensity (Ptr<SpectrumValue> txPsd) |
|
65 |
{ |
|
66 |
NS_LOG_FUNCTION (this << txPsd); |
|
67 |
m_txPsd = txPsd; |
|
68 |
} |
|
69 |
||
70 |
||
71 |
void |
|
72 |
WaveformGeneratorHelper::SetPhyAttribute (std::string name, const AttributeValue &v) |
|
73 |
{ |
|
74 |
m_phy.Set (name, v); |
|
75 |
} |
|
76 |
||
77 |
||
78 |
void |
|
79 |
WaveformGeneratorHelper::SetDeviceAttribute (std::string name, const AttributeValue &v) |
|
80 |
{ |
|
81 |
m_device.Set (name, v); |
|
82 |
} |
|
83 |
||
84 |
||
85 |
NetDeviceContainer |
|
86 |
WaveformGeneratorHelper::Install (NodeContainer c) const |
|
87 |
{ |
|
88 |
NetDeviceContainer devices; |
|
89 |
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i) |
|
90 |
{ |
|
91 |
Ptr<Node> node = *i; |
|
92 |
||
93 |
Ptr<NonCommunicatingNetDevice> dev = m_device.Create ()->GetObject<NonCommunicatingNetDevice> (); |
|
7142
89a701fec3a1
run check-style.py on src/spectrum
Nicola Baldo <nicola@baldo.biz>
parents:
6801
diff
changeset
|
94 |
|
6349 | 95 |
Ptr<WaveformGenerator> phy = m_phy.Create ()->GetObject<WaveformGenerator> (); |
96 |
NS_ASSERT (phy); |
|
97 |
||
98 |
dev->SetPhy (phy); |
|
99 |
||
100 |
NS_ASSERT (node); |
|
7553
2b93d333dea6
Bug 1271 - stronger type checking in SpectrumPhy
Nicola Baldo <nbaldo@cttc.es>
parents:
7142
diff
changeset
|
101 |
phy->SetMobility (node->GetObject<MobilityModel> ()); |
6349 | 102 |
|
103 |
NS_ASSERT (dev); |
|
104 |
phy->SetDevice (dev); |
|
105 |
||
106 |
NS_ASSERT_MSG (m_txPsd, "you forgot to call WaveformGeneratorHelper::SetTxPowerSpectralDensity ()"); |
|
107 |
phy->SetTxPowerSpectralDensity (m_txPsd); |
|
108 |
||
109 |
NS_ASSERT_MSG (m_channel, "you forgot to call WaveformGeneratorHelper::SetChannel ()"); |
|
110 |
phy->SetChannel (m_channel); |
|
6355
957e0c6ccb29
fixed spectrum code for python bindings as per Gustavo's suggestion
Nicola Baldo <nicola@baldo.biz>
parents:
6349
diff
changeset
|
111 |
dev->SetChannel (m_channel); |
957e0c6ccb29
fixed spectrum code for python bindings as per Gustavo's suggestion
Nicola Baldo <nicola@baldo.biz>
parents:
6349
diff
changeset
|
112 |
|
6349 | 113 |
|
114 |
node->AddDevice (dev); |
|
115 |
devices.Add (dev); |
|
116 |
} |
|
117 |
return devices; |
|
118 |
} |
|
119 |
||
120 |
NetDeviceContainer |
|
121 |
WaveformGeneratorHelper::Install (Ptr<Node> node) const |
|
122 |
{ |
|
123 |
return Install (NodeContainer (node)); |
|
124 |
} |
|
125 |
||
126 |
NetDeviceContainer |
|
127 |
WaveformGeneratorHelper::Install (std::string nodeName) const |
|
128 |
{ |
|
129 |
Ptr<Node> node = Names::Find<Node> (nodeName); |
|
130 |
return Install (node); |
|
131 |
} |
|
132 |
||
133 |
||
134 |
} // namespace ns3 |