A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
src
lte
model
lte-chunk-processor.cc
Go to the documentation of this file.
1
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2010 Centre Tecnologic de Telecomunicacions de Catalunya (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
* Modified by : Marco Miozzo <mmiozzo@cttc.es>
20
* (move from CQI to Ctrl and Data SINR Chunk processors
21
*/
22
23
24
#include <ns3/log.h>
25
#include <ns3/spectrum-value.h>
26
#include "
lte-chunk-processor.h
"
27
28
namespace
ns3
{
29
30
NS_LOG_COMPONENT_DEFINE
(
"LteChunkProcessor"
);
31
32
LteChunkProcessor::LteChunkProcessor
()
33
{
34
NS_LOG_FUNCTION
(
this
);
35
}
36
37
LteChunkProcessor::~LteChunkProcessor
()
38
{
39
NS_LOG_FUNCTION
(
this
);
40
}
41
42
void
43
LteChunkProcessor::AddCallback
(
LteChunkProcessorCallback
c)
44
{
45
NS_LOG_FUNCTION
(
this
);
46
m_lteChunkProcessorCallbacks
.push_back (c);
47
}
48
49
void
50
LteChunkProcessor::Start
()
51
{
52
NS_LOG_FUNCTION
(
this
);
53
m_sumValues
= 0;
54
m_totDuration
=
MicroSeconds
(0);
55
}
56
57
58
void
59
LteChunkProcessor::EvaluateChunk
(
const
SpectrumValue
& sinr,
Time
duration)
60
{
61
NS_LOG_FUNCTION
(
this
<< sinr << duration);
62
if
(
m_sumValues
== 0)
63
{
64
m_sumValues
= Create<SpectrumValue> (sinr.
GetSpectrumModel
());
65
}
66
(*m_sumValues) += sinr * duration.
GetSeconds
();
67
m_totDuration
+= duration;
68
}
69
70
void
71
LteChunkProcessor::End
()
72
{
73
NS_LOG_FUNCTION
(
this
);
74
if
(
m_totDuration
.
GetSeconds
() > 0)
75
{
76
std::vector<LteChunkProcessorCallback>::iterator it;
77
for
(it =
m_lteChunkProcessorCallbacks
.begin (); it !=
m_lteChunkProcessorCallbacks
.end (); it++)
78
{
79
(*it)((*m_sumValues) /
m_totDuration
.
GetSeconds
());
80
}
81
}
82
else
83
{
84
NS_LOG_WARN
(
"m_numSinr == 0"
);
85
}
86
}
87
88
89
90
void
91
LteSpectrumValueCatcher::ReportValue
(
const
SpectrumValue
& value)
92
{
93
m_value
= value.
Copy
();
94
}
95
96
Ptr<SpectrumValue>
97
LteSpectrumValueCatcher::GetValue
()
98
{
99
return
m_value
;
100
}
101
102
103
}
// namespace ns3
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition:
nstime.h:102
ns3::Ptr< SpectrumValue >
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Definition:
log-macros-enabled.h:213
ns3::Callback
Callback template class.
Definition:
callback.h:1176
ns3::LteSpectrumValueCatcher::GetValue
Ptr< SpectrumValue > GetValue()
Definition:
lte-chunk-processor.cc:97
ns3::Time::GetSeconds
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition:
nstime.h:355
ns3::LteSpectrumValueCatcher::ReportValue
void ReportValue(const SpectrumValue &value)
function to be plugged to LteChunkProcessor::AddCallback ()
Definition:
lte-chunk-processor.cc:91
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
ns3::LteChunkProcessor::EvaluateChunk
virtual void EvaluateChunk(const SpectrumValue &sinr, Time duration)
Collect SpectrumValue and duration of signal.
Definition:
lte-chunk-processor.cc:59
ns3::LteChunkProcessor::Start
virtual void Start()
Clear internal variables.
Definition:
lte-chunk-processor.cc:50
ns3::LteChunkProcessor::LteChunkProcessor
LteChunkProcessor()
Definition:
lte-chunk-processor.cc:32
ns3::LteChunkProcessor::AddCallback
virtual void AddCallback(LteChunkProcessorCallback c)
Add callback to list.
Definition:
lte-chunk-processor.cc:43
ns3::LteChunkProcessor::End
virtual void End()
Finish calculation and inform interested objects about calculated value.
Definition:
lte-chunk-processor.cc:71
ns3::LteChunkProcessor::~LteChunkProcessor
virtual ~LteChunkProcessor()
Definition:
lte-chunk-processor.cc:37
ns3::LteSpectrumValueCatcher::m_value
Ptr< SpectrumValue > m_value
spectrum value
Definition:
lte-chunk-processor.h:122
ns3::SpectrumValue::Copy
Ptr< SpectrumValue > Copy() const
Definition:
spectrum-value.cc:409
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
lte-chunk-processor.h
ns3::LteChunkProcessor::m_lteChunkProcessorCallbacks
std::vector< LteChunkProcessorCallback > m_lteChunkProcessorCallbacks
chunk processor callback
Definition:
lte-chunk-processor.h:94
ns3::SpectrumValue::GetSpectrumModel
Ptr< const SpectrumModel > GetSpectrumModel() const
Definition:
spectrum-value.cc:62
ns3::LteChunkProcessor::m_sumValues
Ptr< SpectrumValue > m_sumValues
sum values
Definition:
lte-chunk-processor.h:91
NS_LOG_WARN
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition:
log.h:262
ns3::MicroSeconds
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition:
nstime.h:1030
ns3::SpectrumValue
Set of values corresponding to a given SpectrumModel.
Definition:
spectrum-value.h:58
ns3::LteChunkProcessor::m_totDuration
Time m_totDuration
total duration
Definition:
lte-chunk-processor.h:92
Generated on Wed Nov 7 2018 10:02:00 for ns-3 by
1.8.14