![]() |
User Manual, Developers Guide and API Documentation |
![]() |
00001 /******************************************************************************* 00002 * This file is part of openWNS (open Wireless Network Simulator) 00003 * _____________________________________________________________________________ 00004 * 00005 * Copyright (C) 2004-2007 00006 * Chair of Communication Networks (ComNets) 00007 * Kopernikusstr. 5, D-52074 Aachen, Germany 00008 * phone: ++49-241-80-27910, 00009 * fax: ++49-241-80-22242 00010 * email: info@openwns.org 00011 * www: http://www.openwns.org 00012 * _____________________________________________________________________________ 00013 * 00014 * openWNS is free software; you can redistribute it and/or modify it under the 00015 * terms of the GNU Lesser General Public License version 2 as published by the 00016 * Free Software Foundation; 00017 * 00018 * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY 00019 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 00020 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00021 * details. 00022 * 00023 * You should have received a copy of the GNU Lesser General Public License 00024 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00025 * 00026 ******************************************************************************/ 00027 00028 #ifndef DLL_SERVICES_MANAGEMENT_INTERFERENCECACHE_HPP 00029 #define DLL_SERVICES_MANAGEMENT_INTERFERENCECACHE_HPP 00030 00031 #include <map> 00032 #include <set> 00033 #include <WNS/ldk/ldk.hpp> 00034 #include <WNS/PowerRatio.hpp> 00035 #include <WNS/pyconfig/View.hpp> 00036 #include <WNS/ldk/ManagementServiceInterface.hpp> 00037 #include <WNS/logger/Logger.hpp> 00038 #include <WNS/node/Interface.hpp> 00039 #include <WNS/ldk/PyConfigCreator.hpp> 00040 #include <WNS/service/phy/power/PowerMeasurement.hpp> 00041 00042 namespace wns { 00043 namespace ldk { 00044 class ManagementServiceRegistry; 00045 } 00046 } 00047 00048 namespace dll { namespace services { namespace management { 00049 00050 00052 class InterferenceCache : 00053 public wns::ldk::ManagementService 00054 { 00055 public: 00065 class NotFoundStrategy 00066 { 00067 public: 00068 virtual ~NotFoundStrategy() {} 00069 00073 virtual wns::Power notFoundAverageCarrier() = 0; 00074 00078 virtual wns::Power notFoundAverageInterference() = 0; 00079 00083 virtual wns::Ratio notFoundAveragePathloss() = 0; 00084 00088 virtual wns::Power notFoundDeviationCarrier() = 0; 00089 00093 virtual wns::Power notFoundDeviationInterference() = 0; 00094 }; 00095 00096 typedef wns::ldk::PyConfigCreator<NotFoundStrategy> NotFoundStrategyCreator; 00097 typedef wns::StaticFactory<NotFoundStrategyCreator> NotFoundStrategyFactory; 00098 00099 00103 class ConstantValue : 00104 public NotFoundStrategy 00105 { 00106 public: 00107 00108 ConstantValue( const wns::pyconfig::View& ); 00109 00110 wns::Power notFoundAverageCarrier() 00111 { 00112 return averageCarrier; 00113 } 00114 00115 wns::Power notFoundAverageInterference() 00116 { 00117 return averageInterference; 00118 } 00119 00120 wns::Ratio notFoundAveragePathloss() 00121 { 00122 return averagePathloss; 00123 } 00124 00125 wns::Power notFoundDeviationCarrier() 00126 { 00127 return deviationCarrier; 00128 } 00129 00130 wns::Power notFoundDeviationInterference() 00131 { 00132 return deviationInterference; 00133 } 00134 00135 private: 00136 wns::Power averageCarrier; 00137 wns::Power averageInterference; 00138 wns::Power deviationCarrier; 00139 wns::Power deviationInterference; 00140 wns::Ratio averagePathloss; 00141 }; 00142 00146 class Complain : 00147 public virtual NotFoundStrategy 00148 { 00149 public: 00150 Complain(const wns::pyconfig::View&) 00151 {} 00152 00153 wns::Power notFoundAverageCarrier() 00154 { 00155 throw wns::Exception("Average Carrier value not found"); 00156 return wns::Power(); 00157 } 00158 00159 wns::Power notFoundAverageInterference() 00160 { 00161 throw wns::Exception("Average Interference value not found"); 00162 return wns::Power(); 00163 } 00164 00165 wns::Ratio notFoundAveragePathloss() 00166 { 00167 throw wns::Exception("Average Pathloss value not found"); 00168 return wns::Ratio(); 00169 } 00170 00171 wns::Power notFoundDeviationCarrier() 00172 { 00173 throw wns::Exception("Carrier value deviation not found"); 00174 return wns::Power(); 00175 } 00176 00177 wns::Power notFoundDeviationInterference() 00178 { 00179 throw wns::Exception("Interference calue deviation not found"); 00180 return wns::Power(); 00181 } 00182 }; 00183 00184 00185 InterferenceCache( wns::ldk::ManagementServiceRegistry*, const wns::pyconfig::View& config ); 00186 00187 virtual ~InterferenceCache(){} 00188 00189 virtual void 00190 onMSRCreated(); 00191 00192 enum ValueOrigin { 00193 Local, 00194 Remote 00195 }; 00196 00208 void storeMeasurements( wns::node::Interface* node, wns::service::phy::power::PowerMeasurementPtr rxPowerMeasurement, ValueOrigin origin, int subBand = 0); 00209 00221 void storeCarrier( wns::node::Interface* node, const wns::Power& carrier, ValueOrigin origin, int subBand = 0); 00222 00223 00235 void storeInterference( wns::node::Interface* node, const wns::Power& interference, ValueOrigin origin, int subBand = 0); 00236 00243 void storePathloss( wns::node::Interface* node, const wns::Ratio& pathloss, ValueOrigin origin, int subBand = 0); 00244 00246 wns::Power getAveragedCarrier( wns::node::Interface* node, int subBand = 0 ) const; 00247 00249 wns::Power getAveragedInterference( wns::node::Interface* node, int subBand = 0 ) const; 00250 00252 wns::Ratio getAveragedPathloss( wns::node::Interface* node, int subBand = 0 ) const; 00253 00255 wns::Power getPerSCAveragedCarrier( wns::node::Interface* node) const; 00256 00258 wns::Power getPerSCAveragedInterference( wns::node::Interface* node) const; 00259 00261 wns::Ratio getPerSCAveragedPathloss( wns::node::Interface* node) const; 00265 wns::Ratio 00266 getAverageEmittedInterferencePathloss(wns::node::Interface* node) const; 00267 00269 wns::Power getCarrierDeviation( wns::node::Interface*, int subBand = 0 ) const; 00270 00272 wns::Power getInterferenceDeviation( wns::node::Interface*, int subBand = 0 ) const; 00273 00274 00275 private: 00279 class InterferenceCacheKey : 00280 public std::binary_function<const InterferenceCacheKey, const InterferenceCacheKey, bool> 00281 { 00282 public: 00283 InterferenceCacheKey(wns::node::Interface* node, int subBand) : 00284 node_(node), 00285 subBand_(subBand) 00286 {} 00287 00288 bool operator<(const InterferenceCacheKey& rhs) const 00289 { 00290 if ( node_->getNodeID() == rhs.node_->getNodeID() ) 00291 return subBand_ < rhs.subBand_; 00292 return node_->getNodeID() < rhs.node_->getNodeID(); 00293 } 00294 private: 00295 wns::node::Interface* node_; 00296 int subBand_; 00297 }; 00298 00299 typedef std::map<InterferenceCacheKey, wns::Power> Node2Power; 00300 typedef std::map<InterferenceCacheKey, double> Node2Double; 00301 00302 Node2Power node2CarrierAverage_; 00303 Node2Power node2InterferenceAverage_; 00304 Node2Double node2CarrierSqExp_; 00305 Node2Double node2InterferenceSqExp_; 00306 Node2Double node2pathloss; 00307 double alphaLocal_; 00308 double alphaRemote_; 00309 mutable bool initialized_; 00310 mutable std::list<InterferenceCache*> remoteBSCaches_; 00311 std::map<int, std::set<int> > userSubbands_; 00312 std::string serviceName_; 00313 00314 wns::logger::Logger logger; 00315 00316 std::auto_ptr<NotFoundStrategy> notFoundStrategy; 00317 }; 00318 }}} 00319 #endif // NOT DEFINED DLL_SERVICES_MANAGEMENT_INTERFERENCECACHE_HPP 00320
1.5.5