23 #include "ns3/abort.h"
25 #include "ns3/simulator.h"
27 NS_LOG_COMPONENT_DEFINE(
"SatOutputFileStreamLongDoubleContainer");
35 static TypeId tid = TypeId(
"ns3::SatOutputFileStreamLongDoubleContainer")
37 .AddConstructor<SatOutputFileStreamLongDoubleContainer>();
43 std::ios::openmode filemode,
45 : m_outputFileStreamWrapper(),
50 m_valuesInRow(valuesInRow),
52 m_figureUnitConversionType(RAW)
58 NS_FATAL_ERROR(
"SatOutputFileStreamLongDoubleContainer::"
59 "SatOutputFileStreamLongDoubleContainer - No values in the row");
64 : m_outputFileStreamWrapper(),
71 m_figureUnitConversionType()
73 NS_LOG_FUNCTION(
this);
74 NS_FATAL_ERROR(
"SatOutputFileStreamLongDoubleContainer::SatOutputFileStreamLongDoubleContainer "
75 "- Constructor not in use");
80 NS_LOG_FUNCTION(
this);
88 NS_LOG_FUNCTION(
this);
97 NS_LOG_FUNCTION(
this);
122 NS_ABORT_MSG(
"Output stream is not valid for writing.");
136 NS_LOG_FUNCTION(
this);
140 plot.AddDataset(dataset);
142 std::string plotFileName =
m_fileName +
".plt";
143 std::ofstream plotFile(plotFileName.c_str());
144 plot.GenerateOutput(plotFile);
147 std::string conversionCommand =
"gnuplot " +
m_fileName +
".plt";
149 int result = system(conversionCommand.c_str());
153 std::cout <<
"Unable to open shell process for Gnuplot file conversion for " <<
m_fileName
154 <<
", conversion not done!" << std::endl;
161 NS_LOG_FUNCTION(
this);
166 "SatOutputFileStreamLongDoubleContainer::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;
233 ret.SetStyle(Gnuplot2dDataset::LINES);
247 NS_ABORT_MSG(
"SatOutputFileStreamLongDoubleContainer::GetGnuplotDataset - Figure "
248 "output 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<long double>::min());
276 return 20.0 * std::log10(value);
278 return 20.0 * std::log10(std::numeric_limits<long double>::min());
282 "SatOutputFileStreamLongDoubleContainer::ConvertValue - Invalid conversion type.");
292 NS_LOG_FUNCTION(
this);
296 ret.SetTerminal(
"png");
299 ret.AppendExtra(
"set grid xtics mxtics ytics");
308 std::string keyPosition,
311 NS_LOG_FUNCTION(
this);
std::string m_fileName
File name.
uint32_t m_valuesInRow
Number of values in a row.
void AddToContainer(std::vector< long double > newItem)
Function for adding the values to container.
Gnuplot GetGnuplot()
Function for creating Gnuplots.
void DoDispose()
Do needed dispose actions.
~SatOutputFileStreamLongDoubleContainer()
Destructor.
void Reset()
Function for resetting the variables.
std::string m_title
Figure title.
void PrintFigure()
Function for printing the container contents into a figure.
std::vector< std::vector< long double > > m_container
Container for value rows.
bool m_printFigure
Enable / disable printing of container contents into a figure.
SatOutputFileStreamLongDoubleContainer()
Constructor.
void WriteContainerToFile()
Function for writing the container contents to file.
std::ofstream * m_outputFileStream
Pointer to output file stream.
FigureUnitConversion_t m_figureUnitConversionType
Describes which unit conversion should be used with the figure.
std::string m_legendY
Figure Y-axis title.
void EnableFigureOutput(std::string title, std::string legendY, std::string legendX, std::string keyPosition, FigureUnitConversion_t figureUnitConversionType)
Function for enabling the figure output.
SatOutputFileStreamWrapper * m_outputFileStreamWrapper
Pointer to output file stream wrapper.
long double ConvertValue(long double value)
Function for converting the container data samples.
void OpenStream()
Function for opening the output file stream.
std::string m_keyPosition
Figure legend position.
std::ios::openmode m_fileMode
File mode.
static TypeId GetTypeId(void)
NS-3 function for type id.
std::string m_legendX
Figure X-axis title.
void ClearContainer()
Function for clearing the container.
void ResetStream()
Function for resetting the stream.
Gnuplot2dDataset GetGnuplotDataset()
Function for creating Gnuplot datasets.
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.