![]() |
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-2009 00006 * Chair of Communication Networks (ComNets) 00007 * Kopernikusstr. 5, D-52074 Aachen, Germany 00008 * email: info@openwns.org 00009 * www: http://www.openwns.org 00010 * _____________________________________________________________________________ 00011 * 00012 * openWNS is free software; you can redistribute it and/or modify it under the 00013 * terms of the GNU Lesser General Public License version 2 as published by the 00014 * Free Software Foundation; 00015 * 00016 * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY 00017 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 00018 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00019 * details. 00020 * 00021 * You should have received a copy of the GNU Lesser General Public License 00022 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00023 * 00024 ******************************************************************************/ 00025 00026 00032 #include <WIMAC/ErrorModelling.hpp> 00033 #include <WIMAC/CIRProvider.hpp> 00034 00035 using namespace wimac; 00036 00037 STATIC_FACTORY_REGISTER_WITH_CREATOR( 00038 wimac::ErrorModelling, 00039 wns::ldk::FunctionalUnit, 00040 "wimac.ErrorModelling", 00041 wns::ldk::FUNConfigCreator); 00042 00043 00044 ErrorModelling::ErrorModelling(wns::ldk::fun::FUN* fun, const wns::pyconfig::View& config) : 00045 wns::ldk::fu::Plain<ErrorModelling, ErrorModellingCommand>(fun), 00046 wns::ldk::Forwarding<ErrorModelling>(), 00047 CIRProviderName_(config.get<std::string>("cirProvider")), 00048 PHYModeProviderName_( config.get<std::string>("phyModeProvider")), 00049 friends() 00050 { 00051 } 00052 00053 void 00054 ErrorModelling::processOutgoing(const wns::ldk::CompoundPtr& compound) 00055 { 00056 activateCommand(compound->getCommandPool()); 00057 00058 LOG_INFO( getFUN()->getName(), " ErrorModelling: Outgoing Compound passed!" ); 00059 } 00060 00061 00062 void 00063 ErrorModelling::processIncoming(const wns::ldk::CompoundPtr& compound) 00064 { 00065 wns::Ratio cir = dynamic_cast<CIRProviderCommand*> 00066 (friends.CIRProvider->getCommand(compound->getCommandPool()))->getCIR(); 00067 00068 const wns::service::phy::phymode::PhyModeInterface* phyModePtr = 00069 dynamic_cast<wimac::PhyModeProviderCommand*>( 00070 friends.PHYModeProvider->getCommand(compound->getCommandPool())) 00071 ->getPhyModePtr(); 00072 00073 int blocksize = compound->getLengthInBits(); 00074 double mib = phyModePtr->getSINR2MIB(cir); 00075 double per = phyModePtr->getMI2PER(mib, blocksize); 00076 00077 // Output 00078 this->getCommand(compound->getCommandPool())->local.per = per; 00079 00080 LOG_INFO( getFUN()->getName(), 00081 ": doOnData! CIR=",cir.get_dB()," PHY Mode=", phyModePtr->getString(), 00082 " ; PER=",getCommand( compound->getCommandPool() )->local.per); 00083 } 00084 00085 void 00086 ErrorModelling::onFUNCreated() 00087 { 00088 friends.CIRProvider = getFUN()->findFriend<FunctionalUnit*>(CIRProviderName_); 00089 assure(friends.CIRProvider, 00090 "ErrorModelling requires a PHYUser friend with name '" 00091 + CIRProviderName_ + "' \n"); 00092 friends.PHYModeProvider = getFUN()->findFriend<FunctionalUnit*>(PHYModeProviderName_); 00093 assure(friends.PHYModeProvider, 00094 "ErrorModelling requires a PHYModeProvider friend with name '" 00095 + PHYModeProviderName_ + "' \n"); 00096 } 00097 00098
1.5.5