User Manual, Developers Guide and API Documentation

PathlossChooser.cpp

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-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/PathlossChooser.hpp>
00029 #include <RISE/scenario/pathloss/defs.hpp>
00030 #include <RISE/antenna/Antenna.hpp>
00031 #include <RISE/scenario/Propagation.hpp>
00032 #include <WNS/distribution/Uniform.hpp>
00033 #include <WNS/StaticFactoryBroker.hpp>
00034 #include <WNS/Types.hpp>
00035 #include <WNS/Assure.hpp>
00036 
00037 #include <WNS/probe/bus/ProbeBus.hpp>
00038 #include <WNS/probe/bus/ProbeBusRegistry.hpp>
00039 #include <WNS/probe/bus/ContextCollector.hpp>
00040 
00041 
00042 using namespace rise::scenario::pathloss;
00043 
00044 STATIC_FACTORY_BROKER_REGISTER(PathlossChooser, Pathloss, "PathlossChooser");
00045 
00046 PathlossChooser::PathlossChooser(const wns::pyconfig::View& config)
00047     : DistanceDependent(config),
00048     plLOS(Propagation::create<Pathloss>(config.getView("plLOS"))),
00049     plNLOS(Propagation::create<Pathloss>(config.getView("plNLOS"))),
00050     notYetDecided(true),
00051     decisionDistribution(NULL),
00052     plModelName(config.get<std::string>("plModelName")),
00053     logger(config.get("logger")),
00054     losProbability("PathlossChooser.losProbability"),
00055     losDecision("PathlossChooser.losDecision"),
00056     usedDistance(-1)
00057     {
00058         MESSAGE_SINGLE(NORMAL, logger, "new PathlossChooser model created ");
00059     }
00060 
00061 wns::Ratio PathlossChooser::calculatePathloss(const antenna::Antenna& source,
00062                          const antenna::Antenna& target,
00063                          const wns::Frequency& frequency,
00064                          const wns::Distance& distance) const
00065 {
00066     // choosing pathloss only once at the beginning when distance between stations defined
00067     if (notYetDecided)
00068     {
00069         pathLossModelLos = Distribution(distance);
00070         notYetDecided = false;
00071     }
00072     
00073 //     if(usedDistance!=distance)
00074 //         {
00075 //         usedDistance = distance;
00076 //      pathLossModelLos = Distribution(distance);
00077 //         }
00078     
00079     if (pathLossModelLos)
00080         {
00081             losDecision.put(1);
00082             MESSAGE_SINGLE(NORMAL, logger, "Using LOS pathloss model for scenario: "<<plModelName<<",source:"<<source.getPosition()<<",target:"<<target.getPosition()<<",frequency:"<<frequency);
00083             return plLOS->getPathloss(source, target, frequency);
00084         }
00085     else
00086         {
00087             losDecision.put(0);
00088             MESSAGE_SINGLE(NORMAL, logger, "Using NLOS pathloss model for scenario: "<<plModelName<<",source:"<<source.getPosition()<<",target:"<<target.getPosition()<<",frequency:"<<frequency);
00089             return plNLOS->getPathloss(source, target, frequency);
00090         }
00091    // }
00092     
00093 }
00094 
00095 
00096 bool PathlossChooser::Distribution(const wns::Distance& distance) const
00097 {
00098     double p;
00099     
00100     decisionDistribution = new wns::distribution::Uniform(0.0, 1.0);
00101     //decisionDistribution = new wns::distribution::Uniform(0.4, 0.7);
00102     double random = (*decisionDistribution)();
00103     
00104     if(plModelName == "UrbanMicro")
00105     {
00106         p=std::min(18 / distance,1.0) * (1 - exp(-distance / 36))+exp(-distance / 36);
00107     }
00108     else if(plModelName == "UrbanMacro")
00109     {
00110         p=std::min(18 / distance,1.0) * (1 - exp(-distance / 63))+exp(-distance / 63);
00111     }
00112     else if(plModelName == "SuburbanMacro")
00113     {
00114         if(distance <= 10) p=1;
00115         else  p=exp(-(distance - 10) / 200);
00116     }
00117     else if(plModelName == "RuralMacro")
00118     {
00119         if(distance <= 10) p=1;
00120         else p=exp(-(distance - 10) / 1000);
00121     }
00122     MESSAGE_SINGLE(NORMAL, logger, "distance:"<<distance<<",random number:"<<random<<",probability:"<<p);
00123     losProbability.put(p);
00124     if(random > p)
00125             return false;
00126         else 
00127             return true;
00128     
00129 };

Generated on Fri May 25 03:31:58 2012 for openWNS by  doxygen 1.5.5