User Manual, Developers Guide and API Documentation

TwoSizesWindowed.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/arq/statuscollector/TwoSizesWindowed.hpp>
00029 #include <WNS/logger/Logger.hpp>
00030 
00031 using namespace wns::ldk::arq::statuscollector;
00032 
00033 STATIC_FACTORY_REGISTER_WITH_CREATOR(TwoSizesWindowed, 
00034                      Interface,
00035                      "StatusCollectorTwoSizesWindowed",
00036                      wns::ldk::PyConfigCreator);
00037 
00038 TwoSizesWindowed::TwoSizesWindowed(const wns::pyconfig::View& config) :
00039         logger(config.get("logger")),
00040         windowSize(config.get<wns::simulator::Time>("windowSize")),
00041         minSamples(config.get<int>("minSamples")),
00042         insufficientSamplesReturn(config.get<double>("insufficientSamplesReturn")),
00043         frameSizeThreshold(config.get<Bit>("frameSizeThreshold"))
00044 {
00045     smallFrames = new wns::SlidingWindow(windowSize);
00046     bigFrames = new wns::SlidingWindow(windowSize);
00047 }
00048 
00049 TwoSizesWindowed::~TwoSizesWindowed()
00050 {
00051     delete smallFrames;
00052     delete bigFrames;
00053 }
00054 
00055 void TwoSizesWindowed::reset()
00056 {
00057     smallFrames->reset();
00058     bigFrames->reset();
00059 }
00060 
00061 void TwoSizesWindowed::onSuccessfullTransmission(const CompoundPtr& compound)
00062 {
00063     if(compound->getLengthInBits() > frameSizeThreshold)
00064     {
00065         bigFrames->put(1.0);
00066     }
00067     else
00068     {
00069         smallFrames->put(1.0);
00070     }
00071 }
00072 
00073 void TwoSizesWindowed::onFailedTransmission(const CompoundPtr& compound)
00074 {
00075     if(compound->getLengthInBits() > frameSizeThreshold)
00076     {
00077         bigFrames->put(0.0);
00078     }
00079     else
00080     {
00081         smallFrames->put(0.0);
00082     }
00083 }
00084 
00085 double TwoSizesWindowed::getSuccessRate(const CompoundPtr& compound)
00086 {
00087     wns::SlidingWindow* window;
00088     if(compound->getLengthInBits() > frameSizeThreshold)
00089     {
00090         window = bigFrames;
00091     }
00092     else
00093     {
00094         window = smallFrames;
00095     }
00096     
00097     if(window->getNumSamples() < minSamples)
00098     {
00099         return(insufficientSamplesReturn);
00100     }
00101     else
00102     {
00103         return(window->getAbsolute() / window->getNumSamples());
00104     }
00105 }

Generated on Sat May 26 03:31:38 2012 for openWNS by  doxygen 1.5.5