SUMO - Simulation of Urban MObility
MSE2Collector.h
Go to the documentation of this file.
1 /****************************************************************************/
12 // An areal (along a single lane) detector
13 /****************************************************************************/
14 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
15 // Copyright (C) 2014 DLR (http://www.dlr.de/) and contributors
16 /****************************************************************************/
17 //
18 // This file is part of SUMO.
19 // SUMO is free software: you can redistribute it and/or modify
20 // it under the terms of the GNU General Public License as published by
21 // the Free Software Foundation, either version 3 of the License, or
22 // (at your option) any later version.
23 //
24 /****************************************************************************/
25 #ifndef MSE2Collector_h
26 #define MSE2Collector_h
27 
28 
29 // ===========================================================================
30 // included modules
31 // ===========================================================================
32 #ifdef _MSC_VER
33 #include <windows_config.h>
34 #else
35 #include <config.h>
36 #endif
37 
38 #include <vector>
39 #include <list>
40 #include <microsim/MSLane.h>
41 #include <microsim/MSNet.h>
46 
47 //Debug
48 //#define SWARM_DEBUG
50 
51 // ===========================================================================
52 // class declarations
53 // ===========================================================================
54 class OutputDevice;
55 
56 
57 // ===========================================================================
58 // class definitions
59 // ===========================================================================
84 public:
97  MSE2Collector(const std::string& id, DetectorUsage usage,
98  MSLane* const lane, SUMOReal startPos, SUMOReal detLength,
99  SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold,
100  SUMOReal jamDistThreshold);
101 
102 
104  virtual ~MSE2Collector();
105 
106 
112  virtual DetectorUsage getUsageType() const {
113  return myUsage;
114  }
115 
116 
117 
120 
136  bool notifyMove(SUMOVehicle& veh, SUMOReal oldPos, SUMOReal newPos,
137  SUMOReal newSpeed);
138 
139 
151  bool notifyLeave(SUMOVehicle& veh, SUMOReal lastPos, MSMoveReminder::Notification reason);
152 
153 
168 
169 
170 
179  void detectorUpdate(const SUMOTime step);
180 
181 
182 
185 
194  void writeXMLOutput(OutputDevice& dev, SUMOTime startTime, SUMOTime stopTime);
195 
196 
203  void writeXMLDetectorProlog(OutputDevice& dev) const;
205 
206 
212  return myStartPos;
213  }
214 
215 
220  SUMOReal getEndPos() const {
221  return myEndPos;
222  }
223 
224 
231  void reset();
232 
234  int getEstimatedCurrentVehicleNumber(SUMOReal speedThreshold) const;
235 
238 
241 
243  unsigned getCurrentVehicleNumber() const;
244 
247 
250 
253 
255  unsigned getCurrentJamNumber() const;
256 
258  unsigned getCurrentMaxJamLengthInVehicles() const;
259 
262 
264  unsigned getCurrentJamLengthInVehicles() const;
265 
268 
270  unsigned getCurrentStartedHalts() const;
271 
278  int getCurrentHaltingNumber() const;
279 
284  std::vector<std::string> getCurrentVehicleIDs() const;
289  const std::list<SUMOVehicle*>& getCurrentVehicles() const;
291 
296  unsigned int getPassedVeh() {
297  return myPassedVeh;
298  }
299 
304  void subtractPassedVeh(int passed) {
305  myPassedVeh -= passed;
306  }
307 
308 protected:
314  struct JamInfo {
316  std::list<SUMOVehicle*>::const_iterator firstStandingVehicle;
317 
319  std::list<SUMOVehicle*>::const_iterator lastStandingVehicle;
320  };
321 
322 
334  public:
340  : myLane(lane) { }
341 
342 
348  : myLane(s.myLane) { }
349 
350 
357  int operator()(const SUMOVehicle* v1, const SUMOVehicle* v2);
358 
359  private:
360  by_vehicle_position_sorter& operator=(const by_vehicle_position_sorter&); // just to avoid a compiler warning
361  private:
363  const MSLane* const myLane;
364  };
365 
366 
367 private:
370 
382 
385 
387  std::list<SUMOVehicle*> myKnownVehicles;
388 
390  std::map<const SUMOVehicle*, SUMOTime> myHaltingVehicleDurations;
391 
393  std::map<const SUMOVehicle*, SUMOTime> myIntervalHaltingVehicleDurations;
394 
396  std::vector<SUMOTime> myPastStandingDurations;
397 
399  std::vector<SUMOTime> myPastIntervalStandingDurations;
400 
401 
404 
416  unsigned myTimeSamples;
434 
435 
438 
446  unsigned myCurrentJamNo;
460  unsigned int myPassedVeh;
462 
463 
464 private:
467 
470 
471 
472 };
473 
474 
475 #endif
476 
477 /****************************************************************************/
478 
std::map< const 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.
long long int SUMOTime
Definition: SUMOTime.h:43
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:83
SUMOReal getCurrentMeanLength() const
Returns the mean vehicle length of vehicles currently on the detector.
Internal representation of a jam.
MSLane *const myLane
Lane on which the reminder works.
unsigned getCurrentMaxJamLengthInVehicles() const
Returns the length in vehicles of the currently largest jam.
int getEstimatedCurrentVehicleNumber(SUMOReal speedThreshold) const
Returns an estimate of the number of vehicles currently on the detector.
unsigned int myPassedVeh
The number of vehicles passed on the sensor.
SUMOReal myStartedHalts
The number of started halts [#].
unsigned int getPassedVeh()
Returns the number of vehicles passed over the sensor.
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.
SUMOReal myCurrentMeanLength
The current mean length.
virtual DetectorUsage getUsageType() const
Returns the detector&#39;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:65
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 getEstimateQueueLength() const
Returns an estimate of the lenght of the queue of vehicles currently stopped on the detector...
const std::list< SUMOVehicle * > & getCurrentVehicles() const
Returns the vehicles within the area.
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
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.
void subtractPassedVeh(int passed)
Subtract the number of vehicles indicated from passed from the sensor count.
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.
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:71
int myCurrentHaltingsNumber
The number of halted vehicles [#].
unsigned getCurrentJamLengthInVehicles() const
Returns the length of all jams in vehicles.
#define SUMOReal
Definition: config.h:213
bool notifyLeave(SUMOVehicle &veh, SUMOReal lastPos, MSMoveReminder::Notification reason)
Removes a known vehicle due to its lane-change.
std::map< const SUMOVehicle *, SUMOTime > myIntervalHaltingVehicleDurations
Storage for halting durations of known vehicles (current interval)
int getCurrentHaltingNumber() const
Returns the number of current haltings within the area.
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
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.