SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSE2Collector.h
Go to the documentation of this file.
1 /****************************************************************************/
11 // An areal (along a single lane) detector
12 /****************************************************************************/
13 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
14 // Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
15 /****************************************************************************/
16 //
17 // This file is part of SUMO.
18 // SUMO is free software: you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation, either version 3 of the License, or
21 // (at your option) any later version.
22 //
23 /****************************************************************************/
24 #ifndef MSE2Collector_h
25 #define MSE2Collector_h
26 
27 
28 // ===========================================================================
29 // included modules
30 // ===========================================================================
31 #ifdef _MSC_VER
32 #include <windows_config.h>
33 #else
34 #include <config.h>
35 #endif
36 
37 #include <vector>
38 #include <list>
39 #include <microsim/MSLane.h>
44 
45 
46 // ===========================================================================
47 // class declarations
48 // ===========================================================================
49 class OutputDevice;
50 
51 
52 // ===========================================================================
53 // class definitions
54 // ===========================================================================
79 public:
92  MSE2Collector(const std::string& id, DetectorUsage usage,
93  MSLane* const lane, SUMOReal startPos, SUMOReal detLength,
94  SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold,
95  SUMOReal jamDistThreshold);
96 
97 
99  virtual ~MSE2Collector();
100 
101 
107  virtual DetectorUsage getUsageType() const {
108  return myUsage;
109  }
110 
111 
112 
115 
131  bool notifyMove(SUMOVehicle& veh, SUMOReal oldPos, SUMOReal newPos,
132  SUMOReal newSpeed);
133 
134 
146  bool notifyLeave(SUMOVehicle& veh, SUMOReal lastPos, MSMoveReminder::Notification reason);
147 
148 
163 
164 
165 
174  void detectorUpdate(const SUMOTime step);
175 
176 
177 
180 
189  void writeXMLOutput(OutputDevice& dev, SUMOTime startTime, SUMOTime stopTime);
190 
191 
198  void writeXMLDetectorProlog(OutputDevice& dev) const;
200 
201 
207  return myStartPos;
208  }
209 
210 
215  SUMOReal getEndPos() const {
216  return myEndPos;
217  }
218 
219 
226  void reset();
227 
228 
231 
233  unsigned getCurrentVehicleNumber() const;
234 
237 
240 
243 
245  unsigned getCurrentJamNumber() const;
246 
248  unsigned getCurrentMaxJamLengthInVehicles() const;
249 
252 
254  unsigned getCurrentJamLengthInVehicles() const;
255 
258 
260  unsigned getCurrentStartedHalts() const;
261 
269 
274  std::vector<std::string> getCurrentVehicleIDs() const;
276 
277 
278 protected:
284  struct JamInfo {
286  std::list<SUMOVehicle*>::const_iterator firstStandingVehicle;
287 
289  std::list<SUMOVehicle*>::const_iterator lastStandingVehicle;
290  };
291 
292 
304  public:
310  : myLane(lane) { }
311 
312 
318  : myLane(s.myLane) { }
319 
320 
327  int operator()(const SUMOVehicle* v1, const SUMOVehicle* v2);
328 
329  private:
330  by_vehicle_position_sorter& operator=(const by_vehicle_position_sorter&); // just to avoid a compiler warning
331  private:
333  const MSLane* const myLane;
334  };
335 
336 
337 private:
340 
352 
355 
357  std::list<SUMOVehicle*> myKnownVehicles;
358 
360  std::map<SUMOVehicle*, SUMOTime> myHaltingVehicleDurations;
361 
363  std::map<SUMOVehicle*, SUMOTime> myIntervalHaltingVehicleDurations;
364 
366  std::vector<SUMOTime> myPastStandingDurations;
367 
369  std::vector<SUMOTime> myPastIntervalStandingDurations;
370 
371 
374 
386  unsigned myTimeSamples;
404 
405 
408 
416  unsigned myCurrentJamNo;
430 
431 
432 private:
435 
438 
439 
440 };
441 
442 
443 #endif
444 
445 /****************************************************************************/
446 
std::map< SUMOVehicle *, SUMOTime > myHaltingVehicleDurations
Storage for halting durations of known vehicles (for halting vehicles)
std::vector< SUMOTime > myPastIntervalStandingDurations
Halting durations of ended halts for the current interval [s].
std::vector< std::string > getCurrentVehicleIDs() const
Returns the IDs of the vehicles within the area.
unsigned myCurrentJamNo
The current jam number.
unsigned getCurrentJamNumber() const
Returns the current number of jams.
SUMOReal myMaxJamInMeters
The max jam length [m].
unsigned getCurrentStartedHalts() const
Returns the length of all jams in meters.
virtual ~MSE2Collector()
Destructor.
An areal (along a single lane) detector.
Definition: MSE2Collector.h:78
SUMOReal getCurrentMeanLength() const
Returns the mean vehicle length of vehicles currently on the detector.
Internal representation of a jam.
unsigned getCurrentMaxJamLengthInVehicles() const
Returns the length in vehicles of the currently largest jam.
SUMOReal myStartedHalts
The number of started halts [#].
Notification
Definition of a vehicle state.
A class used to sort known vehicles by their position.
std::vector< SUMOTime > myPastStandingDurations
Halting durations of ended halts [s].
unsigned myMaxVehicleNumber
The max number of vehicles [#veh].
SUMOReal getCurrentJamLengthInMeters() const
Returns the length of all jams in meters.
by_vehicle_position_sorter & operator=(const by_vehicle_position_sorter &)
SUMOReal myCurrentMeanLength
The current mean length.
virtual DetectorUsage getUsageType() const
Returns the detector's usage type.
unsigned myCurrentStartedHalts
The number of started halts in the last step.
by_vehicle_position_sorter(const MSLane *const lane)
constructor
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason)
Adds the vehicle to known vehicles if not beyond the dector.
MSE2Collector & operator=(const MSE2Collector &)
Invalidated assignment operator.
unsigned myVehicleSamples
The number of collected samples [#].
Representation of a vehicle.
Definition: SUMOVehicle.h:63
std::map< SUMOVehicle *, SUMOTime > myIntervalHaltingVehicleDurations
Storage for halting durations of known vehicles (current interval)
SUMOReal getStartPos() const
Returns the begin position of the detector.
std::list< SUMOVehicle * > myKnownVehicles
List of known vehicles.
SUMOReal getCurrentMeanSpeed() const
Returns the mean vehicle speed of vehicles currently on the detector.
Something on a lane to be noticed about vehicle movement.
SUMOReal myJamHaltingSpeedThreshold
A vehicle must driver slower than this to be counted as a part of a jam.
unsigned myCurrentJamLengthInVehicles
The overall jam length in vehicles.
SUMOTime myJamHaltingTimeThreshold
A vehicle must be that long beyond myJamHaltingSpeedThreshold to be counted as a part of a jam...
SUMOReal mySpeedSum
The sum of collected vehicle speeds [m/s].
unsigned myMeanVehicleNumber
The mean number of vehicles [#veh].
SUMOReal myCurrentMaxJamLengthInMeters
the current maximum jam length in meters
SUMOReal getCurrentHaltingNumber() const
Returns the number of current haltings within the area.
unsigned myMeanMaxJamInVehicles
The mean jam length [#veh].
SUMOReal myCurrentJamLengthInMeters
The overall jam length in meters.
by_vehicle_position_sorter(const by_vehicle_position_sorter &s)
copy constructor
std::list< SUMOVehicle * >::const_iterator firstStandingVehicle
The first standing vehicle.
SUMOReal myStartPos
The position the detector starts at.
unsigned myMaxJamInVehicles
The max jam length [#veh].
void detectorUpdate(const SUMOTime step)
Computes the detector values in each time step.
SUMOReal myEndPos
The position the detector ends at.
SUMOReal myCurrentOccupancy
The current occupancy.
SUMOReal myMaxOccupancy
The maximum occupancy [%].
bool notifyMove(SUMOVehicle &veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed)
Adds/removes vehicles from the list of vehicles to regard.
void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime)
Writes collected values into the given stream.
SUMOReal getCurrentOccupancy() const
Returns the curent detector occupancy.
DetectorUsage myUsage
Information about how this detector is used.
SUMOReal myCurrentMeanSpeed
The current mean speed.
void reset()
Resets all values.
unsigned myTimeSamples
The current aggregation duration [#steps].
unsigned getCurrentVehicleNumber() const
Returns the number of vehicles currently on the detector.
SUMOReal myMeanMaxJamInMeters
The mean jam length [m].
SUMOReal myOccupancySum
The sum of occupancies [%].
const MSLane *const myLane
The lane the detector is placed at.
int SUMOTime
Definition: SUMOTime.h:43
MSE2Collector(const std::string &id, DetectorUsage usage, MSLane *const lane, SUMOReal startPos, SUMOReal detLength, SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold, SUMOReal jamDistThreshold)
Constructor.
std::list< SUMOVehicle * >::const_iterator lastStandingVehicle
The last standing vehicle.
unsigned myCurrentMaxJamLengthInVehicles
The current maximum jam length in vehicles.
SUMOReal myJamLengthInMetersSum
The sum of jam lengths [m].
SUMOReal getCurrentMaxJamLengthInMeters() const
Returns the length in meters of the currently largest jam.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
unsigned getCurrentJamLengthInVehicles() const
Returns the length of all jams in vehicles.
#define SUMOReal
Definition: config.h:215
bool notifyLeave(SUMOVehicle &veh, SUMOReal lastPos, MSMoveReminder::Notification reason)
Removes a known vehicle due to its lane-change.
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
SUMOReal myCurrentHaltingsNumber
The number of halted vehicles [#].
int operator()(const SUMOVehicle *v1, const SUMOVehicle *v2)
Comparison funtcion.
Base of value-generating classes (detectors)
unsigned myJamLengthInVehiclesSum
The sum of jam lengths [#veh].
SUMOReal myJamDistanceThreshold
Two standing vehicles must be closer than this to be counted into the same jam.
void writeXMLDetectorProlog(OutputDevice &dev) const
Opens the XML-output using "detector" as root element.
SUMOReal getEndPos() const
Returns the end position of the detector.