SUMO - Simulation of Urban MObility

MSMoveReminder.cpp

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // Something on a lane to be noticed about vehicle movement
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This program is free software; you can redistribute it and/or modify
00014 //   it under the terms of the GNU General Public License as published by
00015 //   the Free Software Foundation; either version 2 of the License, or
00016 //   (at your option) any later version.
00017 //
00018 /****************************************************************************/
00019 
00020 // ===========================================================================
00021 // included modules
00022 // ===========================================================================
00023 #ifdef _MSC_VER
00024 #include <windows_config.h>
00025 #else
00026 #include <config.h>
00027 #endif
00028 
00029 #include <string>
00030 #include <cassert>
00031 #include "MSLane.h"
00032 #include "MSMoveReminder.h"
00033 
00034 
00035 // ===========================================================================
00036 // method definitions
00037 // ===========================================================================
00038 MSMoveReminder::MSMoveReminder(MSLane* const lane, const bool doAdd) throw()
00039     : myLane(lane) {
00040     if (myLane!=0 && doAdd) {
00041         // add reminder to lane
00042         myLane->addMoveReminder(this);
00043     }
00044 }
00045 
00046 
00047 #ifdef HAVE_MESOSIM
00048 void
00049 MSMoveReminder::updateDetector(SUMOVehicle& veh, SUMOReal entryPos, SUMOReal leavePos,
00050                                SUMOTime entryTime, SUMOTime currentTime, SUMOTime leaveTime) throw() {
00051     std::map<SUMOVehicle*, std::pair<SUMOTime, SUMOReal> >::iterator j=myLastVehicleUpdateValues.find(&veh);
00052     if (j!=myLastVehicleUpdateValues.end()) {
00053         // the vehicle already has reported its values before; use these
00054         entryTime = (*j).second.first;
00055         entryPos = (*j).second.second;
00056         myLastVehicleUpdateValues.erase(j);
00057     }
00058     const SUMOReal timeOnLane = STEPS2TIME(currentTime - entryTime);
00059     const SUMOReal speed = (leavePos - entryPos) / STEPS2TIME(leaveTime - entryTime);
00060     myLastVehicleUpdateValues[&veh] = std::pair<SUMOTime, SUMOReal>(currentTime, entryPos+speed*timeOnLane);
00061     notifyMoveInternal(veh, timeOnLane, speed);
00062 }
00063 #endif
00064 /****************************************************************************/
00065 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines