|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00012 // The simulated network and simulation perfomer 00013 /****************************************************************************/ 00014 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00015 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00016 /****************************************************************************/ 00017 // 00018 // This file is part of SUMO. 00019 // SUMO is free software: you can redistribute it and/or modify 00020 // it under the terms of the GNU General Public License as published by 00021 // the Free Software Foundation, either version 3 of the License, or 00022 // (at your option) any later version. 00023 // 00024 /****************************************************************************/ 00025 00026 00027 // =========================================================================== 00028 // included modules 00029 // =========================================================================== 00030 #ifdef _MSC_VER 00031 #include <windows_config.h> 00032 #else 00033 #include <config.h> 00034 #endif 00035 00036 #ifdef HAVE_VERSION_H 00037 #include <version.h> 00038 #endif 00039 00040 #include <iostream> 00041 #include <sstream> 00042 #include <typeinfo> 00043 #include <algorithm> 00044 #include <cassert> 00045 #include <vector> 00046 #include <sstream> 00047 #include <utils/common/UtilExceptions.h> 00048 #include "MSNet.h" 00049 #include "MSPersonControl.h" 00050 #include "MSEdgeControl.h" 00051 #include "MSJunctionControl.h" 00052 #include "MSInsertionControl.h" 00053 #include "MSEventControl.h" 00054 #include "MSEdge.h" 00055 #include "MSJunction.h" 00056 #include "MSJunctionLogic.h" 00057 #include "MSLane.h" 00058 #include "MSVehicleTransfer.h" 00059 #include "MSRoute.h" 00060 #include "MSRouteLoaderControl.h" 00061 #include "traffic_lights/MSTLLogicControl.h" 00062 #include "MSVehicleControl.h" 00063 #include <utils/common/MsgHandler.h> 00064 #include <utils/common/ToString.h> 00065 #include <microsim/output/MSDetectorControl.h> 00066 #include <microsim/MSVehicleTransfer.h> 00067 #include "traffic_lights/MSTrafficLightLogic.h" 00068 #include <utils/shapes/Polygon.h> 00069 #include <utils/shapes/ShapeContainer.h> 00070 #include "output/MSXMLRawOut.h" 00071 #include <utils/iodevices/OutputDevice.h> 00072 #include <utils/common/SysUtils.h> 00073 #include <utils/common/WrappingCommand.h> 00074 #include <utils/options/OptionsCont.h> 00075 #include "MSGlobals.h" 00076 #include <utils/geom/GeoConvHelper.h> 00077 #include <ctime> 00078 #include "MSPerson.h" 00079 #include "MSEdgeWeightsStorage.h" 00080 00081 00082 #ifdef _MESSAGES 00083 #include "MSMessageEmitter.h" 00084 #endif 00085 00086 #ifdef HAVE_MESOSIM 00087 #include <mesosim/MELoop.h> 00088 #include <utils/iodevices/BinaryInputDevice.h> 00089 #endif 00090 00091 #ifndef NO_TRACI 00092 #include <traci-server/TraCIServer.h> 00093 #endif 00094 00095 #ifdef CHECK_MEMORY_LEAKS 00096 #include <foreign/nvwa/debug_new.h> 00097 #endif // CHECK_MEMORY_LEAKS 00098 00099 00100 // =========================================================================== 00101 // static member definitions 00102 // =========================================================================== 00103 MSNet* MSNet::myInstance = 0; 00104 00105 00106 // =========================================================================== 00107 // member method definitions 00108 // =========================================================================== 00109 // --------------------------------------------------------------------------- 00110 // MSNet::EdgeWeightsProxi - methods 00111 // --------------------------------------------------------------------------- 00112 SUMOReal 00113 MSNet::EdgeWeightsProxi::getEffort(const MSEdge* const e, 00114 const SUMOVehicle* const v, 00115 SUMOReal t) const { 00116 SUMOReal value; 00117 if (myVehicleKnowledge.retrieveExistingEffort(e, v, t, value)) { 00118 return value; 00119 } 00120 if (myNetKnowledge.retrieveExistingEffort(e, v, t, value)) { 00121 return value; 00122 } 00123 return 0; 00124 } 00125 00126 00127 SUMOReal 00128 MSNet::EdgeWeightsProxi::getTravelTime(const MSEdge* const e, 00129 const SUMOVehicle* const v, 00130 SUMOReal t) const { 00131 SUMOReal value; 00132 if (myVehicleKnowledge.retrieveExistingTravelTime(e, v, t, value)) { 00133 return value; 00134 } 00135 if (myNetKnowledge.retrieveExistingTravelTime(e, v, t, value)) { 00136 return value; 00137 } 00138 const MSLane* const l = e->getLanes()[0]; 00139 return l->getLength() / l->getMaxSpeed(); 00140 } 00141 00142 00143 00144 // --------------------------------------------------------------------------- 00145 // MSNet - methods 00146 // --------------------------------------------------------------------------- 00147 MSNet* 00148 MSNet::getInstance(void) { 00149 if (myInstance != 0) { 00150 return myInstance; 00151 } 00152 throw ProcessError("A network was not yet constructed."); 00153 } 00154 00155 00156 MSNet::MSNet(MSVehicleControl* vc, MSEventControl* beginOfTimestepEvents, 00157 MSEventControl* endOfTimestepEvents, MSEventControl* insertionEvents, 00158 ShapeContainer* shapeCont) { 00159 if (myInstance != 0) { 00160 throw ProcessError("A network was already constructed."); 00161 } 00162 OptionsCont& oc = OptionsCont::getOptions(); 00163 myStep = string2time(oc.getString("begin")); 00164 myLogExecutionTime = !oc.getBool("no-duration-log"); 00165 myLogStepNumber = !oc.getBool("no-step-log"); 00166 myTooManyVehicles = oc.getInt("max-num-vehicles"); 00167 myInserter = new MSInsertionControl(*vc, string2time(oc.getString("max-depart-delay")), oc.getBool("sloppy-insert")); 00168 myVehicleControl = vc; 00169 myDetectorControl = new MSDetectorControl(); 00170 myEdges = 0; 00171 myJunctions = 0; 00172 myRouteLoaders = 0; 00173 myLogics = 0; 00174 myPersonControl = 0; 00175 myEdgeWeights = 0; 00176 myShapeContainer = shapeCont == 0 ? new ShapeContainer() : shapeCont; 00177 00178 myBeginOfTimestepEvents = beginOfTimestepEvents; 00179 myEndOfTimestepEvents = endOfTimestepEvents; 00180 myInsertionEvents = insertionEvents; 00181 00182 #ifdef HAVE_MESOSIM 00183 if (MSGlobals::gUseMesoSim) { 00184 MSGlobals::gMesoNet = new MELoop(string2time(oc.getString("meso-recheck"))); 00185 } 00186 #endif 00187 myInstance = this; 00188 } 00189 00190 00191 00192 00193 void 00194 MSNet::closeBuilding(MSEdgeControl* edges, MSJunctionControl* junctions, 00195 MSRouteLoaderControl* routeLoaders, 00196 MSTLLogicControl* tlc, 00197 std::vector<SUMOTime> stateDumpTimes, 00198 std::vector<std::string> stateDumpFiles) { 00199 myEdges = edges; 00200 myJunctions = junctions; 00201 myRouteLoaders = routeLoaders; 00202 myLogics = tlc; 00203 // save the time the network state shall be saved at 00204 myStateDumpTimes = stateDumpTimes; 00205 myStateDumpFiles = stateDumpFiles; 00206 00207 // set requests/responses 00208 myJunctions->postloadInitContainer(); 00209 00210 // initialise performance computation 00211 if (myLogExecutionTime) { 00212 mySimBeginMillis = SysUtils::getCurrentMillis(); 00213 } 00214 } 00215 00216 00217 MSNet::~MSNet() { 00218 // delete controls 00219 delete myJunctions; 00220 delete myDetectorControl; 00221 // delete mean data 00222 delete myEdges; 00223 delete myInserter; 00224 delete myLogics; 00225 delete myRouteLoaders; 00226 delete myVehicleControl; 00227 if (myPersonControl != 0) { 00228 delete myPersonControl; 00229 } 00230 delete myShapeContainer; 00231 #ifdef _MESSAGES 00232 myMsgEmitter.clear(); 00233 msgEmitVec.clear(); 00234 #endif 00235 #ifdef HAVE_MESOSIM 00236 if (MSGlobals::gUseMesoSim) { 00237 delete MSGlobals::gMesoNet; 00238 } 00239 #endif 00240 delete myBeginOfTimestepEvents; 00241 delete myEndOfTimestepEvents; 00242 delete myInsertionEvents; 00243 delete myEdgeWeights; 00244 clearAll(); 00245 myInstance = 0; 00246 } 00247 00248 00249 int 00250 MSNet::simulate(SUMOTime start, SUMOTime stop) { 00251 // the simulation loop 00252 MSNet::SimulationState state = SIMSTATE_RUNNING; 00253 myStep = start; 00254 #ifndef NO_TRACI 00255 #ifdef HAVE_PYTHON 00256 if (OptionsCont::getOptions().isSet("python-script")) { 00257 traci::TraCIServer::runEmbedded(OptionsCont::getOptions().getString("python-script")); 00258 WRITE_MESSAGE("Simulation End: Script ended"); 00259 closeSimulation(start); 00260 return 0; 00261 } 00262 #endif 00263 #endif 00264 while (state == SIMSTATE_RUNNING) { 00265 if (myLogStepNumber) { 00266 preSimStepOutput(); 00267 } 00268 simulationStep(); 00269 if (myLogStepNumber) { 00270 postSimStepOutput(); 00271 } 00272 state = simulationState(stop); 00273 #ifndef NO_TRACI 00274 if (state != SIMSTATE_RUNNING) { 00275 if (OptionsCont::getOptions().getInt("remote-port") != 0 && !traci::TraCIServer::wasClosed()) { 00276 state = SIMSTATE_RUNNING; 00277 } 00278 } 00279 #endif 00280 } 00281 WRITE_MESSAGE("Simulation End: " + getStateMessage(state)); 00282 // exit simulation loop 00283 closeSimulation(start); 00284 return 0; 00285 } 00286 00287 00288 void 00289 MSNet::closeSimulation(SUMOTime start) { 00290 if (myLogExecutionTime) { 00291 long duration = SysUtils::getCurrentMillis() - mySimBeginMillis; 00292 std::ostringstream msg; 00293 msg << "Performance: " << "\n" << " Duration: " << duration << " ms" << "\n"; 00294 if (duration != 0) { 00295 msg << " Real time factor: " << ((SUMOReal)(myStep - start) * 1000. / (SUMOReal)duration) << "\n"; 00296 msg.setf(std::ios::fixed , std::ios::floatfield); // use decimal format 00297 msg.setf(std::ios::showpoint); // print decimal point 00298 msg << " UPS: " << ((SUMOReal) myVehiclesMoved * 1000. / (SUMOReal) duration) << "\n"; 00299 } 00300 msg << "Vehicles: " << "\n" 00301 << " Emitted: " << myVehicleControl->getDepartedVehicleNo() << "\n" 00302 << " Running: " << myVehicleControl->getRunningVehicleNo() << "\n" 00303 << " Waiting: " << myInserter->getWaitingVehicleNo() << "\n"; 00304 WRITE_MESSAGE(msg.str()); 00305 } 00306 myDetectorControl->close(myStep); 00307 #ifndef NO_TRACI 00308 traci::TraCIServer::close(); 00309 #endif 00310 } 00311 00312 00313 void 00314 MSNet::simulationStep() { 00315 #ifndef NO_TRACI 00316 traci::TraCIServer::processCommandsUntilSimStep(myStep); 00317 #endif 00318 // execute beginOfTimestepEvents 00319 if (myLogExecutionTime) { 00320 mySimStepBegin = SysUtils::getCurrentMillis(); 00321 } 00322 #ifdef HAVE_MESOSIM 00323 // netstate output 00324 std::vector<SUMOTime>::iterator timeIt = find(myStateDumpTimes.begin(), myStateDumpTimes.end(), myStep); 00325 if (timeIt != myStateDumpTimes.end()) { 00326 const int dist = distance(myStateDumpTimes.begin(), timeIt); 00327 std::ofstream strm(myStateDumpFiles[dist].c_str(), std::fstream::out | std::fstream::binary); 00328 saveState(strm); 00329 } 00330 #endif 00331 myBeginOfTimestepEvents->execute(myStep); 00332 if (MSGlobals::gCheck4Accidents) { 00333 myEdges->detectCollisions(myStep); 00334 } 00335 // check whether the tls programs need to be switched 00336 myLogics->check2Switch(myStep); 00337 // set the signals 00338 myLogics->setTrafficLightSignals(myStep); 00339 00340 #ifdef HAVE_MESOSIM 00341 if (MSGlobals::gUseMesoSim) { 00342 MSGlobals::gMesoNet->simulate(myStep); 00343 } else { 00344 #endif 00345 00346 // assure all lanes with vehicles are 'active' 00347 myEdges->patchActiveLanes(); 00348 00349 // move vehicles 00350 // precompute possible positions for vehicles that do interact with 00351 // their lane's end 00352 myEdges->moveCritical(myStep); 00353 00354 // move vehicles which do interact with their lane's end 00355 // (it is now known whether they may drive 00356 myEdges->moveFirst(myStep); 00357 if (MSGlobals::gCheck4Accidents) { 00358 myEdges->detectCollisions(myStep); 00359 } 00360 00361 // Vehicles change Lanes (maybe) 00362 myEdges->changeLanes(myStep); 00363 00364 if (MSGlobals::gCheck4Accidents) { 00365 myEdges->detectCollisions(myStep); 00366 } 00367 #ifdef HAVE_MESOSIM 00368 } 00369 #endif 00370 // load routes 00371 myRouteLoaders->loadNext(myStep); 00372 00373 // persons 00374 if (myPersonControl != 0) { 00375 myPersonControl->checkArrivedPersons(this, myStep); 00376 } 00377 // emit Vehicles 00378 myInsertionEvents->execute(myStep); 00379 myInserter->emitVehicles(myStep); 00380 if (MSGlobals::gCheck4Accidents) { 00381 myEdges->detectCollisions(myStep); 00382 } 00383 MSVehicleTransfer::getInstance()->checkInsertions(myStep); 00384 00385 // execute endOfTimestepEvents 00386 myEndOfTimestepEvents->execute(myStep); 00387 00388 // update and write (if needed) detector values 00389 writeOutput(); 00390 00391 if (myLogExecutionTime) { 00392 mySimStepEnd = SysUtils::getCurrentMillis(); 00393 mySimStepDuration = mySimStepEnd - mySimStepBegin; 00394 myVehiclesMoved += myVehicleControl->getRunningVehicleNo(); 00395 } 00396 myStep += DELTA_T; 00397 } 00398 00399 00400 MSNet::SimulationState 00401 MSNet::simulationState(SUMOTime stopTime) const { 00402 if (myTooManyVehicles > 0 && (int) myVehicleControl->getRunningVehicleNo() > myTooManyVehicles) { 00403 return SIMSTATE_TOO_MANY_VEHICLES; 00404 } 00405 #ifndef NO_TRACI 00406 if (traci::TraCIServer::wasClosed()) { 00407 return SIMSTATE_CONNECTION_CLOSED; 00408 } 00409 if (stopTime < 0 && OptionsCont::getOptions().getInt("remote-port") == 0) { 00410 #else 00411 if (stopTime < 0) { 00412 #endif 00413 if (myInsertionEvents->isEmpty() 00414 && (myVehicleControl->getActiveVehicleCount() == 0) 00415 && (myInserter->getPendingFlowCount() == 0) 00416 && (myPersonControl == 0 || !myPersonControl->hasPedestrians())) { 00417 if (myPersonControl) { 00418 myPersonControl->abortWaiting(); 00419 } 00420 myVehicleControl->abortWaiting(); 00421 return SIMSTATE_NO_FURTHER_VEHICLES; 00422 } 00423 } 00424 if (stopTime >= 0 && myStep >= stopTime) { 00425 return SIMSTATE_END_STEP_REACHED; 00426 } 00427 return SIMSTATE_RUNNING; 00428 } 00429 00430 00431 std::string 00432 MSNet::getStateMessage(MSNet::SimulationState state) { 00433 switch (state) { 00434 case MSNet::SIMSTATE_RUNNING: 00435 return ""; 00436 case MSNet::SIMSTATE_END_STEP_REACHED: 00437 return "The final simulation step has been reached."; 00438 case MSNet::SIMSTATE_NO_FURTHER_VEHICLES: 00439 return "All vehicles have left the simulation."; 00440 case MSNet::SIMSTATE_CONNECTION_CLOSED: 00441 return "TraCI requested termination."; 00442 case MSNet::SIMSTATE_ERROR_IN_SIM: 00443 return "An error occured (see log)."; 00444 case MSNet::SIMSTATE_TOO_MANY_VEHICLES: 00445 return "Too many vehicles."; 00446 default: 00447 return "Unknown reason."; 00448 } 00449 } 00450 00451 00452 void 00453 MSNet::clearAll() { 00454 // clear container 00455 MSEdge::clear(); 00456 MSLane::clear(); 00457 MSRoute::clear(); 00458 delete MSVehicleTransfer::getInstance(); 00459 } 00460 00461 00462 SUMOTime 00463 MSNet::getCurrentTimeStep() const { 00464 return myStep; 00465 } 00466 00467 00468 void 00469 MSNet::writeOutput() { 00470 // update detector values 00471 myDetectorControl->updateDetectors(myStep); 00472 // check state dumps 00473 if (OptionsCont::getOptions().isSet("netstate-dump")) { 00474 MSXMLRawOut::write(OutputDevice::getDeviceByOption("netstate-dump"), *myEdges, myStep); 00475 } 00476 // emission output 00477 if (OptionsCont::getOptions().isSet("summary-output")) { 00478 OutputDevice& od = OutputDevice::getDeviceByOption("summary"); 00479 od << " <step time=\"" << time2string(myStep) << "\" " 00480 << "loaded=\"" << myVehicleControl->getLoadedVehicleNo() << "\" " 00481 << "emitted=\"" << myVehicleControl->getDepartedVehicleNo() << "\" " 00482 << "running=\"" << myVehicleControl->getRunningVehicleNo() << "\" " 00483 << "waiting=\"" << myInserter->getWaitingVehicleNo() << "\" " 00484 << "ended=\"" << myVehicleControl->getEndedVehicleNo() << "\" " 00485 << "meanWaitingTime=\""; 00486 myVehicleControl->printMeanWaitingTime(od); 00487 od << "\" meanTravelTime=\""; 00488 myVehicleControl->printMeanTravelTime(od); 00489 od << "\" "; 00490 if (myLogExecutionTime) { 00491 od << "duration=\"" << mySimStepDuration << "\" "; 00492 } 00493 od << "/>\n"; 00494 } 00495 // write detector values 00496 myDetectorControl->writeOutput(myStep + DELTA_T, false); 00497 } 00498 00499 00500 bool 00501 MSNet::logSimulationDuration() const { 00502 return myLogExecutionTime; 00503 } 00504 00505 00506 #ifdef HAVE_MESOSIM 00507 void 00508 MSNet::saveState(std::ostream& os) { 00509 FileHelpers::writeString(os, VERSION_STRING); 00510 FileHelpers::writeUInt(os, sizeof(size_t)); 00511 FileHelpers::writeUInt(os, sizeof(SUMOReal)); 00512 FileHelpers::writeUInt(os, MSEdge::dictSize()); 00513 FileHelpers::writeUInt(os, myStep); 00514 MSRoute::dict_saveState(os); 00515 myVehicleControl->saveState(os); 00516 if (MSGlobals::gUseMesoSim) { 00517 MSGlobals::gMesoNet->saveState(os); 00518 } 00519 } 00520 00521 00522 unsigned int 00523 MSNet::loadState(BinaryInputDevice& bis) { 00524 std::string version; 00525 unsigned int sizeT, fpSize, numEdges, step; 00526 bis >> version; 00527 bis >> sizeT; 00528 bis >> fpSize; 00529 bis >> numEdges; 00530 bis >> step; 00531 if (version != VERSION_STRING) { 00532 WRITE_WARNING("State was written with sumo version " + version + " (present: " + VERSION_STRING + ")!"); 00533 } 00534 if (sizeT != sizeof(size_t)) { 00535 WRITE_WARNING("State was written on a different platform (32bit vs. 64bit)!"); 00536 } 00537 if (fpSize != sizeof(SUMOReal)) { 00538 WRITE_WARNING("State was written with a different precision for SUMOReal!"); 00539 } 00540 if (numEdges != MSEdge::dictSize()) { 00541 WRITE_WARNING("State was written for a different net!"); 00542 } 00543 const SUMOTime offset = string2time(OptionsCont::getOptions().getString("load-state.offset")); 00544 MSRoute::dict_loadState(bis); 00545 myVehicleControl->loadState(bis, offset); 00546 if (MSGlobals::gUseMesoSim) { 00547 MSGlobals::gMesoNet->loadState(bis, *myVehicleControl, offset); 00548 } 00549 return step; 00550 } 00551 #endif 00552 00553 00554 MSPersonControl& 00555 MSNet::getPersonControl() { 00556 if (myPersonControl == 0) { 00557 myPersonControl = new MSPersonControl(); 00558 } 00559 return *myPersonControl; 00560 } 00561 00562 00563 MSEdgeWeightsStorage& 00564 MSNet::getWeightsStorage() { 00565 if (myEdgeWeights == 0) { 00566 myEdgeWeights = new MSEdgeWeightsStorage(); 00567 } 00568 return *myEdgeWeights; 00569 } 00570 00571 00572 void 00573 MSNet::preSimStepOutput() const { 00574 std::cout << std::setprecision(OUTPUT_ACCURACY); 00575 std::cout << "Step #" << time2string(myStep); 00576 } 00577 00578 00579 void 00580 MSNet::postSimStepOutput() const { 00581 if (myLogExecutionTime) { 00582 std::string msg; 00583 std::ostringstream oss; 00584 oss.setf(std::ios::fixed , std::ios::floatfield); // use decimal format 00585 oss.setf(std::ios::showpoint); // print decimal point 00586 oss << std::setprecision(OUTPUT_ACCURACY); 00587 if (mySimStepDuration != 0) { 00588 oss << " (" << mySimStepDuration << "ms ~= " 00589 << (1000. / (SUMOReal) mySimStepDuration) << "*RT, ~" 00590 << ((SUMOReal) myVehicleControl->getRunningVehicleNo() / (SUMOReal) mySimStepDuration * 1000.); 00591 } else { 00592 oss << " (0ms ?*RT. ?"; 00593 } 00594 oss << "UPS, vehicles" 00595 << " TOT " << myVehicleControl->getDepartedVehicleNo() 00596 << " ACT " << myVehicleControl->getRunningVehicleNo() 00597 << ") "; 00598 msg = oss.str(); 00599 std::string prev = "Step #" + time2string(myStep - DELTA_T); 00600 msg = msg.substr(0, 78 - prev.length()); 00601 std::cout << msg; 00602 } 00603 std::cout << (char) 13; 00604 } 00605 00606 00607 void 00608 MSNet::addVehicleStateListener(VehicleStateListener* listener) { 00609 if (find(myVehicleStateListeners.begin(), myVehicleStateListeners.end(), listener) == myVehicleStateListeners.end()) { 00610 myVehicleStateListeners.push_back(listener); 00611 } 00612 } 00613 00614 00615 void 00616 MSNet::removeVehicleStateListener(VehicleStateListener* listener) { 00617 std::vector<VehicleStateListener*>::iterator i = find(myVehicleStateListeners.begin(), myVehicleStateListeners.end(), listener); 00618 if (i != myVehicleStateListeners.end()) { 00619 myVehicleStateListeners.erase(i); 00620 } 00621 } 00622 00623 00624 void 00625 MSNet::informVehicleStateListener(const SUMOVehicle* const vehicle, VehicleState to) { 00626 for (std::vector<VehicleStateListener*>::iterator i = myVehicleStateListeners.begin(); i != myVehicleStateListeners.end(); ++i) { 00627 (*i)->vehicleStateChanged(vehicle, to); 00628 } 00629 } 00630 00631 00632 00633 // ------ Insertion and retrieval of bus stops ------ 00634 bool 00635 MSNet::addBusStop(MSBusStop* busStop) { 00636 return myBusStopDict.add(busStop->getID(), busStop); 00637 } 00638 00639 00640 MSBusStop* 00641 MSNet::getBusStop(const std::string& id) const { 00642 return myBusStopDict.get(id); 00643 } 00644 00645 00646 std::string 00647 MSNet::getBusStopID(const MSLane* lane, const SUMOReal pos) const { 00648 const std::map<std::string, MSBusStop*> &vals = myBusStopDict.getMyMap(); 00649 for (std::map<std::string, MSBusStop*>::const_iterator it = vals.begin(); it != vals.end(); ++it) { 00650 MSBusStop* stop = it->second; 00651 if (&stop->getLane() == lane && fabs(stop->getEndLanePosition() - pos) < POSITION_EPS) { 00652 return stop->getID(); 00653 } 00654 } 00655 return ""; 00656 } 00657 00658 00659 #ifdef _MESSAGES 00660 MSMessageEmitter* 00661 MSNet::getMsgEmitter(const std::string& whatemit) { 00662 msgEmitVec.clear(); 00663 msgEmitVec = myMsgEmitter.buildAndGetStaticVector(); 00664 MSMessageEmitter* msgEmitter = 0; 00665 for (int i = 0; i < msgEmitVec.size(); ++i) { 00666 if (msgEmitVec.at(i)->getEventsEnabled(whatemit)) { 00667 msgEmitter = msgEmitVec.at(i); 00668 break; 00669 } 00670 } 00671 // returns 0 if the requested MessageEmitter is not in the map 00672 return msgEmitter; 00673 } 00674 00675 00676 void 00677 MSNet::createMsgEmitter(std::string& id, 00678 std::string& file, 00679 const std::string& base, 00680 std::string& whatemit, 00681 bool reverse, 00682 bool table, 00683 bool xy, 00684 SUMOReal step) { 00685 MSMessageEmitter* msgEmitter = new MSMessageEmitter(file, base, whatemit, reverse, table, xy, step); 00686 myMsgEmitter.add(id, msgEmitter); 00687 } 00688 #endif 00689 00690 00691 /****************************************************************************/ 00692