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 * 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: Mitch Watrous (watrous@u.washington.edu)
18 */
19
20#include "time-series-adaptor.h"
21
22#include "ns3/log.h"
23#include "ns3/object.h"
24#include "ns3/simulator.h"
25#include "ns3/traced-value.h"
26
27#include <cfloat>
28#include <cmath>
29
30namespace ns3
31{
32
33NS_LOG_COMPONENT_DEFINE("TimeSeriesAdaptor");
34
35NS_OBJECT_ENSURE_REGISTERED(TimeSeriesAdaptor);
36
37TypeId
39{
40 static TypeId tid = TypeId("ns3::TimeSeriesAdaptor")
42 .SetGroupName("Stats")
43 .AddConstructor<TimeSeriesAdaptor>()
44 .AddTraceSource("Output",
45 "The current simulation time versus "
46 "the current value converted to a double",
48 "ns3::TimeSeriesAdaptor::OutputTracedCallback");
49 return tid;
50}
51
53{
54 NS_LOG_FUNCTION(this);
55}
56
58{
59 NS_LOG_FUNCTION(this);
60}
61
62void
63TimeSeriesAdaptor::TraceSinkDouble(double oldData, double newData)
64{
65 NS_LOG_FUNCTION(this << oldData << newData);
66
67 // Don't do anything if the time series adaptor is not enabled.
68 if (!IsEnabled())
69 {
70 NS_LOG_DEBUG("Time series adaptor not enabled");
71 return;
72 }
73
74 // Time stamp the value with the current time in seconds.
75 m_output(Simulator::Now().GetSeconds(), newData);
76}
77
78void
79TimeSeriesAdaptor::TraceSinkBoolean(bool oldData, bool newData)
80{
81 NS_LOG_FUNCTION(this << oldData << newData);
82
83 // Call the trace sink that actually does something.
84 TraceSinkDouble(oldData, newData);
85}
86
87void
88TimeSeriesAdaptor::TraceSinkUinteger8(uint8_t oldData, uint8_t newData)
89{
90 NS_LOG_FUNCTION(this << oldData << newData);
91
92 // Call the trace sink that actually does something.
93 TraceSinkDouble(oldData, newData);
94}
95
96void
97TimeSeriesAdaptor::TraceSinkUinteger16(uint16_t oldData, uint16_t newData)
98{
99 NS_LOG_FUNCTION(this << oldData << newData);
100
101 // Call the trace sink that actually does something.
102 TraceSinkDouble(oldData, newData);
103}
104
105void
107{
108 NS_LOG_FUNCTION(this << oldData << newData);
109
110 // Call the trace sink that actually does something.
111 TraceSinkDouble(oldData, newData);
112}
113
114} // 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:208
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:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#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:46
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.