User Manual, Developers Guide and API Documentation

ErrorRate.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 <WNS/ldk/probe/ErrorRate.hpp>
00029 #include <WNS/probe/bus/ContextProviderCollection.hpp>
00030 #include <WNS/ldk/fun/FUN.hpp>
00031 #include <WNS/ldk/Layer.hpp>
00032 
00033 using namespace wns::ldk;
00034 using namespace wns::ldk::probe;
00035 
00036 STATIC_FACTORY_REGISTER_WITH_CREATOR(
00037     ErrorRate,
00038     Probe,
00039     "wns.probe.ErrorRate",
00040     FUNConfigCreator);
00041 
00042 STATIC_FACTORY_REGISTER_WITH_CREATOR(
00043     ErrorRate,
00044     FunctionalUnit,
00045     "wns.probe.ErrorRate",
00046     FUNConfigCreator);
00047 
00048 ErrorRate::ErrorRate(fun::FUN* fuNet, const wns::pyconfig::View& config) :
00049     fu::Plain<ErrorRate>(fuNet),
00050     Forwarding<ErrorRate>(),
00051     errorRateProviderName(config.get<std::string>("errorRateProvider")),
00052     logger(config.get("logger"))
00053 {
00054     // this is for the new probe bus
00055     wns::probe::bus::ContextProviderCollection* cpcParent = &fuNet->getLayer()->getContextProviderCollection();
00056 
00057     wns::probe::bus::ContextProviderCollection cpc(cpcParent);
00058 
00059     probe = wns::probe::bus::ContextCollectorPtr(
00060         new wns::probe::bus::ContextCollector(cpc, config.get<std::string>("probeName")));
00061 } // ErrorRate
00062 
00063 ErrorRate::~ErrorRate()
00064 {}
00065 
00066 void
00067 ErrorRate::onFUNCreated()
00068 {
00069     friends.errorRateProvider = getFUN()->findFriend<FunctionalUnit*>(errorRateProviderName);
00070     assure(
00071         friends.errorRateProvider,
00072         "ErrorRate probe requires a ErrorRateProvider friend with name '" + errorRateProviderName + "'");
00073 }
00074 
00075 void
00076 ErrorRate::processOutgoing(const CompoundPtr& compound)
00077 {
00078     // nothing to do here, simply forward the PDU
00079     Forwarding<ErrorRate>::processOutgoing(compound);
00080 } // processOutgoing
00081 
00082 
00083 void
00084 ErrorRate::processIncoming(const CompoundPtr& compound)
00085 {
00086     ErrorRateProviderInterface* ppi = dynamic_cast<ErrorRateProviderInterface*>(
00087         friends.errorRateProvider->getCommand(compound->getCommandPool()));
00088 
00089     assure(ppi, "Expected a ErrorRateProviderInterface instance.");
00090 
00091     probe->put(ppi->getErrorRate());
00092 
00093     Forwarding<ErrorRate>::processIncoming(compound);
00094 } // processIncoming
00095 
00096 
00097 

Generated on Wed May 23 03:31:42 2012 for openWNS by  doxygen 1.5.5