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. More... | |
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. More... | |
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. More... | |
Ptr< Probe > | GetProbe (std::string probeName) const |
Gets the specified probe. More... | |
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. More... | |
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. More... | |
void | ConstructAggregator () |
Constructs the aggregator. More... | |
Private Attributes | |
Ptr< GnuplotAggregator > | m_aggregator |
The aggregator used to make the plots. More... | |
ObjectFactory | m_factory |
Used to create the probes and collectors as they are added. More... | |
std::string | m_outputFileNameWithoutExtension |
The name of the output file to created without its extension. More... | |
uint32_t | m_plotProbeCount |
Number of plot probes that have been created. More... | |
std::map< std::string, std::pair< Ptr< Probe >, std::string > > | m_probeMap |
Maps probe names to probes. More... | |
std::string | m_terminalType |
Terminal type for the plot. More... | |
std::map< std::string, Ptr< TimeSeriesAdaptor > > | m_timeSeriesAdaptorMap |
Maps time series adaptor names to time series adaptors. More... | |
std::string | m_title |
Title string to use for this plot. More... | |
std::string | m_xLegend |
Legend for the x axis. More... | |
std::string | m_yLegend |
Legend for the y axis. More... | |
Helper class used to make gnuplot plots.
Definition at line 40 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 38 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 53 of file gnuplot-helper.cc.
References ConstructAggregator(), and NS_LOG_FUNCTION.
|
virtual |
Definition at line 72 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 200 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 236 of file gnuplot-helper.cc.
References 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 78 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 305 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 288 of file gnuplot-helper.cc.
References 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 274 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 257 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 106 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 187 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 184 of file gnuplot-helper.h.
Referenced by AddProbe().
|
private |
The name of the output file to created without its extension.
Definition at line 199 of file gnuplot-helper.h.
Referenced by ConfigurePlot(), and ConstructAggregator().
|
private |
Number of plot probes that have been created.
Definition at line 196 of file gnuplot-helper.h.
Referenced by ConnectProbeToAggregator().
Maps probe names to probes.
Definition at line 190 of file gnuplot-helper.h.
Referenced by AddProbe(), ConnectProbeToAggregator(), and GetProbe().
|
private |
Terminal type for the plot.
Definition at line 211 of file gnuplot-helper.h.
Referenced by ConfigurePlot(), and ConstructAggregator().
|
private |
Maps time series adaptor names to time series adaptors.
Definition at line 193 of file gnuplot-helper.h.
Referenced by AddTimeSeriesAdaptor(), and ConnectProbeToAggregator().
|
private |
Title string to use for this plot.
Definition at line 202 of file gnuplot-helper.h.
Referenced by ConfigurePlot(), ConstructAggregator(), and PlotProbe().
|
private |
Legend for the x axis.
Definition at line 205 of file gnuplot-helper.h.
Referenced by ConfigurePlot(), and ConstructAggregator().
|
private |
Legend for the y axis.
Definition at line 208 of file gnuplot-helper.h.
Referenced by ConfigurePlot(), and ConstructAggregator().