44 #ifdef CHECK_MEMORY_LEAKS
46 #endif // CHECK_MEMORY_LEAKS
59 myJamHaltingSpeedThreshold(haltingSpeedThreshold),
60 myJamHaltingTimeThreshold(haltingTimeThreshold),
61 myJamDistanceThreshold(jamDistThreshold),
62 myStartPos(startPos), myEndPos(startPos + detLength),
64 myCurrentOccupancy(0), myCurrentMeanSpeed(-1), myCurrentJamNo(0),
65 myCurrentMaxJamLengthInMeters(0), myCurrentMaxJamLengthInVehicles(0),
66 myCurrentJamLengthInMeters(0), myCurrentJamLengthInVehicles(0), myCurrentStartedHalts(0),
67 myCurrentHaltingsNumber(0)
71 assert(
myStartPos >= 0 && myStartPos < myLane->getLength());
166 std::map<const SUMOVehicle*, SUMOTime> haltingVehicles;
167 std::map<const SUMOVehicle*, SUMOTime> intervalHaltingVehicles;
168 std::vector<JamInfo*> jams;
206 bool isInJam =
false;
217 haltingVehicles[veh] =
DELTA_T;
218 intervalHaltingVehicles[veh] =
DELTA_T;
245 if (currentJam == 0) {
256 jams.push_back(currentJam);
265 if (currentJam != 0) {
266 jams.push_back(currentJam);
271 if (currentJam != 0) {
272 jams.push_back(currentJam);
281 for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
284 (*(*i)->firstStandingVehicle)->getPositionOnLane()
285 - (*(*i)->lastStandingVehicle)->getPositionOnLane()
286 + (*(*i)->lastStandingVehicle)->getVehicleType().getLengthWithGap();
288 if (occ && occ == *(*i)->firstStandingVehicle && occ != *(*i)->lastStandingVehicle) {
290 - (*(*i)->lastStandingVehicle)->getPositionOnLane()
291 + (*(*i)->lastStandingVehicle)->getVehicleType().getLengthWithGap();
293 unsigned jamLengthInVehicles = (unsigned) distance((*i)->firstStandingVehicle, (*i)->lastStandingVehicle) + 1;
328 for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
338 dev <<
" <interval begin=\"" <<
time2string(startTime) <<
"\" end=\"" <<
time2string(stopTime) <<
"\" " <<
"id=\"" <<
getID() <<
"\" ";
348 unsigned haltingNo = 0;
350 haltingDurationSum += (*i);
351 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i));
355 haltingDurationSum += (*i).second;
356 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i).second);
359 const SUMOTime meanHaltingDuration = haltingNo != 0 ? haltingDurationSum / haltingNo : 0;
361 SUMOTime intervalHaltingDurationSum = 0;
362 SUMOTime intervalMaxHaltingDuration = 0;
363 unsigned intervalHaltingNo = 0;
365 intervalHaltingDurationSum += (*i);
366 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i));
370 intervalHaltingDurationSum += (*i).second;
371 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i).second);
374 const SUMOTime intervalMeanHaltingDuration = intervalHaltingNo != 0 ? intervalHaltingDurationSum / intervalHaltingNo : 0;
377 <<
"meanSpeed=\"" << meanSpeed <<
"\" "
378 <<
"meanOccupancy=\"" << meanOccupancy <<
"\" "
380 <<
"meanMaxJamLengthInVehicles=\"" << meanJamLengthInVehicles <<
"\" "
381 <<
"meanMaxJamLengthInMeters=\"" << meanJamLengthInMeters <<
"\" "
386 <<
"meanHaltingDuration=\"" <<
STEPS2TIME(meanHaltingDuration) <<
"\" "
387 <<
"maxHaltingDuration=\"" <<
STEPS2TIME(maxHaltingDuration) <<
"\" "
388 <<
"haltingDurationSum=\"" <<
STEPS2TIME(haltingDurationSum) <<
"\" "
389 <<
"meanIntervalHaltingDuration=\"" <<
STEPS2TIME(intervalMeanHaltingDuration) <<
"\" "
390 <<
"maxIntervalHaltingDuration=\"" <<
STEPS2TIME(intervalMaxHaltingDuration) <<
"\" "
391 <<
"intervalHaltingDurationSum=\"" <<
STEPS2TIME(intervalHaltingDurationSum) <<
"\" "
393 <<
"meanVehicleNumber=\"" << meanVehicleNumber <<
"\" "
402 dev.
writeXMLHeader(
"detector",
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo-sim.org/xsd/det_e2_file.xsd\"");
484 std::vector<std::string>
486 std::vector<std::string> ret;
489 ret.push_back(veh->
getID());
491 std::sort(ret.begin(), ret.end());
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.
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::list< SUMOVehicle * > myKnownVehicles
List of known vehicles.
SUMOReal getCurrentMeanSpeed() const
Returns the mean vehicle speed of vehicles currently on the detector.
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
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.
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.
std::map< const SUMOVehicle *, SUMOTime > myIntervalHaltingVehicleDurations
Storage for halting durations of known vehicles (current interval)
MSLane * getLane() const
Returns the lane the vehicle is on.
Representation of a lane in the micro simulation.
SUMOReal myCurrentHaltingsNumber
The number of halted vehicles [#].
int operator()(const SUMOVehicle *v1, const SUMOVehicle *v2)
Comparison funtcion.
Base of value-generating classes (detectors)
const std::string & getID() const
Returns the name of the vehicle.
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.