26 #include "ns3/abort.h"
45 : m_outputFileNameWithoutExtension (outputFileNameWithoutExtension),
46 m_graphicsFileName (m_outputFileNameWithoutExtension +
".png"),
47 m_title (
"Data Values"),
48 m_xLegend (
"X Values"),
49 m_yLegend (
"Y Values"),
51 m_xAndYLegendsSet (false),
52 m_gnuplot (m_graphicsFileName)
62 NS_LOG_WARN (
"Warning: The plot title was not set for the gnuplot aggregator");
66 NS_LOG_WARN (
"Warning: The axis legends were not set for the gnuplot aggregator");
74 std::ofstream plotFile;
75 plotFile.open (plotFileName.c_str ());
76 std::ofstream dataFile;
77 dataFile.open (dataFileName.c_str ());
90 std::ofstream scriptFile;
91 scriptFile.open (scriptFileName.c_str ());
94 scriptFile <<
"#!/bin/sh" << std::endl;
95 scriptFile << std::endl;
96 scriptFile <<
"gnuplot " << plotFileName << std::endl;
109 NS_ABORT_MSG (
"Dataset " << context <<
" has not been added");
129 NS_ABORT_MSG (
"Dataset " << context <<
" has not been added");
149 NS_ABORT_MSG (
"Dataset " << context <<
" has not been added");
166 NS_LOG_FUNCTION (
this << context << x << y << xErrorDelta << yErrorDelta);
170 NS_ABORT_MSG (
"Dataset " << context <<
" has not been added");
228 NS_ABORT_MSG (
"Dataset " << dataset <<
" has already been added");
252 NS_ABORT_MSG (
"Dataset " << dataset <<
" has not been added");
265 NS_ABORT_MSG (
"Dataset " << dataset <<
" has not been added");
288 NS_ABORT_MSG (
"Dataset " << dataset <<
" has not been added");
308 NS_ABORT_MSG (
"Dataset " << dataset <<
" has not been added");
void AppendExtra(const std::string &extra)
#define NS_LOG_FUNCTION(parameters)
void Write2dWithXErrorDelta(std::string context, double x, double y, double errorDelta)
Writes a 2D value to a 2D gnuplot dataset with error bars in the x direction.
std::map< std::string, Gnuplot2dDataset > m_2dDatasetMap
Maps context strings to 2D datasets.
GnuplotAggregator(const std::string &outputFileNameWithoutExtension)
Class to represent a 2D points plot. Set the line or points style using SetStyle() and set points usi...
virtual ~GnuplotAggregator()
std::string m_graphicsFileName
The graphics file name with its extension.
Gnuplot m_gnuplot
Used to create gnuplot files.
void Write2dWithXYErrorDelta(std::string context, double x, double y, double xErrorDelta, double yErrorDelta)
Writes a 2D value to a 2D gnuplot dataset with error bars in the x and y directions.
static void SetDefaultExtra(const std::string &extra)
Change extra formatting style parameters for newly created objects.
void Add2dDataset(const std::string &dataset, const std::string &title)
Adds a 2D dataset to the plot.
static void Set2dDatasetDefaultStyle(enum Gnuplot2dDataset::Style style)
Change default style for all newly created objects.
void Write2d(std::string context, double x, double y)
Writes a 2D value to a 2D gnuplot dataset.
void SetTitle(const std::string &title)
void AddDataset(const GnuplotDataset &dataset)
void Set2dDatasetStyle(const std::string &dataset, enum Gnuplot2dDataset::Style style)
Set the style of plotting to use for this dataset.
void Write2dDatasetEmptyLine(const std::string &dataset)
Add an empty line in the data output sequence.
void SetLegend(const std::string &xLegend, const std::string &yLegend)
void AppendExtra(const std::string &extra)
void Set2dDatasetExtra(const std::string &dataset, const std::string &extra)
Add extra formatting parameters to this dataset.
void SetKeyLocation(enum KeyLocation keyLocation)
Set the location of the key in the plot.
void SetTerminal(const std::string &terminal)
static void Set2dDatasetDefaultExtra(const std::string &extra)
Change extra formatting style parameters for newly created objects.
void SetOutputFilename(const std::string &outputFilename)
bool m_xAndYLegendsSet
Set equal to true after setting the x and y legends.
void SetTitle(const std::string &title)
void SetExtra(const std::string &extra)
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
void GenerateOutput(std::ostream &os)
Writes gnuplot commands and data values to a single output stream.
bool m_enabled
Object's activation state.
static TypeId GetTypeId()
bool m_titleSet
Set equal to true after setting the title.
void SetLegend(const std::string &xLegend, const std::string &yLegend)
std::string m_outputFileNameWithoutExtension
The output file name without any extension.
static void SetDefaultErrorBars(enum ErrorBars errorBars)
static void SetDefaultStyle(enum Style style)
void SetExtra(const std::string &extra)
static void Set2dDatasetDefaultErrorBars(enum Gnuplot2dDataset::ErrorBars errorBars)
Change default errorbars style for all newly created objects.
void Write2dWithYErrorDelta(std::string context, double x, double y, double errorDelta)
Writes a 2D value to a 2D gnuplot dataset with error bars in the y direction.
#define NS_ABORT_MSG(msg)
Abnormal program termination.
NS_LOG_COMPONENT_DEFINE("PacketLossCounter")
KeyLocation
The location of the key in the plot.
void Set2dDatasetErrorBars(const std::string &dataset, enum Gnuplot2dDataset::ErrorBars errorBars)
Set the error bars to use for this dataset.
void SetTerminal(const std::string &terminal)
a unique identifier for an interface.
TypeId SetParent(TypeId tid)