![]() |
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 #include <RISE/scenario/pathloss/OneSlope.hpp> 00029 #include <RISE/scenario/pathloss/MultiSlope.hpp> 00030 #include <RISE/scenario/Propagation.hpp> 00031 00032 #include <WNS/pyconfig/View.hpp> 00033 #include <WNS/StaticFactoryBroker.hpp> 00034 #include <WNS/PowerRatio.hpp> 00035 00036 #include <limits> 00037 #include <sstream> 00038 00039 using namespace rise::scenario::pathloss; 00040 00041 STATIC_FACTORY_BROKER_REGISTER(MultiSlope, Pathloss, "MultiSlope"); 00042 00043 MultiSlope::MultiSlope(const wns::pyconfig::View& config) 00044 : RangeChecked(config), 00045 outOfMinRange(Propagation::create<Pathloss>(config.getView("outOfMinRange"))), 00046 outOfMaxRange(Propagation::create<Pathloss>(config.getView("outOfMaxRange"))) 00047 { 00048 const wns::Frequency infFreq = std::numeric_limits<wns::Frequency>::infinity(); 00049 const FrequencyRange validFrequencies = FrequencyRange::CreateFrom(config.getView("validFrequencies")); 00050 const FrequencyRange toLowFrequencies = FrequencyRange::FromIncluding(0).ToExcluding(validFrequencies.min()); 00051 const FrequencyRange toHighFrequencies = FrequencyRange::Between(validFrequencies.max()).And(infFreq); 00052 addRange(validFrequencies, true); 00053 if (!toLowFrequencies.isEmpty()) addRange(toLowFrequencies, false); 00054 if (!toHighFrequencies.isEmpty()) addRange(toHighFrequencies, false); 00055 00056 const DistanceRange validDistances = DistanceRange::CreateFrom(config.getView("validDistances")); 00057 00058 const wns::Distance infDist = std::numeric_limits<wns::Frequency>::infinity(); 00059 const DistanceRange toLowDistances = DistanceRange::FromIncluding(0).ToExcluding(validDistances.min()); 00060 const DistanceRange toHighDistances = DistanceRange::Between(validDistances.max()).And(infDist); 00061 if (!toLowDistances.isEmpty()) addRange(toLowDistances, outOfMinRange); 00062 if (!toHighDistances.isEmpty()) addRange(toHighDistances, outOfMaxRange); 00063 00064 00065 const double distNormFactor = config.get<double>("distNormFactor"); 00066 00067 for (int ii=0; ii<config.len("ranges"); ++ii) 00068 { 00069 wns::pyconfig::View rangeConfig = config.get("ranges",ii); 00070 00071 const DistanceRange thisRangesDistances = DistanceRange::CreateFrom(rangeConfig.getView("distRange")); 00072 00073 std::stringstream complaint; 00074 complaint << "The distance range for one of the slopes exceeds the validDistances Range:\n" 00075 << "Valid: " << validDistances.min() << " - " << validDistances.max() << "\n" 00076 << "This: " << thisRangesDistances.min() << " - " << thisRangesDistances.max() << "\n"; 00077 assure(validDistances.contains(thisRangesDistances), complaint.str()); 00078 00079 const wns::Ratio offset = rangeConfig.get<wns::Ratio>("offset"); 00080 const double freqFactor = rangeConfig.get<double>("freqFactor"); 00081 const double distFactor = rangeConfig.get<double>("distFactor"); 00082 00083 Pathloss* thisSlope = new OneSlope<NoHeightFreqAttFormula, NoHeightDistAttFormula>( 00084 config, offset, freqFactor, distFactor, distNormFactor); 00085 00086 addRange(thisRangesDistances, thisSlope); 00087 00088 // The RangeChecked can not delete the slopes when it is destroyed. So 00089 // we have to remember them for later destruction 00090 slopes.push_back(thisSlope); 00091 } 00092 } 00093 00094 MultiSlope::~MultiSlope() 00095 { 00096 while (!slopes.empty()) 00097 { 00098 delete *slopes.begin(); 00099 slopes.pop_front(); 00100 } 00101 } 00102 00103 wns::Ratio 00104 MultiSlope::calculatePathloss(const rise::antenna::Antenna& source, 00105 const rise::antenna::Antenna& target, 00106 const wns::Frequency& frequency, 00107 const wns::Distance& /*distance*/) const 00108 { 00109 return RangeChecked::calculatePathloss(source, target, frequency); 00110 }
1.5.5