User Manual, Developers Guide and API Documentation

Propagation.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/Propagation.hpp>
00029 
00030 #include <WNS/pyconfig/helper/Functions.hpp>
00031 #include <WNS/Ttos.hpp>
00032 #include <WNS/Assure.hpp>
00033 
00034 using namespace rise::scenario;
00035 
00036 Propagation::NoModelError::NoModelError(const std::string& modelType,
00037                     const std::string& transmitterName,
00038                     const std::string& receiverName)
00039     : wns::Exception("No " + modelType + "-model configured for " + transmitterName + " -> " + receiverName)
00040 {
00041 }
00042 
00043 Propagation::Propagation(const wns::pyconfig::View& config)
00044     : config(config)
00045 {
00046     PathlossMatrix::SizeType sizes[2];
00047     sizes[0] = sizes[1] = config.get<std::size_t>("maxId()");
00048     pathlossMatrix = PathlossMatrix(sizes, NULL);
00049     shadowingMatrix = ShadowingMatrix(sizes, NULL);
00050     fastFadingMatrix = FastFadingMatrix(sizes, NULL);
00051 
00052     for (PathlossMatrix::SizeType i = 0; i < sizes[0]; ++i)
00053     {
00054         for (PathlossMatrix::SizeType j = 0; j < sizes[1]; ++j) 
00055         {
00056             if (config.get<bool>("knowsPairById(" + wns::Ttos(i) + ", " + wns::Ttos(j) + ")")) 
00057             {
00058                 wns::pyconfig::View pairView = config.getView("getPair(" + wns::Ttos(i) + ", " + wns::Ttos(j) + ")");
00059                 pathlossMatrix[i][j] = create<pathloss::Pathloss>(pairView.getView("pathloss"));
00060                 shadowingMatrix[i][j] = create<shadowing::Shadowing>(pairView.getView("shadowing"));
00061                 fastFadingMatrix[i][j] = create<fastfading::FastFading>(pairView.getView("fastFading"));
00062             }
00063         }
00064     }
00065 }
00066 
00067 Propagation::~Propagation()
00068 {
00069 }
00070 
00071 const pathloss::Pathloss&
00072 Propagation::getPathlossModel(const IdType& transmitterId, const IdType& receiverId) const
00073 {
00074     pathloss::Pathloss* model = pathlossMatrix[transmitterId][receiverId];
00075     if (model == NULL)
00076     throw NoModelError("pathloss", getName(transmitterId), getName(receiverId));
00077     return *model;
00078 }
00079 
00080 const shadowing::Shadowing&
00081 Propagation::getShadowingModel(const IdType& transmitterId, const IdType& receiverId) const
00082 {
00083     shadowing::Shadowing* model = shadowingMatrix[transmitterId][receiverId];
00084     if (model == NULL)
00085     throw NoModelError("shadowing", getName(transmitterId), getName(receiverId));
00086     return *model;
00087 }
00088 
00089 const fastfading::FastFading&
00090 Propagation::getFastFadingModel(const IdType& transmitterId, const IdType& receiverId) const
00091 {
00092     fastfading::FastFading* model = fastFadingMatrix[transmitterId][receiverId];
00093     if (model == NULL)
00094     throw NoModelError("shadowing", getName(transmitterId), getName(receiverId));
00095     return *model;
00096 }
00097 
00098 std::string
00099 Propagation::getName(const IdType& id) const
00100 {
00101     return config.get<std::string>("findName(" + wns::Ttos(id) + ")");
00102 }
00103 

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