![]() |
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/SchedulerTypes.hpp> 00029 #include <WNS/scheduler/strategy/SchedulerState.hpp> 00030 #include <WNS/scheduler/strategy/StrategyInterface.hpp> 00031 #include <WNS/service/dll/StationTypes.hpp> 00032 #include <WNS/service/phy/ofdma/Pattern.hpp> 00033 #include <WNS/service/phy/phymode/PhyModeInterface.hpp> 00034 #include <WNS/ldk/Command.hpp> 00035 #include <WNS/ldk/Compound.hpp> 00036 #include <WNS/ldk/FunctionalUnit.hpp> 00037 #include <WNS/ldk/Classifier.hpp> 00038 #include <WNS/node/Node.hpp> 00039 #include <WNS/PowerRatio.hpp> 00040 #include <WNS/CandI.hpp> 00041 #include <WNS/Enum.hpp> 00042 00043 #include <map> 00044 #include <vector> 00045 #include <set> 00046 #include <list> 00047 #include <string> 00048 #include <sstream> 00049 00050 using namespace wns::scheduler; 00051 using namespace wns::scheduler::strategy; 00052 00053 00054 RequestForResource::RequestForResource(ConnectionID _cid, UserID _user, Bits _bits, Bits _queuedBits, bool useHARQ) 00055 : cid(_cid), 00056 user(_user), 00057 bits(_bits), 00058 queuedBits(_queuedBits), 00059 phyModePtr(), // empty means undefined, still open, freely selectable 00060 subChannel(wns::scheduler::subChannelNotFound), 00061 timeSlot(0), 00062 spatialLayer(0), 00063 cqiOnSubChannel(), 00064 useHARQ(useHARQ) 00065 { 00066 } 00067 00068 RequestForResource::~RequestForResource() 00069 { 00070 } 00071 00072 std::string 00073 RequestForResource::toString() const 00074 { 00075 std::stringstream s; 00076 s << "Req(cid="<<cid<<"," << user.getName(); 00077 s <<","<<int(bits)<<"bits (queued "; 00078 s << int(queuedBits) << ")"; 00079 if (phyModePtr!=wns::service::phy::phymode::PhyModeInterfacePtr()) { 00080 s << "," << *phyModePtr; } 00081 if (timeSlot>0) { 00082 s << ",slot=" << timeSlot; } 00083 if (subChannel!=wns::scheduler::subChannelNotFound) { 00084 s << ",sc=" << subChannel; } 00085 s <<")"; 00086 return s.str(); 00087 } 00088 00089 simTimeType 00090 RequestForResource::getDuration() const 00091 { 00092 assure(phyModePtr!=wns::service::phy::phymode::PhyModeInterfacePtr(),"phyMode must be defined for getDuration()"); 00093 double dataRate = phyModePtr->getDataRate(); 00094 return bits / dataRate; 00095 } 00096 00098 00099 RevolvingState::RevolvingState(const strategy::StrategyInput* _strategyInput) 00100 : strategyInput(_strategyInput), 00101 bursts(), 00102 schedulingMap(), 00103 activeConnections(), 00104 grouping(), 00105 currentPriority(0) 00106 { 00107 assure(strategyInput!=NULL,"strategyInput==NULL"); 00108 if (strategyInput->inputSchedulingMap != wns::scheduler::SchedulingMapPtr()) 00109 { 00110 assure(schedulingMap == wns::scheduler::SchedulingMapPtr(),"schedulingMap must be empty before overwriting it"); 00111 // initialize working datastructure with an nonempty schedulingMap 00112 schedulingMap = strategyInput->inputSchedulingMap; 00113 } else { // empty inputSchedulingMap 00114 schedulingMap = strategyInput->getEmptySchedulingMap(); 00115 } 00116 } 00117 00118 RevolvingState::~RevolvingState() 00119 { 00120 strategyInput=NULL; 00121 } 00122 00123 std::string 00124 RevolvingState::toString() const 00125 { 00126 return "(RevolvingState)"; 00127 } 00128 00129 GroupingPtr 00130 RevolvingState::getNewGrouping() 00131 { 00132 grouping = GroupingPtr(new Grouping()); // set member 00133 return grouping; 00134 } 00135 00136 bool 00137 RevolvingState::groupingIsValid() const 00138 { 00139 return (grouping!=GroupingPtr()); 00140 } 00141 00142 bool 00143 RevolvingState::sdmaGroupingIsValid() const 00144 { 00145 return (groupingIsValid() && (strategyInput->getMaxSpatialLayers() > 1)); 00146 } 00147 GroupingPtr 00148 RevolvingState::getGrouping() const 00149 { 00150 //assure(grouping!=GroupingPtr(),"invalid grouping"); 00151 return grouping; 00152 } 00153 00154 void 00155 RevolvingState::setGrouping(GroupingPtr groupingPtr) 00156 { 00157 assure(groupingPtr!=GroupingPtr(),"invalid grouping"); 00158 grouping=groupingPtr; // set member 00159 } 00160 00161 void 00162 RevolvingState::setCurrentPriority(int priority) 00163 { 00164 currentPriority=priority; 00165 } 00166 00167 int 00168 RevolvingState::getCurrentPriority() const 00169 { 00170 return currentPriority; 00171 } 00172 00173 void 00174 RevolvingState::clearMap() 00175 { 00176 bursts = MapInfoCollectionPtr(); 00177 }
1.5.5