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