![]() |
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 00029 #include <RISE/scenario/mobility/Roadmap.hpp> 00030 #include <RISE/scenario/mobility/roadmap/Map.hpp> 00031 00032 using namespace rise; 00033 using namespace rise::scenario::mobility; 00034 00035 STATIC_FACTORY_REGISTER_WITH_CREATOR( 00036 Roadmap, 00037 MobilityInterface, 00038 "rise.mobility.Roadmap", 00039 wns::PyConfigViewCreator); 00040 00041 00042 Roadmap::Roadmap(const wns::pyconfig::View& mobilityView) : 00043 Mobility(mobilityView), 00044 map(NULL), 00045 user(NULL) 00046 { 00047 RoadmapRegistry& rmr = getRoadmapRegistry(); 00048 00049 std::string mapName = mobilityView.get<wns::pyconfig::View>("roadMap").get<std::string>("name"); 00050 00051 if (rmr.find(mapName) == rmr.end() ) 00052 rmr[mapName] = new roadmap::Map(mobilityView.get<wns::pyconfig::View>("roadMap")); 00053 00054 map = rmr[mapName]; 00055 00056 wns::rng::RNGen* rng = 00057 wns::simulator::getRegistry()->find<wns::rng::RNGen*>("MOBILITY-RNG"); 00058 00059 wns::pyconfig::View velocityConfig = mobilityView.get<wns::pyconfig::View>("userVelocityDist"); 00060 00061 std::string name = velocityConfig.get<std::string>("__plugin__"); 00062 velocityDistribution = 00063 wns::distribution::RNGDistributionFactory::creator(name)->create(rng, velocityConfig); 00064 00065 user = map->createNewUser((*velocityDistribution)()); 00066 00067 this->setPosition(map->getPosition(user)); 00068 00069 startPeriodicTimeout(moveTimeStep, moveTimeStep); 00070 } 00071 00072 Roadmap::~Roadmap() 00073 { 00074 // Don't delete others might be using this ... 00075 // delete map; 00076 delete user; 00077 delete velocityDistribution; 00078 } 00079 00080 void 00081 Roadmap::periodically() 00082 { 00083 this->move(); 00084 } 00085 00086 void 00087 Roadmap::move() 00088 { 00089 wns::Position newPosition = map->getNextPosition(user, moveTimeStep); 00090 this->setPosition(newPosition); 00091 } 00092 00093 Roadmap::RoadmapRegistry& 00094 Roadmap::getRoadmapRegistry() 00095 { 00096 static RoadmapRegistry map; 00097 return map; 00098 }
1.5.5