A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
time-data-calculators.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2008 Drexel University
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Joe Kopena (tjkopena@cs.drexel.edu)
7
*/
8
9
#include "
time-data-calculators.h
"
10
11
#include "ns3/log.h"
12
#include "ns3/nstime.h"
13
14
using namespace
ns3
;
15
16
NS_LOG_COMPONENT_DEFINE
(
"TimeDataCalculators"
);
17
18
//--------------------------------------------------------------
19
//----------------------------------------------
20
TimeMinMaxAvgTotalCalculator::TimeMinMaxAvgTotalCalculator
()
21
{
22
NS_LOG_FUNCTION
(
this
);
23
24
m_count
= 0;
25
}
26
27
TimeMinMaxAvgTotalCalculator::~TimeMinMaxAvgTotalCalculator
()
28
{
29
NS_LOG_FUNCTION
(
this
);
30
}
31
32
/* static */
33
TypeId
34
TimeMinMaxAvgTotalCalculator::GetTypeId
()
35
{
36
static
TypeId
tid =
TypeId
(
"ns3::TimeMinMaxAvgTotalCalculator"
)
37
.
SetParent
<
DataCalculator
>()
38
.SetGroupName(
"Stats"
)
39
.AddConstructor<
TimeMinMaxAvgTotalCalculator
>();
40
return
tid;
41
}
42
43
void
44
TimeMinMaxAvgTotalCalculator::DoDispose
()
45
{
46
NS_LOG_FUNCTION
(
this
);
47
48
DataCalculator::DoDispose
();
49
// TimeMinMaxAvgTotalCalculator::DoDispose
50
}
51
52
void
53
TimeMinMaxAvgTotalCalculator::Update
(
const
Time
i)
54
{
55
NS_LOG_FUNCTION
(
this
<< i);
56
57
if
(
m_enabled
)
58
{
59
if
(
m_count
)
60
{
61
m_total
+= i;
62
63
if
(i <
m_min
)
64
{
65
m_min
= i;
66
}
67
68
if
(i >
m_max
)
69
{
70
m_max
= i;
71
}
72
}
73
else
74
{
75
m_min
= i;
76
m_max
= i;
77
m_total
= i;
78
}
79
m_count
++;
80
}
81
// end TimeMinMaxAvgTotalCalculator::Update
82
}
83
84
void
85
TimeMinMaxAvgTotalCalculator::Output
(
DataOutputCallback
& callback)
const
86
{
87
NS_LOG_FUNCTION
(
this
<< &callback);
88
89
callback.
OutputSingleton
(
m_context
,
m_key
+
"-count"
,
m_count
);
90
if
(
m_count
> 0)
91
{
92
callback.
OutputSingleton
(
m_context
,
m_key
+
"-total"
,
m_total
);
93
callback.
OutputSingleton
(
m_context
,
m_key
+
"-average"
,
Time
(
m_total
/
m_count
));
94
callback.
OutputSingleton
(
m_context
,
m_key
+
"-max"
,
m_max
);
95
callback.
OutputSingleton
(
m_context
,
m_key
+
"-min"
,
m_min
);
96
}
97
// end TimeMinMaxAvgTotalCalculator::Output
98
}
ns3::DataCalculator
Calculates data during a simulation.
Definition
data-calculator.h:107
ns3::DataCalculator::m_enabled
bool m_enabled
Descendant classes must check & respect m_enabled!
Definition
data-calculator.h:171
ns3::DataCalculator::m_context
std::string m_context
Context value.
Definition
data-calculator.h:174
ns3::DataCalculator::m_key
std::string m_key
Key value.
Definition
data-calculator.h:173
ns3::DataCalculator::DoDispose
void DoDispose() override
Destructor implementation.
Definition
data-calculator.cc:45
ns3::DataOutputCallback
Callback class for the DataOutput classes.
Definition
data-output-interface.h:73
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:94
ns3::TimeMinMaxAvgTotalCalculator
Unfortunately, templating the base MinMaxAvgTotalCalculator to operate over Time values isn't straigh...
Definition
time-data-calculators.h:32
ns3::TimeMinMaxAvgTotalCalculator::m_total
Time m_total
Total value of TimeMinMaxAvgTotalCalculator.
Definition
time-data-calculators.h:59
ns3::TimeMinMaxAvgTotalCalculator::Update
void Update(const Time i)
Updates all variables of TimeMinMaxAvgTotalCalculator.
Definition
time-data-calculators.cc:53
ns3::TimeMinMaxAvgTotalCalculator::DoDispose
void DoDispose() override
Destructor implementation.
Definition
time-data-calculators.cc:44
ns3::TimeMinMaxAvgTotalCalculator::Output
void Output(DataOutputCallback &callback) const override
Outputs data based on the provided callback.
Definition
time-data-calculators.cc:85
ns3::TimeMinMaxAvgTotalCalculator::GetTypeId
static TypeId GetTypeId()
Register this type.
Definition
time-data-calculators.cc:34
ns3::TimeMinMaxAvgTotalCalculator::m_count
uint32_t m_count
Count value of TimeMinMaxAvgTotalCalculator.
Definition
time-data-calculators.h:58
ns3::TimeMinMaxAvgTotalCalculator::m_min
Time m_min
Minimum value of TimeMinMaxAvgTotalCalculator.
Definition
time-data-calculators.h:60
ns3::TimeMinMaxAvgTotalCalculator::TimeMinMaxAvgTotalCalculator
TimeMinMaxAvgTotalCalculator()
Definition
time-data-calculators.cc:20
ns3::TimeMinMaxAvgTotalCalculator::~TimeMinMaxAvgTotalCalculator
~TimeMinMaxAvgTotalCalculator() override
Definition
time-data-calculators.cc:27
ns3::TimeMinMaxAvgTotalCalculator::m_max
Time m_max
Maximum value of TimeMinMaxAvgTotalCalculator.
Definition
time-data-calculators.h:61
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
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:229
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 Fri Nov 8 2024 13:59:06 for ns-3 by
1.11.0