75 NS_LOG_FUNCTION(
this);
80 <<
" is not a valid output type for this statistics.");
87 <<
" is not a valid identifier type for this statistics.");
96 "EnableContextPrinting",
101 Callback<void, std::string, uint32_t> waveformUsageCallback =
105 Ptr<SatBeamHelper> beamHelper =
GetSatHelper()->GetBeamHelper();
106 NS_ASSERT(beamHelper !=
nullptr);
107 Ptr<SatNcc> ncc = beamHelper->GetNcc();
108 NS_ASSERT(ncc !=
nullptr);
109 std::list<std::pair<uint32_t, uint32_t>> beams = beamHelper->GetBeams();
111 for (std::list<std::pair<uint32_t, uint32_t>>::const_iterator it = beams.begin();
115 std::ostringstream context;
118 Ptr<SatBeamScheduler> s = ncc->GetBeamScheduler(it->first, it->second);
119 NS_ASSERT_MSG(s !=
nullptr,
"Error finding beam " << it->second);
120 const bool ret = s->TraceConnect(
"WaveformTrace", context.str(), waveformUsageCallback);
121 NS_ASSERT_MSG(ret,
"Error connecting to WaveformTrace of beam " << it->second);
122 NS_LOG_INFO(
this <<
" successfully connected" <<
" with beam " << it->second);
151 NS_LOG_FUNCTION(
this << context << waveformId);
154 std::stringstream ss(context);
156 if (!(ss >> identifier))
158 NS_FATAL_ERROR(
"Cannot convert '" << context <<
"' to number");
161 std::map<uint32_t, CollectorMap>::iterator it =
m_collectors.find(waveformId);
165 NS_LOG_INFO(
this <<
" Creating new collectors for waveform ID " << waveformId);
166 CollectorMap collectorMap;
167 collectorMap.SetType(
"ns3::ScalarCollector");
168 collectorMap.SetAttribute(
"InputDataType",
169 EnumValue(ScalarCollector::INPUT_DATA_TYPE_UINTEGER));
170 collectorMap.SetAttribute(
"OutputType", EnumValue(ScalarCollector::OUTPUT_TYPE_SUM));
182 std::ostringstream name;
183 name <<
"0 " << waveformId;
184 collectorMap.SetAttribute(
"Name", StringValue(name.str()));
185 collectorMap.Create(0);
191 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
192 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
194 const uint32_t gwId =
GetGwId(*it);
195 std::ostringstream name;
196 name << gwId <<
" " << waveformId;
197 collectorMap.SetAttribute(
"Name", StringValue(name.str()));
198 collectorMap.Create(gwId);
205 std::list<std::pair<uint32_t, uint32_t>> beams =
207 for (std::list<std::pair<uint32_t, uint32_t>>::const_iterator it = beams.begin();
211 const uint32_t satId = (it->first);
212 const uint32_t beamId = (it->second);
213 std::ostringstream name;
214 name << satId <<
"-" << beamId <<
" " << waveformId;
215 collectorMap.SetAttribute(
"Name", StringValue(name.str()));
224 NS_FATAL_ERROR(
"SatStatsWaveformUsageHelper - Invalid identifier type");
228 collectorMap.ConnectToAggregator(
"Output",
m_aggregator, &MultiFileAggregator::Write1d);
229 NS_LOG_INFO(
this <<
" created " << n <<
" instance(s)" <<
" of "
230 << collectorMap.GetType().GetName() <<
" for "
233 std::pair<std::map<uint32_t, CollectorMap>::iterator,
bool> ret;
234 ret =
m_collectors.insert(std::make_pair(waveformId, collectorMap));
235 NS_ASSERT(ret.second);
243 Ptr<DataCollectionObject> collector = it->second.Get(identifier);
244 NS_ASSERT_MSG(collector !=
nullptr,
"Unable to find collector with identifier " << identifier);
245 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
246 NS_ASSERT(c !=
nullptr);
249 c->TraceSinkUinteger32(0, 1);
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.