OLD | NEW |
| (Empty) |
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 namespace ns3 { | |
31 | |
32 NS_LOG_COMPONENT_DEFINE ("TimeSeriesAdaptor"); | |
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 .SetGroupName ("Stats") | |
42 .AddConstructor<TimeSeriesAdaptor> () | |
43 .AddTraceSource ( "Output", | |
44 "The current simulation time versus " | |
45 "the current value converted to a double", | |
46 MakeTraceSourceAccessor (&TimeSeriesAdaptor::m_output), | |
47 "ns3::TimeSeriesAdaptor::OutputTracedCallback") | |
48 ; | |
49 return tid; | |
50 } | |
51 | |
52 TimeSeriesAdaptor::TimeSeriesAdaptor () | |
53 { | |
54 NS_LOG_FUNCTION (this); | |
55 } | |
56 | |
57 TimeSeriesAdaptor::~TimeSeriesAdaptor () | |
58 { | |
59 NS_LOG_FUNCTION (this); | |
60 } | |
61 | |
62 void | |
63 TimeSeriesAdaptor::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 | |
78 void | |
79 TimeSeriesAdaptor::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 | |
87 void | |
88 TimeSeriesAdaptor::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 | |
96 void | |
97 TimeSeriesAdaptor::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 | |
105 void | |
106 TimeSeriesAdaptor::TraceSinkUinteger32 (uint32_t oldData, uint32_t newData) | |
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 | |
115 | |
OLD | NEW |