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) 2001-2016 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:
87  struct VehicleInfo {
88  VehicleInfo(std::string _id, std::string _type, SUMOReal _speed, SUMOReal _timeOnDet, SUMOReal _lengthOnDet, SUMOReal _position, SUMOReal _lengthWithGap, SUMOReal _accel, bool _stillOnDet)
89  : id(_id), type(_type), speed(_speed), timeOnDet(_timeOnDet), lengthOnDet(_lengthOnDet), position(_position), lengthWithGap(_lengthWithGap), accel(_accel), stillOnDet(_stillOnDet) {}
90  std::string id;
91  std::string type;
98  bool stillOnDet;
99  };
100 
101 
114  MSE2Collector(const std::string& id, DetectorUsage usage,
115  MSLane* const lane, SUMOReal startPos, SUMOReal detLength,
116  SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold,
117  SUMOReal jamDistThreshold,
118  const std::string& vTypes);
119 
132  MSE2Collector(const std::string& id, DetectorUsage usage,
133  MSLane* const lane, SUMOReal startPos, SUMOReal detLength,
134  SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold,
135  SUMOReal jamDistThreshold,
136  const std::set<std::string>& vTypes);
137 
138 
140  virtual ~MSE2Collector();
141 
142 
148  virtual DetectorUsage getUsageType() const {
149  return myUsage;
150  }
151 
152 
153 
156 
172  bool notifyMove(SUMOVehicle& veh, SUMOReal oldPos, SUMOReal newPos,
173  SUMOReal newSpeed);
174 
175 
187  bool notifyLeave(SUMOVehicle& veh, SUMOReal lastPos, MSMoveReminder::Notification reason);
188 
189 
204 
205 
206 
215  void detectorUpdate(const SUMOTime step);
216 
217 
218 
221 
230  void writeXMLOutput(OutputDevice& dev, SUMOTime startTime, SUMOTime stopTime);
231 
232 
239  void writeXMLDetectorProlog(OutputDevice& dev) const;
241 
242 
248  return myStartPos;
249  }
250 
251 
256  SUMOReal getEndPos() const {
257  return myEndPos;
258  }
259 
260 
267  void reset();
268 
270  int getEstimatedCurrentVehicleNumber(SUMOReal speedThreshold) const;
271 
274 
277 
279  int getCurrentVehicleNumber() const;
280 
283 
286 
289 
291  int getCurrentJamNumber() const;
292 
295 
298 
300  int getCurrentJamLengthInVehicles() const;
301 
304 
306  int getCurrentStartedHalts() const;
307 
314  int getCurrentHaltingNumber() const;
315 
320  std::vector<std::string> getCurrentVehicleIDs() const;
325  const std::vector<VehicleInfo>& getCurrentVehicles() const;
327 
332  int getPassedVeh() {
333  return myPassedVeh;
334  }
335 
340  void subtractPassedVeh(int passed) {
341  myPassedVeh -= passed;
342  }
343 
344 private:
350  struct JamInfo {
352  std::vector<VehicleInfo>::const_iterator firstStandingVehicle;
353 
355  std::vector<VehicleInfo>::const_iterator lastStandingVehicle;
356  };
357 
358 
361 
373 
376 
378  std::vector<VehicleInfo> myKnownVehicles;
379 
381  std::vector<VehicleInfo> myPreviousKnownVehicles;
382 
384  std::map<const std::string, SUMOTime> myHaltingVehicleDurations;
385 
387  std::map<const std::string, SUMOTime> myIntervalHaltingVehicleDurations;
388 
390  std::vector<SUMOTime> myPastStandingDurations;
391 
393  std::vector<SUMOTime> myPastIntervalStandingDurations;
394 
395 
398 
428 
429 
432 
456 
457 
458 private:
461 
464 
465 
466 };
467 
468 
469 #endif
470 
471 /****************************************************************************/
472 
int myMaxVehicleNumber
The max number of vehicles [#veh].
SUMOReal getCurrentMeanSpeed() const
Returns the mean vehicle speed of vehicles currently on the detector.
int myMeanMaxJamInVehicles
The mean jam length [#veh].
std::vector< SUMOTime > myPastIntervalStandingDurations
Halting durations of ended halts for the current interval [s].
SUMOReal getCurrentJamLengthInMeters() const
Returns the length of all jams in meters.
long long int SUMOTime
Definition: SUMOTime.h:43
SUMOReal myMaxJamInMeters
The max jam length [m].
std::vector< std::string > getCurrentVehicleIDs() const
Returns the IDs of the vehicles within the area.
int getCurrentJamLengthInVehicles() const
Returns the length of all jams in vehicles.
virtual ~MSE2Collector()
Destructor.
An areal (along a single lane) detector.
Definition: MSE2Collector.h:83
std::map< const std::string, SUMOTime > myIntervalHaltingVehicleDurations
Storage for halting durations of known vehicles (current interval)
Internal representation of a jam.
int myCurrentMaxJamLengthInVehicles
The current maximum jam length in vehicles.
SUMOReal myStartedHalts
The number of started halts [#].
SUMOReal getEstimateQueueLength() const
Returns an estimate of the lenght of the queue of vehicles currently stopped on the detector...
Notification
Definition of a vehicle state.
std::vector< SUMOTime > myPastStandingDurations
Halting durations of ended halts [s].
std::map< const std::string, SUMOTime > myHaltingVehicleDurations
Storage for halting durations of known vehicles (for halting vehicles)
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.
SUMOReal myVehicleSamples
The number of collected samples [#].
SUMOReal getCurrentMaxJamLengthInMeters() const
Returns the length in meters of the currently largest jam.
SUMOReal getEndPos() const
Returns the end position of the detector.
VehicleInfo(std::string _id, std::string _type, SUMOReal _speed, SUMOReal _timeOnDet, SUMOReal _lengthOnDet, SUMOReal _position, SUMOReal _lengthWithGap, SUMOReal _accel, bool _stillOnDet)
Definition: MSE2Collector.h:88
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.
int getCurrentMaxJamLengthInVehicles() const
Returns the length in vehicles of the currently largest jam.
Internal representation of a vehicle.
Definition: MSE2Collector.h:87
std::vector< VehicleInfo > myKnownVehicles
List of known vehicles.
MSE2Collector & operator=(const MSE2Collector &)
Invalidated assignment operator.
int myCurrentJamLengthInVehicles
The overall jam length in vehicles.
void writeXMLDetectorProlog(OutputDevice &dev) const
Opens the XML-output using "detector" as root element.
Representation of a vehicle.
Definition: SUMOVehicle.h:66
int myJamLengthInVehiclesSum
The sum of jam lengths [#veh].
std::vector< VehicleInfo >::const_iterator firstStandingVehicle
The first standing vehicle.
int getCurrentJamNumber() const
Returns the current number of jams.
SUMOReal getCurrentOccupancy() const
Returns the curent detector occupancy.
std::vector< VehicleInfo >::const_iterator lastStandingVehicle
The last standing vehicle.
int myCurrentJamNo
The current jam number.
int getCurrentHaltingNumber() const
Returns the number of current haltings within the area.
SUMOReal getStartPos() const
Returns the begin position of 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.
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].
SUMOReal myCurrentMaxJamLengthInMeters
the current maximum jam length in meters
const std::vector< VehicleInfo > & getCurrentVehicles() const
Returns the vehicles within the area.
SUMOReal myCurrentJamLengthInMeters
The overall jam length in meters.
SUMOReal myStartPos
The position the detector starts at.
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.
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.
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.
int getCurrentStartedHalts() const
Returns the length of all jams in meters.
virtual DetectorUsage getUsageType() const
Returns the detector&#39;s usage type.
int myMaxJamInVehicles
The max jam length [#veh].
SUMOReal myMeanMaxJamInMeters
The mean jam length [m].
SUMOReal myOccupancySum
The sum of occupancies [%].
int getEstimatedCurrentVehicleNumber(SUMOReal speedThreshold) const
Returns an estimate of the number of vehicles currently on the detector.
SUMOReal myJamLengthInMetersSum
The sum of jam lengths [m].
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:213
bool notifyLeave(SUMOVehicle &veh, SUMOReal lastPos, MSMoveReminder::Notification reason)
Removes a known vehicle due to its lane-change.
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 getCurrentMeanLength() const
Returns the mean vehicle length of vehicles currently on the detector.
SUMOReal myJamDistanceThreshold
Two standing vehicles must be closer than this to be counted into the same jam.
int getCurrentVehicleNumber() const
Returns the number of vehicles currently on the detector.