![]() |
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/cache/h2cache.hpp> 00029 #include <RISE/transceiver/cache/propcacheentry.hpp> 00030 #include <RISE/transceiver/transmitter.hpp> 00031 #include <RISE/transceiver/receiver.hpp> 00032 #include <RISE/transmissionobjects/transmissionobject.hpp> 00033 #include <RISE/antenna/Antenna.hpp> 00034 #include <RISE/stations/station.hpp> 00035 #include <RISE/manager/systemmanager.hpp> 00036 #include <WNS/PowerRatio.hpp> 00037 00038 using namespace std; 00039 using namespace __gnu_cxx; 00040 using namespace rise; 00041 00042 H2Cache::H2Cache(receiver::ReceiverInterface* r) 00043 : PropagationCache(r, "H2"), 00044 pathlossShadowGain(CacheVector()), 00045 transmitters(TransmitterContainer()) 00046 { 00047 pathlossShadowGain = std::vector<PropCacheEntry>(0); 00048 } 00049 00050 H2Cache::~H2Cache() 00051 { 00052 } 00053 00054 wns::Ratio H2Cache::getLoss(Transmitter* t, double freq) 00055 { 00056 unsigned long int tId = t->getTransmitterId(); 00057 if(!transmitters.contains(t)) 00058 attach(t, tId); 00059 PropCacheEntry& cacheEntry = pathlossShadowGain.at(tId); 00060 if(!cacheEntry.isValid()) { 00061 updatePropEntry(cacheEntry, 00062 t, 00063 freq); 00064 } 00065 return cacheEntry.getTotalLoss(); 00066 } 00067 00068 00069 void H2Cache::attach(Transmitter* t, unsigned long int tId) { 00070 00071 transmitters.push_back(t); 00072 if(pathlossShadowGain.size() <= tId) 00073 { 00074 unsigned long int numTx = tId+1; 00075 pathlossShadowGain = std::vector<PropCacheEntry>(numTx); 00076 } 00077 } 00078 00079 void H2Cache::invalidatePropagationEntries(Transmitter* t) 00080 { 00081 unsigned long int tId = t->getTransmitterId(); 00082 if(tId >= pathlossShadowGain.size()) 00083 attach(t, tId); 00084 pathlossShadowGain.at(tId).setValid(false); 00085 } 00086 00087 void H2Cache::invalidatePropagationEntries() 00088 { 00089 TransmitterIterator itrTEnd = transmitters.end(); 00090 for(TransmitterIterator itrT = transmitters.begin(); 00091 itrT!=itrTEnd; 00092 ++itrT) 00093 { 00094 unsigned long int tId = (*itrT)->getTransmitterId(); 00095 pathlossShadowGain.at(tId).setValid(false); 00096 } 00097 } 00098 00099
1.5.5