User Manual, Developers Guide and API Documentation

Events.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/FUNConfigCreator.hpp>
00029 
00030 #include <LTE/timing/events/ut/Events.hpp>
00031 #include <LTE/timing/TimingScheduler.hpp>
00032 
00033 #include <LTE/timing/ResourceSchedulerInterface.hpp>
00034 #include <LTE/controlplane/MapHandlerInterface.hpp>
00035 #include <LTE/macr/RACHInterface.hpp>
00036 
00037 using namespace lte::timing;
00038 using namespace lte::timing::events;
00039 
00040 // objects of these classes are created by name:
00041 // the names are specified in Timing.py as __plugin__
00042 STATIC_FACTORY_REGISTER_WITH_CREATOR(ut::StartBCH,  ut::EventBase, "lte.timing.BCH", wns::ldk::FUNConfigCreator);
00043 STATIC_FACTORY_REGISTER_WITH_CREATOR(ut::StartRACH, ut::EventBase, "lte.timing.RACH", wns::ldk::FUNConfigCreator);
00044 STATIC_FACTORY_REGISTER_WITH_CREATOR(ut::StartMap,  ut::EventBase, "lte.timing.Map", wns::ldk::FUNConfigCreator);
00045 STATIC_FACTORY_REGISTER_WITH_CREATOR(ut::StartData, ut::EventBase, "lte.timing.Data", wns::ldk::FUNConfigCreator);
00046 
00047 
00048 ut::StartRACH::StartRACH(wns::ldk::fun::FUN* _fun, const wns::pyconfig::View& config) :
00049     EventBase(_fun, config),
00050     rach(_fun->findFriend<lte::macr::IRachTimingTx*>(mode+separator+"rach"))
00051 {}
00052 
00053 void
00054 ut::StartRACH::execute()
00055 {
00056     assure(timer, "Timer has not been set in Event!");
00057     MESSAGE_SINGLE(NORMAL, logger, "Event StartRACH (as UT)");
00058     setStateRxTx(lte::macr::PhyUser::Tx);
00059     rach->startTx(duration);
00060 }
00061 
00062 ut::StartBCH::StartBCH(wns::ldk::fun::FUN* _fun, const wns::pyconfig::View& config) :
00063     EventBase(_fun, config)
00064 {}
00065 
00066 void
00067 ut::StartBCH::execute()
00068 {
00069     assure(timer, "Timer has not been set in Event!");
00070     MESSAGE_SINGLE(NORMAL, logger, "Event StartBCH (as UT)");
00071     setStateRxTx(lte::macr::PhyUser::Rx);
00072 }
00073 
00074 
00075 ut::StartMap::StartMap(wns::ldk::fun::FUN* _fun, const wns::pyconfig::View& config) :
00076     EventBase(_fun, config),
00077     frameNr(config.get<int>("frameNr")),
00078     useMapResourcesInUL(config.get<bool>("useMapResourcesInUL")),
00079     mapHandler(_fun->findFriend<lte::controlplane::IMapHandlerTiming*>(mode+separator+"mapHandler")),
00080     rstx(_fun->findFriend<lte::timing::SlaveScheduler*>(mode+separator+rsNameSuffix+"TX"))
00081 {}
00082 
00083 void
00084 ut::StartMap::execute()
00085 {
00086     assure(timer, "Timer has not been set in Event!");
00087     MESSAGE_SINGLE(NORMAL, logger, "Event StartMap (as UT) on current frame="<<frameNr);
00088     setStateRxTx(lte::macr::PhyUser::Rx);
00089 
00090     // needed to reset resources at the and of a frame
00091     mapHandler->setCurrentPhase();
00092 
00093     timer->frameTrigger();
00094 
00095     mapHandler->startMapRx();
00096 
00097     // Only valid for FDD
00098     if (useMapResourcesInUL)
00099     {
00100         MESSAGE_SINGLE(NORMAL, logger, "Starting UL transmission during Map phase!");
00101         // this is now done within rstxSlave->startCollection():
00102         //wns::scheduler::MapInfoCollectionPtr ulMapInfo = mapHandler->getTxResources(frameNr);
00103         setStateRxTx(lte::macr::PhyUser::Tx);
00104         //rstx->startCollection(frameNr, ulMapInfo); // start+finish inclusive
00105         rstx->startCollection(frameNr); // start+finish inclusive
00106     }
00107 }
00108 
00109 
00110 ut::StartData::StartData(wns::ldk::fun::FUN* _fun, const wns::pyconfig::View& config) :
00111     EventBase(_fun, config),
00112     rstx(_fun->findFriend<lte::timing::SlaveScheduler*>(mode+separator+rsNameSuffix+"TX")),
00113     mapHandler(_fun->findFriend<lte::controlplane::IMapHandlerTiming*>(mode+separator+"mapHandler")),
00114     mySwitchingPointEvent(_fun, config),
00115     myStopDataEvent(_fun, config),
00116     frameNr(config.get<int>("frameNr")),
00117     framesPerSuperFrame(config.get<int>("framesPerSuperFrame")),
00118     useMapResourcesInUL(config.get<bool>("useMapResourcesInUL"))
00119 {}
00120 
00121 ut::StartData::~StartData()
00122 {
00123 }
00124 
00125 // wns::CloneableInterface*
00126 // ut::StartData::clone() const
00127 // {
00128 //     // use default implementation of copy c'tor
00129 //     ut::StartData* that = new ut::StartData(*this);
00130 //     // and make deep copies of the contained events
00131 //     that->mySwitchingPointEvent = mySwitchingPointEvent;
00132 //     that->myStopDataEvent = myStopDataEvent;
00133 //     return that;
00134 // }
00135 
00136 void
00137 ut::StartData::setTimer(lte::timing::TimingScheduler* _timer) {
00138     EventBase::setTimer(_timer);
00139     mySwitchingPointEvent.setTimer(_timer);
00140     myStopDataEvent.setTimer(_timer);
00141 }
00142 
00143 void
00144 ut::StartData::execute()
00145 {
00146     assure(timer, "Timer has not been set in Event!");
00147     assure(mapHandler, "mapHandler not set!");
00148     simTimeType now = wns::simulator::getEventScheduler()->getTime();
00149 
00150     MESSAGE_SINGLE(NORMAL, logger, "Event StartData (as UT). frameNr=" << frameNr);
00151 
00152     //setExpectation
00153     //rstx->setExpectations(frameNr); // obsolete
00154     setStateRxTx(lte::macr::PhyUser::Rx);
00155 
00156     // TDD, in case of FDD we don't have a switching point
00157     if (timer->switchingPointOffset > 0.0) {
00158         wns::simulator::getEventScheduler()->schedule(mySwitchingPointEvent,
00159                                                       now + timer->switchingPointOffset);
00160     }
00161     // FDD
00162     else {
00163         if(!useMapResourcesInUL)
00164         {
00165             MESSAGE_SINGLE(NORMAL, logger, "Not using Map Resources in UL!");
00166             // obsolete:
00167             //wns::scheduler::MapInfoCollectionPtr ulMapInfo = mapHandler->getTxResources(frameNr);
00168             setStateRxTx(lte::macr::PhyUser::Tx);
00169             //rstx->startCollection(frameNr, ulMapInfo); // start+finish inclusive
00170             rstx->startCollection(frameNr); // start+finish inclusive
00171         }
00172         mapHandler->resetResources(frameNr);
00173     }
00174     wns::simulator::getEventScheduler()->schedule(myStopDataEvent,
00175                                                   now + duration);
00176 }
00177 
00178 ut::StartData::SwitchingPoint::SwitchingPoint(wns::ldk::fun::FUN* _fun, const wns::pyconfig::View& config) :
00179     EventBase(_fun, config),
00180     rstxSlave(_fun->findFriend<lte::timing::SlaveScheduler*>(mode+separator+rsNameSuffix+"TX")),
00181     rstxIncoming(_fun->findFriend<lte::timing::SchedulerIncoming*>(mode+separator+rsNameSuffix+"TX")),
00182     mapHandler(_fun->findFriend<lte::controlplane::IMapHandlerTiming*>(mode+separator+"mapHandler")),
00183     frameNr(config.get<int>("frameNr"))
00184 {
00185 }
00186 
00187 void
00188 ut::StartData::SwitchingPoint::execute()
00189 {
00190     assure(timer, "Timer has not been set in Event!");
00191     assure(mapHandler, "mapHandler not set!");
00192     MESSAGE_SINGLE(NORMAL, logger, "SwitchingPoint reached (as UT). frameNr="<<frameNr);
00193     //rstxIncoming->deliverReceived(); // obsolete
00194     setStateRxTx(lte::macr::PhyUser::Tx);
00195     // this is now done within rstxSlave->startCollection():
00196     //wns::scheduler::MapInfoCollectionPtr ulMapInfo = mapHandler->getTxResources(frameNr);
00197     //rstxSlave->startCollection(frameNr, ulMapInfo); // start+finish inclusive
00198     rstxSlave->startCollection(frameNr); // start+finish inclusive
00199     mapHandler->resetResources(frameNr);
00200 }
00201 
00202 ut::StartData::StopData::StopData(wns::ldk::fun::FUN* _fun, const wns::pyconfig::View& config) :
00203     EventBase(_fun, config),
00204     rstx(_fun->findFriend<lte::timing::SchedulerIncoming*>(mode+separator+rsNameSuffix+"TX"))
00205 {}
00206 
00207 void
00208 ut::StartData::StopData::execute()
00209 {
00210     MESSAGE_SINGLE(NORMAL, logger, "Event StopData");
00211 
00212     // HARQ, must be done BEFORE deliverReceived
00213     rstx->sendPendingHARQFeedback();
00214     
00215     // in case of a UT in TDD mode here deliverReceived() has no effect, because
00216     // it has already been called at the swtiching point
00217     rstx->deliverReceived(); // obsolete
00218 }
00219 
00220 
00221 
00222 
00223 

Generated on Sun May 27 03:32:05 2012 for openWNS by  doxygen 1.5.5