![]() |
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-2009 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/scheduler/strategy/dsastrategy/DSASlave.hpp> 00029 #include <WNS/scheduler/strategy/dsastrategy/DSAStrategy.hpp> 00030 #include <WNS/scheduler/strategy/dsastrategy/DSAStrategyInterface.hpp> 00031 #include <WNS/scheduler/SchedulerTypes.hpp> 00032 #include <vector> 00033 #include <iostream> 00034 #include <algorithm> 00035 00036 using namespace wns::scheduler; 00037 using namespace wns::scheduler::strategy; 00038 using namespace wns::scheduler::strategy::dsastrategy; 00039 00040 STATIC_FACTORY_REGISTER_WITH_CREATOR(DSASlave, 00041 DSAStrategyInterface, 00042 "DSASlave", 00043 wns::PyConfigViewCreator); 00044 00045 DSASlave::DSASlave(const wns::pyconfig::View& config) 00046 : DSAStrategy(config), 00047 lastUsedSubChannel(0), 00048 lastUsedTimeSlot(0), 00049 lastUsedBeam(0) 00050 { 00051 } 00052 00053 DSASlave::~DSASlave() 00054 { 00055 } 00056 00057 // call this before each timeSlot/frame 00058 void 00059 DSASlave::initialize(SchedulerStatePtr schedulerState, 00060 SchedulingMapPtr schedulingMap) 00061 { 00062 assure(schedulerState->schedulerSpot == wns::scheduler::SchedulerSpot::ULSlave(), 00063 "this DSASlave strategy can only be used as slave scheduler (RS-Tx, uplink)"); 00064 DSAStrategy::initialize(schedulerState,schedulingMap); // must always initialize base class too 00065 lastUsedSubChannel = 0; 00066 lastUsedTimeSlot = 0; 00067 lastUsedBeam = 0; 00068 // schedulingMap is an inputSchedulingMap 00069 } 00070 00071 DSAResult 00072 DSASlave::getSubChannelWithDSA(RequestForResource& request, 00073 SchedulerStatePtr schedulerState, 00074 SchedulingMapPtr schedulingMap) 00075 { 00076 DSAResult dsaResult; 00077 //simTimeType requestedCompoundDuration = getCompoundDuration(request); 00078 //MESSAGE_SINGLE(NORMAL, logger, "getSubChannelWithDSA("<<request.toString()<<"): d="<<requestedCompoundDuration<<"s"); 00079 int subChannel = lastUsedSubChannel; 00080 int timeSlot = lastUsedTimeSlot; 00081 int spatialLayer = lastUsedBeam; 00082 int maxSubChannel = schedulerState->currentState->strategyInput->getFChannels(); 00083 int numberOfTimeSlots = schedulerState->currentState->strategyInput->getNumberOfTimeSlots(); 00084 int maxSpatialLayers = schedulerState->currentState->strategyInput->getMaxSpatialLayers(); 00085 assure(subChannel<maxSubChannel,"invalid subChannel="<<subChannel); 00086 assure(timeSlot<numberOfTimeSlots,"invalid timeSlot="<<timeSlot); 00087 assure(spatialLayer<maxSpatialLayers,"invalid spatialLayer="<<spatialLayer); 00088 MESSAGE_SINGLE(NORMAL, logger, "getSubChannelWithDSA("<<request.toString()<<"): lastSC="<<lastUsedSubChannel); 00089 bool found = false; 00090 bool giveUp = false; 00091 // TODO: 00092 while(!found && !giveUp) { 00093 if (channelIsUsable(subChannel, timeSlot, spatialLayer, request, schedulerState, schedulingMap)) 00094 { // PDU fits in 00095 found=true; break; 00096 } 00097 if (++spatialLayer>=maxSpatialLayers) 00098 { // all spatialLayers full; take next timeSlot 00099 spatialLayer=0; 00100 if (++timeSlot>=numberOfTimeSlots) 00101 { // all timeSlots full; take next subChannel 00102 timeSlot=0; 00103 if (++subChannel>=maxSubChannel) 00104 { // wraparound 00105 subChannel=0; 00106 } 00107 } 00108 } 00109 if (subChannel==lastUsedSubChannel && timeSlot == lastUsedTimeSlot && spatialLayer == lastUsedBeam) 00110 { // one complete round already done 00111 giveUp=true; break; 00112 } 00113 } // while 00114 if (giveUp) { 00115 MESSAGE_SINGLE(NORMAL, logger, "getSubChannelWithDSA(): no free subchannel"); 00116 return dsaResult; // empty with subChannel=DSAsubChannelNotFound 00117 } else { 00118 MESSAGE_SINGLE(NORMAL, logger, "getSubChannelWithDSA(): subChannel="<<subChannel<<"."<<timeSlot<<"."<<spatialLayer); 00119 lastUsedSubChannel = subChannel; 00120 lastUsedTimeSlot = timeSlot; 00121 lastUsedBeam = spatialLayer; 00122 dsaResult.subChannel = subChannel; 00123 dsaResult.timeSlot = timeSlot; 00124 dsaResult.spatialLayer = spatialLayer; 00125 return dsaResult; 00126 } 00127 } // getSubChannelWithDSA
1.5.5