SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00009 // A detector of vehicles passing an area between entry/exit points 00010 /****************************************************************************/ 00011 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00012 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00013 /****************************************************************************/ 00014 // 00015 // This file is part of SUMO. 00016 // SUMO is free software: you can redistribute it and/or modify 00017 // it under the terms of the GNU General Public License as published by 00018 // the Free Software Foundation, either version 3 of the License, or 00019 // (at your option) any later version. 00020 // 00021 /****************************************************************************/ 00022 #ifndef MSE3Collector_h 00023 #define MSE3Collector_h 00024 00025 00026 // =========================================================================== 00027 // included modules 00028 // =========================================================================== 00029 #ifdef _MSC_VER 00030 #include <windows_config.h> 00031 #else 00032 #include <config.h> 00033 #endif 00034 00035 #include <string> 00036 #include <cassert> 00037 #include <vector> 00038 #include <limits> 00039 #include <microsim/MSMoveReminder.h> 00040 #include <microsim/output/MSDetectorFileOutput.h> 00041 #include <utils/common/Named.h> 00042 #include <microsim/output/MSCrossSection.h> 00043 #include <utils/common/UtilExceptions.h> 00044 00045 00046 // =========================================================================== 00047 // class declarations 00048 // =========================================================================== 00049 class SUMOVehicle; 00050 class OutputDevice; 00051 00052 00053 // =========================================================================== 00054 // class definitions 00055 // =========================================================================== 00065 class MSE3Collector : public MSDetectorFileOutput { 00066 public: 00071 class MSE3EntryReminder : public MSMoveReminder { 00072 public: 00078 MSE3EntryReminder(const MSCrossSection& crossSection, MSE3Collector& collector) ; 00079 00080 00083 00099 bool notifyMove(SUMOVehicle& veh, SUMOReal , SUMOReal newPos, SUMOReal) ; 00100 00101 00112 bool notifyLeave(SUMOVehicle& veh, SUMOReal lastPos, MSMoveReminder::Notification reason) ; 00114 00115 00116 private: 00118 MSE3Collector& myCollector; 00119 00121 SUMOReal myPosition; 00122 00123 private: 00125 MSE3EntryReminder(const MSE3EntryReminder&); 00126 00128 MSE3EntryReminder& operator=(const MSE3EntryReminder&); 00129 00130 }; 00131 00132 00133 00138 class MSE3LeaveReminder : public MSMoveReminder { 00139 public: 00145 MSE3LeaveReminder(const MSCrossSection& crossSection, MSE3Collector& collector) ; 00146 00147 00149 00150 00166 bool notifyMove(SUMOVehicle& veh, SUMOReal , SUMOReal newPos, SUMOReal) ; 00168 00169 00170 private: 00172 MSE3Collector& myCollector; 00173 00175 SUMOReal myPosition; 00176 00177 private: 00179 MSE3LeaveReminder(const MSE3LeaveReminder&); 00180 00182 MSE3LeaveReminder& operator=(const MSE3LeaveReminder&); 00183 00184 }; 00185 00186 00197 MSE3Collector(const std::string& id, 00198 const CrossSectionVector& entries, const CrossSectionVector& exits, 00199 SUMOReal haltingSpeedThreshold, 00200 SUMOTime haltingTimeThreshold) ; 00201 00202 00204 virtual ~MSE3Collector() ; 00205 00206 00209 void reset() ; 00210 00211 00219 void enter(SUMOVehicle& veh, SUMOReal entryTimestep) ; 00220 00221 00229 void leave(SUMOVehicle& veh, SUMOReal leaveTimestep) ; 00230 00231 00234 00241 SUMOReal getCurrentMeanSpeed() const ; 00242 00243 00250 SUMOReal getCurrentHaltingNumber() const ; 00251 00252 00256 SUMOReal getVehiclesWithin() const ; 00257 00258 00263 std::vector<std::string> getCurrentVehicleIDs() const ; 00265 00266 00269 00278 void writeXMLOutput(OutputDevice& dev, SUMOTime startTime, SUMOTime stopTime); 00279 00280 00289 void writeXMLDetectorProlog(OutputDevice& dev) const; 00291 00292 00293 00302 void detectorUpdate(const SUMOTime step) ; 00303 00304 00305 protected: 00307 CrossSectionVector myEntries; 00308 00310 CrossSectionVector myExits; 00311 00313 std::vector<MSE3EntryReminder*> myEntryReminders; 00314 00316 std::vector<MSE3LeaveReminder*> myLeaveReminders; 00317 00318 00319 // @brief Time-threshold to determine if a vehicle is halting. 00320 SUMOTime myHaltingTimeThreshold; 00321 00323 SUMOReal myHaltingSpeedThreshold; 00324 00333 struct E3Values { 00335 SUMOReal entryTime; 00337 SUMOReal leaveTime; 00339 SUMOReal speedSum; 00341 unsigned haltings; 00343 SUMOReal haltingBegin; 00345 SUMOReal intervalSpeedSum; 00347 unsigned intervalHaltings; 00349 bool hadUpdate; 00350 }; 00351 00353 std::map<SUMOVehicle*, E3Values> myEnteredContainer; 00354 00356 std::map<SUMOVehicle*, E3Values> myLeftContainer; 00357 00358 00361 00363 SUMOReal myCurrentMeanSpeed; 00364 00366 SUMOReal myCurrentHaltingsNumber; 00367 00373 SUMOReal myCurrentTouchedVehicles; 00375 00376 00378 SUMOTime myLastResetTime; 00379 00380 00381 private: 00383 MSE3Collector(const MSE3Collector&); 00384 00386 MSE3Collector& operator=(const MSE3Collector&); 00387 00388 00389 }; 00390 00391 00392 #endif 00393 00394 /****************************************************************************/ 00395