A Discrete-Event Network Simulator
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
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
19namespace ns3
20{
21
22NS_LOG_COMPONENT_DEFINE("TimeSeriesAdaptor");
23
24NS_OBJECT_ENSURE_REGISTERED(TimeSeriesAdaptor);
25
26TypeId
28{
29 static TypeId tid = TypeId("ns3::TimeSeriesAdaptor")
31 .SetGroupName("Stats")
32 .AddConstructor<TimeSeriesAdaptor>()
33 .AddTraceSource("Output",
34 "The current simulation time versus "
35 "the current value converted to a double",
37 "ns3::TimeSeriesAdaptor::OutputTracedCallback");
38 return tid;
39}
40
45
50
51void
52TimeSeriesAdaptor::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
67void
68TimeSeriesAdaptor::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
76void
77TimeSeriesAdaptor::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
85void
86TimeSeriesAdaptor::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
94void
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
Base class for data collection framework objects.
virtual bool IsEnabled() const
Check the status of an individual object.
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:197
Takes probed values of different types and outputs the current time plus the value with both converte...
void TraceSinkUinteger8(uint8_t oldData, uint8_t newData)
Trace sink for receiving data from uint8_t valued trace sources.
void TraceSinkDouble(double oldData, double newData)
Trace sink for receiving data from double valued trace sources.
TracedCallback< double, double > m_output
output trace
void TraceSinkBoolean(bool oldData, bool newData)
Trace sink for receiving data from bool valued trace sources.
void TraceSinkUinteger32(uint32_t oldData, uint32_t newData)
Trace sink for receiving data from uint32_t valued trace sources.
void TraceSinkUinteger16(uint16_t oldData, uint16_t newData)
Trace sink for receiving data from uint16_t valued trace sources.
static TypeId GetTypeId()
Get the type ID.
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.