Helper class used to make gnuplot plots. More...
#include "gnuplot-helper.h"
Public Member Functions | |
GnuplotHelper () | |
Constructs a gnuplot helper that will create a space separated gnuplot data file named "gnuplot-helper.dat", a gnuplot control file named "gnuplot-helper.plt", and a shell script to generate the gnuplot named "gnuplot-helper.sh" unless it is later configured otherwise. | |
GnuplotHelper (const std::string &outputFileNameWithoutExtension, const std::string &title, const std::string &xLegend, const std::string &yLegend, const std::string &terminalType="png") | |
virtual | ~GnuplotHelper () |
void | AddTimeSeriesAdaptor (const std::string &adaptorName) |
Adds a time series adaptor to be used to make the plot. | |
void | ConfigurePlot (const std::string &outputFileNameWithoutExtension, const std::string &title, const std::string &xLegend, const std::string &yLegend, const std::string &terminalType="png") |
Ptr< GnuplotAggregator > | GetAggregator () |
Gets the aggregator. | |
Ptr< Probe > | GetProbe (std::string probeName) const |
Gets the specified probe. | |
void | PlotProbe (const std::string &typeId, const std::string &path, const std::string &probeTraceSource, const std::string &title, GnuplotAggregator::KeyLocation keyLocation=GnuplotAggregator::KEY_INSIDE) |
Private Member Functions | |
void | AddProbe (const std::string &typeId, const std::string &probeName, const std::string &path) |
Adds a probe to be used to make the plot. | |
void | ConnectProbeToAggregator (const std::string &typeId, const std::string &matchIdentifier, const std::string &path, const std::string &probeTraceSource, const std::string &title) |
Connects the probe to the aggregator. | |
void | ConstructAggregator () |
Constructs the aggregator. | |
Private Attributes | |
Ptr< GnuplotAggregator > | m_aggregator |
The aggregator used to make the plots. | |
ObjectFactory | m_factory |
Used to create the probes and collectors as they are added. | |
std::string | m_outputFileNameWithoutExtension |
The name of the output file to created without its extension. | |
uint32_t | m_plotProbeCount |
Number of plot probes that have been created. | |
std::map< std::string, std::pair< Ptr< Probe >, std::string > > | m_probeMap |
Maps probe names to probes. | |
std::string | m_terminalType |
Terminal type for the plot. | |
std::map< std::string, Ptr< TimeSeriesAdaptor > > | m_timeSeriesAdaptorMap |
Maps time series adaptor names to time series adaptors. | |
std::string | m_title |
Title string to use for this plot. | |
std::string | m_xLegend |
Legend for the x axis. | |
std::string | m_yLegend |
Legend for the y axis. | |
Helper class used to make gnuplot plots.
Definition at line 29 of file gnuplot-helper.h.
ns3::GnuplotHelper::GnuplotHelper | ( | ) |
Constructs a gnuplot helper that will create a space separated gnuplot data file named "gnuplot-helper.dat", a gnuplot control file named "gnuplot-helper.plt", and a shell script to generate the gnuplot named "gnuplot-helper.sh" unless it is later configured otherwise.
Definition at line 27 of file gnuplot-helper.cc.
References NS_LOG_FUNCTION.
ns3::GnuplotHelper::GnuplotHelper | ( | const std::string & | outputFileNameWithoutExtension, |
const std::string & | title, | ||
const std::string & | xLegend, | ||
const std::string & | yLegend, | ||
const std::string & | terminalType = "png" ) |
outputFileNameWithoutExtension | name of gnuplot related files to write with no extension |
title | plot title string to use for this plot. |
xLegend | the legend for the x horizontal axis. |
yLegend | the legend for the y vertical axis. |
terminalType | terminal type setting string for output. The default terminal type is "png" |
Constructs a gnuplot helper that will create a space separated gnuplot data file named outputFileNameWithoutExtension + ".dat", a gnuplot control file named outputFileNameWithoutExtension + ".plt", and a shell script to generate the gnuplot named outputFileNameWithoutExtension + ".sh".
Definition at line 42 of file gnuplot-helper.cc.
References ConstructAggregator(), and NS_LOG_FUNCTION.
|
virtual |
Definition at line 61 of file gnuplot-helper.cc.
References NS_LOG_FUNCTION.
|
private |
Adds a probe to be used to make the plot.
typeId | the type ID for the probe used when it is created. |
probeName | the probe's name. |
path | Config path to access the probe. |
Definition at line 189 of file gnuplot-helper.cc.
References ns3::ObjectFactory::Create(), ns3::Object::GetObject(), m_factory, m_probeMap, NS_ABORT_MSG, NS_LOG_FUNCTION, and ns3::ObjectFactory::SetTypeId().
Referenced by ConnectProbeToAggregator().
void ns3::GnuplotHelper::AddTimeSeriesAdaptor | ( | const std::string & | adaptorName | ) |
Adds a time series adaptor to be used to make the plot.
adaptorName | the timeSeriesAdaptor's name. |
Definition at line 225 of file gnuplot-helper.cc.
References ns3::CreateObject(), m_timeSeriesAdaptorMap, NS_ABORT_MSG, and NS_LOG_FUNCTION.
Referenced by ConnectProbeToAggregator().
void ns3::GnuplotHelper::ConfigurePlot | ( | const std::string & | outputFileNameWithoutExtension, |
const std::string & | title, | ||
const std::string & | xLegend, | ||
const std::string & | yLegend, | ||
const std::string & | terminalType = "png" ) |
outputFileNameWithoutExtension | name of gnuplot related files to write with no extension |
title | plot title string to use for this plot. |
xLegend | the legend for the x horizontal axis. |
yLegend | the legend for the y vertical axis. |
terminalType | terminal type setting string for output. The default terminal type is "png" |
Configures plot related parameters for this gnuplot helper so that it will create a space separated gnuplot data file named outputFileNameWithoutExtension + ".dat", a gnuplot control file named outputFileNameWithoutExtension + ".plt", and a shell script to generate the gnuplot named outputFileNameWithoutExtension + ".sh".
Definition at line 67 of file gnuplot-helper.cc.
References ConstructAggregator(), m_aggregator, m_outputFileNameWithoutExtension, m_terminalType, m_title, m_xLegend, m_yLegend, NS_LOG_FUNCTION, and NS_LOG_WARN.
|
private |
Connects the probe to the aggregator.
typeId | the type ID for the probe used when it is created. |
matchIdentifier | this string is used to make the probe's context be unique. |
path | Config path to access the probe. |
probeTraceSource | the probe trace source to access. |
title | the title to be associated to this dataset. |
Definition at line 294 of file gnuplot-helper.cc.
References AddProbe(), AddTimeSeriesAdaptor(), GetAggregator(), m_plotProbeCount, m_probeMap, m_timeSeriesAdaptorMap, ns3::MakeCallback(), NS_FATAL_ERROR, NS_LOG_FUNCTION, ns3::TimeSeriesAdaptor::TraceSinkBoolean(), ns3::TimeSeriesAdaptor::TraceSinkDouble(), ns3::TimeSeriesAdaptor::TraceSinkUinteger16(), ns3::TimeSeriesAdaptor::TraceSinkUinteger32(), ns3::TimeSeriesAdaptor::TraceSinkUinteger8(), and ns3::GnuplotAggregator::Write2d().
Referenced by PlotProbe().
|
private |
Constructs the aggregator.
Definition at line 277 of file gnuplot-helper.cc.
References ns3::CreateObject(), m_aggregator, m_outputFileNameWithoutExtension, m_terminalType, m_title, m_xLegend, m_yLegend, and NS_LOG_FUNCTION.
Referenced by GnuplotHelper(), ConfigurePlot(), and GetAggregator().
Ptr< GnuplotAggregator > ns3::GnuplotHelper::GetAggregator | ( | ) |
Gets the aggregator.
This function is non-const because an aggregator may be lazily created by this method.
Definition at line 263 of file gnuplot-helper.cc.
References ConstructAggregator(), m_aggregator, and NS_LOG_FUNCTION.
Referenced by ConnectProbeToAggregator(), and PlotProbe().
Gets the specified probe.
probeName | the probe's name. |
Definition at line 246 of file gnuplot-helper.cc.
References m_probeMap, and NS_ABORT_MSG.
void ns3::GnuplotHelper::PlotProbe | ( | const std::string & | typeId, |
const std::string & | path, | ||
const std::string & | probeTraceSource, | ||
const std::string & | title, | ||
GnuplotAggregator::KeyLocation | keyLocation = GnuplotAggregator::KEY_INSIDE ) |
typeId | the type ID for the probe used when it is created. |
path | Config path for underlying trace source to be probed |
probeTraceSource | the probe trace source to access. |
title | the title to be associated to this dataset |
keyLocation | the location of the key in the plot. |
Plots a dataset generated by hooking the ns-3 trace source with a probe, and then plot the values from the probeTraceSource. The dataset will have the provided title, and will consist of the 'newValue' at each timestamp.
This method will create one or more probes according to the TypeId provided, connect the probe(s) to the trace source specified by the config path, and hook the probeTraceSource(s) to the downstream aggregator.
If the config path has more than one match in the system (e.g. there is a wildcard), then one dataset for each match will be plotted. The dataset titles will be suffixed with the matched characters for each of the wildcards in the config path, separated by spaces. For example, if the proposed dataset title is the string "bytes", and there are two wildcards in the path, then dataset titles like "bytes-0 0" or "bytes-12 9" will be possible as labels for the datasets that are plotted.
Definition at line 95 of file gnuplot-helper.cc.
References ConnectProbeToAggregator(), GetAggregator(), ns3::Config::MatchContainer::GetMatchedPath(), ns3::Config::MatchContainer::GetN(), ns3::GetWildcardMatches(), ns3::Gnuplot2dDataset::LINES_POINTS, ns3::Config::LookupMatches(), m_title, NS_FATAL_ERROR, NS_LOG_DEBUG, and NS_LOG_FUNCTION.
|
private |
The aggregator used to make the plots.
Definition at line 176 of file gnuplot-helper.h.
Referenced by ConfigurePlot(), ConstructAggregator(), and GetAggregator().
|
private |
Used to create the probes and collectors as they are added.
Definition at line 173 of file gnuplot-helper.h.
Referenced by AddProbe().
|
private |
The name of the output file to created without its extension.
Definition at line 188 of file gnuplot-helper.h.
Referenced by ConfigurePlot(), and ConstructAggregator().
|
private |
Number of plot probes that have been created.
Definition at line 185 of file gnuplot-helper.h.
Referenced by ConnectProbeToAggregator().
Maps probe names to probes.
Definition at line 179 of file gnuplot-helper.h.
Referenced by AddProbe(), ConnectProbeToAggregator(), and GetProbe().
|
private |
Terminal type for the plot.
Definition at line 200 of file gnuplot-helper.h.
Referenced by ConfigurePlot(), and ConstructAggregator().
|
private |
Maps time series adaptor names to time series adaptors.
Definition at line 182 of file gnuplot-helper.h.
Referenced by AddTimeSeriesAdaptor(), and ConnectProbeToAggregator().
|
private |
Title string to use for this plot.
Definition at line 191 of file gnuplot-helper.h.
Referenced by ConfigurePlot(), ConstructAggregator(), and PlotProbe().
|
private |
Legend for the x axis.
Definition at line 194 of file gnuplot-helper.h.
Referenced by ConfigurePlot(), and ConstructAggregator().
|
private |
Legend for the y axis.
Definition at line 197 of file gnuplot-helper.h.
Referenced by ConfigurePlot(), and ConstructAggregator().