![]() |
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 #include <RISE/transceiver/cache/vectorcache.hpp> 00028 #include <RISE/transceiver/transmitter.hpp> 00029 #include <RISE/transceiver/receiver.hpp> 00030 #include <RISE/transmissionobjects/transmissionobject.hpp> 00031 #include <RISE/antenna/Antenna.hpp> 00032 #include <RISE/stations/station.hpp> 00033 #include <WNS/Position.hpp> 00034 #include <RISE/manager/systemmanager.hpp> 00035 #include <RISE/transceiver/cache/propcacheentry.hpp> 00036 #include <WNS/PowerRatio.hpp> 00037 00038 using namespace rise; 00039 using namespace std; 00040 00041 VectorCache::VectorCache(receiver::ReceiverInterface* r) 00042 : PropagationCache(r, "Vector"), 00043 pathlossShadowGain(FrequencyHash()) 00044 { 00045 } 00046 00047 VectorCache::~VectorCache() 00048 { 00049 } 00050 00051 wns::Ratio VectorCache::getLoss(Transmitter* t, double freq) { 00052 //if frequency is not in hash attach it 00053 if(pathlossShadowGain.find(freq)==pathlossShadowGain.end()) 00054 attachFrequency(freq); 00055 int tIndex = getIndex(t); 00056 PropCacheEntry& vectorEntry = pathlossShadowGain[freq].at(tIndex); 00057 if(!vectorEntry.isValid()){ 00058 updatePropEntry(vectorEntry, t, freq); 00059 } 00060 return vectorEntry.getTotalLoss(); 00061 } 00062 00063 00064 int VectorCache::getIndex(Transmitter* t) 00065 { 00066 PointerHashMap<Transmitter*, long int>::iterator itr=transmitter2Index.find(t); 00067 if(itr==transmitter2Index.end()) 00068 { 00069 unsigned long int index = 0; 00070 FrequencyIterator fItrEnd = frequencies.end(); 00071 assert(frequencies.size()>0); 00072 transmitters.push_back(t); 00073 for(FrequencyIterator fItr = frequencies.begin(); 00074 fItr!=fItrEnd; 00075 ++fItr) 00076 { 00077 index = pathlossShadowGain[*fItr].size(); 00078 CacheVector p = std::vector<PropCacheEntry>(index+1); 00079 pathlossShadowGain[*fItr] = p; 00080 } 00081 transmitter2Index[t] = index; 00082 invalidatePropagationEntries(t); 00083 itr=transmitter2Index.find(t); 00084 } 00085 return itr->second; 00086 00087 } 00088 00089 00090 void VectorCache::invalidatePropagationEntries(Transmitter* t) 00091 { 00092 if(frequencies.size()>0) 00093 { 00094 unsigned long int index = getIndex(t); 00095 FrequencyIterator itrFEnd = frequencies.end(); 00096 for(FrequencyIterator itrF = frequencies.begin();itrF!=itrFEnd;++itrF) 00097 { 00098 PropCacheEntry& vectorEntry = pathlossShadowGain[*itrF].at(index); 00099 updatePropEntry(vectorEntry, t, (*itrF)); 00100 } 00101 } 00102 } 00103 00104 00105 void VectorCache::invalidatePropagationEntries() 00106 { 00107 FrequencyIterator itrFEnd = frequencies.end(); 00108 for(FrequencyIterator itrF = frequencies.begin();itrF!=itrFEnd;++itrF) 00109 { 00110 TransmitterIterator itrTEnd = transmitters.end(); 00111 for(TransmitterIterator itrT = transmitters.begin();itrT!=itrTEnd;++itrT) 00112 { 00113 unsigned long int index = getIndex(*itrT); 00114 PropCacheEntry& vectorEntry = pathlossShadowGain[*itrF].at(index); 00115 updatePropEntry(vectorEntry, *itrT, (*itrF)); 00116 } 00117 } 00118 } 00120 void VectorCache::attachFrequency(double freq) 00121 { 00122 unsigned long int numTx = (transmitter2Index.size()+1); 00123 pathlossShadowGain[freq] = std::vector<PropCacheEntry>(numTx); 00124 TransmitterIterator itrTEnd = transmitters.end(); 00125 00126 for(TransmitterIterator itrT = transmitters.begin();itrT!=itrTEnd;++itrT) 00127 { 00128 unsigned long int index = getIndex(*itrT); 00129 PropCacheEntry& vectorEntry = pathlossShadowGain[freq].at(index); 00130 updatePropEntry(vectorEntry, *itrT, freq); 00131 } 00132 frequencies.push_back(freq); 00133 } 00134 00135
1.5.5