Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(105)

Unified Diff: src/stats/model/time-series-collector.h

Issue 245260043: DCF collectors
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/stats/model/time-series-collector.h
===================================================================
new file mode 100644
--- /dev/null
+++ b/src/stats/model/time-series-collector.h
@@ -0,0 +1,109 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * 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
+ * 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: Li Li (ll024@bucknell.edu)
+ */
+
+#ifndef TIME_SERIES_COLLECTOR_H
+#define TIME_SERIES_COLLECTOR_H
+
+#include "ns3/object.h"
+#include "ns3/collector.h"
+#include "ns3/event-id.h"
+#include "ns3/type-id.h"
+#include "ns3/traced-value.h"
+#include "ns3/nstime.h"
+
+namespace ns3 {
+
+/**
+ * \ingroup collectors
+ * \brief TimeSeriesCollector class used to collect a single trace of
+ * double value and output the data to downstream objects every certain
+ * amount of time
+ */
+class TimeSeriesCollector : public Collector
+{
+public:
+ /**
+ * \brief Get the type ID
+ * \return the object TypeId
+ */
+ static TypeId GetTypeId (void);
+
+ /**
+ * \brief Constructs a TimeSeriesCollector object
+ */
+ TimeSeriesCollector ();
+
+ virtual ~TimeSeriesCollector ();
+
+ /**
+ * \brief Collects the double values produced by the upstream probes
+ *
+ * \param oldValue previous value produced by a Probe
+ * \param newValue new value produced by a Probe
+ */
+ void TraceSinkDouble (double oldValue, double newValue);
+
+ /**
+ * \brief Sets the time period to report data. Cancels any pending
+ * report if one is scheduled.
+ *
+ * \param period a variable of type Time to indicate the period
+ */
+ void SetPeriod (Time period);
+
+ /**
+ * \brief Gets the time period to report data
+ *
+ * \return the time period to report data
+ */
+ Time GetPeriod () const;
+
+ /**
+ * \brief Override DataCollectionObject::Enable() to schedule the very
+ * first event whenever the collector is enabled. This method will
+ * also cancel any previously scheduled event if one exists.
+ *
+ * \sa ns3::DataCollectionObject::Enable
+ */
+ void Enable (void);
+private:
+ // the output data trace source
+ TracedCallback<double, double> m_output;
+
+ /**
+ * \brief Reports data to downstream objects
+ */
+ void ReportData (void);
+
+ // a double value to keep track of the double value
+ // received by the trace sink
+ double m_doubleValue;
+
+ Time m_period;
+ EventId m_reportEventId;
+ bool m_hasReportBeenScheduled;
+ void PeriodChanged (void);
+
+};
+
+
+} // namespace ns3
+
+#endif // TIME_SERIES_COLLECTOR_H

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b