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), myPassedVeh(0)
71 assert(
myStartPos >= 0 && myStartPos < myLane->getLength());
92 if (type.find(
"COLOMBO_undetectable") == std::string::npos) {
97 std::ostringstream str;
99 <<
" MSE2Collector::notifyMove::" 145 if (type.find(
"COLOMBO_undetectable") == std::string::npos) {
150 std::ostringstream str;
152 <<
" MSE2Collector::notifyEnter::" 198 std::map<const SUMOVehicle*, SUMOTime> haltingVehicles;
199 std::map<const SUMOVehicle*, SUMOTime> intervalHaltingVehicles;
200 std::vector<JamInfo*> jams;
237 bool isInJam =
false;
248 haltingVehicles[veh] =
DELTA_T;
249 intervalHaltingVehicles[veh] =
DELTA_T;
276 if (currentJam == 0) {
287 jams.push_back(currentJam);
296 if (currentJam != 0) {
297 jams.push_back(currentJam);
302 if (currentJam != 0) {
303 jams.push_back(currentJam);
312 for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
315 (*(*i)->firstStandingVehicle)->getPositionOnLane()
316 - (*(*i)->lastStandingVehicle)->getPositionOnLane()
317 + (*(*i)->lastStandingVehicle)->getVehicleType().getLengthWithGap();
318 if ((*(*i)->firstStandingVehicle)->getLane() !=
myLane) {
321 jamLengthInMeters -= ((*(*i)->firstStandingVehicle)->getVehicleType().getLengthWithGap() -
324 int jamLengthInVehicles = (int)distance((*i)->firstStandingVehicle, (*i)->lastStandingVehicle) + 1;
359 for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
369 dev <<
" <interval begin=\"" <<
time2string(startTime) <<
"\" end=\"" <<
time2string(stopTime) <<
"\" " <<
"id=\"" <<
getID() <<
"\" ";
381 haltingDurationSum += (*i);
382 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i));
386 haltingDurationSum += (*i).second;
387 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i).second);
390 const SUMOTime meanHaltingDuration = haltingNo != 0 ? haltingDurationSum / haltingNo : 0;
392 SUMOTime intervalHaltingDurationSum = 0;
393 SUMOTime intervalMaxHaltingDuration = 0;
394 int intervalHaltingNo = 0;
396 intervalHaltingDurationSum += (*i);
397 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i));
401 intervalHaltingDurationSum += (*i).second;
402 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i).second);
405 const SUMOTime intervalMeanHaltingDuration = intervalHaltingNo != 0 ? intervalHaltingDurationSum / intervalHaltingNo : 0;
408 <<
"meanSpeed=\"" << meanSpeed <<
"\" " 409 <<
"meanOccupancy=\"" << meanOccupancy <<
"\" " 411 <<
"meanMaxJamLengthInVehicles=\"" << meanJamLengthInVehicles <<
"\" " 412 <<
"meanMaxJamLengthInMeters=\"" << meanJamLengthInMeters <<
"\" " 417 <<
"meanHaltingDuration=\"" <<
STEPS2TIME(meanHaltingDuration) <<
"\" " 418 <<
"maxHaltingDuration=\"" <<
STEPS2TIME(maxHaltingDuration) <<
"\" " 419 <<
"haltingDurationSum=\"" <<
STEPS2TIME(haltingDurationSum) <<
"\" " 420 <<
"meanIntervalHaltingDuration=\"" <<
STEPS2TIME(intervalMeanHaltingDuration) <<
"\" " 421 <<
"maxIntervalHaltingDuration=\"" <<
STEPS2TIME(intervalMaxHaltingDuration) <<
"\" " 422 <<
"intervalHaltingDurationSum=\"" <<
STEPS2TIME(intervalHaltingDurationSum) <<
"\" " 424 <<
"meanVehicleNumber=\"" << meanVehicleNumber <<
"\" " 433 dev.
writeXMLHeader(
"detector",
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo.dlr.de/xsd/det_e2_file.xsd\"");
449 for (std::list<SUMOVehicle*>::const_iterator it =
myKnownVehicles.begin();
462 if (vel <= thresholdSpeed || acceleration > 0) {
463 count = (int)(realDistance / carLength) + 1;
480 for (std::list<SUMOVehicle*>::const_iterator it =
myKnownVehicles.begin();
493 realDistance = distance - carLength;
497 std::ostringstream str;
499 <<
" MSE2Collector::getEstimateQueueLength::" 501 <<
" vehicle " << veh->
getID()
504 <<
" realDistance " << realDistance;
587 std::vector<std::string>
589 std::vector<std::string> ret;
592 ret.push_back(veh->
getID());
594 std::sort(ret.begin(), ret.end());
int myMaxVehicleNumber
The max number of vehicles [#veh].
std::map< const SUMOVehicle *, SUMOTime > myHaltingVehicleDurations
Storage for halting durations of known vehicles (for halting vehicles)
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.
Representation of a vehicle in the micro simulation.
SUMOReal myMaxJamInMeters
The max jam length [m].
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.
int myCurrentMaxJamLengthInVehicles
The current maximum jam length in vehicles.
SUMOReal getLength() const
Returns the lane's length.
MSLane *const myLane
Lane on which the reminder works.
int getCurrentStartedHalts() const
Returns the length of all jams in meters.
virtual SUMOReal getPositionOnLane() const =0
Get the vehicle's position along the lane.
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.
std::string time2string(SUMOTime t)
SUMOReal getLength() const
Get vehicle's length [m].
A class used to sort known vehicles by their position.
int getCurrentJamLengthInVehicles() const
Returns the length of all jams in vehicles.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
int myVehicleSamples
The number of collected samples [#].
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].
SUMOReal getPositionOnLane() const
Get the vehicle's position along the lane.
int myCurrentStartedHalts
The number of started halts in the last step.
SUMOReal myCurrentMeanLength
The current mean length.
const MSLane * getLane() const
Returns the lane the reminder works on.
bool writeXMLHeader(const std::string &rootElement, const std::string &attrs="", const std::string &comment="")
Writes an XML header with optional configuration.
int myTimeSamples
The current aggregation duration [#steps].
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.
int myCurrentJamLengthInVehicles
The overall jam length in vehicles.
Representation of a vehicle.
int myJamLengthInVehiclesSum
The sum of jam lengths [#veh].
std::list< SUMOVehicle * > myKnownVehicles
List of known vehicles.
virtual bool isFrontOnLane(const MSLane *) const =0
Returns the information whether the front of the vehhicle is on the given lane.
SUMOReal getCurrentMeanSpeed() const
Returns the mean vehicle speed of vehicles currently on the detector.
int myCurrentJamNo
The current jam number.
SUMOReal getSpeedLimit() const
Returns the lane's maximum allowed speed.
int getCurrentVehicleNumber() const
Returns the number 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.
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].
SUMOReal myCurrentMaxJamLengthInMeters
the current maximum jam length in meters
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.
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.
SUMOReal myCurrentOccupancy
The current occupancy.
SUMOReal myMaxOccupancy
The maximum occupancy [%].
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.
SUMOReal getAcceleration() const
Returns the vehicle's acceleration in m/s.
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.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
int myMaxJamInVehicles
The max jam length [#veh].
SUMOReal myMeanMaxJamInMeters
The mean jam length [m].
SUMOReal myOccupancySum
The sum of occupancies [%].
const std::string & getID() const
Returns the name of the vehicle type.
virtual SUMOReal getBackPositionOnLane(const MSLane *lane) const =0
Get the vehicle's back position along the given lane.
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.
SUMOReal getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
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.
int myCurrentHaltingsNumber
The number of halted 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.
#define WRITE_MESSAGE(msg)
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.
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.
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.