User Manual, Developers Guide and API Documentation

MACgUT.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 <LTE/macg/MACgUT.hpp>
00029 
00030 #include <DLL/Layer2.hpp>
00031 
00032 #include <WNS/ldk/IConnectorReceptacle.hpp>
00033 
00034 using namespace lte::macg;
00035 using namespace wns::ldk;
00036 
00037 STATIC_FACTORY_REGISTER_WITH_CREATOR(MACgUT,
00038                      FunctionalUnit,
00039                      "lte.macg.UserTerminal",
00040                      FUNConfigCreator);
00041 
00042 MACgSchedulerUT::MACgSchedulerUT() :
00043     MACgScheduler()
00044 {}
00045 
00046 
00047 bool
00048 MACgSchedulerUT::hasAcceptor(const CompoundPtr& compound)
00049 {
00050     lte::helper::Route route = getRoute(compound);
00051 
00052     MESSAGE_BEGIN(VERBOSE, *logger, m, "");
00053     m << "hasAcceptor(compound) ->";
00054     if(!route.valid()) {
00055     m << " false";
00056     } else {
00057     m << " mode " << route.modeName
00058       << " target DLL Address " << route.target
00059       << " accepting " << (layers.at(route.mode)->isAccepting(compound) ? "true" : "false");
00060     }
00061     MESSAGE_END();
00062 
00063     return (route.valid() && layers.at(route.mode)->isAccepting(compound));
00064 } // hasAcceptor
00065 
00066 
00067 wns::ldk::IConnectorReceptacle*
00068 MACgSchedulerUT::getAcceptor(const CompoundPtr& compound)
00069 {
00070     lte::macg::MACgCommand* macgCommand = macg->getCommand(compound->getCommandPool());
00071 
00072     MESSAGE_BEGIN(NORMAL, *logger, m, "");
00073     m << "getAcceptor(compound) ->"
00074       << " mode " << macgCommand->local.modeName
00075       << " target DLL Address " << macgCommand->peer.dest
00076       << " accepting " << (layers.at(macgCommand->local.modeID)->isAccepting(compound) ? "true" : "false");
00077     MESSAGE_END();
00078 
00079     return layers.at(macgCommand->local.modeID);
00080 } // getAcceptor
00081 
00082 
00083 MACgUT::MACgUT(wns::ldk::fun::FUN* fun, const wns::pyconfig::View& config) :
00084     MACg(fun, config),
00085     HasReceptor<wns::ldk::RoundRobinReceptor>(),
00086     HasConnector<MACgSchedulerUT>(),
00087     HasDeliverer<>(),
00088     Forwarding<MACgUT>(),
00089     wns::Cloneable<MACgUT>()
00090 {
00091     // Resolve issues with the Connector - set pointer to myself
00092     getConnector()->setMACg(this);
00093     // and fire up its logger
00094     getConnector()->setLogger(config.get("logger"));
00095 } // MACgUT
00096 
00097 
00098 void
00099 MACgUT::processOutgoing(const CompoundPtr& compound)
00100 {
00101     MACgCommand* macgCommand = activateCommand(compound->getCommandPool());
00102 
00103     // set source MACg Identification
00104     dll::ILayer2* layer2 = getFUN()->getLayer<dll::ILayer2*>();
00105     //source
00106     macgCommand->peer.source   = layer2->getDLLAddress();
00107     //mode: the macr with the best value
00108     lte::helper::Route  bestRoute = getConnector()->getRoute(compound);
00109     macgCommand->local.modeID          = bestRoute.mode;
00110     macgCommand->local.modeName        = bestRoute.modeName;
00111     //destination
00112     macgCommand->peer.dest   = bestRoute.target;
00113     fun->getProxy()->commitSizes(compound->getCommandPool(), this);
00114 } // processOutgoing
00115 
00116 
00117 

Generated on Fri May 25 03:32:05 2012 for openWNS by  doxygen 1.5.5