![]() |
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/OFDMAMeasurement.hpp> 00029 #include <WNS/events/scheduler/Interface.hpp> 00030 #include <RISE/scenario/ftfading/FTFading.hpp> 00031 #include <fstream> 00032 #include <iomanip> 00033 00034 using namespace ofdmaphy; 00035 00036 OFDMAMeasurement::OFDMAMeasurement(wns::node::Interface* _source, 00037 int _numberOfSubChannels, 00038 simTimeType _timeOfValidity, 00039 wns::Ratio _quasiStaticPathLoss, 00040 rise::scenario::ftfading::FTFading* _ftfading, 00041 std::vector<wns::Power> _interferenceVector, 00042 wns::logger::Logger& _logger 00043 ) : 00044 source(_source), 00045 numberOfSubChannels(_numberOfSubChannels), 00046 timeOfValidity(_timeOfValidity), 00047 quasiStaticPathLoss(_quasiStaticPathLoss), 00048 ftfading(_ftfading), 00049 logger(_logger) 00050 { 00051 assure(source!=NULL,"source==NULL"); 00052 assure(numberOfSubChannels>0,"wrong numberOfSubChannels="<<numberOfSubChannels); 00053 assure(timeOfValidity > 0.0,"OFDMAMeasurement is valid too shortly ("<<timeOfValidity<<"s)"); 00054 //assure(ftfading!=NULL,"ftfading==NULL"); // ftfading==NULL means no fading (0dB) 00055 timestamp = wns::simulator::getEventScheduler()->getTime(); 00056 //wns::Power interferenceTemplate = wns::Power::from_mW(0.0); // from_dBm() 00057 //interferencePlusNoise = std::vector<wns::Power>(numberOfSubChannels,interferenceTemplate); 00058 interferencePlusNoise = _interferenceVector; // big copy 00059 } 00060 00061 OFDMAMeasurement::~OFDMAMeasurement() 00062 { 00063 } 00064 00065 const wns::Ratio 00066 OFDMAMeasurement::getPathLoss(int subChannel) const 00067 { 00068 assure(subChannel>=0,"invalid subChannel="<<subChannel); 00069 assure(subChannel<numberOfSubChannels,"invalid subChannel="<<subChannel); 00070 wns::Ratio pathLoss = quasiStaticPathLoss; 00071 if (ftfading) { 00072 wns::Ratio ftfadingValue = ftfading->getFTFading(subChannel); 00073 pathLoss -= ftfadingValue; 00074 MESSAGE_SINGLE(NORMAL, logger, "OFDMAMeasurement::getPathLoss(subChannel="<<subChannel<<"):" 00075 <<" spl="<<quasiStaticPathLoss 00076 <<", ftf="<<ftfadingValue 00077 <<", pathLoss="<<pathLoss); 00078 } else { 00079 MESSAGE_SINGLE(NORMAL, logger, "OFDMAMeasurement::getPathLoss(subChannel="<<subChannel<<"): pathLoss="<<pathLoss); 00080 } 00081 return pathLoss; 00082 } 00083 00084 // const wns::Ratio OFDMAMeasurement::getPathLossInFuture(int subChannel, int samplingTimeOffset) const 00085 //{ 00086 // assure(samplingTimeOffset>=0,"invalid samplingTimeOffset="<<samplingTimeOffset); 00087 // assure(samplingTimeOffset<=1,"invalid samplingTimeOffset="<<samplingTimeOffset); 00088 //} 00089 00090 const std::vector<wns::Ratio> 00091 OFDMAMeasurement::getPathLoss() const 00092 { 00093 // make a local object that is _copied_ to the caller: 00094 std::vector<wns::Ratio> pathLossVector; // temporary object 00095 if (ftfading) 00096 assure(numberOfSubChannels==ftfading->getNumberOfSubChannels(),"mismatch of numberOfSubChannels"); 00097 for(int subChannel=0; subChannel<numberOfSubChannels; ++subChannel) { 00098 wns::Ratio pathLoss = quasiStaticPathLoss; 00099 if (ftfading) { 00100 wns::Ratio ftfadingValue = ftfading->getFTFading(subChannel); 00101 pathLoss -= ftfadingValue; 00102 MESSAGE_SINGLE(NORMAL, logger, "OFDMAMeasurement::getPathLoss(subChannel="<<subChannel<<"):" 00103 << std::setiosflags(std::ios::dec) 00104 << std::resetiosflags(std::ios::scientific) 00105 << std::setprecision(2) 00106 <<" spl="<<quasiStaticPathLoss 00107 <<", ftf="<<ftfadingValue 00108 <<", pathLoss="<<pathLoss); 00109 } else { 00110 MESSAGE_SINGLE(NORMAL, logger, "OFDMAMeasurement::getPathLoss(subChannel="<<subChannel<<"): pathLoss="<<pathLoss); 00111 } 00112 pathLossVector.push_back(pathLoss); 00113 } 00114 return pathLossVector; // copy back 00115 } 00116 00117 //const std::vector<wns::Ratio> OFDMAMeasurement::getPathLossInFuture(int samplingTimeOffset) const 00118 //{ 00119 // assure(samplingTimeOffset>=0,"invalid samplingTimeOffset="<<samplingTimeOffset); 00120 // assure(samplingTimeOffset<=1,"invalid samplingTimeOffset="<<samplingTimeOffset); 00121 //} 00122 00123 const wns::Power 00124 OFDMAMeasurement::getInterferencePlusNoise(int subChannel) const 00125 { 00126 assure(subChannel>=0,"invalid subChannel="<<subChannel); 00127 assure(subChannel<numberOfSubChannels,"invalid subChannel="<<subChannel); 00128 assure(subChannel<(int)interferencePlusNoise.size(),"subChannel out of bounds="<<subChannel); 00129 //wns::Power interference = wns::Power::from_mW(0.0); 00130 return interferencePlusNoise[subChannel]; 00131 } 00132 00133 const std::vector<wns::Power>& 00134 OFDMAMeasurement::getInterferencePlusNoise() const 00135 { 00136 //return std::vector<wns::Power>(); 00137 return interferencePlusNoise; 00138 } 00139 00140 wns::node::Interface* 00141 OFDMAMeasurement::getSourceNode() const 00142 { 00143 return source; 00144 } 00145 00146 const bool 00147 OFDMAMeasurement::isUpToDate() const 00148 { 00149 simTimeType now = wns::simulator::getEventScheduler()->getTime(); 00150 simTimeType diff = now - timestamp; 00151 return (diff>=0.0) && (diff<=timeOfValidity); 00152 } 00153 00154 std::string 00155 OFDMAMeasurement::getString() const 00156 { 00157 std::stringstream s; 00158 s<<"OFDMAMeasurement: "; 00159 s.setf(std::ios::dec); 00160 s.unsetf(std::ios::scientific); 00161 s.precision(2); 00162 for(int subChannel=0; subChannel<numberOfSubChannels; ++subChannel) { 00163 //wns::Ratio pathLoss = getPathLoss(subChannel); // short way but verbose 00164 wns::Ratio pathLoss = quasiStaticPathLoss; 00165 if (ftfading) { 00166 wns::Ratio ftfadingValue = ftfading->getFTFading(subChannel); 00167 pathLoss -= ftfadingValue; 00168 } 00169 s<<pathLoss<<" "; 00170 } 00171 return s.str(); 00172 } 00173 00174
1.5.5