![]() |
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 <RISE/manager/systemmanager.hpp> 00029 #include <RISE/manager/metasystemmanager.hpp> 00030 #include <RISE/scenario/Scenario.hpp> 00031 #include <RISE/stations/station.hpp> 00032 #include <RISE/RISE.hpp> 00033 #include <WNS/Assure.hpp> 00034 00035 #include <string> 00036 #include <sstream> 00037 #include <vector> 00038 #include <map> 00039 #include <fstream> 00040 00041 using namespace std; 00042 using namespace rise; 00043 00044 SystemManager::SystemManager(const string &aSystemName, 00045 const wns::pyconfig::View& config) 00046 : systemName(aSystemName), 00047 scenario(NULL), 00048 stations(StationContainer()), 00049 pyConfigView(config), 00050 stationId(0), 00051 log(string("SystemManager (")+aSystemName+string(")")) 00052 { 00053 const wns::pyconfig::View& riseConfig = RISE::getPyConfigView(); 00054 MetaSystemManager::getInstance()->attach(this); 00055 if (riseConfig.getView("debug").get<bool>("systemManager")) { 00056 log.switchOn(); 00057 } else { 00058 log.switchOff(); 00059 } 00060 if (pyConfigView.knows("wraparoundShiftVectors") 00061 && !pyConfigView.isNone("wraparoundShiftVectors")) { 00062 int shiftListLength = pyConfigView.len("wraparoundShiftVectors"); 00063 MESSAGE_SINGLE(NORMAL, log, "rise::SystemManager(): "<<shiftListLength<<" wraparoundShiftVectors"); 00064 for(int i=0; i<shiftListLength; i++) { 00065 const wns::pyconfig::View& shiftVectorConfig = pyConfigView.getView("wraparoundShiftVectors", i); 00066 double x = shiftVectorConfig.get<double>("x"); 00067 double y = shiftVectorConfig.get<double>("y"); 00068 wraparoundShiftVector.push_back(wns::geometry::Vector(x,y,0.0)); 00069 MESSAGE_SINGLE(NORMAL, log, "rise::SystemManager(): wraparoundShift["<<i<<"]=("<<x<<","<<y<<")"); 00070 } 00071 } 00072 } 00073 00074 SystemManager::~SystemManager() 00075 { 00076 MetaSystemManager::getInstance()->detach(this); 00077 if (scenario != NULL) delete scenario; 00078 } 00079 00080 wns::pyconfig::View 00081 SystemManager::getConfigFile() const 00082 { 00083 return pyConfigView; 00084 } 00085 00086 const SystemManager::WraparoundShiftVectorContainer* 00087 SystemManager::getWraparoundShiftVectors() const 00088 { 00089 return &wraparoundShiftVector; 00090 } 00091 00092 SystemManager::StationContainer SystemManager::getAllStations() const 00093 { 00094 return stations; 00095 } 00096 00097 string SystemManager::getSystemName() const 00098 { 00099 return systemName; 00100 } 00101 00102 scenario::Scenario* SystemManager::getScenario() const 00103 { 00104 assure(scenario, "must be non-NULL"); 00105 return scenario; 00106 } 00107 00108 void SystemManager::addStation(Station* station) 00109 { 00110 assert(find(stations.begin(), stations.end(), station)==stations.end()); 00111 station->initialize(); 00112 station->setStationId(stationId++); 00113 stations.push_back(station); 00114 } 00115 00116 void SystemManager::createScenario() 00117 { 00118 MESSAGE_BEGIN(NORMAL, log, m, "Creating Scenario"); 00119 MESSAGE_END(); 00120 scenario = new scenario::Scenario(pyConfigView.getView("Scenario")); 00121 } 00122 00123
1.5.5