SUMO - Simulation of Urban MObility
MSE2Collector.h
Go to the documentation of this file.
00001 /****************************************************************************/
00010 // An areal (along a single lane) detector
00011 /****************************************************************************/
00012 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00013 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00014 /****************************************************************************/
00015 //
00016 //   This file is part of SUMO.
00017 //   SUMO is free software: you can redistribute it and/or modify
00018 //   it under the terms of the GNU General Public License as published by
00019 //   the Free Software Foundation, either version 3 of the License, or
00020 //   (at your option) any later version.
00021 //
00022 /****************************************************************************/
00023 #ifndef MSE2Collector_h
00024 #define MSE2Collector_h
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 #include <vector>
00037 #include <list>
00038 #include <microsim/MSLane.h>
00039 #include <microsim/MSMoveReminder.h>
00040 #include <microsim/output/MSDetectorFileOutput.h>
00041 #include <utils/common/UtilExceptions.h>
00042 #include <utils/common/SUMOVehicle.h>
00043 
00044 
00045 // ===========================================================================
00046 // class declarations
00047 // ===========================================================================
00048 class OutputDevice;
00049 
00050 
00051 // ===========================================================================
00052 // class definitions
00053 // ===========================================================================
00077 class MSE2Collector : public MSMoveReminder, public MSDetectorFileOutput {
00078 public:
00091     MSE2Collector(const std::string& id, DetectorUsage usage,
00092                   MSLane* const lane, SUMOReal startPos, SUMOReal detLength,
00093                   SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold,
00094                   SUMOReal jamDistThreshold) ;
00095 
00096 
00098     virtual ~MSE2Collector() ;
00099 
00100 
00106     virtual DetectorUsage getUsageType() const {
00107         return myUsage;
00108     }
00109 
00110 
00111 
00114 
00130     bool notifyMove(SUMOVehicle& veh, SUMOReal oldPos, SUMOReal newPos,
00131                     SUMOReal newSpeed) ;
00132 
00133 
00145     bool notifyLeave(SUMOVehicle& veh, SUMOReal lastPos, MSMoveReminder::Notification reason) ;
00146 
00147 
00160     bool notifyEnter(SUMOVehicle& veh, MSMoveReminder::Notification reason) ;
00162 
00163 
00164 
00173     void detectorUpdate(const SUMOTime step) ;
00174 
00175 
00176 
00179 
00188     void writeXMLOutput(OutputDevice& dev, SUMOTime startTime, SUMOTime stopTime);
00189 
00190 
00197     void writeXMLDetectorProlog(OutputDevice& dev) const;
00199 
00200 
00205     SUMOReal getStartPos() const {
00206         return myStartPos;
00207     }
00208 
00209 
00214     SUMOReal getEndPos() const {
00215         return myEndPos;
00216     }
00217 
00218 
00225     void reset() ;
00226 
00227 
00230 
00232     unsigned getCurrentVehicleNumber() const ;
00233 
00235     SUMOReal getCurrentOccupancy() const ;
00236 
00238     SUMOReal getCurrentMeanSpeed() const ;
00239 
00241     SUMOReal getCurrentMeanLength() const ;
00242 
00244     unsigned getCurrentJamNumber() const ;
00245 
00247     unsigned getCurrentMaxJamLengthInVehicles() const ;
00248 
00250     SUMOReal getCurrentMaxJamLengthInMeters() const ;
00251 
00253     unsigned getCurrentJamLengthInVehicles() const ;
00254 
00256     SUMOReal getCurrentJamLengthInMeters() const ;
00257 
00259     unsigned getCurrentStartedHalts() const ;
00261 
00262 
00263 protected:
00269     struct JamInfo {
00271         std::list<SUMOVehicle*>::const_iterator firstStandingVehicle;
00272 
00274         std::list<SUMOVehicle*>::const_iterator lastStandingVehicle;
00275     };
00276 
00277 
00288     class by_vehicle_position_sorter {
00289     public:
00294         by_vehicle_position_sorter(const MSLane* const lane)
00295             : myLane(lane) { }
00296 
00297 
00302         by_vehicle_position_sorter(const by_vehicle_position_sorter& s)
00303             : myLane(s.myLane) { }
00304 
00305 
00312         int operator()(const SUMOVehicle* v1, const SUMOVehicle* v2);
00313 
00314     private:
00315         by_vehicle_position_sorter& operator=(const by_vehicle_position_sorter&); // just to avoid a compiler warning
00316     private:
00318         const MSLane* const myLane;
00319     };
00320 
00321 
00322 private:
00325 
00327     SUMOReal myJamHaltingSpeedThreshold;
00329     SUMOTime myJamHaltingTimeThreshold;
00331     SUMOReal myJamDistanceThreshold;
00333     SUMOReal myStartPos;
00335     SUMOReal myEndPos;
00337 
00339     DetectorUsage myUsage;
00340 
00342     std::list<SUMOVehicle*> myKnownVehicles;
00343 
00345     std::map<SUMOVehicle*, SUMOTime> myHaltingVehicleDurations;
00346 
00348     std::map<SUMOVehicle*, SUMOTime> myIntervalHaltingVehicleDurations;
00349 
00351     std::vector<SUMOTime> myPastStandingDurations;
00352 
00354     std::vector<SUMOTime> myPastIntervalStandingDurations;
00355 
00356 
00359 
00361     SUMOReal mySpeedSum;
00363     SUMOReal myStartedHalts;
00365     SUMOReal myJamLengthInMetersSum;
00367     unsigned myJamLengthInVehiclesSum;
00369     unsigned myVehicleSamples;
00371     unsigned myTimeSamples;
00373     SUMOReal myOccupancySum;
00375     SUMOReal myMaxOccupancy;
00377     unsigned myMeanMaxJamInVehicles;
00379     SUMOReal myMeanMaxJamInMeters;
00381     unsigned myMaxJamInVehicles;
00383     SUMOReal myMaxJamInMeters;
00385     unsigned myMeanVehicleNumber;
00387     unsigned myMaxVehicleNumber;
00389 
00390 
00393 
00395     SUMOReal myCurrentOccupancy;
00397     SUMOReal myCurrentMeanSpeed;
00399     SUMOReal myCurrentMeanLength;
00401     unsigned myCurrentJamNo;
00403     SUMOReal myCurrentMaxJamLengthInMeters;
00405     unsigned myCurrentMaxJamLengthInVehicles;
00407     SUMOReal myCurrentJamLengthInMeters;
00409     unsigned myCurrentJamLengthInVehicles;
00411     unsigned myCurrentStartedHalts;
00413 
00414 
00415 private:
00417     MSE2Collector(const MSE2Collector&);
00418 
00420     MSE2Collector& operator=(const MSE2Collector&);
00421 
00422 
00423 };
00424 
00425 
00426 #endif
00427 
00428 /****************************************************************************/
00429 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines