![]() |
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/receiver/PowerMeasurement.hpp> 00028 00029 using namespace rise::receiver; 00030 00031 PowerMeasurement::PowerMeasurement(rise::TransmissionObjectPtr t, 00032 wns::node::Interface* _sourceNode, 00033 wns::Power _rxPower, 00034 wns::Power _interference, 00035 wns::Ratio _iot, 00036 wns::Ratio _fading, 00037 wns::Ratio _omniAttenuation, 00038 double _distance, 00039 std::vector<wns::Ratio> _postProcessingSINRFactor 00040 ) 00041 : wns::service::phy::power::PowerMeasurementInterface(), // inherited 00042 rxPower(_rxPower), 00043 interference(_interference), 00044 iot(_iot), 00045 fading(_fading), 00046 omniAttenuation(_omniAttenuation), 00047 transmissionObjectPtr(t), 00048 sourceNode(_sourceNode), 00049 distance(_distance), 00050 postProcessingSINRFactor(_postProcessingSINRFactor) 00051 { 00052 assure(transmissionObjectPtr,"transmissionObjectPtr==NULL"); 00053 00054 wns::service::phy::phymode::PhyModeInterfacePtr t_phyModePtr = transmissionObjectPtr->getPhyModePtr(); 00055 if (t_phyModePtr) 00056 { 00057 this->phyModePtr = t_phyModePtr; 00058 } 00059 else 00060 { 00061 this->phyModePtr = wns::service::phy::phymode::PhyModeInterfacePtr(); 00062 } 00063 00064 rise::Transmitter* transmitter = transmissionObjectPtr->getTransmitter(); 00065 assure(transmitter != NULL,"transmitter==NULL"); 00066 00067 this->transmitterStation = transmitter->getStation(); 00068 assure(transmitterStation != NULL,"transmitterStation==NULL"); 00069 } 00070 00071 PowerMeasurement::~PowerMeasurement() 00072 { 00073 } 00074 00075 const wns::Power 00076 PowerMeasurement::getRxPower() const 00077 { 00078 return rxPower; 00079 } 00080 00081 const wns::Power 00082 PowerMeasurement::getInterferencePower() const 00083 { 00084 return interference; 00085 } 00086 00087 const wns::Power 00088 PowerMeasurement::getOmniInterferencePower() const 00089 { 00090 return wns::Power::from_mW(interference.get_mW() / omniAttenuation.get_factor()); 00091 } 00092 00093 const wns::Ratio 00094 PowerMeasurement::getIoT() const 00095 { 00096 return iot; 00097 } 00098 00099 const wns::Ratio 00100 PowerMeasurement::getSINR() const 00101 { 00102 // interference contains noise 00103 return rxPower / interference; 00104 } 00105 00106 const std::vector<wns::Ratio> 00107 PowerMeasurement::getPostProcessingSINRFactor() const 00108 { 00109 return postProcessingSINRFactor; 00110 } 00111 00112 const double 00113 PowerMeasurement::getMI() const 00114 { 00115 assure(phyModePtr, "invalid phyModePtr"); 00116 return phyModePtr->getSINR2MI(getSINR()); 00117 } 00118 00119 const double 00120 PowerMeasurement::getMIB() const 00121 { 00122 assure(phyModePtr, "invalid phyModePtr"); 00123 return phyModePtr->getSINR2MIB(getSINR()); 00124 } 00125 00126 const wns::Power 00127 PowerMeasurement::getTxPower() const 00128 { 00129 return transmissionObjectPtr->getTxPower(); 00130 } 00131 00132 const wns::Ratio 00133 PowerMeasurement::getPathLoss() const 00134 { 00135 return transmissionObjectPtr->getTxPower()/rxPower + getFading(); 00136 } 00137 00138 const wns::Ratio 00139 PowerMeasurement::getLoss() const 00140 { 00141 return transmissionObjectPtr->getTxPower()/rxPower; 00142 } 00143 00144 const wns::Ratio 00145 PowerMeasurement::getFading() const 00146 { 00147 return fading; 00148 } 00149 00150 const double 00151 PowerMeasurement::getDistance() const 00152 { 00153 return distance; 00154 } 00155 00156 const wns::Power 00157 PowerMeasurement::getRSS() const 00158 { 00159 return rxPower+interference; 00160 } 00161 00162 const wns::service::phy::phymode::PhyModeInterfacePtr 00163 PowerMeasurement::getPhyMode() const 00164 { 00165 assure(phyModePtr,"phyModePtr==NULL"); 00166 return phyModePtr; 00167 } 00168 00169 const 00170 rise::Station* PowerMeasurement::getSourceStation() const 00171 { 00172 assure(transmitterStation != NULL,"transmitterStation==NULL"); 00173 return transmitterStation; 00174 } 00175 00176 //const 00177 wns::node::Interface* PowerMeasurement::getSourceNode() const 00178 { 00179 assure(sourceNode != NULL,"sourceNode==NULL"); 00180 return sourceNode; 00181 } 00182 00183 std::string PowerMeasurement::getString() const 00184 { 00185 std::stringstream s; 00186 s << "[RxP="<<getRxPower()<<", I="<<getInterferencePower()<<", SINR="<<getSINR(); 00187 s << ", IoT="<<getIoT(); 00188 if(postProcessingSINRFactor.size() > 1 or (not postProcessingSINRFactor.empty() and postProcessingSINRFactor[0].get_factor() != 1.0)) 00189 { 00190 s << " +("; 00191 for(std::vector<wns::Ratio>::const_iterator it = postProcessingSINRFactor.begin(); 00192 it != postProcessingSINRFactor.end(); 00193 ++it) 00194 { 00195 s << *it << " "; 00196 } 00197 s << ")]"; 00198 } 00199 else 00200 { 00201 s << "]"; 00202 } 00203 return s.str(); 00204 }
1.5.5