A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
time-data-calculators.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2008 Drexel University
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: Joe Kopena (tjkopena@cs.drexel.edu)
18
*/
19
20
#include "
time-data-calculators.h
"
21
22
#include "ns3/log.h"
23
#include "ns3/nstime.h"
24
25
using namespace
ns3
;
26
27
NS_LOG_COMPONENT_DEFINE
(
"TimeDataCalculators"
);
28
29
//--------------------------------------------------------------
30
//----------------------------------------------
31
TimeMinMaxAvgTotalCalculator::TimeMinMaxAvgTotalCalculator
()
32
{
33
NS_LOG_FUNCTION
(
this
);
34
35
m_count
= 0;
36
}
37
38
TimeMinMaxAvgTotalCalculator::~TimeMinMaxAvgTotalCalculator
()
39
{
40
NS_LOG_FUNCTION
(
this
);
41
}
42
43
/* static */
44
TypeId
45
TimeMinMaxAvgTotalCalculator::GetTypeId
()
46
{
47
static
TypeId
tid =
TypeId
(
"ns3::TimeMinMaxAvgTotalCalculator"
)
48
.
SetParent
<
DataCalculator
>()
49
.SetGroupName(
"Stats"
)
50
.AddConstructor<
TimeMinMaxAvgTotalCalculator
>();
51
return
tid;
52
}
53
54
void
55
TimeMinMaxAvgTotalCalculator::DoDispose
()
56
{
57
NS_LOG_FUNCTION
(
this
);
58
59
DataCalculator::DoDispose
();
60
// TimeMinMaxAvgTotalCalculator::DoDispose
61
}
62
63
void
64
TimeMinMaxAvgTotalCalculator::Update
(
const
Time
i)
65
{
66
NS_LOG_FUNCTION
(
this
<< i);
67
68
if
(
m_enabled
)
69
{
70
if
(
m_count
)
71
{
72
m_total
+= i;
73
74
if
(i <
m_min
)
75
{
76
m_min
= i;
77
}
78
79
if
(i >
m_max
)
80
{
81
m_max
= i;
82
}
83
}
84
else
85
{
86
m_min
= i;
87
m_max
= i;
88
m_total
= i;
89
}
90
m_count
++;
91
}
92
// end TimeMinMaxAvgTotalCalculator::Update
93
}
94
95
void
96
TimeMinMaxAvgTotalCalculator::Output
(
DataOutputCallback
& callback)
const
97
{
98
NS_LOG_FUNCTION
(
this
<< &callback);
99
100
callback.
OutputSingleton
(
m_context
,
m_key
+
"-count"
,
m_count
);
101
if
(
m_count
> 0)
102
{
103
callback.
OutputSingleton
(
m_context
,
m_key
+
"-total"
,
m_total
);
104
callback.
OutputSingleton
(
m_context
,
m_key
+
"-average"
,
Time
(
m_total
/
m_count
));
105
callback.
OutputSingleton
(
m_context
,
m_key
+
"-max"
,
m_max
);
106
callback.
OutputSingleton
(
m_context
,
m_key
+
"-min"
,
m_min
);
107
}
108
// end TimeMinMaxAvgTotalCalculator::Output
109
}
ns3::DataCalculator
Calculates data during a simulation.
Definition:
data-calculator.h:118
ns3::DataCalculator::m_enabled
bool m_enabled
Descendant classes must check & respect m_enabled!
Definition:
data-calculator.h:182
ns3::DataCalculator::m_context
std::string m_context
Context value.
Definition:
data-calculator.h:185
ns3::DataCalculator::m_key
std::string m_key
Key value.
Definition:
data-calculator.h:184
ns3::DataCalculator::DoDispose
void DoDispose() override
Destructor implementation.
Definition:
data-calculator.cc:56
ns3::DataOutputCallback
Callback class for the DataOutput classes.
Definition:
data-output-interface.h:84
ns3::DataOutputCallback::OutputSingleton
virtual void OutputSingleton(std::string key, std::string variable, int val)=0
Associates the integer value with the variable name for a specific output format.
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition:
nstime.h:105
ns3::TimeMinMaxAvgTotalCalculator
Unfortunately, templating the base MinMaxAvgTotalCalculator to operate over Time values isn't straigh...
Definition:
time-data-calculators.h:43
ns3::TimeMinMaxAvgTotalCalculator::m_total
Time m_total
Total value of TimeMinMaxAvgTotalCalculator.
Definition:
time-data-calculators.h:70
ns3::TimeMinMaxAvgTotalCalculator::Update
void Update(const Time i)
Updates all variables of TimeMinMaxAvgTotalCalculator.
Definition:
time-data-calculators.cc:64
ns3::TimeMinMaxAvgTotalCalculator::DoDispose
void DoDispose() override
Destructor implementation.
Definition:
time-data-calculators.cc:55
ns3::TimeMinMaxAvgTotalCalculator::Output
void Output(DataOutputCallback &callback) const override
Outputs data based on the provided callback.
Definition:
time-data-calculators.cc:96
ns3::TimeMinMaxAvgTotalCalculator::GetTypeId
static TypeId GetTypeId()
Register this type.
Definition:
time-data-calculators.cc:45
ns3::TimeMinMaxAvgTotalCalculator::m_count
uint32_t m_count
Count value of TimeMinMaxAvgTotalCalculator.
Definition:
time-data-calculators.h:69
ns3::TimeMinMaxAvgTotalCalculator::m_min
Time m_min
Minimum value of TimeMinMaxAvgTotalCalculator.
Definition:
time-data-calculators.h:71
ns3::TimeMinMaxAvgTotalCalculator::TimeMinMaxAvgTotalCalculator
TimeMinMaxAvgTotalCalculator()
Definition:
time-data-calculators.cc:31
ns3::TimeMinMaxAvgTotalCalculator::~TimeMinMaxAvgTotalCalculator
~TimeMinMaxAvgTotalCalculator() override
Definition:
time-data-calculators.cc:38
ns3::TimeMinMaxAvgTotalCalculator::m_max
Time m_max
Maximum value of TimeMinMaxAvgTotalCalculator.
Definition:
time-data-calculators.h:72
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:931
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
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:240
ns3::TracedValueCallback::Time
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Definition:
nstime.h:839
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
time-data-calculators.h
src
stats
model
time-data-calculators.cc
Generated on Sun Mar 3 2024 17:11:08 for ns-3 by
1.9.1