![]() |
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 _RISE_SCENARIO_PATHLOSS_ONESLOPE_HPP 00029 #define _RISE_SCENARIO_PATHLOSS_ONESLOPE_HPP 00030 00031 #include <RISE/stations/base/base.hpp> 00032 #include <RISE/antenna/Antenna.hpp> 00033 #include <RISE/scenario/pathloss/RangeChecked.hpp> 00034 00035 #include <WNS/PowerRatio.hpp> 00036 #include <WNS/Enumerator.hpp> 00037 #include <WNS/isClass.hpp> 00038 00039 namespace rise { namespace scenario { namespace pathloss { 00040 00044 class NoHeightFreqAttFormula 00045 { 00046 public: 00047 static const bool needsHeight = false; 00048 00049 NoHeightFreqAttFormula(const double& freqFactor, 00050 const double&) 00051 : freqFactor(freqFactor) 00052 {} 00053 00054 inline wns::Ratio freqAtt(const wns::Frequency& frequency, 00055 const wns::Distance&) const 00056 { 00057 return wns::Ratio::from_dB(freqFactor * std::log10(frequency)); 00058 } 00059 00060 private: 00061 const double freqFactor; 00062 }; 00063 00067 class DefaultFreqAttFormula 00068 { 00069 public: 00070 static const bool needsHeight = true; 00071 00072 DefaultFreqAttFormula(const double& freqFactor, 00073 const double& heightFactor) 00074 : freqFactor(freqFactor), 00075 heightFactor(heightFactor) 00076 {} 00077 00078 inline wns::Ratio freqAtt(const wns::Frequency& frequency, 00079 wns::Distance baseHeight) const 00080 { 00081 if (baseHeight < 1) baseHeight = 1;; 00082 return wns::Ratio::from_dB(freqFactor * std::log10(frequency) - 00083 heightFactor * std::log10(baseHeight)); 00084 } 00085 00086 private: 00087 const double freqFactor; 00088 const double heightFactor; 00089 }; 00090 00094 class NoHeightDistAttFormula 00095 { 00096 public: 00097 static const bool needsHeight = false; 00098 00099 NoHeightDistAttFormula(const double& distFactor, 00100 const double&) 00101 : distFactor(distFactor) 00102 {} 00103 00104 inline wns::Ratio distAtt(wns::Distance distance, 00105 const wns::Distance&) const 00106 { 00107 if (distance == 0) distance = ++wns::makeEnumerable(distance); 00108 return wns::Ratio::from_dB(distFactor * std::log10(distance)); 00109 } 00110 00111 private: 00112 const double distFactor; 00113 }; 00114 00118 class DefaultDistAttFormula 00119 { 00120 public: 00121 00122 static const bool needsHeight = true; 00123 00124 DefaultDistAttFormula(const double& distFactor, 00125 const double& heightFactor) 00126 : distFactor(distFactor), 00127 heightFactor(heightFactor) 00128 {} 00129 00130 inline wns::Ratio distAtt(wns::Distance distance, 00131 wns::Distance baseHeight) const 00132 { 00133 if (distance == 0) distance = ++wns::makeEnumerable(distance); 00134 if (baseHeight < 1) baseHeight = 1;; 00135 return wns::Ratio::from_dB((distFactor - heightFactor * std::log10(baseHeight)) 00136 * std::log10(distance)); 00137 } 00138 00139 private: 00140 const double distFactor; 00141 const double heightFactor; 00142 }; 00143 00147 class Umts3003DistAttFormula 00148 { 00149 public: 00150 static const bool needsHeight = true; 00151 00152 Umts3003DistAttFormula(const double& distFactor, 00153 const double& heightFactor) 00154 : distFactor(distFactor), 00155 heightFactor(heightFactor) 00156 {} 00157 00158 inline wns::Ratio distAtt(wns::Distance distance, 00159 wns::Distance baseHeight) const 00160 { 00161 if (distance == 0) distance = ++wns::makeEnumerable(distance); 00162 if (baseHeight < 1) baseHeight = 1;; 00163 return wns::Ratio::from_dB((distFactor - heightFactor * baseHeight) 00164 * std::log10(distance)); 00165 } 00166 private: 00167 const double distFactor; 00168 const double heightFactor; 00169 }; 00170 00176 template<class FreqAttFormula = DefaultFreqAttFormula, 00177 class DistAttFormula = DefaultDistAttFormula> 00178 class OneSlope : 00179 public RangeChecked 00180 { 00181 friend class MultiSlope; 00182 protected: 00183 OneSlope(const wns::pyconfig::View& config, 00184 const wns::Ratio& offset, 00185 const double& freqFactor, 00186 const double& distFactor, 00187 const double& distNormFactor, 00188 const double& heightFactor = 0, 00189 const double& distXheightFactor = 0) 00190 : RangeChecked(config), 00191 freqTerm(freqFactor, heightFactor), 00192 distTerm(distFactor, distXheightFactor), 00193 distNormFactor(distNormFactor), 00194 offset(offset) 00195 {} 00196 00197 00198 virtual wns::Ratio calculatePathloss(const antenna::Antenna& source, 00199 const antenna::Antenna& target, 00200 const wns::Frequency& frequency, 00201 const wns::Distance& distance) const 00202 { 00203 wns::Distance baseHeight = 0; 00204 if (FreqAttFormula::needsHeight || DistAttFormula::needsHeight) 00205 baseHeight = fetchBaseHeight(source, target); 00206 return offset + freqTerm.freqAtt(frequency, baseHeight) 00207 + distTerm.distAtt(distance * distNormFactor, baseHeight); 00208 } 00209 00210 private: 00211 FreqAttFormula freqTerm; 00212 DistAttFormula distTerm; 00213 double distNormFactor; 00214 wns::Ratio offset; 00215 00216 static inline wns::Distance fetchBaseHeight(const antenna::Antenna& source, 00217 const antenna::Antenna& target) 00218 { 00219 bool sourceIsBase = wns::isClass<Base>(*(source.getStation())); 00220 const antenna::Antenna& baseAntenna(sourceIsBase ? source : target); 00221 return baseAntenna.getPosition().getZ(); 00222 } 00223 }; 00224 00225 }}} 00226 00227 #endif // NOT defined _RISE_SCENARIO_PATHLOSS_ONESLOPE_HPP
1.5.5