SUMO - Simulation of Urban MObility
MSE2Collector.h
Go to the documentation of this file.
1 /****************************************************************************/
13 // An areal (along a single lane) detector
14 /****************************************************************************/
15 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
16 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
17 /****************************************************************************/
18 //
19 // This file is part of SUMO.
20 // SUMO is free software: you can redistribute it and/or modify
21 // it under the terms of the GNU General Public License as published by
22 // the Free Software Foundation, either version 3 of the License, or
23 // (at your option) any later version.
24 //
25 /****************************************************************************/
26 #ifndef MSE2Collector_h
27 #define MSE2Collector_h
28 
29 
30 // ===========================================================================
31 // included modules
32 // ===========================================================================
33 #ifdef _MSC_VER
34 #include <windows_config.h>
35 #else
36 #include <config.h>
37 #endif
38 
39 #include <vector>
40 #include <list>
41 #include <microsim/MSLane.h>
42 #include <microsim/MSNet.h>
47 
48 //Debug
49 //#define SWARM_DEBUG
51 
52 // ===========================================================================
53 // class declarations
54 // ===========================================================================
55 class OutputDevice;
56 
57 
58 // ===========================================================================
59 // class definitions
60 // ===========================================================================
85 public:
88  struct VehicleInfo {
89  VehicleInfo(std::string _id, std::string _type, SUMOReal _speed, SUMOReal _timeOnDet,
90  SUMOReal _lengthOnDet, SUMOReal _position, SUMOReal _lengthWithGap,
91  SUMOReal _accel, SUMOReal vmax, bool _stillOnDet) :
92  id(_id),
93  type(_type),
94  speed(_speed),
95  timeOnDet(_timeOnDet),
96  lengthOnDet(_lengthOnDet),
97  position(_position),
98  lengthWithGap(_lengthWithGap),
99  accel(_accel),
100  timeLoss(vmax > 0 ? timeOnDet * (vmax - speed) / vmax : 0),
102  stillOnDet(_stillOnDet) {}
103  std::string id;
104  std::string type;
114  };
115 
116 
129  MSE2Collector(const std::string& id, DetectorUsage usage,
130  MSLane* const lane, SUMOReal startPos, SUMOReal detLength,
131  SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold,
132  SUMOReal jamDistThreshold,
133  const std::string& vTypes);
134 
147  MSE2Collector(const std::string& id, DetectorUsage usage,
148  MSLane* const lane, SUMOReal startPos, SUMOReal detLength,
149  SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold,
150  SUMOReal jamDistThreshold,
151  const std::set<std::string>& vTypes);
152 
153 
155  virtual ~MSE2Collector();
156 
157 
163  virtual DetectorUsage getUsageType() const {
164  return myUsage;
165  }
166 
167 
168 
171 
187  bool notifyMove(SUMOVehicle& veh, SUMOReal oldPos, SUMOReal newPos,
188  SUMOReal newSpeed);
189 
190 
202  bool notifyLeave(SUMOVehicle& veh, SUMOReal lastPos, MSMoveReminder::Notification reason);
203 
204 
219 
220 
221 
230  void detectorUpdate(const SUMOTime step);
231 
232 
233 
236 
245  void writeXMLOutput(OutputDevice& dev, SUMOTime startTime, SUMOTime stopTime);
246 
247 
254  void writeXMLDetectorProlog(OutputDevice& dev) const;
256 
257 
263  return myStartPos;
264  }
265 
266 
271  SUMOReal getEndPos() const {
272  return myEndPos;
273  }
274 
275 
282  void reset();
283 
285  int getEstimatedCurrentVehicleNumber(SUMOReal speedThreshold) const;
286 
289 
292 
294  int getCurrentVehicleNumber() const;
295 
298 
301 
304 
306  int getCurrentJamNumber() const;
307 
310 
313 
315  int getCurrentJamLengthInVehicles() const;
316 
319 
321  int getCurrentStartedHalts() const;
322 
329  int getCurrentHaltingNumber() const;
330 
335  std::vector<std::string> getCurrentVehicleIDs() const;
340  const std::vector<VehicleInfo>& getCurrentVehicles() const;
342 
347  int getPassedVeh() {
348  return myPassedVeh;
349  }
350 
355  void subtractPassedVeh(int passed) {
356  myPassedVeh -= passed;
357  }
358 
359 private:
365  struct JamInfo {
367  std::vector<VehicleInfo>::const_iterator firstStandingVehicle;
368 
370  std::vector<VehicleInfo>::const_iterator lastStandingVehicle;
371  };
372 
373 
376 
388 
391 
393  std::vector<VehicleInfo> myKnownVehicles;
394 
396  std::vector<VehicleInfo> myPreviousKnownVehicles;
397 
399  std::map<std::string, SUMOTime> myHaltingVehicleDurations;
400 
402  std::map<std::string, SUMOTime> myIntervalHaltingVehicleDurations;
403 
405  std::vector<SUMOTime> myPastStandingDurations;
406 
408  std::vector<SUMOTime> myPastIntervalStandingDurations;
409 
410 
413 
445 
446 
449 
473 
474 
475 private:
478 
481 
482 
483 };
484 
485 
486 #endif
487 
488 /****************************************************************************/
489 
int myMaxVehicleNumber
The max number of vehicles [#veh].
int myMeanMaxJamInVehicles
The mean jam length [#veh].
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
SUMOReal myTimeLossSum
The sum of timeLoss values [s].
SUMOReal myMaxJamInMeters
The max jam length [m].
virtual ~MSE2Collector()
Destructor.
An areal (along a single lane) detector.
Definition: MSE2Collector.h:84
SUMOReal getCurrentMeanLength() const
Returns the mean vehicle length of vehicles currently on the detector.
Internal representation of a jam.
int myCurrentMaxJamLengthInVehicles
The current maximum jam length in vehicles.
int getCurrentStartedHalts() const
Returns the length of all jams in meters.
int getEstimatedCurrentVehicleNumber(SUMOReal speedThreshold) const
Returns an estimate of the number of vehicles currently on the detector.
SUMOReal myStartedHalts
The number of started halts [#].
Notification
Definition of a vehicle state.
int getCurrentJamLengthInVehicles() const
Returns the length of all jams in vehicles.
std::vector< SUMOTime > myPastStandingDurations
Halting durations of ended halts [s].
SUMOReal getCurrentJamLengthInMeters() const
Returns the length of all jams in meters.
int myMeanVehicleNumber
The mean number of vehicles [#veh].
int myCurrentStartedHalts
The number of started halts in the last step.
SUMOReal myCurrentMeanLength
The current mean length.
virtual DetectorUsage getUsageType() const
Returns the detector&#39;s usage type.
SUMOReal myVehicleSamples
The number of collected samples [#].
VehicleInfo(std::string _id, std::string _type, SUMOReal _speed, SUMOReal _timeOnDet, SUMOReal _lengthOnDet, SUMOReal _position, SUMOReal _lengthWithGap, SUMOReal _accel, SUMOReal vmax, bool _stillOnDet)
Definition: MSE2Collector.h:89
int myTimeSamples
The current aggregation duration [#steps].
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason)
Adds the vehicle to known vehicles if not beyond the dector.
Internal representation of a vehicle.
Definition: MSE2Collector.h:88
std::vector< VehicleInfo > myKnownVehicles
List of known vehicles.
MSE2Collector & operator=(const MSE2Collector &)
Invalidated assignment operator.
int myCurrentJamLengthInVehicles
The overall jam length in vehicles.
Representation of a vehicle.
Definition: SUMOVehicle.h:67
int myJamLengthInVehiclesSum
The sum of jam lengths [#veh].
std::vector< VehicleInfo >::const_iterator firstStandingVehicle
The first standing vehicle.
SUMOReal getStartPos() const
Returns the begin position of the detector.
SUMOReal getCurrentMeanSpeed() const
Returns the mean vehicle speed of vehicles currently on the detector.
std::vector< VehicleInfo >::const_iterator lastStandingVehicle
The last standing vehicle.
int myCurrentJamNo
The current jam number.
int getCurrentVehicleNumber() const
Returns the number of vehicles currently on the detector.
Something on a lane to be noticed about vehicle movement.
std::map< std::string, SUMOTime > myIntervalHaltingVehicleDurations
Storage for halting durations of known vehicles (current interval)
SUMOReal myJamHaltingSpeedThreshold
A vehicle must driver slower than this to be counted as a part of a jam.
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...
SUMOReal mySpeedSum
The sum of collected vehicle speeds [m/s].
SUMOReal myCurrentMaxJamLengthInMeters
the current maximum jam length in meters
SUMOReal myCurrentJamLengthInMeters
The overall jam length in meters.
SUMOReal myStartPos
The position the detector starts at.
int getCurrentMaxJamLengthInVehicles() const
Returns the length in vehicles of the currently largest jam.
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 [%].
std::vector< VehicleInfo > myPreviousKnownVehicles
List of previously known vehicles.
int getCurrentJamNumber() const
Returns the current number of jams.
bool notifyMove(SUMOVehicle &veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed)
Adds/removes vehicles from the list of vehicles to regard.
MSE2Collector(const std::string &id, DetectorUsage usage, MSLane *const lane, SUMOReal startPos, SUMOReal detLength, SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold, SUMOReal jamDistThreshold, const std::string &vTypes)
Constructor.
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.
int getPassedVeh()
Returns the number of vehicles passed over the sensor.
void reset()
Resets all values.
std::map< std::string, SUMOTime > myHaltingVehicleDurations
Storage for halting durations of known vehicles (for halting vehicles)
int myMaxJamInVehicles
The max jam length [#veh].
SUMOReal myMeanMaxJamInMeters
The mean jam length [m].
SUMOReal myOccupancySum
The sum of occupancies [%].
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 [#].
#define SUMOReal
Definition: config.h:208
bool notifyLeave(SUMOVehicle &veh, SUMOReal lastPos, MSMoveReminder::Notification reason)
Removes a known vehicle due to its lane-change.
const std::vector< VehicleInfo > & getCurrentVehicles() const
Returns the vehicles within the area.
int getCurrentHaltingNumber() const
Returns the number of current haltings within the area.
int myPassedVeh
The number of vehicles passed on the sensor.
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
Base of value-generating classes (detectors)
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.