![]() |
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 "RelayMetaGrouper.hpp" 00029 #include <WNS/scheduler/SchedulerTypes.hpp> 00030 #include <WNS/pyconfig/View.hpp> 00031 #include <WNS/StaticFactory.hpp> 00032 00033 using namespace wns::scheduler; 00034 using namespace wns::scheduler::grouper; 00035 00036 STATIC_FACTORY_REGISTER_WITH_CREATOR( 00037 RelayMetaGrouper, 00038 GroupingProviderInterface, 00039 "RelayMetaGrouper", 00040 wns::PyConfigViewCreator); 00041 00042 00043 RelayMetaGrouper::RelayMetaGrouper(const wns::pyconfig::View& config) : 00044 SpatialGrouper(config), 00045 internalStrategy(NULL) 00046 { 00047 // Create internal strategy from Static Factory 00048 std::string grouperName = config.get<std::string>("internalStrategy.nameInGrouperFactory"); 00049 SpatialGrouperCreator* grouperCreator = wns::scheduler::grouper::SpatialGrouperFactory::creator(grouperName); 00050 internalStrategy = grouperCreator->create(config.get<wns::pyconfig::View>("internalStrategy")); 00051 assure(internalStrategy, "Internal Strategy creation failed"); 00052 } 00053 00054 RelayMetaGrouper::~RelayMetaGrouper() 00055 { 00056 delete internalStrategy; 00057 } 00058 00059 Grouping 00060 RelayMetaGrouper::getTxGrouping(const UserSet activeUsers, int maxBeams) 00061 { 00062 // sort users into Relays and Terminals 00063 UserSet relayStations; 00064 UserSet userTerminals; 00065 for ( UserSet::const_iterator iter = activeUsers.begin(); 00066 iter != activeUsers.end(); ++iter) 00067 { 00068 if ( colleagues.registry->getStationType(*iter) == wns::service::dll::StationTypes::FRS() ) 00069 relayStations.insert(*iter); 00070 else 00071 userTerminals.insert(*iter); 00072 } 00073 00074 // Group them separately 00075 Grouping relayGroups = internalStrategy->getTxGrouping(relayStations, maxBeams); 00076 Grouping userGroups = internalStrategy->getTxGrouping(userTerminals, maxBeams); 00077 00078 // Join the two Groupings 00079 Grouping result = joinGroupings(relayGroups, userGroups); 00080 return result; 00081 } 00082 00083 Grouping 00084 RelayMetaGrouper::getRxGrouping(const UserSet activeUsers, int maxBeams) 00085 { 00086 // sort users into Relays and Terminals 00087 UserSet relayStations; 00088 UserSet userTerminals; 00089 for ( UserSet::const_iterator iter = activeUsers.begin(); 00090 iter != activeUsers.end(); ++iter) 00091 { 00092 if ( colleagues.registry->getStationType(*iter) == wns::service::dll::StationTypes::FRS() ) 00093 relayStations.insert(*iter); 00094 else 00095 userTerminals.insert(*iter); 00096 } 00097 00098 // Group them separately 00099 Grouping relayGroups = internalStrategy->getRxGrouping(relayStations, maxBeams); 00100 Grouping userGroups = internalStrategy->getRxGrouping(userTerminals, maxBeams); 00101 00102 // Join the two Groupings 00103 Grouping result = joinGroupings(relayGroups, userGroups); 00104 return result; 00105 } 00106 00107 void 00108 RelayMetaGrouper::setColleagues(RegistryProxyInterface* _registry) 00109 { 00110 colleagues.registry = _registry; 00111 internalStrategy->setColleagues(_registry); 00112 } 00113 00114 void 00115 RelayMetaGrouper::setFriends(wns::service::phy::ofdma::BFInterface* _ofdmaProvider) 00116 { 00117 internalStrategy->setFriends(_ofdmaProvider); 00118 } 00119 00120 Grouping 00121 RelayMetaGrouper::joinGroupings(const Grouping& a, const Grouping& b) const 00122 { 00123 Grouping result; 00124 result.patterns = a.patterns; 00125 result.patterns.insert(b.patterns.begin(), b.patterns.end()); 00126 00127 result.groups = a.groups; 00128 result.groups.insert(result.groups.end(), b.groups.begin(), b.groups.end()); 00129 00130 std::size_t numGroupsInA = a.groups.size(); 00131 00132 result.userGroupNumber = a.userGroupNumber; 00133 00134 for (std::map<UserID,int>::const_iterator iter = b.userGroupNumber.begin(); 00135 iter != b.userGroupNumber.end(); 00136 ++iter) 00137 { 00138 // add offset on all groupNumbers from b 00139 result.userGroupNumber[iter->first] = iter->second + numGroupsInA; 00140 } 00141 00142 return result; 00143 }
1.5.5