![]() |
User Manual, Developers Guide and API Documentation |
![]() |
00001 00002 /******************************************************************************* 00003 * This file is part of openWNS (open Wireless Network Simulator) 00004 * _____________________________________________________________________________ 00005 * 00006 * Copyright (C) 2004-2007 00007 * Chair of Communication Networks (ComNets) 00008 * Kopernikusstr. 5, D-52074 Aachen, Germany 00009 * phone: ++49-241-80-27910, 00010 * fax: ++49-241-80-22242 00011 * email: info@openwns.org 00012 * www: http://www.openwns.org 00013 * _____________________________________________________________________________ 00014 * 00015 * openWNS is free software; you can redistribute it and/or modify it under the 00016 * terms of the GNU Lesser General Public License version 2 as published by the 00017 * Free Software Foundation; 00018 * 00019 * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY 00020 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 00021 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00022 * details. 00023 * 00024 * You should have received a copy of the GNU Lesser General Public License 00025 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00026 * 00027 ******************************************************************************/ 00028 #include <WNS/ldk/fcf/FrameBuilder.hpp> 00029 00030 #include <WNS/Exception.hpp> 00031 #include <WNS/SmartPtr.hpp> 00032 #include <WNS/ldk/Layer.hpp> 00033 #include <WNS/logger/Logger.hpp> 00034 #include <WNS/ldk/fcf/CompoundCollector.hpp> 00035 #include <WNS/ldk/fcf/PhaseDescriptor.hpp> 00036 #include <WNS/ldk/fcf/TimingControl.hpp> 00037 00038 00039 STATIC_FACTORY_REGISTER_WITH_CREATOR( 00040 wns::ldk::fcf::FrameBuilder, 00041 wns::ldk::FunctionalUnit, 00042 "wns.ldk.fcf.FrameBuilder", 00043 wns::ldk::FUNConfigCreator ); 00044 00045 using namespace wns::ldk::fcf; 00046 using namespace std; 00047 00048 00049 FrameBuilder::FrameBuilder( wns::ldk::fun::FUN* fun, const wns::pyconfig::View& config ) : 00050 wns::ldk::multiplexer::Dispatcher( fun, config ), 00051 wns::ldk::fcf::NewFrameProvider(fun->getName()), 00052 timingControl_(NULL), 00053 logger("WNS", "FrameBuilder") 00054 { 00055 frameDuration_ = config.get<simTimeType>("frameDuration"); 00056 symbolDuration_ = config.get<simTimeType>("symbolDuration"); 00057 00058 // Create Timing Control from static Factory 00059 wns::pyconfig::View timingControlConfig( config, "timingControl"); 00060 std::string name = timingControlConfig.get<std::string>("name"); 00061 timingControl_ = TimingControlFactory::creator(name)->create( this , timingControlConfig); 00062 00063 // Create the phase descriptors 00064 for(int i = 0; i < config.len("phaseDescriptor"); i++) { 00065 wns::pyconfig::View pDesc(config.get("phaseDescriptor", i)); 00066 std::string plugin = pDesc.get<std::string>("__plugin__"); 00067 PhaseDescriptorCreator* pCreator = PhaseDescriptorFactory::creator(plugin); 00068 PhaseDescriptorPtr pDescPtr(pCreator->create(this, pDesc)); 00069 descriptors_.push_back(pDescPtr); 00070 } 00071 } 00072 00073 FrameBuilder::~FrameBuilder() 00074 { 00075 delete timingControl_; 00076 } 00077 00078 void FrameBuilder::onFUNCreated() 00079 { 00080 for(FrameBuilder::Descriptors::const_iterator it = descriptors_.begin(); 00081 it != descriptors_.end(); 00082 ++it) { 00083 (*it)->onFUNCreated(); 00084 } 00085 00086 // timing node must be configured after phase descriptors 00087 timingControl_->configure(); 00088 } 00089 00090 void FrameBuilder::start() 00091 { 00092 MESSAGE_BEGIN(NORMAL, logger, m, "" ); 00093 m << getFUN()->getName() << ": starting FrameBuilder"; 00094 MESSAGE_END(); 00095 00096 timingControl_->start(); 00097 } 00098 00099 void FrameBuilder::pause() 00100 { 00101 MESSAGE_BEGIN(NORMAL, logger, m, "" ); 00102 m << getFUN()->getName() <<": pausing FrameBuilder "; 00103 MESSAGE_END(); 00104 00105 timingControl_->pause(); 00106 } 00107 00108 void FrameBuilder::stop() 00109 { 00110 MESSAGE_BEGIN(NORMAL, logger, m, "" ); 00111 m << getFUN()->getName() << ": stopping FrameBuilder"; 00112 MESSAGE_END(); 00113 00114 timingControl_->stop(); 00115 } 00116 00117 00118 void FrameBuilder::finishedPhase( CompoundCollectorInterface* collector ) 00119 { 00120 getTimingControl()->finishedPhase( collector ); 00121 } 00122 00123
1.5.5