SUMO - Simulation of Urban MObility

MSE3Collector.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // A detector of vehicles passing an area between entry/exit points
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 #ifndef MSE3Collector_h
00020 #define MSE3Collector_h
00021 
00022 
00023 // ===========================================================================
00024 // included modules
00025 // ===========================================================================
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031 
00032 #include <string>
00033 #include <cassert>
00034 #include <vector>
00035 #include <limits>
00036 #include <microsim/MSMoveReminder.h>
00037 #include <microsim/output/MSDetectorFileOutput.h>
00038 #include <utils/common/Named.h>
00039 #include <microsim/output/MSCrossSection.h>
00040 #include <utils/common/UtilExceptions.h>
00041 
00042 
00043 // ===========================================================================
00044 // class declarations
00045 // ===========================================================================
00046 class SUMOVehicle;
00047 class OutputDevice;
00048 
00049 
00050 // ===========================================================================
00051 // class definitions
00052 // ===========================================================================
00062 class MSE3Collector : public MSDetectorFileOutput {
00063 public:
00068     class MSE3EntryReminder : public MSMoveReminder {
00069     public:
00075         MSE3EntryReminder(const MSCrossSection& crossSection, MSE3Collector& collector) throw();
00076 
00077 
00080 
00096         bool notifyMove(SUMOVehicle& veh, SUMOReal , SUMOReal newPos, SUMOReal) throw();
00097 
00098 
00109         bool notifyLeave(SUMOVehicle& veh, SUMOReal lastPos, MSMoveReminder::Notification reason) throw();
00111 
00112 
00113     private:
00115         MSE3Collector& myCollector;
00116 
00118         SUMOReal myPosition;
00119 
00120     private:
00122         MSE3EntryReminder(const MSE3EntryReminder&);
00123 
00125         MSE3EntryReminder& operator=(const MSE3EntryReminder&);
00126 
00127     };
00128 
00129 
00130 
00135     class MSE3LeaveReminder : public MSMoveReminder {
00136     public:
00142         MSE3LeaveReminder(const MSCrossSection& crossSection, MSE3Collector& collector) throw();
00143 
00144 
00146 
00147 
00163         bool notifyMove(SUMOVehicle& veh, SUMOReal , SUMOReal newPos, SUMOReal) throw();
00165 
00166 
00167     private:
00169         MSE3Collector& myCollector;
00170 
00172         SUMOReal myPosition;
00173 
00174     private:
00176         MSE3LeaveReminder(const MSE3LeaveReminder&);
00177 
00179         MSE3LeaveReminder& operator=(const MSE3LeaveReminder&);
00180 
00181     };
00182 
00183 
00194     MSE3Collector(const std::string& id,
00195                   const CrossSectionVector& entries, const CrossSectionVector& exits,
00196                   SUMOReal haltingSpeedThreshold,
00197                   SUMOTime haltingTimeThreshold) throw();
00198 
00199 
00201     virtual ~MSE3Collector() throw();
00202 
00203 
00206     void reset() throw();
00207 
00208 
00216     void enter(SUMOVehicle& veh, SUMOReal entryTimestep) throw();
00217 
00218 
00226     void leave(SUMOVehicle& veh, SUMOReal leaveTimestep) throw();
00227 
00228 
00231 
00238     SUMOReal getCurrentMeanSpeed() const throw();
00239 
00240 
00247     SUMOReal getCurrentHaltingNumber() const throw();
00248 
00249 
00253     SUMOReal getVehiclesWithin() const throw();
00254 
00255 
00260     std::vector<std::string> getCurrentVehicleIDs() const throw();
00262 
00263 
00266 
00275     void writeXMLOutput(OutputDevice& dev, SUMOTime startTime, SUMOTime stopTime) throw(IOError);
00276 
00277 
00286     void writeXMLDetectorProlog(OutputDevice& dev) const throw(IOError);
00288 
00289 
00290 
00299     void detectorUpdate(const SUMOTime step) throw();
00300 
00301 
00302 protected:
00304     CrossSectionVector myEntries;
00305 
00307     CrossSectionVector myExits;
00308 
00310     std::vector<MSE3EntryReminder*> myEntryReminders;
00311 
00313     std::vector<MSE3LeaveReminder*> myLeaveReminders;
00314 
00315 
00316     // @brief Time-threshold to determine if a vehicle is halting.
00317     SUMOTime myHaltingTimeThreshold;
00318 
00320     SUMOReal myHaltingSpeedThreshold;
00321 
00330     struct E3Values {
00332         SUMOReal entryTime;
00334         SUMOReal leaveTime;
00336         SUMOReal speedSum;
00338         unsigned haltings;
00340         SUMOReal haltingBegin;
00342         SUMOReal intervalSpeedSum;
00344         unsigned intervalHaltings;
00346         bool hadUpdate;
00347     };
00348 
00350     std::map<SUMOVehicle*, E3Values> myEnteredContainer;
00351 
00353     std::map<SUMOVehicle*, E3Values> myLeftContainer;
00354 
00355 
00358 
00360     SUMOReal myCurrentMeanSpeed;
00361 
00363     SUMOReal myCurrentHaltingsNumber;
00364 
00370     SUMOReal myCurrentTouchedVehicles;
00372 
00373 
00375     SUMOTime myLastResetTime;
00376 
00377 
00378 private:
00380     MSE3Collector(const MSE3Collector&);
00381 
00383     MSE3Collector& operator=(const MSE3Collector&);
00384 
00385 
00386 };
00387 
00388 
00389 #endif
00390 
00391 /****************************************************************************/
00392 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines