![]() |
User Manual, Developers Guide and API Documentation |
![]() |
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/rap/Events.hpp> 00031 #include <LTE/timing/TimingScheduler.hpp> 00032 #include <LTE/macr/PhyUser.hpp> 00033 00034 #include <LTE/timing/ResourceSchedulerInterface.hpp> 00035 #include <LTE/controlplane/MapHandlerInterface.hpp> 00036 #include <LTE/macr/RACHInterface.hpp> 00037 #include <LTE/controlplane/bch/BCHUnitInterface.hpp> 00038 00039 using namespace lte::timing; 00040 using namespace lte::timing::events; 00041 00042 // objects of these classes are created by name: 00043 // the names are specified in Timing.py as __plugin__ 00044 STATIC_FACTORY_REGISTER_WITH_CREATOR(rap::StartBCH, rap::EventBase, "lte.timing.BCH", wns::ldk::FUNConfigCreator); 00045 STATIC_FACTORY_REGISTER_WITH_CREATOR(rap::StartRACH, rap::EventBase, "lte.timing.RACH", wns::ldk::FUNConfigCreator); 00046 STATIC_FACTORY_REGISTER_WITH_CREATOR(rap::StartMap, rap::EventBase, "lte.timing.Map", wns::ldk::FUNConfigCreator); 00047 STATIC_FACTORY_REGISTER_WITH_CREATOR(rap::StartData, rap::EventBase, "lte.timing.Data", wns::ldk::FUNConfigCreator); 00048 00049 00050 rap::StartRACH::StartRACH(wns::ldk::fun::FUN* _fun, const wns::pyconfig::View& config) : 00051 EventBase(_fun, config), 00052 rach(_fun->findFriend<lte::macr::IRachTimingRx*>(mode+separator+"rach")) 00053 {} 00054 00055 void 00056 rap::StartRACH::execute() 00057 { 00058 assure(timer, "Timer has not been set in Event!"); 00059 // Transmit all pending RACH compounds 00060 MESSAGE_SINGLE(NORMAL, logger, "Event StartRACH (as RAP)"); 00061 setStateRxTx(lte::macr::PhyUser::Rx); 00062 rach->startRx(duration); 00063 } 00064 00065 rap::StartBCH::StartBCH(wns::ldk::fun::FUN* _fun, const wns::pyconfig::View& config) : 00066 EventBase(_fun, config), 00067 bch(_fun->findFriend<lte::controlplane::bch::IBCHTimingTx*>(mode+separator+"bch")) 00068 {} 00069 00070 void 00071 rap::StartBCH::execute() 00072 { 00073 assure(timer, "Timer has not been set in Event!"); 00074 MESSAGE_SINGLE(NORMAL, logger, "Event StartBCH (as RAP)"); 00075 setStateRxTx(lte::macr::PhyUser::Tx); 00076 bch->sendBCH(duration); 00077 } 00078 00079 00080 rap::StartMap::StartMap(wns::ldk::fun::FUN* _fun, const wns::pyconfig::View& config) : 00081 EventBase(_fun, config), 00082 rstx(_fun->findFriend<lte::timing::MasterScheduler*>(mode+separator+rsNameSuffix+"TX")), 00083 rsrx(_fun->findFriend<lte::timing::MasterScheduler*>(mode+separator+rsNameSuffix+"RX")), 00084 mapHandler(_fun->findFriend<lte::controlplane::IMapHandlerTiming*>(mode+separator+"mapHandler")), 00085 frameNr(config.get<int>("frameNr")), 00086 framesPerSuperFrame(config.get<int>("framesPerSuperFrame")), 00087 useMapResourcesInUL(config.get<bool>("useMapResourcesInUL")) 00088 {} 00089 00090 void 00091 rap::StartMap::execute() 00092 { 00093 assure(timer, "Timer has not been set in Event!"); 00094 MESSAGE_SINGLE(NORMAL, logger, "Event StartMap (as RAP) on current frame="<<frameNr); 00095 setStateRxTx(lte::macr::PhyUser::Tx); 00096 simTimeType now = wns::simulator::getEventScheduler()->getTime(); 00097 00098 // needed to reset resources at the and of a frame 00099 mapHandler->setCurrentPhase(); 00100 // ^ mapHandler sets currentPhase via friends.timer->phaseNumberAtOffset(0=now) 00101 00102 int ulWorkingFrameNr; 00103 int dlWorkingFrameNr; 00104 int schedulingOffset = timer->getSchedulingOffset(); 00105 int numberOfFrames = timer->getNumberOfFramesToSchedule(); 00106 std::vector<int> ulFrameNumbers; 00107 std::vector<int> dlFrameNumbers; 00108 00109 MESSAGE_SINGLE(NORMAL, logger, "startMap: Scheduling for " << numberOfFrames << " frames,starting with frameNr=" << frameNr+schedulingOffset); 00110 int j = 0; 00111 int i = 0; 00112 00113 // if we allow UL traffic during the map phase we need to set the 00114 // expectations (only valid for FDD): 00115 if (useMapResourcesInUL) 00116 { 00117 MESSAGE_SINGLE(NORMAL, logger, "Setting Expectations at beginning of Map -> Thus starting UL"); 00118 00119 // If we use the map resources in UL, then the map gives the transmissions for the next frame 00120 ulWorkingFrameNr = (frameNr + 1) % framesPerSuperFrame; 00121 rsrx->finishCollection(/*current*/ulWorkingFrameNr, now); // only beamforming etc. 00122 } 00123 00124 // Now we can start the scheduling as normal 00125 // this is scheduling in advance... 00126 while (i < numberOfFrames) 00127 { 00128 // make sure that the RN only schedules frames where it is in RAP phase! 00129 // (i, j) 00130 dlWorkingFrameNr = (frameNr + schedulingOffset + i + j) % framesPerSuperFrame; 00131 if (useMapResourcesInUL) 00132 { 00133 ulWorkingFrameNr = (frameNr + schedulingOffset + i + j + 1) % framesPerSuperFrame; 00134 } 00135 else 00136 { 00137 ulWorkingFrameNr = dlWorkingFrameNr; 00138 } 00139 00140 int taskPhase = timer->stationTaskAtFrame(dlWorkingFrameNr); 00141 MESSAGE_SINGLE(NORMAL, logger, "startMap: taskPhase=" << taskPhase); 00142 if (taskPhase == StationTasks::RAP()) 00143 { 00144 // first DL 00145 MESSAGE_SINGLE(NORMAL, logger, "startMap(): DL Scheduling for frameNr=" << dlWorkingFrameNr); 00146 rstx->startCollection(dlWorkingFrameNr); 00147 00148 // now UL 00149 MESSAGE_SINGLE(NORMAL, logger, "startMap(): UL Scheduling for frameNr=" << ulWorkingFrameNr); 00150 rsrx->startCollection(ulWorkingFrameNr); 00151 00152 // finally save the map 00153 //mapHandler->saveMap(workingFrameNr); // now done in ResourceScheduler.cpp 00154 dlFrameNumbers.push_back(dlWorkingFrameNr); 00155 ulFrameNumbers.push_back(ulWorkingFrameNr); 00156 00157 i++; 00158 } else { 00159 j++; 00160 } 00161 } 00162 MESSAGE_SINGLE(NORMAL, logger, "startMap(): scheduled dlFrameNumbers=" << dlFrameNumbers.size() << " ulFrameNumbers=" << ulFrameNumbers.size()); 00163 timer->frameTrigger(); 00164 mapHandler->startMapTx(duration, dlFrameNumbers, ulFrameNumbers); 00165 // duration is needed for phyCommand->local.stop = startTime + duration 00166 } // rap::StartMap::execute() 00167 00168 rap::StartData::StartData(wns::ldk::fun::FUN* _fun, const wns::pyconfig::View& config) : 00169 EventBase(_fun, config), 00170 rstx(_fun->findFriend<lte::timing::MasterScheduler*>(mode+separator+rsNameSuffix+"TX")), 00171 rsrx(_fun->findFriend<lte::timing::MasterScheduler*>(mode+separator+rsNameSuffix+"RX")), 00172 mapHandler(_fun->findFriend<lte::controlplane::IMapHandlerTiming*>(mode+separator+"mapHandler")), 00173 mySwitchingPointEvent(_fun, config), 00174 myStopDataEvent(_fun, config), 00175 frameNr(config.get<int>("frameNr")), 00176 useMapResourcesInUL(config.get<bool>("useMapResourcesInUL")) 00177 {} 00178 00179 rap::StartData::~StartData() 00180 { 00181 } 00182 00183 // wns::CloneableInterface* 00184 // rap::StartData::clone() const 00185 // { 00186 // // use default implementation of copy c'tor 00187 // rap::StartData* that = new rap::StartData(*this); 00188 // // and make deep copies of the contained events 00189 // that->mySwitchingPointEvent = mySwitchingPointEvent; 00190 // that->myStopDataEvent = myStopDataEvent; 00191 // return that; 00192 // } 00193 00194 void 00195 rap::StartData::setTimer(lte::timing::TimingScheduler* _timer) 00196 { 00197 EventBase::setTimer(_timer); 00198 mySwitchingPointEvent.setTimer(_timer); 00199 myStopDataEvent.setTimer(_timer); 00200 } 00201 00202 void 00203 rap::StartData::execute() 00204 { 00205 //MESSAGE_SINGLE(NORMAL, logger, "Event StartData"); 00206 assure(timer, "Timer has not been set in Event!"); 00207 simTimeType now = wns::simulator::getEventScheduler()->getTime(); 00208 00209 MESSAGE_SINGLE(NORMAL, logger, "Event StartData (as RAP). frameNr="<<frameNr); 00210 00211 //setExpectation 00212 if (!useMapResourcesInUL) 00213 { 00214 MESSAGE_SINGLE(NORMAL, logger, "useMapResourcesInUL="<<useMapResourcesInUL); 00215 //rstx->setExpectations(frameNr); //might have been done in StartMap 00216 } 00217 00218 setStateRxTx(lte::macr::PhyUser::Tx); 00219 rstx->finishCollection(frameNr, now); 00220 00221 if (timer->switchingPointOffset > 0.0) { 00222 // TDD, in case of FDD we don't have a switching point 00223 wns::simulator::getEventScheduler()->schedule(mySwitchingPointEvent, 00224 now + timer->switchingPointOffset); 00225 } else { 00226 // FDD 00227 if (!useMapResourcesInUL) //might have been done in StartMap 00228 { 00229 rsrx->finishCollection(frameNr, now); // only beamforming etc., 00230 } 00231 mapHandler->resetResources(frameNr); 00232 } 00233 wns::simulator::getEventScheduler()->schedule(myStopDataEvent, 00234 now + duration); 00235 } 00236 00237 rap::StartData::SwitchingPoint::SwitchingPoint(wns::ldk::fun::FUN* _fun, const wns::pyconfig::View& config) : 00238 EventBase(_fun, config), 00239 rsrx(_fun->findFriend<lte::timing::MasterScheduler*>(mode+separator+rsNameSuffix+"RX")), 00240 mapHandler(_fun->findFriend<lte::controlplane::IMapHandlerTiming*>(mode+separator+"mapHandler")), 00241 frameNr(config.get<int>("frameNr")) 00242 { 00243 } 00244 00245 void 00246 rap::StartData::SwitchingPoint::execute() 00247 { 00248 assure(timer, "Timer has not been set in Event!"); 00249 assure(mapHandler, "mapHandler not set!"); 00250 MESSAGE_SINGLE(NORMAL, logger, "SwitchingPoint reached (as RAP). From Tx to Rx, DL to UL"); 00251 setStateRxTx(lte::macr::PhyUser::Rx); 00252 simTimeType now = wns::simulator::getEventScheduler()->getTime(); 00253 rsrx->finishCollection(frameNr, now); // only beamforming etc. 00254 mapHandler->resetResources(frameNr); 00255 } 00256 00257 rap::StartData::StopData::StopData(wns::ldk::fun::FUN* _fun, const wns::pyconfig::View& config) : 00258 EventBase(_fun, config), 00259 rstx(_fun->findFriend<lte::timing::SchedulerIncoming*>(mode+separator+rsNameSuffix+"TX")) 00260 {} 00261 00262 void 00263 rap::StartData::StopData::execute() 00264 { 00265 MESSAGE_SINGLE(NORMAL, logger, "Event StopData"); 00266 00267 // HARQ, must be done BEFORE deliverReceived 00268 rstx->sendPendingHARQFeedback(); 00269 00270 // in case of a UT in TDD mode here deliverReceived() has no effect, because 00271 // it has already been called at the swtiching point 00272 rstx->deliverReceived(); // obsolete 00273 } 00274 00275 00276 00277
1.5.5