15#include "ns3/nstime.h"
44 .SetGroupName(
"Stats")
63 bool decimalPtSeen =
false;
64 bool exponentSeen =
false;
67 for (
auto it = s.begin(); it != s.end(); it++)
69 if ((*it ==
'.' && decimalPtSeen) || (*it ==
'e' && exponentSeen) ||
70 (*it ==
'-' && it != s.begin() && last !=
'e'))
81 decimalPtSeen =
false;
94 std::ofstream scalarFile;
96 scalarFile.open(fn, std::ios_base::out);
99 scalarFile <<
"run " << dc.
GetRunLabel() << std::endl;
101 scalarFile <<
"attr strategy \"" << dc.
GetStrategyLabel() <<
"\"" << std::endl;
102 scalarFile <<
"attr measurement \"" << dc.
GetInputLabel() <<
"\"" << std::endl;
103 scalarFile <<
"attr description \"" << dc.
GetDescription() <<
"\"" << std::endl;
107 std::pair<std::string, std::string> blob = (*i);
108 scalarFile <<
"attr \"" << blob.first <<
"\" \"" << blob.second <<
"\"" << std::endl;
111 scalarFile << std::endl;
114 scalarFile <<
"scalar . measurement \"" << dc.
GetInputLabel() <<
"\"" << std::endl;
118 std::pair<std::string, std::string> blob = (*i);
121 scalarFile <<
"scalar . \"" << blob.first <<
"\" \"" << blob.second <<
"\""
129 (*i)->Output(callback);
132 scalarFile << std::endl << std::endl;
159 (*m_scalar) <<
"statistic " << context <<
" " << name << std::endl;
160 if (!std::isnan(statSum->
getCount()))
162 (*m_scalar) <<
"field count " << statSum->
getCount() << std::endl;
164 if (!std::isnan(statSum->
getSum()))
166 (*m_scalar) <<
"field sum " << statSum->
getSum() << std::endl;
168 if (!std::isnan(statSum->
getMean()))
170 (*m_scalar) <<
"field mean " << statSum->
getMean() << std::endl;
172 if (!std::isnan(statSum->
getMin()))
174 (*m_scalar) <<
"field min " << statSum->
getMin() << std::endl;
176 if (!std::isnan(statSum->
getMax()))
178 (*m_scalar) <<
"field max " << statSum->
getMax() << std::endl;
182 (*m_scalar) <<
"field sqrsum " << statSum->
getSqrSum() << std::endl;
186 (*m_scalar) <<
"field stddev " << statSum->
getStddev() << std::endl;
205 (*m_scalar) <<
"scalar " << context <<
" " << name <<
" " << val << std::endl;
224 (*m_scalar) <<
"scalar " << context <<
" " << name <<
" " << val << std::endl;
243 (*m_scalar) <<
"scalar " << context <<
" " << name <<
" " << val << std::endl;
262 (*m_scalar) <<
"scalar " << context <<
" " << name <<
" " << val << std::endl;
281 (*m_scalar) <<
"scalar " << context <<
" " << name <<
" " << val.
GetTimeStep() << std::endl;
std::string GetExperimentLabel() const
Return the experiment label.
DataCalculatorList::iterator DataCalculatorBegin()
Returns an iterator to the beginning of the DataCalculator list.
DataCalculatorList::iterator DataCalculatorEnd()
Returns an iterator to the past-the-end of the DataCalculator list.
std::string GetDescription() const
Return the description label.
MetadataList::iterator MetadataBegin()
Returns an iterator to the beginning of the metadata list.
MetadataList::iterator MetadataEnd()
Returns an iterator to the past-the-end of the metadata list.
std::string GetStrategyLabel() const
Return the strategy label.
std::string GetRunLabel() const
Return the runID label.
std::string GetInputLabel() const
Return the input label.
Abstract Data Output Interface class s.
void DoDispose() override
Destructor implementation.
std::string m_filePrefix
File prefix for the DataOutputInterface.
Class to generate OMNeT output.
OmnetOutputCallback(std::ostream *scalar)
Constructor.
void OutputSingleton(std::string context, std::string name, int val) override
Generates a single data output.
void OutputStatistic(std::string context, std::string name, const StatisticalSummary *statSum) override
Generates data statistics.
Outputs data in a format compatible with OMNeT library and framework.
void DoDispose() override
Destructor implementation.
~OmnetDataOutput() override
void Output(DataCollector &dc) override
Outputs information from the provided DataCollector.
static TypeId GetTypeId()
Register this type.
Abstract class for calculating statistical data.
virtual double getMax() const =0
Returns the maximum of the values.
virtual double getMean() const =0
Returns the mean of the (weighted) observations.
virtual double getStddev() const =0
Returns the standard deviation of the (weighted) observations.
virtual long getCount() const =0
Returns the number of observations.
virtual double getMin() const =0
Returns the minimum of the values.
virtual double getSum() const =0
virtual double getSqrSum() const =0
Simulation virtual time values and global simulation resolution.
int64_t GetTimeStep() const
Get the raw time value, in the current resolution unit.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool isNumeric(const std::string &s)