User Manual, Developers Guide and API Documentation

ReceiverBF.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/transceiver/ReceiverBF.hpp>
00029 #include <RISE/stations/station.hpp>
00030 #include <RISE/transceiver/cache/propcacheentry.hpp>
00031 #include <RISE/manager/systemmanager.hpp>
00032 #include <RISE/antenna/Beamforming.hpp>
00033 #include <RISE/transceiver/transmitter.hpp>
00034 #include <RISE/transceiver/cache/propagationcache.hpp>
00035 #include <RISE/transmissionobjects/transmissionobjectbf.hpp>
00036 #include <RISE/scenario/Scenario.hpp>
00037 
00038 using namespace rise;
00039 
00040 ReceiverBF::ReceiverBF(Station* s,
00041                antenna::Beamforming* a,
00042                Demodulator *demodulator,
00043                Decoder *decoder,
00044                wns::Ratio rnf)
00045     : ReceiverBase(s, demodulator, decoder, rnf),
00046       antenna(a)
00047 {}
00048 
00049 ReceiverBF::~ReceiverBF()
00050 {}
00051 
00052 wns::Power ReceiverBF::getRxPower(const TransmissionObjectPtr& t,
00053                                   const TransmissionObjectPtr& whenListeningToTO)
00054 {
00055     //transmit power
00056     wns::Power rxPower = t->getTxPower();
00057     //antenna gain - transmitter side, at the posision of the receiver
00058     rxPower += t->getTransmittersAntennaGain(getAntenna()->getPosition());
00059     //antenna gain - receiver side, at the position of the transmitter
00060     //jem : separate beamforming and nonbeamforming transmitters,
00061     //      receivers... everything to avoid dynamic casts
00062     rxPower += getAntenna()->getGain(t->getTransmitter()->getAntenna()->getPosition(),
00063                                      whenListeningToTO);
00064     PhysicalResourceIterator itr,itrEND;
00065     itr = prc.begin();
00066     itrEND = prc.end();
00067     while((!(*itr)->contains(t)) && itr != itrEND)
00068     {
00069         ++itr;
00070     }
00071     assert(itr!=itrEND);
00072     double freq = (*itr)->getFrequency();
00073     rxPower -= propCache->getLoss(t->getTransmitter(),freq);
00074     return rxPower;
00075 }
00076 
00077 wns::Power ReceiverBF::getInterference(const TransmissionObjectPtr& t)
00078 {
00079     wns::Power rxPower = getRxPower(t, t);
00080     assert(this->contains(t));
00081     wns::Power Interference = getTotalRxPower(t) - rxPower;
00082     assert(Interference>=getNoise()*.99);
00083     return Interference;
00084 }
00085 
00086 
00087 wns::Power ReceiverBF::getTotalRxPower(const TransmissionObjectPtr& whenListeningToTO)
00088 {
00089     assure(active, "Receiver is not active! Should we return 0 W here?");
00090     totalRxPower = getNoise();
00091     PhysicalResourceIterator itr,itrEND;
00092     itrEND = prc.end();
00093     itr = prc.begin();
00094     while(itr != itrEND)
00095     {
00096         medium::PhysicalResource::TransmissionObjectIterator TOI,TOI_END;
00097         TOI_END = (*itr)->getTOEnd();
00098         for(TOI = (*itr)->getTOBegin(); TOI != TOI_END; ++TOI) {
00099             totalRxPower += getRxPower(*TOI, whenListeningToTO);
00100         }
00101         ++itr;
00102     }
00103     return totalRxPower;
00104 }
00105 
00106 void ReceiverBF::writeCacheEntry(PropCacheEntry& cacheEntry,
00107                                  Transmitter* t,
00108                                  double freq)
00109 {
00110     wns::Ratio pl = getPathloss(*t, freq);
00111     wns::Ratio sh = getShadowing(*t);
00112 
00113     antenna::Antenna* txA = t->getAntenna();
00114     Station* RxStation = antenna->getStation();
00115     Station* TxStation = txA->getStation();
00116     MESSAGE_BEGIN(NORMAL, log, m, "");
00117     m  << TxStation->getStationId() << TxStation->getPosition()
00118        << " -> "
00119        << RxStation->getStationId() << RxStation->getPosition()
00120        << " pathloss: " << pl;
00121     MESSAGE_END();
00122     cacheEntry.setPathloss(pl);
00123     cacheEntry.setShadowing(sh);
00124     // antenna gain is not cached, but calculated when needed
00125     cacheEntry.setAntennaGain(wns::Ratio::from_dB(0));
00126     cacheEntry.setValid(true);
00127 }

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