MSE2Collector.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // An areal (along a single lane) detector
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright 2001-2010 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 MSE2Collector_h
00020 #define MSE2Collector_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 <microsim/MSMoveReminder.h>
00033 #include <microsim/MSLane.h>
00034 #include <microsim/output/MSDetectorFileOutput.h>
00035 #include <utils/common/ToString.h>
00036 #include <string>
00037 #include <cassert>
00038 #include <vector>
00039 #include <limits>
00040 #include <set>
00041 #include <utils/iodevices/OutputDevice.h>
00042 #include <utils/common/MsgHandler.h>
00043 #include <utils/common/UtilExceptions.h>
00044 #include <utils/common/Named.h>
00045 
00046 
00047 // ===========================================================================
00048 // class definitions
00049 // ===========================================================================
00073 class MSE2Collector : public Named, public MSMoveReminder, public MSDetectorFileOutput, public MSVehicleQuitReminded {
00074 public:
00087     MSE2Collector(const std::string &id, DetectorUsage usage,
00088                   MSLane * const lane, SUMOReal startPos, SUMOReal detLength,
00089                   SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold,
00090                   SUMOReal jamDistThreshold) throw();
00091 
00092 
00094     virtual ~MSE2Collector() throw();
00095 
00096 
00102     virtual DetectorUsage getUsageType() const throw() {
00103         return myUsage;
00104     }
00105 
00106 
00107 
00110 
00126     bool isStillActive(MSVehicle& veh, SUMOReal oldPos, SUMOReal newPos,
00127                        SUMOReal newSpeed) throw();
00128 
00129 
00140     void notifyLeave(MSVehicle& veh, bool isArrival, bool isLaneChange) throw();
00141 
00142 
00155     bool notifyEnter(MSVehicle& veh, bool isEmit, bool isLaneChange) throw();
00157 
00158 
00159 
00168     void update(SUMOTime currentTime) throw();
00169 
00170 
00171 
00174 
00183     void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime) throw(IOError);
00184 
00185 
00192     void writeXMLDetectorProlog(OutputDevice &dev) const throw(IOError);
00194 
00195 
00196 
00199 
00204     void removeOnTripEnd(MSVehicle *veh) throw();
00206 
00207 
00212     SUMOReal getStartPos() const throw() {
00213         return myStartPos;
00214     }
00215 
00216 
00221     SUMOReal getEndPos() const throw() {
00222         return myEndPos;
00223     }
00224 
00225 
00232     void reset() throw();
00233 
00234 
00237 
00239     unsigned getCurrentVehicleNumber() const throw();
00240 
00242     SUMOReal getCurrentOccupancy() const throw();
00243 
00245     SUMOReal getCurrentMeanSpeed() const throw();
00246 
00248     SUMOReal getCurrentMeanLength() const throw();
00249 
00251     unsigned getCurrentJamNumber() const throw();
00252 
00254     unsigned getCurrentMaxJamLengthInVehicles() const throw();
00255 
00257     SUMOReal getCurrentMaxJamLengthInMeters() const throw();
00258 
00260     unsigned getCurrentJamLengthInVehicles() const throw();
00261 
00263     SUMOReal getCurrentJamLengthInMeters() const throw();
00264 
00266     unsigned getCurrentStartedHalts() const throw();
00268 
00269 
00270 protected:
00276     struct JamInfo {
00278         std::list<MSVehicle*>::const_iterator firstStandingVehicle;
00279 
00281         std::list<MSVehicle*>::const_iterator lastStandingVehicle;
00282     };
00283 
00284 
00295     class by_vehicle_position_sorter {
00296     public:
00301         by_vehicle_position_sorter(const MSLane * const lane) throw()
00302                 : myLane(lane) { }
00303 
00304 
00309         by_vehicle_position_sorter(const by_vehicle_position_sorter &s) throw()
00310                 : myLane(s.myLane) { }
00311 
00312 
00319         int operator()(const MSVehicle *v1, const MSVehicle *v2) throw() {
00320             return v1->getPositionOnActiveMoveReminderLane(myLane)>v2->getPositionOnActiveMoveReminderLane(myLane);
00321         }
00322 
00323     private:
00325         const MSLane * const myLane;
00326     };
00327 
00328 
00329 private:
00332 
00334     SUMOReal myJamHaltingSpeedThreshold;
00336     SUMOTime myJamHaltingTimeThreshold;
00338     SUMOReal myJamDistanceThreshold;
00340     SUMOReal myStartPos;
00342     SUMOReal myEndPos;
00344 
00346     DetectorUsage myUsage;
00347 
00349     std::list<MSVehicle*> myKnownVehicles;
00350 
00352     std::map<MSVehicle*, SUMOReal> myHaltingVehicleDurations;
00353 
00355     std::map<MSVehicle*, SUMOReal> myIntervalHaltingVehicleDurations;
00356 
00358     std::vector<SUMOReal> myPastStandingDurations;
00359 
00361     std::vector<SUMOReal> myPastIntervalStandingDurations;
00362 
00363 
00366 
00368     SUMOReal mySpeedSum;
00370     SUMOReal myStartedHalts;
00372     SUMOReal myJamLengthInMetersSum;
00374     unsigned myJamLengthInVehiclesSum;
00376     unsigned myVehicleSamples;
00378     unsigned myTimeSamples;
00380     SUMOReal myOccupancySum;
00382     SUMOReal myMaxOccupancy;
00384     unsigned myMeanMaxJamInVehicles;
00386     SUMOReal myMeanMaxJamInMeters;
00388     unsigned myMaxJamInVehicles;
00390     SUMOReal myMaxJamInMeters;
00392     unsigned myMeanVehicleNumber;
00394     unsigned myMaxVehicleNumber;
00396 
00397 
00400 
00402     SUMOReal myCurrentOccupancy;
00404     SUMOReal myCurrentMeanSpeed;
00406     SUMOReal myCurrentMeanLength;
00408     unsigned myCurrentJamNo;
00410     SUMOReal myCurrentMaxJamLengthInMeters;
00412     unsigned myCurrentMaxJamLengthInVehicles;
00414     SUMOReal myCurrentJamLengthInMeters;
00416     unsigned myCurrentJamLengthInVehicles;
00418     unsigned myCurrentStartedHalts;
00420 
00421 
00422 private:
00424     MSE2Collector(const MSE2Collector&);
00425 
00427     MSE2Collector& operator=(const MSE2Collector&);
00428 
00429 
00430 };
00431 
00432 
00433 #endif
00434 
00435 /****************************************************************************/
00436 

Generated on Wed May 5 00:06:31 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6