Replace TimeSeriesAdaptor with DoubleEventDrivenCollector draft
authorLi Li <ll024@bucknell.edu>
Tue, 03 Mar 2015 14:41:09 -0500
changeset 10997 9d72ee6faf01
parent 10996 21cc0a86b808
child 10998 08f2099366c9
Replace TimeSeriesAdaptor with DoubleEventDrivenCollector
src/stats/helper/collectorplot-helper.cc
src/stats/helper/collectorplot-helper.h
src/stats/model/time-series-adaptor.cc
src/stats/model/time-series-adaptor.h
src/stats/wscript
--- a/src/stats/helper/collectorplot-helper.cc	Tue Mar 03 14:22:06 2015 -0500
+++ b/src/stats/helper/collectorplot-helper.cc	Tue Mar 03 14:41:09 2015 -0500
@@ -235,24 +235,24 @@
 }
 
 void
-CollectorplotHelper::AddTimeSeriesAdaptor (const std::string &adaptorName)
+CollectorplotHelper::AddDoubleEventDrivenCollector (const std::string &collectorName)
 {
-  NS_LOG_FUNCTION (this << adaptorName);
+  NS_LOG_FUNCTION (this << collectorName);
 
-  // See if this time series adaptor had already been added.
-  if (m_timeSeriesAdaptorMap.count (adaptorName) > 0)
+  // See if this double event driven collector had already been added.
+  if (m_eventDrivenCollectorMap.count (collectorName) > 0)
     {
-      NS_ABORT_MSG ("That time series adaptor has already been added");
+      NS_ABORT_MSG ("That double event driven collector has already been added");
     }
 
-  // Create the time series adaptor.
-  Ptr<TimeSeriesAdaptor> timeSeriesAdaptor = CreateObject<TimeSeriesAdaptor> ();
+  // Create the double event driven collector.
+  Ptr<DoubleEventDrivenCollector> doubleEventDrivenCollector = CreateObject<DoubleEventDrivenCollector> ();
 
-  // Enable logging of data for the time series adaptor.
-  timeSeriesAdaptor->Enable ();
+  // Enable logging of data for the double event driven collector.
+  doubleEventDrivenCollector->Enable ();
 
-  // Add this time series adaptor to the map so that can be used.
-  m_timeSeriesAdaptorMap[adaptorName] = timeSeriesAdaptor;
+  // Add this double event driven collector to the map so that can be used.
+  m_eventDrivenCollectorMap[collectorName] = doubleEventDrivenCollector;
 }
 
 Ptr<Probe>
@@ -352,71 +352,71 @@
   // Because the callbacks to the collectors' trace sources don't use
   // the probe's context, a unique adaptor needs to be created for each 
   // collector context so that information is not last.
