![]() |
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 <LTE/timing/partitioning/Partition.hpp> 00029 00030 #include <iostream> 00031 00032 using namespace lte::timing::partitioning; 00033 00034 Partition::Partition(const wns::pyconfig::View& config) : 00035 numberOfSubChannels(config.get<int>("numberOfSubChannels")), 00036 grouping(), 00037 dedication(), 00038 logger(config.get("logger")) 00039 { 00040 MESSAGE_SINGLE(NORMAL, logger,"Partition::Partition():"); 00041 for (int gg = 0; gg<config.len("groups.keys()"); ++gg) 00042 { 00043 std::stringstream dictEntry; 00044 dictEntry << "groups[groups.keys()[" << gg << "]]"; 00045 00046 wns::pyconfig::View groupView = config.get(dictEntry.str()); 00047 00048 uint32_t groupNumber = groupView.get<uint32_t>("number"); 00049 00050 SubChannelRangeSet group; 00051 usableSubChannelsPerGroup[groupNumber] = wns::scheduler::UsableSubChannelVector(numberOfSubChannels,false); 00052 assure(numberOfSubChannels==usableSubChannelsPerGroup[groupNumber].size(),"size error"); 00053 00054 for (int bb = 0; bb<groupView.len("bands"); ++bb) 00055 { 00056 wns::pyconfig::View bandView = groupView.get("bands",bb); 00057 00058 int fMin = bandView.get<int>("fMin"); 00059 int fMax = bandView.get<int>("fMax"); 00060 00061 SubChannelRange band = SubChannelRange::FromIncluding(fMin).ToIncluding(fMax); 00062 group.push_back(band); 00063 assure(fMax<numberOfSubChannels,"fMax="<<fMax<<" must be < numberOfSubChannels="<<numberOfSubChannels); 00064 for(int subChannel=fMin; subChannel<=fMax; ++subChannel) 00065 { 00066 usableSubChannelsPerGroup[groupNumber][subChannel] = true; 00067 } 00068 } 00069 grouping[groupNumber] = group; 00070 dedication[groupNumber] = groupView.get<std::string>("dedication"); 00071 //MESSAGE_SINGLE(NORMAL, logger,"groups["<<gg<<"="<<dictEntry.str()<<"]: groupNumber="<<groupNumber<<", dedication="<<dedication[groupNumber]); 00072 MESSAGE_SINGLE(NORMAL, logger,"groups["<<gg<<"]: groupNumber="<<groupNumber<<", dedication="<<dedication[groupNumber]); 00073 } 00074 MESSAGE_SINGLE(NORMAL, logger, "Partition = "<<doToString()); 00075 } 00076 00077 Partition::~Partition() 00078 {} 00079 00080 bool 00081 Partition::hasResources(uint32_t groupNumber) const 00082 { 00083 //return (grouping.find(groupNumber) != grouping.end()); 00084 return (usableSubChannelsPerGroup.find(groupNumber) != usableSubChannelsPerGroup.end()); 00085 } 00086 00087 lte::timing::partitioning::SubChannelRangeSet 00088 Partition::getFreeResources(uint32_t groupNumber) const 00089 { 00090 if (grouping.find(groupNumber) == grouping.end()) 00091 assure(false, "Requested resource info for unknown group!"); 00092 00093 return grouping.find(groupNumber)->second; 00094 } 00095 00096 // return const reference only (efficient); origin does not change 00097 wns::scheduler::UsableSubChannelVector 00098 Partition::getUsableSubChannels(uint32_t groupNumber) 00099 { 00100 if (usableSubChannelsPerGroup.find(groupNumber) != usableSubChannelsPerGroup.end()) 00101 { 00102 return usableSubChannelsPerGroup[groupNumber]; 00103 } else { 00104 MESSAGE_SINGLE(NORMAL, logger, "WARNING: cannot find usableSubChannelsPerGroup[groupNumber="<<groupNumber<<"]"); 00105 static wns::scheduler::UsableSubChannelVector empty(numberOfSubChannels,false); 00106 //=wns::scheduler::UsableSubChannelVector(numberOfSubChannels,false); 00107 return empty; 00108 } 00109 } 00110 00111 std::string 00112 Partition::getDedication(uint32_t groupNumber) const 00113 { 00114 if (dedication.find(groupNumber) == dedication.end()) 00115 assure(false, "Requested resource info for unknown group!"); 00116 00117 return dedication.find(groupNumber)->second; 00118 } 00119 00120 std::string 00121 Partition::doToString() const 00122 { 00123 std::stringstream s; 00124 s << "---\n"; 00125 for (GroupContainer::const_iterator iter = grouping.begin(); 00126 iter != grouping.end(); 00127 ++iter) 00128 { 00129 s << "GroupNumber=" << iter->first << ": Dedication=" << getDedication(iter->first) << ", sc="; 00130 for (lte::timing::partitioning::SubChannelRangeSet::const_iterator sciter = iter->second.begin(); 00131 sciter != iter->second.end(); 00132 ++sciter) 00133 { 00134 s << sciter->min() << ".." << sciter->max(); 00135 if (sciter != iter->second.end()) s << std::endl; 00136 } 00137 } 00138 return s.str(); 00139 } 00140 00141
1.5.5