42 #ifdef CHECK_MEMORY_LEAKS
44 #endif // CHECK_MEMORY_LEAKS
57 myJamHaltingSpeedThreshold(haltingSpeedThreshold),
58 myJamHaltingTimeThreshold(haltingTimeThreshold),
59 myJamDistanceThreshold(jamDistThreshold),
60 myStartPos(startPos), myEndPos(startPos + detLength),
62 myCurrentOccupancy(0), myCurrentMeanSpeed(-1), myCurrentJamNo(0),
63 myCurrentMaxJamLengthInMeters(0), myCurrentMaxJamLengthInVehicles(0),
64 myCurrentJamLengthInMeters(0), myCurrentJamLengthInVehicles(0), myCurrentStartedHalts(0)
68 assert(
myStartPos >= 0 && myStartPos < myLane->getLength());
159 std::map<SUMOVehicle*, SUMOTime> haltingVehicles;
160 std::map<SUMOVehicle*, SUMOTime> intervalHaltingVehicles;
161 std::vector<JamInfo*> jams;
198 bool isInJam =
false;
208 haltingVehicles[veh] =
DELTA_T;
209 intervalHaltingVehicles[veh] =
DELTA_T;
236 if (currentJam == 0) {
247 jams.push_back(currentJam);
256 if (currentJam != 0) {
257 jams.push_back(currentJam);
262 if (currentJam != 0) {
263 jams.push_back(currentJam);
272 for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
275 (*(*i)->firstStandingVehicle)->getPositionOnLane()
276 - (*(*i)->lastStandingVehicle)->getPositionOnLane()
277 + (*(*i)->lastStandingVehicle)->getVehicleType().getLengthWithGap();
279 if (occ && occ == *(*i)->firstStandingVehicle && occ != *(*i)->lastStandingVehicle) {
281 - (*(*i)->lastStandingVehicle)->getPositionOnLane()
282 + (*(*i)->lastStandingVehicle)->getVehicleType().getLengthWithGap();
284 unsigned jamLengthInVehicles = (unsigned) distance((*i)->firstStandingVehicle, (*i)->lastStandingVehicle) + 1;
319 for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
329 dev <<
" <interval begin=\"" <<
time2string(startTime) <<
"\" end=\"" <<
time2string(stopTime) <<
"\" " <<
"id=\"" <<
getID() <<
"\" ";
339 unsigned haltingNo = 0;
341 haltingDurationSum += (*i);
342 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i));
346 haltingDurationSum += (*i).second;
347 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i).second);
350 const SUMOTime meanHaltingDuration = haltingNo != 0 ? haltingDurationSum / haltingNo : 0;
352 SUMOTime intervalHaltingDurationSum = 0;
353 SUMOTime intervalMaxHaltingDuration = 0;
354 unsigned intervalHaltingNo = 0;
356 intervalHaltingDurationSum += (*i);
357 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i));
361 intervalHaltingDurationSum += (*i).second;
362 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i).second);
365 const SUMOTime intervalMeanHaltingDuration = intervalHaltingNo != 0 ? intervalHaltingDurationSum / intervalHaltingNo : 0;
368 <<
"meanSpeed=\"" << meanSpeed <<
"\" "
369 <<
"meanOccupancy=\"" << meanOccupancy <<
"\" "
371 <<
"meanMaxJamLengthInVehicles=\"" << meanJamLengthInVehicles <<
"\" "
372 <<
"meanMaxJamLengthInMeters=\"" << meanJamLengthInMeters <<
"\" "
377 <<
"meanHaltingDuration=\"" <<
STEPS2TIME(meanHaltingDuration) <<
"\" "
378 <<
"maxHaltingDuration=\"" <<
STEPS2TIME(maxHaltingDuration) <<
"\" "
379 <<
"haltingDurationSum=\"" <<
STEPS2TIME(haltingDurationSum) <<
"\" "
380 <<
"meanIntervalHaltingDuration=\"" <<
STEPS2TIME(intervalMeanHaltingDuration) <<
"\" "
381 <<
"maxIntervalHaltingDuration=\"" <<
STEPS2TIME(intervalMaxHaltingDuration) <<
"\" "
382 <<
"intervalHaltingDurationSum=\"" <<
STEPS2TIME(intervalHaltingDurationSum) <<
"\" "
384 <<
"meanVehicleNumber=\"" << meanVehicleNumber <<
"\" "
393 dev.
writeXMLHeader(
"detector",
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo.sf.net/xsd/det_e2_file.xsd\"");
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].
Representation of a vehicle in the micro simulation.
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.
SUMOReal getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
SUMOReal getCurrentMeanLength() const
Returns the mean vehicle length of vehicles currently on the detector.
The vehicle arrived at a junction.
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.
virtual SUMOReal getPositionOnLane() const =0
Get the vehicle's position along the lane.
SUMOReal myStartedHalts
The number of started halts [#].
Notification
Definition of a vehicle state.
std::string time2string(SUMOTime t)
SUMOReal getLength() const
Get vehicle's length [m].
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 getPositionOnLane() const
Get the vehicle's position along the lane.
SUMOReal myCurrentMeanLength
The current mean length.
unsigned myCurrentStartedHalts
The number of started halts in the last step.
const MSLane * getLane() const
Returns the lane the reminder works on.
SUMOReal getPartialOccupatorEnd() const
Returns the position of the in-lapping vehicle's end.
bool writeXMLHeader(const std::string &rootElement, const std::string &attrs="", const std::string &comment="")
Writes an XML header with optional configuration.
const std::string & getID() const
Returns the id.
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason)
Adds the vehicle to known vehicles if not beyond the dector.
unsigned myVehicleSamples
The number of collected samples [#].
Representation of a vehicle.
std::map< SUMOVehicle *, SUMOTime > myIntervalHaltingVehicleDurations
Storage for halting durations of known vehicles (current interval)
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
unsigned myMeanMaxJamInVehicles
The mean jam length [#veh].
SUMOReal myCurrentJamLengthInMeters
The overall jam length in meters.
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.
SUMOReal myCurrentMeanSpeed
The current mean speed.
void reset()
Resets all values.
unsigned myTimeSamples
The current aggregation duration [#steps].
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
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.
SUMOReal getSpeed() const
Returns the vehicle's current speed.
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.
MSVehicle * getPartialOccupator() const
Returns the vehicle which laps into this lane.
Static storage of an output device and its base (abstract) implementation.
unsigned getCurrentJamLengthInVehicles() const
Returns the length of all jams in vehicles.
bool notifyLeave(SUMOVehicle &veh, SUMOReal lastPos, MSMoveReminder::Notification reason)
Removes a known vehicle due to its lane-change.
MSLane * getLane() const
Returns the lane the vehicle is on.
Representation of a lane in the micro simulation.
int operator()(const SUMOVehicle *v1, const SUMOVehicle *v2)
Comparison funtcion.
Base of value-generating classes (detectors)
SUMOReal myJamDistanceThreshold
Two standing vehicles must be closer than this to be counted into the same jam.
unsigned myJamLengthInVehiclesSum
The sum of jam lengths [#veh].
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
void writeXMLDetectorProlog(OutputDevice &dev) const
Opens the XML-output using "detector" as root element.