![]() |
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 <OFDMAPHY/receiver/FTFadingAspect.hpp> 00029 00030 //#include <RISE/scenario/Scenario.hpp> 00031 00032 using namespace ofdmaphy::receiver; 00033 00034 // constructor 00035 FTFadingAspect::FTFadingAspect(const wns::pyconfig::View& config) : 00036 //ReceiverBase(config), 00037 ftfading(NULL), 00038 active(false), 00039 samplingTime(0.0) 00040 { 00041 // somehow ReceiverBase(config) does not initialize the logger 00042 if (logger.getModuleName().compare("unspecified")==0) 00043 logger=wns::logger::Logger(config.getView("logger")); // workaround. 00044 00045 assure(config.knows("FTFadingStrategy"),"FTFadingStrategy unknown"); 00046 if (!config.isNone("FTFadingStrategy")) 00047 { 00048 wns::pyconfig::View ftfadingView = config.get("FTFadingStrategy"); 00049 00050 assure(ftfadingView.knows("ftfadingName"),"ftfadingName unknown"); 00051 if (!ftfadingView.isNone("ftfadingName")) 00052 { 00053 std::string ftfadingName = ftfadingView.get<std::string>("ftfadingName"); 00054 assure(ftfadingName.length()>0,"invalid ftfadingName"); 00055 assure(logger.getModuleName().compare("unspecified")!=0,"logger problem"); 00056 00057 MESSAGE_SINGLE(NORMAL, logger, "Establishing ftfading strategy "<<ftfadingName); 00058 00060 rise::scenario::ftfading::FTFading::FTFadingCreator* FTFadingCreator = 00061 rise::scenario::ftfading::FTFading::FTFadingFactory::creator(ftfadingName); 00062 00063 ftfading = FTFadingCreator->create(ftfadingView); 00064 assure(ftfading!=NULL,"Error getting ftfading"); 00065 00066 samplingTime = ftfading->getSamplingTime(); 00067 assure(samplingTime>=0.0,"samplingTime must be positive: t="<<samplingTime); 00068 00069 // samplingTime of all ftfading processes should be the same 00070 if (samplingTime > 0.0) 00071 { 00072 MESSAGE_SINGLE(NORMAL, logger, "Retrieved ftfading (strategy "<<ftfadingName<<") from Broker."); 00073 active=true; 00074 } 00075 else 00076 { 00077 // effectively fading is off 00078 MESSAGE_SINGLE(NORMAL, logger, "Retrieved ftfading (strategy "<<ftfadingName<<") from Broker. Switching off."); 00079 delete ftfading; ftfading=NULL; 00080 active=false; 00081 } 00082 } 00083 } // else ftfading = NULL; 00084 } 00085 00086 // destructor 00087 FTFadingAspect::~FTFadingAspect() 00088 { 00089 } 00090 00091 bool FTFadingAspect::FTFadingIsActive() const 00092 { 00093 return active && (ftfading!=NULL); 00094 } 00095 00096 wns::Ratio FTFadingAspect::getFTFading(int _subCarrier) 00097 { 00098 assure(ftfading,"no FTFading object"); 00099 assure(_subCarrier>=0,"subCarrier must be positive"); 00100 00101 // positive value = constructive; negative value = destructive 00102 return ftfading->getFTFading(_subCarrier); 00103 } 00104 00105 wns::Ratio FTFadingAspect::getFTFading(wns::node::Interface* source, int _subCarrier) 00106 { 00107 assure(ftfading!=NULL,"no FTFading object"); 00108 assure(_subCarrier>=0,"subCarrier must be positive"); 00109 assure(source!=NULL,"source==NULL"); 00110 00111 //PerSourceContainer myPerSourceContainer = perSourceMap[source]; 00112 PerSourceMap::iterator perSourceMapFound = perSourceMap.find(source); 00113 assure(perSourceMapFound!= perSourceMap.end(),"cannot find source in perSourceMap"); 00114 00115 PerSourceContainer& myPerSourceContainer = (*perSourceMapFound).second; 00116 00117 rise::scenario::ftfading::FTFading* myFTFading = myPerSourceContainer.ftfading; 00118 00119 if (myFTFading==NULL) 00120 { 00121 // create on demand 00122 // copy the single fading object for all sources 00123 myFTFading = ftfading; 00124 // TODO: make individual 00125 myPerSourceContainer.ftfading = myFTFading; 00126 MESSAGE_SINGLE(NORMAL, logger, "FTFadingAspect::getFTFading("<<source->getName()<<","<<_subCarrier<<"): new ftFading"); 00127 } 00128 00129 assure(myFTFading!=NULL,"myFTFading==NULL"); 00130 00131 // positive value = constructive; negative value = destructive 00132 return myFTFading->getFTFading(_subCarrier); 00133 } 00134
1.5.5