-  AddTimeSeriesAdaptor (collectorContext);
+  AddDoubleEventDrivenCollector (collectorContext);
 
   // Connect the collecor to the adaptor.
   if (m_probeMap[probeName].second == "ns3::DoubleProbe")
     {
       m_collectorMap[collectorName].first->TraceConnectWithoutContext
         (collectorTraceSource,
-        MakeCallback (&TimeSeriesAdaptor::TraceSinkDouble,
-                      m_timeSeriesAdaptorMap[collectorContext]));
+        MakeCallback (&DoubleEventDrivenCollector::TraceSinkDouble,
+                      m_eventDrivenCollectorMap[collectorContext]));
     }
   else if (m_probeMap[probeName].second == "ns3::BooleanProbe")
     {
       m_probeMap[collectorName].first->TraceConnectWithoutContext
         (collectorTraceSource,
-        MakeCallback (&TimeSeriesAdaptor::TraceSinkBoolean,
-                      m_timeSeriesAdaptorMap[collectorContext]));
+        MakeCallback (&DoubleEventDrivenCollector::TraceSinkBoolean,
+                      m_eventDrivenCollectorMap[collectorContext]));
     }
   else if (m_probeMap[probeName].second == "ns3::PacketProbe")
     {
       m_probeMap[collectorName].first->TraceConnectWithoutContext
         (collectorTraceSource,
-        MakeCallback (&TimeSeriesAdaptor::TraceSinkUinteger32,
-                      m_timeSeriesAdaptorMap[collectorContext]));
+        MakeCallback (&DoubleEventDrivenCollector::TraceSinkUinteger32,
+                      m_eventDrivenCollectorMap[collectorContext]));
     }
   else if (m_probeMap[probeName].second == "ns3::ApplicationPacketProbe")
     {
       m_probeMap[collectorName].first->TraceConnectWithoutContext
         (collectorTraceSource,
-        MakeCallback (&TimeSeriesAdaptor::TraceSinkUinteger32,
-                      m_timeSeriesAdaptorMap[collectorContext]));
+        MakeCallback (&DoubleEventDrivenCollector::TraceSinkUinteger32,
+                      m_eventDrivenCollectorMap[collectorContext]));
     }
   else if (m_probeMap[probeName].second == "ns3::Ipv4PacketProbe")
     {
       m_probeMap[collectorName].first->TraceConnectWithoutContext
         (collectorTraceSource,
-        MakeCallback (&TimeSeriesAdaptor::TraceSinkUinteger32,
-                      m_timeSeriesAdaptorMap[collectorContext]));
+        MakeCallback (&DoubleEventDrivenCollector::TraceSinkUinteger32,
+                      m_eventDrivenCollectorMap[collectorContext]));
     }
   else if (m_probeMap[probeName].second == "ns3::Ipv6PacketProbe")
     {
       m_probeMap[collectorName].first->TraceConnectWithoutContext
         (collectorTraceSource,
-        MakeCallback (&TimeSeriesAdaptor::TraceSinkUinteger32,
-                      m_timeSeriesAdaptorMap[collectorContext]));
+        MakeCallback (&DoubleEventDrivenCollector::TraceSinkUinteger32,
+                      m_eventDrivenCollectorMap[collectorContext]));
     }
   else if (m_probeMap[probeName].second == "ns3::Uinteger8Probe")
     {
       m_probeMap[collectorName].first->TraceConnectWithoutContext
         (collectorTraceSource,
-        MakeCallback (&TimeSeriesAdaptor::TraceSinkUinteger8,
-                      m_timeSeriesAdaptorMap[collectorContext]));
+        MakeCallback (&DoubleEventDrivenCollector::TraceSinkUinteger8,
+                      m_eventDrivenCollectorMap[collectorContext]));
     }
   else if (m_probeMap[probeName].second == "ns3::Uinteger16Probe")
     {
       m_probeMap[collectorName].first->TraceConnectWithoutContext
         (collectorTraceSource,
-        MakeCallback (&TimeSeriesAdaptor::TraceSinkUinteger16,
-                      m_timeSeriesAdaptorMap[collectorContext]));
+        MakeCallback (&DoubleEventDrivenCollector::TraceSinkUinteger16,
+                      m_eventDrivenCollectorMap[collectorContext]));
     }
   else if (m_probeMap[probeName].second == "ns3::Uinteger32Probe")
     {
       m_probeMap[collectorName].first->TraceConnectWithoutContext
         (collectorTraceSource,
-        MakeCallback (&TimeSeriesAdaptor::TraceSinkUinteger32,
-                      m_timeSeriesAdaptorMap[collectorContext]));
+        MakeCallback (&DoubleEventDrivenCollector::TraceSinkUinteger32,
+                      m_eventDrivenCollectorMap[collectorContext]));
     }
   else
     {
@@ -425,7 +425,7 @@
 
   // Connect the adaptor to the aggregator.
   std::string adaptorTraceSource = "Output";
-  m_timeSeriesAdaptorMap[collectorContext]->TraceConnect
+  m_eventDrivenCollectorMap[collectorContext]->TraceConnect
     (adaptorTraceSource,
     collectorContext,
     MakeCallback (&GnuplotAggregator::Write2d, aggregator));
--- a/src/stats/helper/collectorplot-helper.h	Tue Mar 03 14:22:06 2015 -0500
+++ b/src/stats/helper/collectorplot-helper.h	Tue Mar 03 14:41:09 2015 -0500
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013 University of Washington
+ * Copyright (c) 2015 Bucknell University 
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -16,6 +16,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  * Author: Mitch Watrous (watrous@u.washington.edu)
+ * Modified by: Li Li (ll024@bucknell.edu)
  */
 
 #ifndef COLLECTORPLOT_HELPER_H
@@ -28,7 +29,7 @@
 #include "ns3/ptr.h"
 #include "ns3/probe.h"
 #include "ns3/gnuplot-aggregator.h"
-#include "ns3/time-series-adaptor.h"
+#include "ns3/double-event-driven-collector.h"
 #include "ns3/data-collection-object.h"
 
 namespace ns3 {
@@ -145,11 +146,11 @@
                      const std::string &path) = 0;
 
   /**
-   * \param adaptorName the timeSeriesAdaptor's name.
+   * \param collectorName the DoubleEventDrivenCollector's name.
    *
-   * \brief Adds a time series adaptor to be used to make the plot.
+   * \brief Adds a DoubleEventDrivenCollector to be used to collect data.
    */
-  void AddTimeSeriesAdaptor (const std::string &adaptorName);
+  void AddDoubleEventDrivenCollector (const std::string &collectorName);
 
   /**
    * \param probeName the probe's name.
@@ -201,8 +202,8 @@
   /// Maps collector names to collectors.
   std::map<std::string, std::pair <Ptr<DataCollectionObject>, std::string> > m_collectorMap;
 
-  /// Maps time series adaptor names to time series adaptors.
-  std::map<std::string, Ptr<TimeSeriesAdaptor> > m_timeSeriesAdaptorMap;
+  /// Maps DoubleEventDrivenCollector names to DoubleEventDrivenCollectors.
+  std::map<std::string, Ptr<DoubleEventDrivenCollector> > m_eventDrivenCollectorMap;
 
   /// Number of plot probes that have been created.
   uint32_t m_plotProbeCount;
--- a/src/stats/model/time-series-adaptor.cc	Tue Mar 03 14:22:06 2015 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,112 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2013 University of Washington
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Mitch Watrous (watrous@u.washington.edu)
- */
-
-#include <cmath>
-#include <cfloat>
-
-#include "ns3/time-series-adaptor.h"
-#include "ns3/object.h"
-#include "ns3/traced-value.h"
-#include "ns3/log.h"
-#include "ns3/simulator.h"
-
-NS_LOG_COMPONENT_DEFINE ("TimeSeriesAdaptor");
-
-namespace ns3 {
-
-NS_OBJECT_ENSURE_REGISTERED (TimeSeriesAdaptor);
-
-TypeId
-TimeSeriesAdaptor::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::TimeSeriesAdaptor")
-    .SetParent<DataCollectionObject> ()
-    .AddConstructor<TimeSeriesAdaptor> ()
-    .AddTraceSource ( "Output",
-                      "The current simulation time versus the current value converted to a double",
-                      MakeTraceSourceAccessor (&TimeSeriesAdaptor::m_output))
-  ;
-  return tid;
-}
-
-TimeSeriesAdaptor::TimeSeriesAdaptor ()
-{
-  NS_LOG_FUNCTION (this);
-}
-
-TimeSeriesAdaptor::~TimeSeriesAdaptor ()
-{
-  NS_LOG_FUNCTION (this);
-}
-
-void
-TimeSeriesAdaptor::TraceSinkDouble (double oldData, double newData)
-{
-  NS_LOG_FUNCTION (this << oldData << newData);
-
-  // Don't do anything if the time series adaptor is not enabled.
-  if (!IsEnabled ())
-    {
-      NS_LOG_DEBUG ("Time series adaptor not enabled");
-      return;
-    }
-
-  // Time stamp the value with the current time in seconds.
-  m_output (Simulator::Now ().GetSeconds (), newData);
-}
-
-void
-TimeSeriesAdaptor::TraceSinkBoolean (bool oldData, bool newData)
-{
-  NS_LOG_FUNCTION (this << oldData << newData);
-
-  // Call the trace sink that actually does something.
-  TraceSinkDouble (oldData, newData);
-}
-
-void
-TimeSeriesAdaptor::TraceSinkUinteger8 (uint8_t oldData, uint8_t newData)
-{
-  NS_LOG_FUNCTION (this << oldData << newData);
-
-  // Call the trace sink that actually does something.
-  TraceSinkDouble (oldData, newData);
-}
-
-void
-TimeSeriesAdaptor::TraceSinkUinteger16 (uint16_t oldData, uint16_t newData)
-{
-  NS_LOG_FUNCTION (this << oldData << newData);
-
-  // Call the trace sink that actually does something.
-  TraceSinkDouble (oldData, newData);
-}
-
-void
-TimeSeriesAdaptor::TraceSinkUinteger32 (uint32_t oldData, uint32_t newData)
-{
-  NS_LOG_FUNCTION (this << oldData << newData);
-
-  // Call the trace sink that actually does something.
-  TraceSinkDouble (oldData, newData);
-}
-
-} // namespace ns3
-
--- a/src/stats/model/time-series-adaptor.h	Tue Mar 03 14:22:06 2015 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,121 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2013 University of Washington
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Mitch Watrous (watrous@u.washington.edu)
- */
-
-#ifndef TIME_SERIES_ADAPTOR_H
-#define TIME_SERIES_ADAPTOR_H
-
-#include "ns3/data-collection-object.h"
-#include "ns3/object.h"
-#include "ns3/type-id.h"
-#include "ns3/traced-value.h"
-
-namespace ns3 {
-
-/**
- * \ingroup aggregator
- *
- * \brief Takes probed values of different types and outputs the
- * current time plus the value with both converted to doubles.
- *
- * The role of the TimeSeriesAdaptor class is that of an adaptor
- * class, to take raw-valued probe data of different types, and output
- * a tuple of two double values.  The first is a timestamp which may
- * be set to different resolutions (e.g. Seconds, Milliseconds, etc.)
- * in the future, but which presently is hardcoded to Seconds.  The second
- * is the conversion of
- * a non-double value to a double value (possibly with loss of precision).
- *
- * It should be noted that time series adaptors convert
- * Simulation Time objects to double values in its output.
- */
-class TimeSeriesAdaptor : public DataCollectionObject
-{
-public:
-  /**
-   * \brief Get the type ID.
-   * \return the object TypeId
-   */
-  static TypeId GetTypeId (void);
-
-  TimeSeriesAdaptor ();
-  virtual ~TimeSeriesAdaptor ();
-
-  /**
-   * \brief Trace sink for receiving data from double valued trace
-   * sources.
-   * \param oldData the original value.
-   * \param newData the new value.
-   *
-   * This method serves as a trace sink to double valued trace
-   * sources.
-   */
-  void TraceSinkDouble (double oldData, double newData);
-
-  /**
-   * \brief Trace sink for receiving data from bool valued trace
-   * sources.
-   * \param oldData the original value.
-   * \param newData the new value.
-   *
-   * This method serves as a trace sink to bool valued trace
-   * sources.
-   */
-  void TraceSinkBoolean (bool oldData, bool newData);
-
-  /**
-   * \brief Trace sink for receiving data from uint8_t valued trace
-   * sources.
-   * \param oldData the original value.
-   * \param newData the new value.
-   *
-   * This method serves as a trace sink to uint8_t valued trace
-   * sources.
-   */
-  void TraceSinkUinteger8 (uint8_t oldData, uint8_t newData);
-
-  /**
-   * \brief Trace sink for receiving data from uint16_t valued trace
-   * sources.
-   * \param oldData the original value.
-   * \param newData the new value.
-   *
-   * This method serves as a trace sink to uint16_t valued trace
-   * sources.
-   */
-  void TraceSinkUinteger16 (uint16_t oldData, uint16_t newData);
-
-  /**
-   * \brief Trace sink for receiving data from uint32_t valued trace
-   * sources.
-   * \param oldData the original value.
-   * \param newData the new value.
-   *
-   * This method serves as a trace sink to uint32_t valued trace
-   * sources.
-   */
-  void TraceSinkUinteger32 (uint32_t oldData, uint32_t newData);
-
-private:
-  TracedCallback<double, double> m_output; //!< output trace
-};
-
-} // namespace ns3
-
-#endif // TIME_SERIES_ADAPTOR_H
--- a/src/stats/wscript	Tue Mar 03 14:22:06 2015 -0500
+++ b/src/stats/wscript	Tue Mar 03 14:41:09 2015 -0500
@@ -31,7 +31,6 @@
         'model/uinteger-8-probe.cc',
         'model/uinteger-16-probe.cc',
         'model/uinteger-32-probe.cc',
-        'model/time-series-adaptor.cc',
         'model/file-aggregator.cc',
         'model/gnuplot-aggregator.cc',
         'model/get-wildcard-matches.cc',
@@ -87,7 +86,6 @@
         'model/uinteger-8-probe.h',
         'model/uinteger-16-probe.h',
         'model/uinteger-32-probe.h',
-        'model/time-series-adaptor.h',
         'model/file-aggregator.h',
         'model/gnuplot-aggregator.h',
         'model/get-wildcard-matches.h',