23 #include <ns3/boolean.h>
24 #include <ns3/callback.h>
25 #include <ns3/data-collection-object.h>
26 #include <ns3/distribution-collector.h>
29 #include <ns3/magister-gnuplot-aggregator.h>
30 #include <ns3/multi-file-aggregator.h>
31 #include <ns3/node-container.h>
32 #include <ns3/nstime.h>
33 #include <ns3/probe.h>
34 #include <ns3/satellite-helper.h>
35 #include <ns3/satellite-ut-handover-module.h>
36 #include <ns3/scalar-collector.h>
37 #include <ns3/singleton.h>
38 #include <ns3/string.h>
39 #include <ns3/unit-conversion-collector.h>
43 NS_LOG_COMPONENT_DEFINE(
"SatStatsAntennaGainHelper");
48 NS_OBJECT_ENSURE_REGISTERED(SatStatsAntennaGainHelper);
52 m_averagingMode(false)
54 NS_LOG_FUNCTION(
this << satHelper);
59 NS_LOG_FUNCTION(
this);
66 TypeId(
"ns3::SatStatsAntennaGainHelper")
68 .AddAttribute(
"AveragingMode",
69 "If true, all samples will be averaged before passed to aggregator. "
70 "Only affects histogram, PDF, and CDF output types.",
74 MakeBooleanChecker());
81 NS_LOG_FUNCTION(
this << averagingMode);
88 NS_LOG_FUNCTION(
this);
95 std::stringstream ss(identifier);
96 uint32_t identifierNum;
97 if (!(ss >> identifierNum))
99 NS_FATAL_ERROR(
"Cannot convert '" << identifier <<
"' to number");
102 NS_ASSERT_MSG(collector !=
nullptr,
103 "Unable to find collector with identifier " << identifierNum);
109 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
110 NS_ASSERT(c !=
nullptr);
111 c->TraceSinkDouble(0.0, gain);
117 Ptr<UnitConversionCollector> c = collector->GetObject<UnitConversionCollector>();
118 NS_ASSERT(c !=
nullptr);
119 c->TraceSinkDouble(0.0, gain);
131 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
132 NS_ASSERT(c !=
nullptr);
133 c->TraceSinkDouble(0.0, gain);
137 Ptr<DistributionCollector> c = collector->GetObject<DistributionCollector>();
138 NS_ASSERT(c !=
nullptr);
139 c->TraceSinkDouble(0.0, gain);
145 <<
" is not a valid output type for this statistics.");
153 NS_LOG_FUNCTION(
this);
159 <<
" is not a valid output type for this statistics.");
169 "EnableContextPrinting",
177 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
180 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
184 &MultiFileAggregator::Write1d);
199 EnumValue(UnitConversionCollector::TRANSPARENT));
203 &MultiFileAggregator::Write2d);
218 "EnableContextPrinting",
222 Ptr<MultiFileAggregator> fileAggregator =
224 NS_ASSERT(fileAggregator !=
nullptr);
228 DistributionCollector::OutputType_t outputType =
229 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
232 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
236 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
243 MakeCallback(&MultiFileAggregator::Write2d, fileAggregator));
247 MakeCallback(&MultiFileAggregator::AddContextHeading, fileAggregator));
251 MakeCallback(&MultiFileAggregator::EnableContextWarning, fileAggregator));
256 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
259 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
261 Callback<void, double> callback =
267 it->second->TraceConnectWithoutContext(
"Output", callback);
281 DistributionCollector::OutputType_t outputType =
282 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
285 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
289 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
295 &MultiFileAggregator::Write2d);
298 &MultiFileAggregator::AddContextHeading);
301 &MultiFileAggregator::EnableContextWarning);
310 <<
" is not a valid output type for this statistics.");
320 Ptr<MagisterGnuplotAggregator> plotAggregator =
322 NS_ASSERT(plotAggregator !=
nullptr);
324 plotAggregator->SetLegend(
"Time (in seconds)",
"Antenna Gain (in dB)");
325 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
330 EnumValue(UnitConversionCollector::TRANSPARENT));
336 const std::string context = it->second->GetName();
337 plotAggregator->Add2dDataset(context, context);
341 &MagisterGnuplotAggregator::Write2d);
356 Ptr<MagisterGnuplotAggregator> plotAggregator =
358 NS_ASSERT(plotAggregator !=
nullptr);
360 plotAggregator->SetLegend(
"Antenna gain (in dB)",
"Frequency");
361 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
367 DistributionCollector::OutputType_t outputType =
368 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
371 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
375 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
382 MakeCallback(&MagisterGnuplotAggregator::Write2d, plotAggregator));
388 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
391 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
393 Callback<void, double> callback =
399 it->second->TraceConnectWithoutContext(
"Output", callback);
410 Ptr<MagisterGnuplotAggregator> plotAggregator =
412 NS_ASSERT(plotAggregator !=
nullptr);
414 plotAggregator->SetLegend(
"Antenna gain (in dB)",
"Frequency");
415 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
419 DistributionCollector::OutputType_t outputType =
420 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
423 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
427 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
435 const std::string context = it->second->GetName();
436 plotAggregator->Add2dDataset(context, context);
440 &MagisterGnuplotAggregator::Write2d);
447 NS_FATAL_ERROR(
"SatStatsDelayHelper - Invalid output type");
458 NS_LOG_FUNCTION(
this);
460 Callback<void, std::string, double> callback =
463 NodeContainer utUsers =
GetSatHelper()->GetBeamHelper()->GetUtNodes();
464 for (NodeContainer::Iterator it = utUsers.Begin(); it != utUsers.End(); ++it)
469 NS_LOG_INFO(
"UT " << *it <<
" does not check for antenna gain, bailing out.");
473 std::ostringstream oss;
476 if (hoModule->TraceConnect(
"AntennaGainTrace", oss.str(), callback))
478 NS_LOG_INFO(
this <<
" successfully connected with UT " << *it);
482 NS_LOG_WARN(
this <<
" unable to connect to UT " << *it);
void AntennaGainCallback(std::string identifier, double gain)
Receive inputs from trace sources.
bool m_averagingMode
AveragingMode attribute.
bool GetAveragingMode() const
SatStatsAntennaGainHelper(Ptr< const SatHelper > satHelper)
void InstallProbes()
Set up several probes or other means of listeners and connect them to the collectors.
static TypeId GetTypeId()
inherited from ObjectBase base class
CollectorMap m_terminalCollectors
Maintains a list of collectors created by this helper.
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
void SetAveragingMode(bool averagingMode)
Ptr< DistributionCollector > m_averagingCollector
The final collector utilized in averaged output (histogram, PDF, and CDF).
virtual ~SatStatsAntennaGainHelper()
/ Destructor.
void DoInstall()
Install the probes, collectors, and aggregators necessary to produce the statistics output.
Parent abstract class of all satellite statistics helpers.
Ptr< const SatHelper > GetSatHelper() const
static std::string GetOutputTypeName(OutputType_t outputType)
virtual std::string GetIdentifierHeading(std::string dataLabel) const
virtual std::string GetOutputPath() const
Ptr< DataCollectionObject > CreateAggregator(std::string aggregatorTypeId, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue())
Create the aggregator according to the output type.
virtual std::string GetOutputFileName() const
Compute the path and file name where statistics output should be written to.
uint32_t CreateCollectorPerIdentifier(CollectorMap &collectorMap) const
Create one collector instance for each identifier in the simulation.
OutputType_t GetOutputType() const
uint32_t GetIdentifierForUt(Ptr< Node > utNode) const
std::string GetName() const
virtual std::string GetTimeHeading(std::string dataLabel) const
virtual std::string GetDistributionHeading(std::string dataLabel) const
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.