38 const std::string & sPrefix):
40 pPlatformService_{pPlatformService},
43 pFadingAlgorithmForAll_{}
45 fadingModels_.insert(std::make_pair(
"nakagami",
55 std::string sModelDescription{
"Defines the fading model:" 58 std::string sModelsRegex{
"^(none|event"};
60 for(
const auto & entry : fadingModels_)
62 sModelsRegex +=
"|" + entry.second->name();
63 sModelDescription +=
", " + entry.second->name();
67 sModelDescription +=
".";
78 for(
const auto & entry : fadingModels_)
80 entry.second->initialize(registrar);
100 std::map<std::string,std::tuple<ConfigurationUpdate,FadingAlgorithm*>> configurations{};
102 for(
const auto & entry : fadingModels_)
104 std::string sConfigName{sPrefix_ + entry.second->name() +
"."};
105 configurations.insert(std::make_pair(sConfigName,
107 entry.second.get())));
110 for(
const auto & item :
update)
112 if(item.first == sPrefix_ +
"model")
114 std::string sType{item.second[0].asString()};
118 "PHYI %03hu FrameworkPHY::FadingManager::%s: %s = %s",
128 else if(sType ==
"event")
131 pFadingAlgorithmForAll_ =
nullptr;
136 auto iter = fadingModels_.find(sType);
138 if(iter != fadingModels_.end())
140 pFadingAlgorithmForAll_ = iter->second.get();
146 auto pos1 = std::string::npos;
147 auto pos2 = std::string::npos;
149 pos1 = item.first.find_first_of(
'.');
151 if(pos1 != std::string::npos)
153 pos2 = item.first.find_first_of(
'.',pos1+1);
155 if(pos2 != std::string::npos)
157 std::string sKey{item.first.substr(0,pos2+1)};
159 auto iter = configurations.find(sKey);
161 if(iter != configurations.end())
163 std::get<0>(iter->second).push_back(item);
168 if(pos1 == std::string::npos || pos2 == std::string::npos)
170 throw makeException<ConfigurationException>(
"FrameworkPHY::FadingManager Unexpected" 171 " configuration item %s",
177 for(
const auto & entry : configurations)
180 (std::get<1>(entry.second)->*process)(std::get<0>(entry.second));
185 std::pair<double,EMANE::FadingManager::FadingStatus>
188 const std::pair<LocationInfo,bool> & location)
191 double dOutPowerdBm{};
196 dOutPowerdBm = dPowerdBm;
199 else if(pFadingAlgorithmForAll_)
204 dOutPowerdBm = (*pFadingAlgorithmForAll_)(dPowerdBm,
205 location.first.getDistanceMeters());
211 auto iter = TxNEMFadingSelections_.find(txNEMId);
213 if(iter != TxNEMFadingSelections_.end())
220 dOutPowerdBm = (*iter->second)(dPowerdBm,
221 location.first.getDistanceMeters());
229 dOutPowerdBm = dPowerdBm;
241 return {dOutPowerdBm,status};
246 for(
const auto & selection : fadingSelections)
248 switch(selection.getFadingModel())
251 TxNEMFadingSelections_[selection.getNEMId()] =
nullptr;
254 TxNEMFadingSelections_[selection.getNEMId()] = fadingModels_[
"nakagami"].get();
259 "PHYI %03hu FadingManager::%s: unknown fading model" 260 " selection for NEM %hu",
263 selection.getNEMId());
The Registrar interface provides access to all of the emulator registrars.
virtual ConfigurationRegistrar & configurationRegistrar()=0
void registerNonNumeric(const std::string &sName, const ConfigurationProperties &properties=ConfigurationProperties::NONE, const std::initializer_list< T > &values={}, const std::string &sUsage="", std::size_t minOccurs=1, std::size_t maxOccurs=1, const std::string &sRegexPattern={})
void initialize(Registrar ®istrar)
virtual void configure(const ConfigurationUpdate &update)=0
void update(const Events::FadingSelections &fadingSelections)
void configure(const ConfigurationUpdate &update)
std::pair< double, FadingStatus > calculate(NEMId txNEMId, double dPowerdBm, const std::pair< LocationInfo, bool > &location)
std::vector< ConfigurationNameAnyValues > ConfigurationUpdate
FadingManager(NEMId id, PlatformServiceProvider *pPlatformService, const std::string &sPrefix)
virtual void modify(const ConfigurationUpdate &update)=0
std::list< FadingSelection > FadingSelections
#define LOGGER_STANDARD_LOGGING(logger, level, fmt, args...)
void modify(const ConfigurationUpdate &update)