![]() |
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/OFDMAAspect.hpp> 00029 00030 #include <RISE/medium/Medium.hpp> 00031 #include <RISE/medium/PhysicalResource.hpp> 00032 00033 using namespace ofdmaphy::receiver; 00034 00035 OFDMAAspect::OFDMAAspect(wns::Ratio rnf) : 00036 physicalResources(), 00037 receiverNoiseFigure(rnf), 00038 currentNumberOfSubCarriers(0), 00039 carrierBandwidth(0.0), 00040 lowestFrequency(0.0), 00041 firstCarrierMidFrequency(0.0) 00042 { 00043 } 00044 00045 void 00046 OFDMAAspect::tune(double f, double b, int numberOfSubCarriers) 00047 { 00048 while(!physicalResources.empty()) 00049 { 00050 (*physicalResources.begin())->detach(this); 00051 physicalResources.erase(physicalResources.begin()); 00052 } 00053 00054 assure(physicalResources.empty(), "Tuning not possible. Receiver is already tuned!"); 00055 00056 currentNumberOfSubCarriers = numberOfSubCarriers; 00057 carrierBandwidth = b/numberOfSubCarriers; 00058 lowestFrequency = f - b/2; 00059 firstCarrierMidFrequency = lowestFrequency + carrierBandwidth/2; 00060 00061 // allocate physicalResources for all subCarriers: 00062 for(long int i=0; i<numberOfSubCarriers; ++i) 00063 { 00064 double midFrequency = firstCarrierMidFrequency + i*carrierBandwidth; 00065 rise::medium::Medium* m = rise::medium::Medium::getInstance(); 00066 rise::medium::PhysicalResource* p = m->getPhysicalResource(midFrequency, carrierBandwidth); 00067 physicalResources.push_back(p); 00068 p->attach(this); 00069 } 00070 } 00071 00072 wns::Power 00073 OFDMAAspect::getNoise(int subCarrier) const 00074 { 00075 assure(subCarrier >= 0, "No negative numbers for subCarrier allowed"); 00076 assure(subCarrier < currentNumberOfSubCarriers, "No such subCarrier! Too high!"); 00077 assure(subCarrier < (int)physicalResources.size(), "No such subCarrier! Too high!"); 00078 00079 return getNoisePerSubChannel(); // faster 00080 } 00081 00082 wns::Power 00083 OFDMAAspect::getNoisePerSubChannel() const 00084 { 00085 //thermal noise: -174 dBm at room temperature (290 K) in a 1 Hz bandwidth (BW) 00086 wns::Power noise = wns::Power::from_dBm(-174); 00087 noise += wns::Ratio::from_factor(carrierBandwidth*1E6); 00088 //receiver noise figure: degradation of received signal quality due to imperfections 00089 noise += receiverNoiseFigure; 00090 return noise; 00091 } 00092 00093 wns::Ratio 00094 OFDMAAspect::getNoiseFigure() const 00095 { 00096 return receiverNoiseFigure; 00097 } 00098 00099 int 00100 OFDMAAspect::getSubCarrierIndex(double f) 00101 { 00102 int i = (int)((f-lowestFrequency)/carrierBandwidth); 00103 assure(i>=0,"getSubCarrierIndex("<<f<<") = "<<i<<" is negative"); 00104 return i; 00105 }
1.5.5