A Discrete-Event Network Simulator
API
lte-chunk-processor.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Nicola Baldo <nbaldo@cttc.es>
18  * Modified by : Marco Miozzo <mmiozzo@cttc.es>
19  * (move from CQI to Ctrl and Data SINR Chunk processors
20  */
21 
22 #include "lte-chunk-processor.h"
23 
24 #include <ns3/log.h>
25 #include <ns3/spectrum-value.h>
26 
27 namespace ns3
28 {
29 
30 NS_LOG_COMPONENT_DEFINE("LteChunkProcessor");
31 
33 {
34  NS_LOG_FUNCTION(this);
35 }
36 
38 {
39  NS_LOG_FUNCTION(this);
40 }
41 
42 void
44 {
45  NS_LOG_FUNCTION(this);
46  m_lteChunkProcessorCallbacks.push_back(c);
47 }
48 
49 void
51 {
52  NS_LOG_FUNCTION(this);
53  m_sumValues = nullptr;
55 }
56 
57 void
59 {
60  NS_LOG_FUNCTION(this << sinr << duration);
61  if (!m_sumValues)
62  {
63  m_sumValues = Create<SpectrumValue>(sinr.GetSpectrumModel());
64  }
65  (*m_sumValues) += sinr * duration.GetSeconds();
66  m_totDuration += duration;
67 }
68 
69 void
71 {
72  NS_LOG_FUNCTION(this);
73  if (m_totDuration.GetSeconds() > 0)
74  {
75  for (auto it = m_lteChunkProcessorCallbacks.begin();
76  it != m_lteChunkProcessorCallbacks.end();
77  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 void
90 {
91  m_value = value.Copy();
92 }
93 
96 {
97  return m_value;
98 }
99 
100 } // namespace ns3
Callback template class.
Definition: callback.h:438
virtual void Start()
Clear internal variables.
virtual void AddCallback(LteChunkProcessorCallback c)
Add callback to list.
virtual void EvaluateChunk(const SpectrumValue &sinr, Time duration)
Collect SpectrumValue and duration of signal.
Ptr< SpectrumValue > m_sumValues
sum values
Time m_totDuration
total duration
std::vector< LteChunkProcessorCallback > m_lteChunkProcessorCallbacks
chunk processor callback
virtual void End()
Finish calculation and inform interested objects about calculated value.
Ptr< SpectrumValue > m_value
spectrum value
Ptr< SpectrumValue > GetValue()
void ReportValue(const SpectrumValue &value)
function to be plugged to LteChunkProcessor::AddCallback ()
Set of values corresponding to a given SpectrumModel.
Ptr< const SpectrumModel > GetSpectrumModel() const
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:403
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:261
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1350
Every class exported by the ns3 library is enclosed in the ns3 namespace.