User Manual, Developers Guide and API Documentation

FrameDispatcher.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/multiplexer/FrameDispatcher.hpp>
00029 #include <WNS/ldk/multiplexer/OpcodeSetter.hpp>
00030 
00031 using namespace wns::ldk;
00032 using namespace wns::ldk::multiplexer;
00033 
00034 STATIC_FACTORY_REGISTER_WITH_CREATOR(
00035     FrameDispatcher,
00036     wns::ldk::FunctionalUnit,
00037     "wns.multiplexer.FrameDispatcher",
00038     wns::ldk::FUNConfigCreator);
00039 
00040 FrameDispatcher::FrameDispatcher(fun::FUN* fuNet, const pyconfig::View& _config) :
00041         CommandTypeSpecifier<OpcodeCommand>(fuNet),
00042         HasReceptor<RoundRobinReceptor>(),
00043         HasConnector<RoundRobinConnector>(),
00044         HasDeliverer<OpcodeDeliverer>(),
00045         Processor<FrameDispatcher>(),
00046         Cloneable<FrameDispatcher>(),
00047         config(_config),
00048         opcodeSize(config.get<int>("opcodeSize")),
00049         opcode(),
00050         pending(),
00051         logger(_config.get("logger"))
00052 {
00053     getDeliverer()->setOpcodeProvider(this);
00054 }
00055 
00056 
00057 FunctionalUnit*
00058 FrameDispatcher::whenConnecting()
00059 {
00060     MESSAGE_BEGIN(NORMAL, logger, m, getFUN()->getName());
00061     m << " adding new OpcodeSetter for opcode "
00062       << opcode;
00063     MESSAGE_END();
00064 
00065     assure(!pending || downConnected || upConnected,
00066            "unit above dispatcher without corresponding unit below.");
00067 
00068     pending = new OpcodeSetter(getFUN(), this, config, opcode++);
00069     downConnected = false;
00070     upConnected = false;
00071 
00072     this->getReceptor()->add(pending);
00073     this->getDeliverer()->add(pending);
00074 
00075     return pending;
00076 } // whenConnecting
00077 
00078 
00079 void
00080 FrameDispatcher::doDownConnect(FunctionalUnit* that, const std::string& srcPort, const std::string& dstPort)
00081 {
00082     assure(pending, "no unit above dispatcher waiting for a connect from below.");
00083     assure(!downConnected, "you may only downconnect once.");
00084 
00085         pending->downConnect(that, srcPort, dstPort);
00086     downConnected = true;
00087 } // _downConnect
00088 
00089 
00090 void
00091 FrameDispatcher::doUpConnect(FunctionalUnit* that, const std::string& srcPort, const std::string& dstPort)
00092 {
00093     assure(pending, "no unit above dispatcher waiting for a connect from below.");
00094     assure(!upConnected, "you may only upconnect once.");
00095 
00096         pending->upConnect(that, srcPort, dstPort);
00097     upConnected = true;
00098 } // _upConnect
00099 
00100 
00101 void
00102 FrameDispatcher::processOutgoing(const CompoundPtr& compound)
00103 {
00104     OpcodeCommand* command = getCommand(compound->getCommandPool());
00105 
00106     MESSAGE_BEGIN(NORMAL, logger, m, getFUN()->getName());
00107     m << " sending opcode "
00108       << command->peer.opcode;
00109     MESSAGE_END();
00110 } // processOutgoing
00111 
00112 
00113 void
00114 FrameDispatcher::processIncoming(const CompoundPtr& compound)
00115 {
00116     OpcodeCommand* command = getCommand(compound->getCommandPool());
00117 
00118     MESSAGE_BEGIN(NORMAL, logger, m, getFUN()->getName());
00119     m << " delivering opcode "
00120       << command->peer.opcode;
00121     MESSAGE_END();
00122 } // processIncoming
00123 
00124 
00125 void
00126 FrameDispatcher::calculateSizes(const CommandPool* commandPool, Bit& commandPoolSize, Bit& sduSize) const
00127 {
00128     getFUN()->calculateSizes(commandPool, commandPoolSize, sduSize, this);
00129 
00130     commandPoolSize += opcodeSize;
00131 } // calculateSizes
00132 
00133 

Generated on Thu May 24 03:31:42 2012 for openWNS by  doxygen 1.5.5