![]() |
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 <RISE/transceiver/SCReceiver.hpp> 00029 #include <RISE/transceiver/transmitter.hpp> 00030 #include <RISE/antenna/Antenna.hpp> 00031 #include <RISE/manager/systemmanager.hpp> 00032 #include <RISE/medium/PhysicalResource.hpp> 00033 #include <RISE/transmissionobjects/transmissionobject.hpp> 00034 #include <RISE/stations/station.hpp> 00035 #include <RISE/medium/Medium.hpp> 00036 #include <RISE/transceiver/cache/hashcache.hpp> 00037 #include <RISE/transceiver/cache/idvectorcache.hpp> 00038 #include <RISE/transceiver/cache/vectorcache.hpp> 00039 #include <RISE/transceiver/cache/nocache.hpp> 00040 #include <RISE/transceiver/cache/h2cache.hpp> 00041 #include <RISE/RISE.hpp> 00042 00043 #include <WNS/PowerRatio.hpp> 00044 #include <WNS/TimeWeightedAverage.hpp> 00045 #include <WNS/Assure.hpp> 00046 #include <WNS/pyconfig/View.hpp> 00047 00048 #include <sstream> 00049 00050 00051 using namespace std; 00052 using namespace rise; 00053 00054 SCReceiver::SCReceiver(const wns::pyconfig::View& config, 00055 Station* s, 00056 antenna::Antenna* a, 00057 Demodulator *demodulator, 00058 Decoder *decoder, 00059 wns::Ratio rnf) 00060 : Receiver(s, a, demodulator, decoder, rnf), 00061 LossCalculation(config) 00062 {} 00063 00064 SCReceiver::~SCReceiver() 00065 {} 00066 00067 00068 void SCReceiver::startReceiving() 00069 { 00070 assert(!active); 00071 assert(!prc.empty()); 00072 prc.at(0)->attach(this); 00073 active = true; 00074 } 00075 00076 void SCReceiver::stopReceiving() 00077 { 00078 assert(active); 00079 assert(!prc.empty()); 00080 prc.at(0)->detach(this); 00081 active = false; 00082 // remove all transmission objects and their according averaging objects 00083 transmissionObjects.clear(); 00084 removeAll(); 00085 } 00086 00087 void SCReceiver::notify(TransmissionObjectPtr aTransmissionObject) 00088 { 00089 totalRxPower.setDirty(); 00090 signalLevelsChange(); 00091 if (aTransmissionObject->getIsStart()) 00092 { 00093 transmissionObjects.push_back(aTransmissionObject); 00094 add(aTransmissionObject); 00095 } 00096 else 00097 { 00098 transmissionObjects.remove(aTransmissionObject); 00099 remove(aTransmissionObject); 00100 } 00101 } 00102 00103 wns::Power SCReceiver::getTotalRxPower() { 00104 assert(active); 00105 // if(totalRxPower.isDirty()) { 00106 totalRxPower = getNoise(); 00107 medium::PhysicalResource::TransmissionObjectIterator itr, itrEnd; 00108 itrEnd=prc.at(0)->getTOEnd(); 00109 for(itr=prc.at(0)->getTOBegin(); 00110 itr!=itrEnd; 00111 ++itr) { 00112 totalRxPower += getRxPower(*itr); 00113 } 00114 // } 00115 return totalRxPower; 00116 } 00117 00118 wns::Power SCReceiver::getInterference(const TransmissionObjectPtr& t) { 00119 wns::Power rxPower = getRxPower(t); 00120 assert(prc.at(0)->contains(t)); 00121 wns::Power Interference = getTotalRxPower() - rxPower; 00122 assert(Interference>=getNoise()*.99); 00123 return Interference; 00124 } 00125 00126 wns::Power SCReceiver::getRxPower(const TransmissionObjectPtr& t) { 00127 wns::Power rxPower = t->getTxPower(); 00128 double freq = prc.at(0)->getFrequency(); 00129 rxPower -= propCache->getLoss(t->getTransmitter(), freq); 00130 return rxPower; 00131 } 00132 00133 wns::Ratio SCReceiver::getLoss(Transmitter* t) 00134 { 00135 double freq = prc.at(0)->getFrequency(); 00136 return propCache->getLoss(t, freq); 00137 } 00138 00139 00140 wns::Power SCReceiver::getNoise() 00141 { 00142 wns::Power bg = wns::Power::from_dBm(-174); 00143 bg += receiverNoiseFigure; 00144 bg += wns::Ratio::from_factor(prc.at(0)->getBandwidth()*1E6); 00145 return bg; 00146 } 00147 00148 00149 void SCReceiver::tune(double f, double b) { 00150 if(active) { 00151 stringstream errMsg; 00152 errMsg << "Tuning not possible. Transceiver is active!"; 00153 throw(errMsg.str().c_str()); 00154 } else { 00155 assure(prc.size() <= 1, "Single carrier receiver may have one resource at maximum"); 00156 if(!prc.empty()) { 00157 prc.clear(); 00158 } 00159 prc.push_back(medium::Medium::getInstance()->getPhysicalResource(f, b)); 00160 } 00161 } 00162 00163 bool SCReceiver::contains(TransmissionObjectPtr t) 00164 { 00165 if (find(transmissionObjects.begin(), transmissionObjects.end(), t) 00166 != transmissionObjects.end()) 00167 { 00168 return true; 00169 } 00170 return false; 00171 } 00172 00173 double SCReceiver::getFrequency() 00174 { 00175 assure(!prc.empty(), "SCReceiver not tuned."); 00176 return prc.at(0)->getFrequency(); 00177 } 00178 00179 00180
1.5.5