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
TypeId
37
TimeSeriesAdaptor::GetTypeId
(
void
)
38
{
39
static
TypeId
tid =
TypeId
(
"ns3::TimeSeriesAdaptor"
)
40
.
SetParent
<
DataCollectionObject
> ()
41
.AddConstructor<TimeSeriesAdaptor> ()
42
.AddTraceSource (
"Output"
,
43
"The current simulation time versus the current value converted to a double"
,
44
MakeTraceSourceAccessor
(&
TimeSeriesAdaptor::m_output
))
45
;
46
return
tid;
47
}
48
49
TimeSeriesAdaptor::TimeSeriesAdaptor
()
50
{
51
NS_LOG_FUNCTION
(
this
);
52
}
53
54
TimeSeriesAdaptor::~TimeSeriesAdaptor
()
55
{
56
NS_LOG_FUNCTION
(
this
);
57
}
58
59
void
60
TimeSeriesAdaptor::TraceSinkDouble
(
double
oldData,
double
newData)
61
{
62
NS_LOG_FUNCTION
(
this
<< oldData << newData);
63
64
// Don't do anything if the time series adaptor is not enabled.
65
if
(!
IsEnabled
())
66
{
67
NS_LOG_DEBUG
(
"Time series adaptor not enabled"
);
68
return
;
69
}
70
71
// Time stamp the value with the current time in seconds.
72
m_output
(
Simulator::Now
().GetSeconds (), newData);
73
}
74
75
void
76
TimeSeriesAdaptor::TraceSinkBoolean
(
bool
oldData,
bool
newData)
77
{
78
NS_LOG_FUNCTION
(
this
<< oldData << newData);
79
80
// Call the trace sink that actually does something.
81
TraceSinkDouble
(oldData, newData);
82
}
83
84
void
85
TimeSeriesAdaptor::TraceSinkUinteger8
(uint8_t oldData, uint8_t newData)
86
{
87
NS_LOG_FUNCTION
(
this
<< oldData << newData);
88
89
// Call the trace sink that actually does something.
90
TraceSinkDouble
(oldData, newData);
91
}
92
93
void
94
TimeSeriesAdaptor::TraceSinkUinteger16
(uint16_t oldData, uint16_t newData)
95
{
96
NS_LOG_FUNCTION
(
this
<< oldData << newData);
97
98
// Call the trace sink that actually does something.
99
TraceSinkDouble
(oldData, newData);
100
}
101
102
void
103
TimeSeriesAdaptor::TraceSinkUinteger32
(uint32_t oldData, uint32_t newData)
104
{
105
NS_LOG_FUNCTION
(
this
<< oldData << newData);
106
107
// Call the trace sink that actually does something.
108
TraceSinkDouble
(oldData, newData);
109
}
110
111
}
// namespace ns3
112
ns3::DataCollectionObject::IsEnabled
virtual bool IsEnabled(void) const
Check the status of an individual object.
Definition:
data-collection-object.cc:59
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
Definition:
log.h:311
ns3::DataCollectionObject
Definition:
data-collection-object.h:35
NS_LOG_COMPONENT_DEFINE
NS_LOG_COMPONENT_DEFINE("TimeSeriesAdaptor")
ns3::NS_OBJECT_ENSURE_REGISTERED
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
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:103
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:85
ns3::MakeTraceSourceAccessor
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Definition:
trace-source-accessor.h:135
ns3::TimeSeriesAdaptor::TimeSeriesAdaptor
TimeSeriesAdaptor()
Definition:
time-series-adaptor.cc:49
ns3::TimeSeriesAdaptor::~TimeSeriesAdaptor
virtual ~TimeSeriesAdaptor()
Definition:
time-series-adaptor.cc:54
ns3::Simulator::Now
static Time Now(void)
Definition:
simulator.cc:180
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Definition:
log.h:255
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:94
ns3::TimeSeriesAdaptor::TraceSinkDouble
void TraceSinkDouble(double oldData, double newData)
Trace sink for receiving data from double valued trace sources.
Definition:
time-series-adaptor.cc:60
ns3::TimeSeriesAdaptor::TraceSinkBoolean
void TraceSinkBoolean(bool oldData, bool newData)
Trace sink for receiving data from bool valued trace sources.
Definition:
time-series-adaptor.cc:76
ns3::TimeSeriesAdaptor::m_output
TracedCallback< double, double > m_output
Definition:
time-series-adaptor.h:110
ns3::TimeSeriesAdaptor::GetTypeId
static TypeId GetTypeId(void)
Definition:
time-series-adaptor.cc:37
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:49
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Definition:
type-id.cc:610
src
stats
model
time-series-adaptor.cc
Generated on Sun Apr 20 2014 11:15:02 for ns-3 by
1.8.6