A Discrete-Event Network Simulator
API
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 
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 = 0;
55 }
56 
57 
58 void
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
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
92 {
93  m_value = value.Copy ();
94 }
95 
98 {
99  return m_value;
100 }
101 
102 
103 } // namespace ns3
Callback template class.
Definition: callback.h:1279
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:103
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:379
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#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:265
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1260
Every class exported by the ns3 library is enclosed in the ns3 namespace.