27 #include "ns3/abort.h"    28 #include "ns3/assert.h"    29 #include "ns3/config.h"    31 #include "ns3/get-wildcard-matches.h"    40     m_outputFileNameWithoutExtension (
"gnuplot-helper"),
    41     m_title                          (
"Gnuplot Helper Plot"),
    42     m_xLegend                        (
"X Values"),
    43     m_yLegend                        (
"Y Values"),
    44     m_terminalType                   (
"png")
    53                               const std::string &title,
    54                               const std::string &xLegend,
    55                               const std::string &yLegend,
    56                               const std::string &terminalType)
    59     m_outputFileNameWithoutExtension (outputFileNameWithoutExtension),
    63     m_terminalType                   (terminalType)
    78                               const std::string &title,
    79                               const std::string &xLegend,
    80                               const std::string &yLegend,
    81                               const std::string &terminalType)
    84                         << xLegend << yLegend <<  terminalType);
    90                    " may be destroyed if no references remain.");
   106                           const std::string &path,
   107                           const std::string &probeTraceSource,
   108                           const std::string &title,
   111   NS_LOG_FUNCTION (
this << typeId << path << probeTraceSource << title << keyLocation);
   117   aggregator->SetTitle ( 
m_title + 
" \\n\\nTrace Source Path: " + path);
   123   aggregator->SetKeyLocation (keyLocation);
   125   std::string pathWithoutLastToken;
   126   std::string lastToken;
   129   bool pathHasNoWildcards = path.find (
"*") == std::string::npos;
   133   size_t lastSlash = path.find_last_of (
"/");
   134   if (lastSlash == std::string::npos)
   136       pathWithoutLastToken = path;
   142       pathWithoutLastToken = path.substr (0, lastSlash);
   145       lastToken = path.substr (lastSlash + 1, std::string::npos);
   150   NS_LOG_DEBUG (
"Searching config database for trace source " << path);
   152   uint32_t matchCount = matches.
GetN ();
   153   NS_LOG_DEBUG (
"Found " << matchCount << 
" matches for trace source " << path);
   156   std::string matchIdentifier;
   159   if (matchCount == 1 && pathHasNoWildcards)
   164       matchIdentifier = 
"0";
   171   else if (matchCount > 0)
   174       for (uint32_t i = 0; i < matchCount; i++)
   177           std::ostringstream matchIdentifierStream;
   178           matchIdentifierStream << i;
   179           matchIdentifier = matchIdentifierStream.str ();
   183           std::string wildcardSeparator = 
" ";
   194                                     title + 
"-" + wildcardMatches);
   206                          const std::string &probeName,
   207                          const std::string &path)
   228   probe->SetName (probeName);
   231   probe->ConnectByPath (path);
   237   m_probeMap[probeName] = std::make_pair (probe, typeId);
   248       NS_ABORT_MSG (
"That time series adaptor has already been added");
   255   timeSeriesAdaptor->Enable ();
   265   std::map<std::string, std::pair <Ptr<Probe>, std::string> >::const_iterator mapIterator = 
m_probeMap.find (probeName);
   270       return mapIterator->second.first;
   311                                          const std::string &matchIdentifier,
   312                                          const std::string &path,
   313                                          const std::string &probeTraceSource,
   314                                          const std::string &title)
   316   NS_LOG_FUNCTION (
this << typeId << matchIdentifier << path << probeTraceSource
   325   std::ostringstream probeNameStream;
   327   std::string probeName = probeNameStream.str ();
   330   std::string probeContext = probeName
   331     + 
"/" + matchIdentifier + 
"/" + probeTraceSource;
   345       m_probeMap[probeName].first->TraceConnectWithoutContext
   352       m_probeMap[probeName].first->TraceConnectWithoutContext
   359       m_probeMap[probeName].first->TraceConnectWithoutContext
   366       m_probeMap[probeName].first->TraceConnectWithoutContext
   373       m_probeMap[probeName].first->TraceConnectWithoutContext
   380       m_probeMap[probeName].first->TraceConnectWithoutContext
   387       m_probeMap[probeName].first->TraceConnectWithoutContext
   394       m_probeMap[probeName].first->TraceConnectWithoutContext
   401       m_probeMap[probeName].first->TraceConnectWithoutContext
   408       m_probeMap[probeName].first->TraceConnectWithoutContext
   419   std::string adaptorTraceSource = 
"Output";
   426   aggregator->Add2dDataset (probeContext, title);
 std::string GetMatchedPath(uint32_t i) const
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. 
Smart pointer class similar to boost::intrusive_ptr. 
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message. 
void PlotProbe(const std::string &typeId, const std::string &path, const std::string &probeTraceSource, const std::string &title, enum GnuplotAggregator::KeyLocation keyLocation=GnuplotAggregator::KEY_INSIDE)
void AddTimeSeriesAdaptor(const std::string &adaptorName)
Adds a time series adaptor to be used to make the plot. 
std::map< std::string, std::pair< Ptr< Probe >, std::string > > m_probeMap
Maps probe names to probes. 
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name. 
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory. 
void Write2d(std::string context, double x, double y)
Writes a 2D value to a 2D gnuplot dataset. 
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate. 
std::string m_xLegend
Legend for the x axis. 
GnuplotHelper()
Constructs a gnuplot helper that will create a space separated gnuplot data file named "gnuplot-helpe...
std::size_t GetN(void) const
uint32_t m_plotProbeCount
Number of plot probes that have been created. 
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. 
void ConfigurePlot(const std::string &outputFileNameWithoutExtension, const std::string &title, const std::string &xLegend, const std::string &yLegend, const std::string &terminalType="png")
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId. 
Ptr< GnuplotAggregator > m_aggregator
The aggregator used to make the plots. 
void AddProbe(const std::string &typeId, const std::string &probeName, const std::string &path)
Adds a probe to be used to make the plot. 
std::map< std::string, Ptr< TimeSeriesAdaptor > > m_timeSeriesAdaptorMap
Maps time series adaptor names to time series adaptors. 
void ConstructAggregator()
Constructs the aggregator. 
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void TraceSinkUinteger32(uint32_t oldData, uint32_t newData)
Trace sink for receiving data from uint32_t valued trace sources. 
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object. 
Ptr< GnuplotAggregator > GetAggregator()
Gets the aggregator. 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
void TraceSinkUinteger8(uint8_t oldData, uint8_t newData)
Trace sink for receiving data from uint8_t valued trace sources. 
hold a set of objects which match a specific search string. 
MatchContainer LookupMatches(std::string path)
KeyLocation
The location of the key in the plot. 
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN. 
Ptr< Probe > GetProbe(std::string probeName) const
Gets the specified probe. 
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG. 
void TraceSinkUinteger16(uint16_t oldData, uint16_t newData)
Trace sink for receiving data from uint16_t valued trace sources. 
void TraceSinkDouble(double oldData, double newData)
Trace sink for receiving data from double valued trace sources. 
void TraceSinkBoolean(bool oldData, bool newData)
Trace sink for receiving data from bool valued trace sources. 
std::string m_yLegend
Legend for the y axis. 
std::string GetWildcardMatches(const std::string &configPath, const std::string &matchedPath, const std::string &wildcardSeparator)
Returns the text matches from the matched path for each of the wildcards in the Config path...
std::string m_title
Title string to use for this plot. 
std::string m_terminalType
Terminal type for the plot.