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
waveform-generator-helper.cc
Go to the documentation of this file.
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/antenna-model.h"
28
#include "ns3/spectrum-channel.h"
29
#include "ns3/waveform-generator.h"
30
#include "ns3/non-communicating-net-device.h"
31
#include "
waveform-generator-helper.h
"
32
33
34
35
36
NS_LOG_COMPONENT_DEFINE
(
"WaveformGeneratorHelper"
);
37
38
namespace
ns3 {
39
40
41
WaveformGeneratorHelper::WaveformGeneratorHelper
()
42
{
43
m_phy
.
SetTypeId
(
"ns3::WaveformGenerator"
);
44
m_device
.
SetTypeId
(
"ns3::NonCommunicatingNetDevice"
);
45
m_antenna
.
SetTypeId
(
"ns3::IsotropicAntennaModel"
);
46
}
47
48
WaveformGeneratorHelper::~WaveformGeneratorHelper
()
49
{
50
}
51
52
void
53
WaveformGeneratorHelper::SetChannel
(
Ptr<SpectrumChannel>
channel)
54
{
55
m_channel
= channel;
56
}
57
58
void
59
WaveformGeneratorHelper::SetChannel
(std::string channelName)
60
{
61
Ptr<SpectrumChannel>
channel = Names::Find<SpectrumChannel> (channelName);
62
m_channel
= channel;
63
}
64
65
void
66
WaveformGeneratorHelper::SetTxPowerSpectralDensity
(
Ptr<SpectrumValue>
txPsd)
67
{
68
NS_LOG_FUNCTION
(
this
<< txPsd);
69
m_txPsd
= txPsd;
70
}
71
72
73
void
74
WaveformGeneratorHelper::SetPhyAttribute
(std::string name,
const
AttributeValue
&v)
75
{
76
m_phy
.
Set
(name, v);
77
}
78
79
80
void
81
WaveformGeneratorHelper::SetDeviceAttribute
(std::string name,
const
AttributeValue
&v)
82
{
83
m_device
.
Set
(name, v);
84
}
85
86
void
87
WaveformGeneratorHelper::SetAntenna
(std::string type,
88
std::string n0,
const
AttributeValue
&v0,
89
std::string n1,
const
AttributeValue
&v1,
90
std::string n2,
const
AttributeValue
&v2,
91
std::string n3,
const
AttributeValue
&v3,
92
std::string n4,
const
AttributeValue
&v4,
93
std::string n5,
const
AttributeValue
&v5,
94
std::string n6,
const
AttributeValue
&v6,
95
std::string n7,
const
AttributeValue
&v7)
96
{
97
ObjectFactory
factory;
98
factory.
SetTypeId
(type);
99
factory.
Set
(n0, v0);
100
factory.
Set
(n1, v1);
101
factory.
Set
(n2, v2);
102
factory.
Set
(n3, v3);
103
factory.
Set
(n4, v4);
104
factory.
Set
(n5, v5);
105
factory.
Set
(n6, v6);
106
factory.
Set
(n7, v7);
107
m_antenna
= factory;
108
}
109
110
NetDeviceContainer
111
WaveformGeneratorHelper::Install
(
NodeContainer
c)
const
112
{
113
NetDeviceContainer
devices;
114
for
(
NodeContainer::Iterator
i = c.
Begin
(); i != c.
End
(); ++i)
115
{
116
Ptr<Node>
node = *i;
117
118
Ptr<NonCommunicatingNetDevice>
dev =
m_device
.
Create
()->
GetObject
<
NonCommunicatingNetDevice
> ();
119
120
Ptr<WaveformGenerator>
phy =
m_phy
.
Create
()->
GetObject
<
WaveformGenerator
> ();
121
NS_ASSERT
(phy);
122
123
dev->SetPhy (phy);
124
125
NS_ASSERT
(node);
126
phy->SetMobility (node->
GetObject
<
MobilityModel
> ());
127
128
NS_ASSERT
(dev);
129
phy->SetDevice (dev);
130
131
NS_ASSERT_MSG
(
m_txPsd
,
"you forgot to call WaveformGeneratorHelper::SetTxPowerSpectralDensity ()"
);
132
phy->SetTxPowerSpectralDensity (
m_txPsd
);
133
134
NS_ASSERT_MSG
(
m_channel
,
"you forgot to call WaveformGeneratorHelper::SetChannel ()"
);
135
phy->SetChannel (
m_channel
);
136
dev->SetChannel (
m_channel
);
137
138
Ptr<AntennaModel>
antenna = (
m_antenna
.
Create
())->GetObject<AntennaModel> ();
139
NS_ASSERT_MSG
(antenna,
"error in creating the AntennaModel object"
);
140
phy->SetAntenna (antenna);
141
142
node->
AddDevice
(dev);
143
devices.
Add
(dev);
144
}
145
return
devices;
146
}
147
148
NetDeviceContainer
149
WaveformGeneratorHelper::Install
(
Ptr<Node>
node)
const
150
{
151
return
Install
(
NodeContainer
(node));
152
}
153
154
NetDeviceContainer
155
WaveformGeneratorHelper::Install
(std::string nodeName)
const
156
{
157
Ptr<Node>
node = Names::Find<Node> (nodeName);
158
return
Install
(node);
159
}
160
161
162
}
// namespace ns3
src
spectrum
helper
waveform-generator-helper.cc
Generated on Tue May 14 2013 11:08:32 for ns-3 by
1.8.1.2