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-handover-module.h>
35 #include <ns3/satellite-helper.h>
36 #include <ns3/satellite-topology.h>
37 #include <ns3/scalar-collector.h>
38 #include <ns3/singleton.h>
39 #include <ns3/string.h>
40 #include <ns3/unit-conversion-collector.h>
45 NS_LOG_COMPONENT_DEFINE(
"SatStatsAntennaGainHelper");
50 NS_OBJECT_ENSURE_REGISTERED(SatStatsAntennaGainHelper);
54 m_averagingMode(false)
56 NS_LOG_FUNCTION(
this << satHelper);
61 NS_LOG_FUNCTION(
this);
68 TypeId(
"ns3::SatStatsAntennaGainHelper")
70 .AddAttribute(
"AveragingMode",
71 "If true, all samples will be averaged before passed to aggregator. "
72 "Only affects histogram, PDF, and CDF output types.",
76 MakeBooleanChecker());
83 NS_LOG_FUNCTION(
this << averagingMode);
90 NS_LOG_FUNCTION(
this);
97 std::stringstream ss(identifier);
98 uint32_t identifierNum;
99 if (!(ss >> identifierNum))
101 NS_FATAL_ERROR(
"Cannot convert '" << identifier <<
"' to number");
104 NS_ASSERT_MSG(collector !=
nullptr,
105 "Unable to find collector with identifier " << identifierNum);
111 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
112 NS_ASSERT(c !=
nullptr);
113 c->TraceSinkDouble(0.0, gain);
119 Ptr<UnitConversionCollector> c = collector->GetObject<UnitConversionCollector>();
120 NS_ASSERT(c !=
nullptr);
121 c->TraceSinkDouble(0.0, gain);
133 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
134 NS_ASSERT(c !=
nullptr);
135 c->TraceSinkDouble(0.0, gain);
139 Ptr<DistributionCollector> c = collector->GetObject<DistributionCollector>();
140 NS_ASSERT(c !=
nullptr);
141 c->TraceSinkDouble(0.0, gain);
147 <<
" is not a valid output type for this statistics.");
155 NS_LOG_FUNCTION(
this);
161 <<
" is not a valid output type for this statistics.");
171 "EnableContextPrinting",
179 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
182 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
186 &MultiFileAggregator::Write1d);
201 EnumValue(UnitConversionCollector::TRANSPARENT));
205 &MultiFileAggregator::Write2d);
220 "EnableContextPrinting",
224 Ptr<MultiFileAggregator> fileAggregator =
226 NS_ASSERT(fileAggregator !=
nullptr);
230 DistributionCollector::OutputType_t outputType =
231 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
234 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
238 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
245 MakeCallback(&MultiFileAggregator::Write2d, fileAggregator));
249 MakeCallback(&MultiFileAggregator::AddContextHeading, fileAggregator));
253 MakeCallback(&MultiFileAggregator::EnableContextWarning, fileAggregator));
258 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
261 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
263 Callback<void, double> callback =
269 it->second->TraceConnectWithoutContext(
"Output", callback);
283 DistributionCollector::OutputType_t outputType =
284 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
287 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
291 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
297 &MultiFileAggregator::Write2d);
300 &MultiFileAggregator::AddContextHeading);
303 &MultiFileAggregator::EnableContextWarning);
312 <<
" is not a valid output type for this statistics.");
322 Ptr<MagisterGnuplotAggregator> plotAggregator =
324 NS_ASSERT(plotAggregator !=
nullptr);
326 plotAggregator->SetLegend(
"Time (in seconds)",
"Antenna Gain (in dB)");
327 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
332 EnumValue(UnitConversionCollector::TRANSPARENT));
338 const std::string context = it->second->GetName();
339 plotAggregator->Add2dDataset(context, context);
343 &MagisterGnuplotAggregator::Write2d);
358 Ptr<MagisterGnuplotAggregator> plotAggregator =
360 NS_ASSERT(plotAggregator !=
nullptr);
362 plotAggregator->SetLegend(
"Antenna gain (in dB)",
"Frequency");
363 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
369 DistributionCollector::OutputType_t outputType =
370 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
373 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
377 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
384 MakeCallback(&MagisterGnuplotAggregator::Write2d, plotAggregator));
390 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
393 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
395 Callback<void, double> callback =
401 it->second->TraceConnectWithoutContext(
"Output", callback);
412 Ptr<MagisterGnuplotAggregator> plotAggregator =
414 NS_ASSERT(plotAggregator !=
nullptr);
416 plotAggregator->SetLegend(
"Antenna gain (in dB)",
"Frequency");
417 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
421 DistributionCollector::OutputType_t outputType =
422 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
425 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
429 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
437 const std::string context = it->second->GetName();
438 plotAggregator->Add2dDataset(context, context);
442 &MagisterGnuplotAggregator::Write2d);
449 NS_FATAL_ERROR(
"SatStatsDelayHelper - Invalid output type");
460 NS_LOG_FUNCTION(
this);
462 Callback<void, std::string, double> callback =
465 NodeContainer utUsers = Singleton<SatTopology>::Get()->GetUtNodes();
466 for (NodeContainer::Iterator it = utUsers.Begin(); it != utUsers.End(); ++it)
471 NS_LOG_INFO(
"UT " << *it <<
" does not check for antenna gain, bailing out.");
475 std::ostringstream oss;
478 if (hoModule->TraceConnect(
"AntennaGainTrace", oss.str(), callback))
480 NS_LOG_INFO(
this <<
" successfully connected with UT " << *it);
484 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.
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.