OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2011 Bucknell University | 3 * Copyright (c) 2011 Bucknell University |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 10 matching lines...) Expand all Loading... |
21 * Modified by: Mitch Watrous (watrous@u.washington.edu) | 21 * Modified by: Mitch Watrous (watrous@u.washington.edu) |
22 * | 22 * |
23 */ | 23 */ |
24 | 24 |
25 #include "ns3/time-probe.h" | 25 #include "ns3/time-probe.h" |
26 #include "ns3/object.h" | 26 #include "ns3/object.h" |
27 #include "ns3/log.h" | 27 #include "ns3/log.h" |
28 #include "ns3/names.h" | 28 #include "ns3/names.h" |
29 #include "ns3/config.h" | 29 #include "ns3/config.h" |
30 #include "ns3/trace-source-accessor.h" | 30 #include "ns3/trace-source-accessor.h" |
| 31 #include "ns3/traced-value.h" |
31 | 32 |
32 namespace ns3 { | 33 namespace ns3 { |
33 | 34 |
34 NS_LOG_COMPONENT_DEFINE ("TimeProbe"); | 35 NS_LOG_COMPONENT_DEFINE ("TimeProbe"); |
35 | 36 |
36 NS_OBJECT_ENSURE_REGISTERED (TimeProbe); | 37 NS_OBJECT_ENSURE_REGISTERED (TimeProbe); |
37 | 38 |
38 TypeId | 39 TypeId |
39 TimeProbe::GetTypeId () | 40 TimeProbe::GetTypeId () |
40 { | 41 { |
41 static TypeId tid = TypeId ("ns3::TimeProbe") | 42 static TypeId tid = TypeId ("ns3::TimeProbe") |
42 .SetParent<Probe> () | 43 .SetParent<Probe> () |
43 .SetGroupName ("Stats") | 44 .SetGroupName ("Stats") |
44 .AddConstructor<TimeProbe> () | 45 .AddConstructor<TimeProbe> () |
45 .AddTraceSource ("Output", | 46 .AddTraceSource ("Output", |
46 "The double valued (units of seconds) probe output", | 47 "The double valued (units of seconds) probe output", |
47 MakeTraceSourceAccessor (&TimeProbe::m_output), | 48 MakeTraceSourceAccessor (&TimeProbe::m_output), |
48 "ns3::TracedValue::DoubleCallback") | 49 "ns3::Time::TracedValueCallback") |
49 ; | 50 ; |
50 return tid; | 51 return tid; |
51 } | 52 } |
52 | 53 |
53 TimeProbe::TimeProbe () | 54 TimeProbe::TimeProbe () |
54 { | 55 { |
55 NS_LOG_FUNCTION (this); | 56 NS_LOG_FUNCTION (this); |
56 m_output = 0; | |
57 } | 57 } |
58 | 58 |
59 TimeProbe::~TimeProbe () | 59 TimeProbe::~TimeProbe () |
60 { | 60 { |
61 NS_LOG_FUNCTION (this); | 61 NS_LOG_FUNCTION (this); |
62 } | 62 } |
63 | 63 |
64 double | 64 Time |
65 TimeProbe::GetValue (void) const | 65 TimeProbe::GetValue (void) const |
66 { | 66 { |
67 NS_LOG_FUNCTION (this); | 67 NS_LOG_FUNCTION (this); |
68 return m_output; | 68 return m_output; |
69 } | 69 } |
70 void | 70 void |
71 TimeProbe::SetValue (Time newVal) | 71 TimeProbe::SetValue (Time newVal) |
72 { | 72 { |
73 NS_LOG_FUNCTION (this << newVal.GetSeconds ()); | 73 NS_LOG_FUNCTION (this << newVal.GetSeconds ()); |
74 m_output = newVal.GetSeconds (); | 74 m_output = newVal; |
75 } | 75 } |
76 | 76 |
77 void | 77 void |
78 TimeProbe::SetValueByPath (std::string path, Time newVal) | 78 TimeProbe::SetValueByPath (std::string path, Time newVal) |
79 { | 79 { |
80 NS_LOG_FUNCTION (path << newVal.GetSeconds ()); | 80 NS_LOG_FUNCTION (path << newVal.GetSeconds ()); |
81 Ptr<TimeProbe> probe = Names::Find<TimeProbe> (path); | 81 Ptr<TimeProbe> probe = Names::Find<TimeProbe> (path); |
82 NS_ASSERT_MSG (probe, "Error: Can't find probe for path " << path); | 82 NS_ASSERT_MSG (probe, "Error: Can't find probe for path " << path); |
83 probe->SetValue (newVal); | 83 probe->SetValue (newVal); |
84 } | 84 } |
(...skipping 14 matching lines...) Expand all Loading... |
99 NS_LOG_DEBUG ("Name of trace source to search for in config database: " << pat
h); | 99 NS_LOG_DEBUG ("Name of trace source to search for in config database: " << pat
h); |
100 Config::ConnectWithoutContext (path, MakeCallback (&ns3::TimeProbe::TraceSink,
this)); | 100 Config::ConnectWithoutContext (path, MakeCallback (&ns3::TimeProbe::TraceSink,
this)); |
101 } | 101 } |
102 | 102 |
103 void | 103 void |
104 TimeProbe::TraceSink (Time oldData, Time newData) | 104 TimeProbe::TraceSink (Time oldData, Time newData) |
105 { | 105 { |
106 NS_LOG_FUNCTION (this << oldData.GetSeconds () << newData.GetSeconds ()); | 106 NS_LOG_FUNCTION (this << oldData.GetSeconds () << newData.GetSeconds ()); |
107 if (IsEnabled ()) | 107 if (IsEnabled ()) |
108 { | 108 { |
109 m_output = newData.GetSeconds (); | 109 m_output = newData; |
110 } | 110 } |
111 } | 111 } |
112 | 112 |
113 } // namespace ns3 | 113 } // namespace ns3 |
OLD | NEW |