54 if(moduleType ==
"nem")
62 InputArguments::const_iterator iterArg = args.begin();
65 for(; iterArg != args.end(); ++iterArg)
76 while(posEnd != std::string::npos)
78 posEnd = iterArg->find_first_of(
",",posStart);
80 params.push_back( iterArg->substr(posStart, posEnd - posStart));
82 posStart = posEnd + 1;
86 if(params.size() != 7)
89 "<dstModuleID>,<latency seconds>,<jitter seconds>, " 90 "<loss>,<duplicates>,<unicast bps>,<broadcast bps>");
94 NEMId srcNEM{moduleId};
96 float fLatencySeconds{};
97 float fJitterSeconds{};
98 float fProbabilityLoss{};
99 float fProbabilityDuplicate{};
100 std::uint64_t u64UnicastBitRate{};
101 std::uint64_t u64BroadcastBitRate{};
104 for(
size_t i = 0; i < params.size(); ++i)
113 size_t pos = params[i].find(
':');
115 if(pos != std::string::npos)
117 if(params[i].substr(0,pos) ==
"nem")
124 std::stringstream sstream;
125 throw FormatException(
"LoaderCommEffect only supports 'nem' module type");
162 std::stringstream sstream;
163 sstream<<
"LoaderCommEffect loader: Parameter conversion error. "<<exp.
what()<<std::ends;
170 std::chrono::duration_cast<Microseconds>(
DoubleSeconds{fJitterSeconds}),
172 fProbabilityDuplicate,
174 u64BroadcastBitRate};
177 loadCommEffectCache(dstNEM,commEffect,commeffectEntryCache_);
180 loadCommEffectCache(dstNEM,commEffect,commeffectDeltaEntryCache_);
191 CommEffectEntryCache * pCache = 0;
197 pCache = &commeffectDeltaEntryCache_;
204 pCache = &commeffectEntryCache_;
209 CommEffectEntryCache::iterator iter = pCache->begin();
211 for(;iter != pCache->end(); ++iter)
213 CommEffectEntryMap::iterator iterEntry = iter->second.begin();
215 for(; iterEntry != iter->second.end(); ++iterEntry)
217 commEffects.push_back(iterEntry->second);
220 if(!commEffects.empty())
222 eventInfoList.push_back({iter->first,
231 commeffectDeltaEntryCache_.clear();
233 return eventInfoList;
236 void EMANE::Generators::EEL::LoaderCommEffect::loadCommEffectCache(
NEMId dstNEM,
238 CommEffectEntryCache & cache)
240 CommEffectEntryCache::iterator iter = cache.end();
242 if((iter = cache.find(dstNEM)) != cache.end())
244 std::pair<CommEffectEntryMap::iterator,bool> ret =
245 iter->second.insert(std::make_pair(commEffect.
getNEMId(),commEffect));
249 ret.first->second = commEffect;
254 CommEffectEntryMap entryMap;
255 entryMap.insert(std::make_pair(commEffect.
getNEMId(),commEffect));
256 cache.insert(std::make_pair(dstNEM,entryMap));
void load(const ModuleType &modelType, const ModuleId &moduleId, const EventType &eventType, const InputArguments &args) override
std::vector< std::string > InputArguments
#define DECLARE_EEL_LOADER_PLUGIN(X)
Parameter conversion exception class.
std::uint16_t toUINT16(std::uint16_t u16Min=std::numeric_limits< std::uint16_t >::min(), std::uint16_t u16Max=std::numeric_limits< std::uint16_t >::max()) const
float toFloat(float fMin=std::numeric_limits< float >::lowest(), float fMax=std::numeric_limits< float >::max()) const
std::uint64_t toUINT64(std::uint64_t u64Min=std::numeric_limits< std::uint64_t >::min(), std::uint64_t u64Max=std::numeric_limits< std::uint64_t >::max()) const
const char * what() const
std::list< CommEffect > CommEffects
std::chrono::microseconds Microseconds
std::chrono::duration< double > DoubleSeconds
A CommEffect entry holds the NEM Id of a transmitter and the link effects to apply to received transm...
EventInfoList getEvents(EventPublishMode mode) override
std::list< EventInfo > EventInfoList
Parameter conversion class with range checks.