23 #include "ns3/abort.h"
25 #include "ns3/simulator.h"
27 NS_LOG_COMPONENT_DEFINE(
"SatOutputFileStreamDoubleContainer");
35 static TypeId tid = TypeId(
"ns3::SatOutputFileStreamDoubleContainer")
37 .AddConstructor<SatOutputFileStreamDoubleContainer>();
42 std::ios::openmode filemode,
44 : m_outputFileStreamWrapper(),
49 m_valuesInRow(valuesInRow),
51 m_figureUnitConversionType(RAW),
52 m_style(Gnuplot2dDataset::LINES)
58 NS_FATAL_ERROR(
"SatOutputFileStreamDoubleContainer::SatOutputFileStreamDoubleContainer - "
59 "No values in the row");
64 : m_outputFileStreamWrapper(),
71 m_figureUnitConversionType(),
74 NS_LOG_FUNCTION(
this);
75 NS_FATAL_ERROR(
"SatOutputFileStreamDoubleContainer::SatOutputFileStreamDoubleContainer - "
76 "Constructor not in use");
81 NS_LOG_FUNCTION(
this);
89 NS_LOG_FUNCTION(
this);
98 NS_LOG_FUNCTION(
this);
123 NS_ABORT_MSG(
"Output stream is not valid for writing.");
137 NS_LOG_FUNCTION(
this);
141 plot.AddDataset(dataset);
143 std::string plotFileName =
m_fileName +
".plt";
144 std::ofstream plotFile(plotFileName.c_str());
145 plot.GenerateOutput(plotFile);
148 std::string conversionCommand =
"gnuplot " +
m_fileName +
".plt";
150 int result = system(conversionCommand.c_str());
154 std::cout <<
"Unable to open shell process for Gnuplot file conversion for " <<
m_fileName
155 <<
", conversion not done!" << std::endl;
162 NS_LOG_FUNCTION(
this);
166 NS_FATAL_ERROR(
"SatOutputFileStreamDoubleContainer::AddToContainer - Invalid vector size");
175 NS_LOG_FUNCTION(
this);
184 NS_LOG_FUNCTION(
this);
193 NS_LOG_FUNCTION(
this);
209 NS_LOG_FUNCTION(
this);
229 NS_LOG_FUNCTION(
this);
231 Gnuplot2dDataset ret;
247 NS_ABORT_MSG(
"SatOutputFileStreamDoubleContainer::GetGnuplotDataset - Figure output "
248 "not implemented for "
259 NS_LOG_FUNCTION(
this << value);
269 return 10.0 * std::log10(value);
271 return 10.0 * std::log10(std::numeric_limits<double>::min());
276 return 20.0 * std::log10(value);
278 return 20.0 * std::log10(std::numeric_limits<double>::min());
281 NS_ABORT_MSG(
"SatOutputFileStreamDoubleContainer::ConvertValue - Invalid conversion type.");
291 NS_LOG_FUNCTION(
this);
295 ret.SetTerminal(
"png");
298 ret.AppendExtra(
"set grid xtics mxtics ytics");
307 std::string keyPosition,
309 Gnuplot2dDataset::Style style)
311 NS_LOG_FUNCTION(
this);
std::string m_title
Figure title.
double ConvertValue(double value)
Function for converting the container data samples.
void OpenStream()
Function for opening the output file stream.
std::vector< std::vector< double > > m_container
Container for value rows.
void Reset()
Function for resetting the variables.
SatOutputFileStreamWrapper * m_outputFileStreamWrapper
Pointer to output file stream wrapper.
bool m_printFigure
Enable / disable printing of container contents into a figure.
Gnuplot2dDataset GetGnuplotDataset()
Function for creating Gnuplot datasets.
void DoDispose()
Do needed dispose actions.
uint32_t m_valuesInRow
Number of values in a row.
std::string m_keyPosition
Figure legend position.
void ClearContainer()
Function for clearing the container.
SatOutputFileStreamDoubleContainer()
Constructor.
Gnuplot2dDataset::Style m_style
2D dataset figure style
FigureUnitConversion_t m_figureUnitConversionType
Describes which unit conversion should be used with the figure.
std::ios::openmode m_fileMode
File mode.
void AddToContainer(std::vector< double > newItem)
Function for adding the values to container.
void PrintFigure()
Function for printing the container contents into a figure.
void ResetStream()
Function for resetting the stream.
std::ofstream * m_outputFileStream
Pointer to output file stream.
std::string m_legendY
Figure Y-axis title.
std::string m_legendX
Figure X-axis title.
std::string m_fileName
File name.
void EnableFigureOutput(std::string title, std::string legendY, std::string legendX, std::string keyPosition, FigureUnitConversion_t figureUnitConversionType, Gnuplot2dDataset::Style style)
Function for enabling the figure output.
Gnuplot GetGnuplot()
Function for creating Gnuplots.
~SatOutputFileStreamDoubleContainer()
Destructor.
void WriteContainerToFile()
Function for writing the container contents to file.
static TypeId GetTypeId(void)
NS-3 function for type id.
A class encapsulating an STL output stream.
std::ofstream * GetStream(void)
Return a pointer to an ofstream previously set in the wrapper.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.