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-series-adaptor.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2013 University of Washington
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Mitch Watrous (watrous@u.washington.edu)
7
*/
8
9
#include "
time-series-adaptor.h
"
10
11
#include "ns3/log.h"
12
#include "ns3/object.h"
13
#include "ns3/simulator.h"
14
#include "ns3/traced-value.h"
15
16
#include <cfloat>
17
#include <cmath>
18
19
namespace
ns3
20
{
21
22
NS_LOG_COMPONENT_DEFINE
(
"TimeSeriesAdaptor"
);
23
24
NS_OBJECT_ENSURE_REGISTERED
(
TimeSeriesAdaptor
);
25
26
TypeId
27
TimeSeriesAdaptor::GetTypeId
()
28
{
29
static
TypeId
tid =
TypeId
(
"ns3::TimeSeriesAdaptor"
)
30
.
SetParent
<
DataCollectionObject
>()
31
.SetGroupName(
"Stats"
)
32
.AddConstructor<
TimeSeriesAdaptor
>()
33
.AddTraceSource(
"Output"
,
34
"The current simulation time versus "
35
"the current value converted to a double"
,
36
MakeTraceSourceAccessor
(&
TimeSeriesAdaptor::m_output
),
37
"ns3::TimeSeriesAdaptor::OutputTracedCallback"
);
38
return
tid;
39
}
40
41
TimeSeriesAdaptor::TimeSeriesAdaptor
()
42
{
43
NS_LOG_FUNCTION
(
this
);
44
}
45
46
TimeSeriesAdaptor::~TimeSeriesAdaptor
()
47
{
48
NS_LOG_FUNCTION
(
this
);
49
}
50
51
void
52
TimeSeriesAdaptor::TraceSinkDouble
(
double
oldData,
double
newData)
53
{
54
NS_LOG_FUNCTION
(
this
<< oldData << newData);
55
56
// Don't do anything if the time series adaptor is not enabled.
57
if
(!
IsEnabled
())
58
{
59
NS_LOG_DEBUG
(
"Time series adaptor not enabled"
);
60
return
;
61
}
62
63
// Time stamp the value with the current time in seconds.
64
m_output
(
Simulator::Now
().GetSeconds(), newData);
65
}
66
67
void
68
TimeSeriesAdaptor::TraceSinkBoolean
(
bool
oldData,
bool
newData)
69
{
70
NS_LOG_FUNCTION
(
this
<< oldData << newData);
71
72
// Call the trace sink that actually does something.
73
TraceSinkDouble
(oldData, newData);
74
}
75
76
void
77
TimeSeriesAdaptor::TraceSinkUinteger8
(uint8_t oldData, uint8_t newData)
78
{
79
NS_LOG_FUNCTION
(
this
<< oldData << newData);
80
81
// Call the trace sink that actually does something.
82
TraceSinkDouble
(oldData, newData);
83
}
84
85
void
86
TimeSeriesAdaptor::TraceSinkUinteger16
(uint16_t oldData, uint16_t newData)
87
{
88
NS_LOG_FUNCTION
(
this
<< oldData << newData);
89
90
// Call the trace sink that actually does something.
91
TraceSinkDouble
(oldData, newData);
92
}
93
94
void
95
TimeSeriesAdaptor::TraceSinkUinteger32
(
uint32_t
oldData,
uint32_t
newData)
96
{
97
NS_LOG_FUNCTION
(
this
<< oldData << newData);
98
99
// Call the trace sink that actually does something.
100
TraceSinkDouble
(oldData, newData);
101
}
102
103
}
// namespace ns3
ns3::DataCollectionObject::DataCollectionObject
DataCollectionObject()
Definition
data-collection-object.cc:43
ns3::DataCollectionObject::IsEnabled
virtual bool IsEnabled() const
Check the status of an individual object.
Definition
data-collection-object.cc:53
ns3::Simulator::Now
static Time Now()
Return the current simulation virtual time.
Definition
simulator.cc:197
ns3::TimeSeriesAdaptor
Takes probed values of different types and outputs the current time plus the value with both converte...
Definition
time-series-adaptor.h:39
ns3::TimeSeriesAdaptor::TimeSeriesAdaptor
TimeSeriesAdaptor()
Definition
time-series-adaptor.cc:41
ns3::TimeSeriesAdaptor::TraceSinkUinteger8
void TraceSinkUinteger8(uint8_t oldData, uint8_t newData)
Trace sink for receiving data from uint8_t valued trace sources.
Definition
time-series-adaptor.cc:77
ns3::TimeSeriesAdaptor::TraceSinkDouble
void TraceSinkDouble(double oldData, double newData)
Trace sink for receiving data from double valued trace sources.
Definition
time-series-adaptor.cc:52
ns3::TimeSeriesAdaptor::m_output
TracedCallback< double, double > m_output
output trace
Definition
time-series-adaptor.h:114
ns3::TimeSeriesAdaptor::TraceSinkBoolean
void TraceSinkBoolean(bool oldData, bool newData)
Trace sink for receiving data from bool valued trace sources.
Definition
time-series-adaptor.cc:68
ns3::TimeSeriesAdaptor::~TimeSeriesAdaptor
~TimeSeriesAdaptor() override
Definition
time-series-adaptor.cc:46
ns3::TimeSeriesAdaptor::TraceSinkUinteger32
void TraceSinkUinteger32(uint32_t oldData, uint32_t newData)
Trace sink for receiving data from uint32_t valued trace sources.
Definition
time-series-adaptor.cc:95
ns3::TimeSeriesAdaptor::TraceSinkUinteger16
void TraceSinkUinteger16(uint16_t oldData, uint16_t newData)
Trace sink for receiving data from uint16_t valued trace sources.
Definition
time-series-adaptor.cc:86
ns3::TimeSeriesAdaptor::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
time-series-adaptor.cc:27
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:49
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
uint32_t
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition
log.h:257
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
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
ns3::MakeTraceSourceAccessor
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Definition
trace-source-accessor.h:204
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
time-series-adaptor.h
src
stats
model
time-series-adaptor.cc
Generated on Wed Jun 11 2025 13:15:38 for ns-3 by
1.13.2