User Manual, Developers Guide and API Documentation

StrategyInterface.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-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/CallBackInterface.hpp>
00029 #include <WNS/scheduler/strategy/StrategyInterface.hpp>
00030 
00031 using namespace wns::scheduler;
00032 using namespace wns::scheduler::strategy;
00033 
00034 // interface for master scheduling (old interface)
00035 StrategyInput::StrategyInput(int _fChannels,
00036                              double _slotLength,
00037                              int _numberOfTimeSlots,
00038                              int _maxSpatialLayers,
00039                              CallBackInterface* _callBackObject)
00040     : fChannels(_fChannels),
00041       slotLength(_slotLength),
00042       numberOfTimeSlots(_numberOfTimeSlots), // TODO
00043       beamforming(_maxSpatialLayers>1), // in the old strategies we assume "beamforming" if maxSpatialLayers>1.
00044       maxSpatialLayers(_maxSpatialLayers),
00045       callBackObject(_callBackObject),
00046       mapInfoEntryFromMaster(), // empty SmartPtr
00047       frameNr(-1)
00048 {
00049     // these two checks are equivalent:
00050     assure(mapInfoEntryFromMaster.getPtr()==NULL,"SmartPtr must be initialized with NULL");
00051     assure(mapInfoEntryFromMaster==MapInfoEntryPtr(),"SmartPtr must be initialized with NULL");
00052 }
00053 
00054 // interface for slave scheduling
00055 StrategyInput::StrategyInput(MapInfoEntryPtr _mapInfoEntryFromMaster,
00056                              CallBackInterface* _callBackObject)
00057     : fChannels(1),
00058       slotLength(_mapInfoEntryFromMaster->end - _mapInfoEntryFromMaster->start),
00059       beamforming(false),
00060       numberOfTimeSlots(1),
00061       maxSpatialLayers(1),
00062       callBackObject(_callBackObject),
00063       mapInfoEntryFromMaster(_mapInfoEntryFromMaster), // SmartPtr
00064       inputSchedulingMap(), // SmartPtr
00065       frameNr(-1)
00066 {
00067     // these two checks are equivalent:
00068     assure(mapInfoEntryFromMaster.getPtr()!=NULL,"SmartPtr must be valid");
00069     assure(mapInfoEntryFromMaster!=MapInfoEntryPtr(),"SmartPtr must be valid");
00070 }
00071 
00072 // generic interface for master or slave scheduling
00073 StrategyInput::StrategyInput(int _fChannels,
00074                              double _slotLength,
00075                              int _numberOfTimeSlots,
00076                              int _maxSpatialLayers,
00077                              MapInfoEntryPtr _mapInfoEntryFromMaster,
00078                              CallBackInterface* _callBackObject)
00079     : fChannels(_fChannels),
00080       slotLength(_slotLength),
00081       numberOfTimeSlots(_numberOfTimeSlots),
00082       beamforming(_maxSpatialLayers>1), // in the old strategies we assume "beamforming" if maxSpatialLayers>1.
00083       maxSpatialLayers(_maxSpatialLayers),
00084       callBackObject(_callBackObject),
00085       mapInfoEntryFromMaster(_mapInfoEntryFromMaster), // SmartPtr
00086       frameNr(-1)
00087 {
00088 }
00089 
00090 StrategyInput::~StrategyInput()
00091 {
00092 }
00093 
00094 // set optional parameter:
00095 void
00096 StrategyInput::setFrameNr(int _frameNr)
00097 {
00098     assure(_frameNr>=0,"invalid frameNr="<<frameNr);
00099     frameNr=_frameNr;
00100 }
00101 
00102 bool
00103 StrategyInput::frameNrIsValid() const
00104 {
00105     return (frameNr>=0) ? true:false;
00106 }
00107 
00108 void
00109 StrategyInput::setDefaultPhyMode(wns::service::phy::phymode::PhyModeInterfacePtr _phyModePtr)
00110 {
00111     defaultPhyModePtr = _phyModePtr; //_phyModePtr->clone();
00112 }
00113 
00114 void
00115 StrategyInput::setDefaultTxPower(wns::Power _txPower)
00116 {
00117     defaultTxPower = _txPower;
00118 }
00119 
00120 std::string
00121 StrategyInput::toString() const
00122 {
00123     std::stringstream s;
00124     s << "StrategyInput():";
00125     s << "\tfChannels="<<fChannels<<std::endl;
00126     s << "\tslotLength="<<slotLength<<std::endl;
00127     s << "\ttimeSlots="<<numberOfTimeSlots<<std::endl;
00128     s << "\tmaxSpatialLayers="<<maxSpatialLayers<<std::endl;
00129     s << "\tcallBackObject="<<callBackObject<<std::endl;
00130     //s << "\t"<<std::endl;
00131     return s.str();
00132 };
00133 
00134 wns::scheduler::SchedulingMapPtr
00135 StrategyInput::getEmptySchedulingMap() const
00136 {
00137     // make SmartPtr here
00138     SchedulingMapPtr schedulingMap = wns::scheduler::SchedulingMapPtr(
00139         new wns::scheduler::SchedulingMap(slotLength, fChannels, numberOfTimeSlots, maxSpatialLayers, frameNr));
00140     return schedulingMap;
00141 }
00142 
00143 wns::scheduler::SchedulingMapPtr
00144 StrategyInput::getInputSchedulingMap() const
00145 {
00146     return inputSchedulingMap;
00147 }
00148 
00149 void
00150 StrategyInput::setInputSchedulingMap(wns::scheduler::SchedulingMapPtr _inputSchedulingMap)
00151 {
00152     inputSchedulingMap = _inputSchedulingMap;
00153 }
00154 
00156 
00158 StrategyResult::StrategyResult(wns::scheduler::SchedulingMapPtr _schedulingMap,
00159                                wns::scheduler::MapInfoCollectionPtr _bursts)
00160     : schedulingMap(_schedulingMap),
00161       bursts(_bursts),
00162       sdmaGrouping() // empty SmartPtr
00163 {
00164 }
00165 
00167 StrategyResult::StrategyResult(wns::scheduler::SchedulingMapPtr _schedulingMap,
00168                                wns::scheduler::MapInfoCollectionPtr _bursts,
00169                                wns::scheduler::GroupingPtr _sdmaGrouping)
00170     : schedulingMap(_schedulingMap),
00171       bursts(_bursts),
00172       sdmaGrouping(_sdmaGrouping)
00173 {
00174 }
00175 
00176 StrategyResult::~StrategyResult()
00177 {
00178     // members are SmartPtr's. No need to care.
00179 }
00180 
00181 int
00182 StrategyResult::getNumberOfCompoundsInBursts() const
00183 {
00184     int count=0;
00185     for ( MapInfoCollection::const_iterator iterBurst = bursts->begin();
00186           iterBurst != bursts->end(); ++iterBurst)
00187     {
00188         count += (*iterBurst)->compounds.size();
00189     }
00190     return count;
00191 }
00192 
00193 // this is called by the UL master scheduler, because there are no "real" compounds (just fakes).
00194 void
00195 StrategyResult::deleteCompoundsInBursts()
00196 {
00197     for ( MapInfoCollection::const_iterator iterBurst = bursts->begin();
00198           iterBurst != bursts->end(); ++iterBurst)
00199     {
00200         (*iterBurst)->compounds.clear();
00201     }
00202     schedulingMap->deleteCompounds();
00203 }
00204 
00205 std::string
00206 StrategyResult::toString() const
00207 {
00208     std::stringstream s;
00209     s << "StrategyResult():";
00210     s << schedulingMap->doToString();
00211     return s.str();
00212 }
00213 
00214 float
00215 StrategyResult::getResourceUsage() const
00216 {
00217     return schedulingMap->getResourceUsage();
00218 }
00219 

Generated on Sat May 26 03:31:51 2012 for openWNS by  doxygen 1.5.5