User Manual, Developers Guide and API Documentation

AssociationHandler.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/controlplane/associationHandler/AssociationHandler.hpp>
00029 
00030 #include <DLL/StationManager.hpp>
00031 #include <DLL/Layer2.hpp>
00032 
00033 #include <WNS/service/dll/StationTypes.hpp>
00034 
00035 #define A2N(a) layer2->getStationManager()->getStationByMAC(a)->getName()
00036 
00037 using namespace lte::controlplane::associationHandler;
00038 
00039 AssociationHandler::AssociationHandler(wns::ldk::fun::FUN* fun, const wns::pyconfig::View& config) :
00040   wns::ldk::CommandTypeSpecifier<AssociationCommand>(fun),
00041   wns::ldk::HasReceptor<>(),
00042   wns::ldk::HasConnector<lte::helper::SwitchConnector>(),
00043   wns::ldk::HasDeliverer<>(),
00044   helper::HasModeName(config),
00045   fun(fun),
00046   layer2(fun->getLayer<dll::ILayer2*>()),
00047   associationService(NULL),
00048   connector(dynamic_cast<lte::helper::SwitchConnector*>(getConnector())),
00049   commandSize(config.get<Bit>("commandSize")),
00050   flowSeparatorNames(),
00051   logger(config.get("logger"))
00052 {
00053   for(int i = 0; i < config.len("flowSeparators"); ++i)
00054     {
00055       std::string fsName = config.get<std::string>("flowSeparators", i);
00056       flowSeparatorNames.push_back(fsName);
00057 
00058       MESSAGE_BEGIN(NORMAL, logger, m, " " );
00059       m << "added flowseparatorname to flowseperator: " << fsName;
00060       MESSAGE_END();
00061     }
00062 
00063   friends.rachDispatcher = NULL;
00064   friends.bchBuffer = NULL;
00065   friends.cpDispatcher = NULL;
00066   macgReader = NULL;
00067   rlcReader = NULL;
00068   friends.flowManager = NULL;
00069 
00070   // post myself as an AssociationInfo provider to the Layer2
00071   layer2->addAssociationInfoProvider(mode, this);
00072 }
00073 
00074 AssociationHandler::~AssociationHandler()
00075 {
00076   layer2 = NULL;
00077 }
00078 
00079 void
00080 AssociationHandler::onFUNCreated()
00081 {
00082   associationService = layer2->getControlService<dll::services::control::Association>("ASSOCIATION"+modeBase);
00083 
00084   if (mode == modeBase)
00085     macgReader = fun->getCommandReader("macg");
00086   else
00087     macgReader = fun->getCommandReader("macg"+separator+taskID);
00088 
00089   //get flow separators from config
00090   for(std::list<std::string>::iterator iter = flowSeparatorNames.begin(); iter != flowSeparatorNames.end(); ++iter)
00091     {
00092       wns::ldk::FlowSeparator* flowSeparator = fun->findFriend<wns::ldk::FlowSeparator*>(*iter);
00093       flowSeparators.push_back(flowSeparator);
00094     }
00095 
00096   std::string flowmanagername="FlowManager";
00097 
00098   if (layer2->getStationType() == wns::service::dll::StationTypes::UE()) {
00099     flowmanagername += "UT";
00100   } else { // BS
00101     flowmanagername += "BS";
00102   }
00103   // in the BS we don't activate the connector since we don't send anything
00104 
00105   friends.flowManager = layer2->getControlService<lte::controlplane::flowmanagement::IFlowSwitching>(flowmanagername);
00106   assure(friends.flowManager, "FlowManager not set.");
00107 
00108   rlcReader = fun->getCommandReader("rlc");
00109 }
00110 
00111 void
00112 AssociationHandler::doSendData(const wns::ldk::CompoundPtr&)
00113 {
00114   assure(false, "Should never be called!");
00115 }
00116 
00117 bool
00118 AssociationHandler::doIsAccepting(const wns::ldk::CompoundPtr& /* compound */) const
00119 {
00120   return false;
00121 }
00122 
00123 void
00124 AssociationHandler::doWakeup()
00125 {}
00126 
00127 void
00128 AssociationHandler::calculateSizes(const wns::ldk::CommandPool* commandPool,
00129                    Bit& commandPoolSize,
00130                    Bit& dataSize) const
00131 {
00132   fun->calculateSizes(commandPool, commandPoolSize, dataSize, this);
00133 
00134   // add my commandSize. No Data to add.
00135   commandPoolSize += this->commandSize;
00136 }
00137 
00138 void
00139 AssociationHandler::notifyOnAssociated(wns::service::dll::UnicastAddress user,
00140                        wns::service::dll::UnicastAddress dst)
00141 {
00142   MESSAGE_SINGLE(NORMAL, logger, "notifyOnAssociated(from "<<A2N(user)<<" to "<<A2N(dst)<<")");
00143   dll::services::control::AssociationFunctor doNotification(&dll::services::control::AssociationObserverInterface::onAssociated,
00144                                 user,
00145                                 dst);
00146   this->forEachObserver(doNotification);
00147 }
00148 
00149 void
00150 AssociationHandler::notifyOnDisassociated(wns::service::dll::UnicastAddress user,
00151                       wns::service::dll::UnicastAddress dst)
00152 {
00153   MESSAGE_SINGLE(NORMAL, logger, "notifyOnDisassociated(from "<<A2N(user)<<" to "<<A2N(dst)<<")");
00154   dll::services::control::AssociationFunctor doNotification(&dll::services::control::AssociationObserverInterface::onDisassociated,
00155                                 user,
00156                                 dst);
00157   this->forEachObserver(doNotification);
00158 }

Generated on Mon May 21 03:32:02 2012 for openWNS by  doxygen 1.5.5