User Manual, Developers Guide and API Documentation

InterferenceCache.hpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002  * This file is part of openWNS (open Wireless Network Simulator)
00003  * _____________________________________________________________________________
00004  *
00005  * Copyright (C) 2004-2009
00006  * Chair of Communication Networks (ComNets)
00007  * Kopernikusstr. 5, D-52074 Aachen, Germany
00008  * email: info@openwns.org
00009  * www: http://www.openwns.org
00010  * _____________________________________________________________________________
00011  *
00012  * openWNS is free software; you can redistribute it and/or modify it under the
00013  * terms of the GNU Lesser General Public License version 2 as published by the
00014  * Free Software Foundation;
00015  *
00016  * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY
00017  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
00018  * A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00019  * details.
00020  *
00021  * You should have received a copy of the GNU Lesser General Public License
00022  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00023  *
00024  ******************************************************************************/
00025 #ifndef WIMAC_SERVICES_INTERFERENCECACHE_HPP
00026 #define WIMAC_SERVICES_INTERFERENCECACHE_HPP
00027 
00028 #include <map>
00029 #include <WNS/ldk/ldk.hpp>
00030 #include <WNS/PowerRatio.hpp>
00031 #include <WNS/pyconfig/View.hpp>
00032 #include <WNS/node/Interface.hpp>
00033 #include <WNS/ldk/PyConfigCreator.hpp>
00034 #include <WNS/ldk/ManagementServiceInterface.hpp>
00035 
00036 
00037 #include <WIMAC/Logger.hpp>
00038 
00039 namespace wns {
00040     namespace ldk {
00041         class ManagementServiceRegistry;
00042     }
00043 }
00044 
00045 namespace wimac { namespace service {
00046 
00051         class InterferenceCache :
00052             public wns::ldk::ManagementService
00053         {
00054         public:
00064             class NotFoundStrategy
00065             {
00066             public:
00067                 virtual ~NotFoundStrategy() {}
00068 
00072                 virtual wns::Power notFoundAverageCarrier() = 0;
00073 
00077                 virtual wns::Power notFoundAverageInterference() = 0;
00078 
00082                 virtual wns::Ratio notFoundAveragePathloss() = 0;
00083 
00087                 virtual wns::Power notFoundDeviationCarrier() = 0;
00088 
00092                 virtual wns::Power notFoundDeviationInterference() = 0;
00093             };
00094 
00095             typedef wns::ldk::PyConfigCreator<NotFoundStrategy> NotFoundStrategyCreator;
00096             typedef wns::StaticFactory<NotFoundStrategyCreator> NotFoundStrategyFactory;
00097 
00098 
00102             class ConstantValue :
00103                 public NotFoundStrategy
00104             {
00105             public:
00106 
00107                 ConstantValue( const wns::pyconfig::View& );
00108 
00109                 wns::Power notFoundAverageCarrier()
00110                 {
00111                     return averageCarrier;
00112                 }
00113 
00114                 wns::Power notFoundAverageInterference()
00115                 {
00116                     return averageInterference;
00117                 }
00118 
00119                 wns::Ratio notFoundAveragePathloss()
00120                 {
00121                     return averagePathloss;
00122                 }
00123 
00124                 wns::Power notFoundDeviationCarrier()
00125                 {
00126                     return deviationCarrier;
00127                 }
00128 
00129                 wns::Power notFoundDeviationInterference()
00130                 {
00131                     return deviationInterference;
00132                 }
00133 
00134             private:
00135                 wns::Power averageCarrier;
00136                 wns::Power averageInterference;
00137                 wns::Power deviationCarrier;
00138                 wns::Power deviationInterference;
00139                 wns::Ratio averagePathloss;
00140             };
00141 
00145             class Complain :
00146                 public virtual NotFoundStrategy
00147             {
00148             public:
00149                 Complain(const wns::pyconfig::View&)
00150                 {}
00151 
00152                 wns::Power notFoundAverageCarrier()
00153                 {
00154                     throw wns::Exception("Average Carrier value not found");
00155                     return wns::Power();
00156                 }
00157 
00158                 wns::Power notFoundAverageInterference()
00159                 {
00160                     throw wns::Exception("Average Interference value not found");
00161                     return wns::Power();
00162                 }
00163 
00164                 wns::Ratio notFoundAveragePathloss()
00165                 {
00166                     throw wns::Exception("Average Pathloss value not found");
00167                     return wns::Ratio();
00168                 }
00169 
00170                 wns::Power notFoundDeviationCarrier()
00171                 {
00172                     throw wns::Exception("Carrier value deviation not found");
00173                     return wns::Power();
00174                 }
00175 
00176                 wns::Power notFoundDeviationInterference()
00177                 {
00178                     throw wns::Exception("Interference calue deviation not found");
00179                     return wns::Power();
00180                 }
00181             };
00182 
00183 
00184             InterferenceCache( wns::ldk::ManagementServiceRegistry*, const wns::pyconfig::View& config );
00185 
00186             virtual ~InterferenceCache(){}
00187 
00188             enum ValueOrigin {
00189                 Local,
00190                 Remote
00191             };
00192 
00202             void storeCarrier( wns::node::Interface* node,
00203                                const wns::Power& carrier,
00204                                ValueOrigin origin, int subBand = 0);
00205 
00206 
00217             void storeInterference(
00218                 wns::node::Interface* node,
00219                 const wns::Power& interference,
00220                 ValueOrigin origin, int subBand = 0);
00221 
00226             void
00227             storePathloss(
00228                 wns::node::Interface* node,
00229                 const wns::Ratio& pathloss,
00230                 ValueOrigin origin,
00231                 int subBand = 0);
00232 
00236             wns::Power
00237             getAveragedCarrier(
00238                 wns::node::Interface* node,
00239                 int subBand = 0 ) const;
00240 
00244             wns::Power
00245             getAveragedInterference(
00246                 wns::node::Interface* node,
00247                 int subBand = 0 ) const;
00248 
00252             wns::Ratio
00253             getAveragedPathloss(
00254                 wns::node::Interface* node,
00255                 int subBand = 0 ) const;
00256 
00260             wns::Power
00261             getCarrierDeviation(
00262                 wns::node::Interface*,
00263                 int subBand = 0 ) const;
00264 
00268             wns::Power
00269             getInterferenceDeviation(
00270                 wns::node::Interface*,
00271                 int subBand = 0 ) const;
00272 
00273 
00274         private:
00278             class InterferenceCacheKey :
00279                 public std::binary_function<const InterferenceCacheKey, const InterferenceCacheKey, bool>
00280             {
00281             public:
00282                 InterferenceCacheKey(wns::node::Interface* node, int subBand) :
00283                     node_(node),
00284                     subBand_(subBand)
00285                 {}
00286 
00287                 bool operator<(const InterferenceCacheKey& rhs) const
00288                 {
00289                     if ( node_->getNodeID() == rhs.node_->getNodeID() )
00290                         return subBand_ < rhs.subBand_;
00291                     return node_->getNodeID() < rhs.node_->getNodeID();
00292                 }
00293             private:
00294                 wns::node::Interface* node_;
00295                 int subBand_;
00296             };
00297 
00298             typedef std::map<InterferenceCacheKey, wns::Power> Node2Power;
00299             typedef std::map<InterferenceCacheKey, double> Node2Double;
00300 
00301             Node2Power node2CarrierAverage_;
00302             Node2Power node2InterferenceAverage_;
00303             Node2Double node2CarrierSqExp_;
00304             Node2Double node2InterferenceSqExp_;
00305             Node2Double node2pathloss;
00306             double alphaLocal_;
00307             double alphaRemote_;
00308 
00309             std::auto_ptr<NotFoundStrategy> notFoundStrategy;
00310         };
00311     }
00312 }
00313 #endif
00314 

Generated on Sun May 27 03:31:37 2012 for openWNS by  doxygen 1.5.5