A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
time-series-adaptor.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2013 University of Washington
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Mitch Watrous (watrous@u.washington.edu)
19
*/
20
21
#include <cmath>
22
#include <cfloat>
23
24
#include "ns3/time-series-adaptor.h"
25
#include "ns3/object.h"
26
#include "ns3/traced-value.h"
27
#include "ns3/log.h"
28
#include "ns3/simulator.h"
29
30
NS_LOG_COMPONENT_DEFINE
(
"TimeSeriesAdaptor"
);
31
32
namespace
ns3 {
33
34
NS_OBJECT_ENSURE_REGISTERED
(TimeSeriesAdaptor)
35
;
36
37
TypeId
38
TimeSeriesAdaptor::GetTypeId
(
void
)
39
{
40
static
TypeId
tid =
TypeId
(
"ns3::TimeSeriesAdaptor"
)
41
.
SetParent
<
DataCollectionObject
> ()
42
.AddConstructor<TimeSeriesAdaptor> ()
43
.AddTraceSource (
"Output"
,
44
"The current simulation time versus the current value converted to a double"
,
45
MakeTraceSourceAccessor
(&
TimeSeriesAdaptor::m_output
))
46
;
47
return
tid;
48
}
49
50
TimeSeriesAdaptor::TimeSeriesAdaptor
()
51
{
52
NS_LOG_FUNCTION
(
this
);
53
}
54
55
TimeSeriesAdaptor::~TimeSeriesAdaptor
()
56
{
57
NS_LOG_FUNCTION
(
this
);
58
}
59
60
void
61
TimeSeriesAdaptor::TraceSinkDouble
(
double
oldData,
double
newData)
62
{
63
NS_LOG_FUNCTION
(
this
<< oldData << newData);
64
65
// Don't do anything if the time series adaptor is not enabled.
66
if
(!
IsEnabled
())
67
{
68
NS_LOG_DEBUG
(
"Time series adaptor not enabled"
);
69
return
;
70
}
71
72
// Time stamp the value with the current time in seconds.
73
m_output
(
Simulator::Now
().GetSeconds (), newData);
74
}
75
76
void
77
TimeSeriesAdaptor::TraceSinkBoolean
(
bool
oldData,
bool
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::TraceSinkUinteger8
(uint8_t oldData, uint8_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::TraceSinkUinteger16
(uint16_t oldData, uint16_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
void
104
TimeSeriesAdaptor::TraceSinkUinteger32
(uint32_t oldData, uint32_t newData)
105
{
106
NS_LOG_FUNCTION
(
this
<< oldData << newData);
107
108
// Call the trace sink that actually does something.
109
TraceSinkDouble
(oldData, newData);
110
}
111
112
}
// namespace ns3
113
ns3::DataCollectionObject::IsEnabled
virtual bool IsEnabled(void) const
Check the status of an individual object.
Definition:
data-collection-object.cc:60
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
Definition:
log.h:345
ns3::DataCollectionObject
Base class for data collection framework objects.
Definition:
data-collection-object.h:37
ns3::NS_OBJECT_ENSURE_REGISTERED
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
NS_LOG_COMPONENT_DEFINE
NS_LOG_COMPONENT_DEFINE("TimeSeriesAdaptor")
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:104
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:86
ns3::MakeTraceSourceAccessor
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Definition:
trace-source-accessor.h:135
ns3::TimeSeriesAdaptor::TimeSeriesAdaptor
TimeSeriesAdaptor()
Definition:
time-series-adaptor.cc:50
ns3::TimeSeriesAdaptor::~TimeSeriesAdaptor
virtual ~TimeSeriesAdaptor()
Definition:
time-series-adaptor.cc:55
ns3::Simulator::Now
static Time Now(void)
Return the "current simulation time".
Definition:
simulator.cc:180
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Definition:
log.h:289
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:95
ns3::TimeSeriesAdaptor::TraceSinkDouble
void TraceSinkDouble(double oldData, double newData)
Trace sink for receiving data from double valued trace sources.
Definition:
time-series-adaptor.cc:61
ns3::TimeSeriesAdaptor::TraceSinkBoolean
void TraceSinkBoolean(bool oldData, bool newData)
Trace sink for receiving data from bool valued trace sources.
Definition:
time-series-adaptor.cc:77
ns3::TimeSeriesAdaptor::m_output
TracedCallback< double, double > m_output
output trace
Definition:
time-series-adaptor.h:116
ns3::TimeSeriesAdaptor::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
time-series-adaptor.cc:38
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:49
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Definition:
type-id.cc:611
src
stats
model
time-series-adaptor.cc
Generated on Sat Apr 19 2014 14:07:08 for ns-3 by
1.8.6