66 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
67 const std::string& vTypes) :
71 myJamHaltingSpeedThreshold(haltingSpeedThreshold),
72 myJamHaltingTimeThreshold(haltingTimeThreshold),
73 myJamDistanceThreshold(jamDistThreshold),
74 myNumberOfEnteredVehicles(0),
75 myNumberOfSeenVehicles(0),
76 myNumberOfLeftVehicles(0) {
79 #ifdef DEBUG_E2_CONSTRUCTOR 80 std::cout <<
"\n" <<
"Creating MSE2Collector " <<
id 81 <<
" with lane = " << lane->
getID()
82 <<
" startPos = " << startPos
83 <<
" endPos = " << endPos
84 <<
" length = " << length
85 <<
" haltingTimeThreshold = " << haltingTimeThreshold
86 <<
" haltingSpeedThreshold = " << haltingSpeedThreshold
87 <<
" jamDistThreshold = " << jamDistThreshold
102 WRITE_WARNING(
"No valid detector length and start position given. Assuming startPos = 0 and length = end position");
106 WRITE_WARNING(
"No valid detector length and end position given. Assuming endPos = lane length and length = endPos-startPos");
109 endPos = endPos < 0 ? lane->
getLength() + endPos : endPos;
110 startPos = startPos < 0 ? lane->
getLength() + startPos : startPos;
111 bool valid = endPos <= lane->
getLength() && 0 <= startPos && startPos < endPos;
113 throw InvalidArgument(
"Error in specification for E2Detector '" +
id +
"'. Positional argument is malformed. 0 <= pos < endPos <= lane.getLength() is required.");
118 length = endPos - startPos;
119 }
else if (posInvalid) {
121 endPos = endPos < 0 ? lane->
getLength() + endPos : endPos;
125 startPos = startPos < 0 ? lane->
getLength() + startPos : startPos;
132 std::vector<MSLane*> lanes;
135 }
else if (endPosInvalid) {
139 lanes.push_back(lane);
149 DetectorUsage usage, std::vector<MSLane*> lanes,
double startPos,
double endPos,
150 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
151 const std::string& vTypes) :
167 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
171 #ifdef DEBUG_E2_CONSTRUCTOR 172 std::cout <<
"\n" <<
"Creating MSE2Collector " <<
id 174 <<
" endPos = " << endPos
176 <<
" startPos = " << startPos
177 <<
" haltingTimeThreshold = " << haltingTimeThreshold
178 <<
" haltingSpeedThreshold = " << haltingSpeedThreshold
179 <<
" jamDistThreshold = " << jamDistThreshold
190 myEndPos = lanes[lanes.size() - 1]->getLength();
204 std::stringstream ss;
205 ss <<
"Cannot build detector of length " << desiredLength
233 #ifdef DEBUG_E2_CONSTRUCTOR 234 std::stringstream ss;
237 std::cout <<
"myStartPos = " << myStartPos << std::endl;
238 std::cout <<
"myEndPos = " << myEndPos << std::endl;
252 if (fabs(value - snapPoint) < snapDist) {
262 std::vector<std::string>::const_iterator i;
263 std::vector<MSLane*> lanes;
267 lanes.push_back(lane);
271 std::vector<MSLane*>::const_iterator j;
274 for (j = lanes.begin(); j != lanes.end(); ++j) {
287 #ifdef DEBUG_E2_CONSTRUCTOR 288 std::cout <<
"Total detector length after recalculation = " <<
myDetectorLength << std::endl;
311 assert(dir ==
"fw" || dir ==
"bw");
312 bool fw = dir ==
"fw";
313 double linkLength = 0;
314 bool substractedLinkLength =
false;
316 #ifdef DEBUG_E2_CONSTRUCTOR 317 std::cout <<
"\n" <<
"selectLanes()" << (fw ?
"(forward)" :
"(backward)") << std::endl;
319 std::vector<MSLane*> lanes;
335 lanes.push_back(lane);
336 #ifdef DEBUG_E2_CONSTRUCTOR 337 std::cout <<
"Added lane " << lane->
getID()
338 <<
" (length: " << lane->
getLength() <<
")" << std::endl;
351 substractedLinkLength =
false;
361 length -= linkLength;
362 substractedLinkLength =
true;
366 #ifdef DEBUG_E2_CONSTRUCTOR 368 std::cout << (fw ?
"Successor lane: " :
"Predecessor lane: ") <<
"'" << lane->
getID() <<
"'";
370 std::cout << std::endl;
374 if (substractedLinkLength) {
378 length += linkLength;
392 myEndPos = lanes[lanes.size() - 1]->getLength();
393 }
else if (length < 0) {
394 myEndPos = lanes[lanes.size() - 1]->getLength() + length;
399 }
else if (length < 0) {
406 std::reverse(lanes.begin(), lanes.end());
414 #ifdef DEBUG_E2_CONSTRUCTOR 415 std::cout <<
"\n" <<
"Adding detector " <<
myID <<
" to lanes:" << std::endl;
417 for (std::vector<MSLane*>::iterator l = lanes.begin(); l != lanes.end(); ++l) {
418 (*l)->addMoveReminder(
this);
419 #ifdef DEBUG_E2_CONSTRUCTOR 420 std::cout << (*l)->getID() << std::endl;
431 #ifdef DEBUG_E2_CONSTRUCTOR 432 std::cout <<
"\n" <<
"Initializing auxiliaries:" 451 std::vector<MSLane*>::iterator il = lanes.begin();
458 #ifdef DEBUG_E2_CONSTRUCTOR 459 std::cout <<
"\n" <<
"Initializing offsets:" << std::endl;
463 #pragma warning(push) 464 #pragma warning(disable: 4127) // do not warn about constant conditional expression 471 while (
internal != 0) {
472 myLanes.push_back(internal->getID());
475 #ifdef DEBUG_E2_CONSTRUCTOR 476 std::cout <<
"Offset for lane " <<
internal->getID() <<
" = " <<
myDetectorLength 486 assert(internal->getLinkCont().size() == 1);
488 internal =
internal->getLinkCont()[0]->getViaLaneOrLane();
489 if (!internal->isInternal()) {
501 while (il != lanes.end() && (*il)->isInternal()) {
504 if (il == lanes.end()) {
512 #ifdef DEBUG_E2_CONSTRUCTOR 524 if (++il == lanes.end()) {
528 if ((*il)->isInternal()) {
537 throw InvalidArgument(
"Lanes '" + lane->
getID() +
"' and '" + (*il)->getID() +
"' are not consecutive in defintion of e2Detector '" +
getID() +
"'");
555 #ifdef DEBUG_E2_CONSTRUCTOR 556 std::cout <<
"Total detector length after initAuxiliaries() = " <<
myDetectorLength << std::endl;
566 std::vector<MSLane*> res;
567 for (std::vector<std::string>::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
576 double newPos,
double newSpeed) {
580 const std::string& vehID = veh.
getID();
589 #ifdef DEBUG_E2_NOTIFY_MOVE 591 <<
" MSE2Collector::notifyMove() (detID = " <<
myID <<
"on lane '" <<
myLane->
getID() <<
"')" 592 <<
" called by vehicle '" << vehID <<
"'" 593 <<
" at relative position " << relPos
600 #ifdef DEBUG_E2_NOTIFY_MOVE 601 std::cout <<
"Vehicle has not yet reached the detector start position." << std::endl;
617 if (vehicleEnteredLaneAfterDetector) {
618 #ifdef DEBUG_E2_NOTIFY_MOVE 619 std::cout <<
"Vehicle entered lane behind detector." << std::endl;
626 if (vehPassedDetectorEnd) {
627 #ifdef DEBUG_E2_NOTIFY_MOVE 628 std::cout <<
"Vehicle has left the detector longitudinally." << std::endl;
641 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 642 std::cout <<
"\n" <<
SIMTIME <<
" notifyLeave() (detID = " <<
myID <<
"on lane '" <<
myLane->
getID() <<
"')" 643 <<
"called by vehicle '" << veh.
getID() <<
"'" << std::endl;
649 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 650 std::cout <<
SIMTIME <<
" Left longitudinally (along junction) -> keep subscription [handle exit in notifyMove()]" << std::endl;
657 double exitOffset = vi->second->entryOffset -
myOffsets[vi->second->currentOffsetIndex] - vi->second->currentLane->getLength();
658 vi->second->exitOffset =
MAX2(vi->second->exitOffset, exitOffset);
659 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 660 std::cout <<
SIMTIME <<
" Vehicle '" << veh.
getID() <<
"' leaves the detector. Exit offset = " << vi->second->exitOffset << std::endl;
671 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 672 std::cout <<
SIMTIME <<
" Left non-longitudinally (lanechange, teleport, parking, etc) -> discard subscription" << std::endl;
681 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 682 std::cout <<
"\n" <<
SIMTIME <<
" notifyEnter() (detID = " <<
myID <<
"on lane '" <<
myLane->
getID() <<
"')" 683 <<
"called by vehicle '" << veh.
getID()
684 <<
"' entering lane '" << (enteredLane != 0 ? enteredLane->
getID() :
"NULL") <<
"'" << std::endl;
690 assert(veh.
getLane() == enteredLane);
696 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 699 std::cout <<
"Vehicle is off road (teleporting over edge)..." << std::endl;
703 const std::string& vehID = veh.
getID();
707 vi->second->currentOffsetIndex++;
708 vi->second->currentLane = enteredLane;
710 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 712 <<
"' already known. No new VehicleInfo is created.\n" 713 <<
"enteredLane = " << enteredLane->
getID() <<
"\nmyLanes[vi->offset] = " <<
myLanes[vi->second->currentOffsetIndex]
716 assert(
myLanes[vi->second->currentOffsetIndex] == enteredLane->
getID());
724 #ifdef DEBUG_E2_NOTIFY_ENTER_AND_LEAVE 725 std::cout <<
SIMTIME <<
" Adding VehicleInfo for vehicle '" << veh.
getID() <<
"'." << std::endl;
738 assert(j >= 0 && j <
myLanes.size());
743 #ifdef DEBUG_E2_MAKE_VEHINFO 744 std::cout <<
SIMTIME <<
" Making VehicleInfo for vehicle '" << veh.
getID() <<
"'." 745 <<
"\ndistToDetectorEnd = " << distToDetectorEnd
747 <<
"\nentry lane offset (lane begin from detector begin) = " << entryOffset
757 #ifdef DEBUG_E2_DETECTOR_UPDATE 758 std::cout <<
"\n" <<
SIMTIME <<
" detectorUpdate() for detector '" <<
myID <<
"'" 778 std::vector<JamInfo*> jams;
779 std::map<std::string, SUMOTime> haltingVehicles;
780 std::map<std::string, SUMOTime> intervalHaltingVehicles;
785 const std::string& vehID = (*i)->id;
796 bool isInJam =
checkJam(i, haltingVehicles, intervalHaltingVehicles);
797 buildJam(isInJam, i, currentJam, jams);
810 #ifdef DEBUG_E2_DETECTOR_UPDATE 811 std::cout <<
"\n" <<
SIMTIME <<
" Current lanes for vehicles still on the detector:" << std::endl;
814 VehicleInfoMap::iterator iv;
816 #ifdef DEBUG_E2_DETECTOR_UPDATE 817 std::cout <<
" Vehicle '" << iv->second->id <<
"'" <<
": '" 818 << iv->second->currentLane->getID() <<
"'" 823 #ifdef DEBUG_E2_DETECTOR_UPDATE 824 std::cout <<
SIMTIME <<
" Discarding vehicles that have left the detector:" << std::endl;
827 std::set<std::string>::const_iterator i;
833 #ifdef DEBUG_E2_DETECTOR_UPDATE 834 std::cout <<
"Erased vehicle '" << *i <<
"'" << std::endl;
874 #ifdef DEBUG_E2_DETECTOR_UPDATE 875 std::cout <<
SIMTIME <<
" integrateMoveNotification() for vehicle '" << mni->
id <<
"'" 879 <<
"\nspeed = " << mni->
speed 907 #ifdef DEBUG_E2_NOTIFY_MOVE 908 std::cout <<
SIMTIME <<
" makeMoveNotification() for vehicle '" << veh.
getID() <<
"'" 909 <<
" oldPos = " << oldPos <<
" newPos = " << newPos <<
" newSpeed = " << newSpeed
914 double timeOnDetector;
926 double distToExit = -vehInfo.
exitOffset - newPos;
928 lengthOnDetector =
MAX2(0., lengthOnDetector +
MIN2(0., distToExit));
931 bool stillOnDetector = -distToExit < vehInfo.
length;
933 #ifdef DEBUG_E2_NOTIFY_MOVE 934 std::cout <<
SIMTIME <<
" lengthOnDetector = " << lengthOnDetector
935 <<
"\nvehInfo.exitOffset = " << vehInfo.
exitOffset 936 <<
" vehInfo.entryOffset = " << vehInfo.
entryOffset 937 <<
" distToExit = " << distToExit
948 std::cout <<
SIMTIME <<
" buildJam() for vehicle '" << (*mni)->id <<
"'" << std::endl;
953 if (currentJam == 0) {
955 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"' forms the start of the first jam" << std::endl;
968 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"' forms the start of a new jam" << std::endl;
972 jams.push_back(currentJam);
981 if (currentJam != 0) {
983 std::cout <<
SIMTIME <<
" Closing current jam." << std::endl;
985 jams.push_back(currentJam);
993 MSE2Collector::checkJam(std::vector<MoveNotificationInfo*>::const_iterator mni, std::map<std::string, SUMOTime>& haltingVehicles, std::map<std::string, SUMOTime>& intervalHaltingVehicles) {
995 std::cout <<
SIMTIME <<
" CheckJam() for vehicle '" << (*mni)->id <<
"'" << std::endl;
998 bool isInJam =
false;
1009 #ifdef DEBUG_E2_JAMS 1010 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"' starts halting." << std::endl;
1012 haltingVehicles[(*mni)->id] =
DELTA_T;
1013 intervalHaltingVehicles[(*mni)->id] =
DELTA_T;
1035 #ifdef DEBUG_E2_JAMS 1036 std::cout <<
SIMTIME <<
" vehicle '" << (*mni)->id <<
"'" << (isInJam ?
"is jammed." :
"is not jammed.") << std::endl;
1045 if (currentJam != 0) {
1046 jams.push_back(currentJam);
1050 #ifdef DEBUG_E2_JAMS 1051 std::cout <<
"\n" <<
SIMTIME <<
" processJams()" 1052 <<
"\nNumber of jams: " << jams.size() << std::endl;
1060 for (std::vector<JamInfo*>::const_iterator i = jams.begin(); i != jams.end(); ++i) {
1067 const int jamLengthInVehicles = (int) distance((*i)->firstStandingVehicle, (*i)->lastStandingVehicle) + 1;
1075 #ifdef DEBUG_E2_JAMS 1076 std::cout <<
SIMTIME <<
" processing jam nr." << ((int) distance((std::vector<JamInfo*>::const_iterator) jams.begin(), i) + 1)
1077 <<
"\njamLengthInMeters = " << jamLengthInMeters
1078 <<
" jamLengthInVehicles = " << jamLengthInVehicles
1085 for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
1095 if (oldPos == newPos) {
1098 timeOnDetector =
TS;
1105 double entryTime = 0;
1107 if (oldPos < entryPos) {
1115 assert(entryPos < exitPos);
1119 if (exitPos == newPos) {
1134 timeOnDetector = exitTime - entryTime;
1135 timeLoss =
MAX2(0., timeOnDetector * (vmax - (entrySpeed + exitSpeed) / 2) / vmax);
1137 #ifdef DEBUG_E2_TIME_ON_DETECTOR 1138 std::cout <<
SIMTIME <<
" calculateTimeLoss() for vehicle '" << veh.
getID() <<
"'" 1139 <<
" oldPos = " << oldPos <<
" newPos = " << newPos
1140 <<
" entryPos = " << entryPos <<
" exitPos = " << exitPos
1141 <<
" timeOnDetector = " << timeOnDetector
1142 <<
" timeLoss = " << timeLoss
1155 dev <<
" <interval begin=\"" <<
time2string(startTime) <<
"\" end=\"" <<
time2string(stopTime) <<
"\" " <<
"id=\"" <<
getID() <<
"\" ";
1168 haltingDurationSum += (*i);
1169 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i));
1173 haltingDurationSum += (*i).second;
1174 maxHaltingDuration =
MAX2(maxHaltingDuration, (*i).second);
1177 const SUMOTime meanHaltingDuration = haltingNo != 0 ? haltingDurationSum / haltingNo : 0;
1179 SUMOTime intervalHaltingDurationSum = 0;
1180 SUMOTime intervalMaxHaltingDuration = 0;
1181 int intervalHaltingNo = 0;
1183 intervalHaltingDurationSum += (*i);
1184 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i));
1185 intervalHaltingNo++;
1188 intervalHaltingDurationSum += (*i).second;
1189 intervalMaxHaltingDuration =
MAX2(intervalMaxHaltingDuration, (*i).second);
1190 intervalHaltingNo++;
1192 const SUMOTime intervalMeanHaltingDuration = intervalHaltingNo != 0 ? intervalHaltingDurationSum / intervalHaltingNo : 0;
1194 #ifdef DEBUG_E2_XML_OUT 1195 std::stringstream ss;
1201 <<
"meanSpeed=\"" << meanSpeed <<
"\"";
1202 std::cout << ss.str() << std::endl;
1210 <<
"meanSpeed=\"" << meanSpeed <<
"\" " 1211 <<
"meanTimeLoss=\"" << meanTimeLoss <<
"\" " 1212 <<
"meanOccupancy=\"" << meanOccupancy <<
"\" " 1214 <<
"meanMaxJamLengthInVehicles=\"" << meanJamLengthInVehicles <<
"\" " 1215 <<
"meanMaxJamLengthInMeters=\"" << meanJamLengthInMeters <<
"\" " 1220 <<
"meanHaltingDuration=\"" <<
STEPS2TIME(meanHaltingDuration) <<
"\" " 1221 <<
"maxHaltingDuration=\"" <<
STEPS2TIME(maxHaltingDuration) <<
"\" " 1222 <<
"haltingDurationSum=\"" <<
STEPS2TIME(haltingDurationSum) <<
"\" " 1223 <<
"meanIntervalHaltingDuration=\"" <<
STEPS2TIME(intervalMeanHaltingDuration) <<
"\" " 1224 <<
"maxIntervalHaltingDuration=\"" <<
STEPS2TIME(intervalMaxHaltingDuration) <<
"\" " 1225 <<
"intervalHaltingDurationSum=\"" <<
STEPS2TIME(intervalHaltingDurationSum) <<
"\" " 1227 <<
"meanVehicleNumber=\"" << meanVehicleNumber <<
"\" " 1267 if (it->second->onDetector) {
1276 std::vector<std::string>
1278 std::vector<std::string> ret;
1280 if (i->second->onDetector) {
1281 ret.push_back(i->second->id);
1284 std::sort(ret.begin(), ret.end());
1289 std::vector<MSE2Collector::VehicleInfo*>
1291 std::vector<VehicleInfo*> res;
1292 VehicleInfoMap::const_iterator i;
1294 if (i->second->onDetector) {
1295 res.push_back(i->second);
1312 if (it->second->onDetector) {
1317 const double realDistance = it->second->distToDetectorEnd;
1318 if (it->second->lastSpeed <= thresholdSpeed || it->second->lastAccel > 0) {
1319 count = (int)(realDistance / (it->second->length + it->second->minGap)) + 1;
1335 double realDistance = 0;
1336 bool flowing =
true;
1339 if (it->second->onDetector) {
1340 distance =
MIN2(it->second->lastPos, distance);
1342 if (it->second->lastSpeed <= 0.5) {
1343 realDistance = distance - it->second->length + it->second->minGap;
virtual MSLane * getLane() const =0
Returns the lane the vehicle is on.
std::vector< double > myOffsets
The distances of the lane-beginnings from the detector start-point.
int myMaxVehicleNumber
The maximal number of vehicles located on the detector simultaneously since the last reset...
static double speedAfterTime(const double t, const double oldSpeed, const double dist)
Calculates the speed after a time t [0,TS] given the initial speed and the distance traveled in an i...
double getMinGap() const
Get the free space in front of vehicles of this class.
bool checkJam(std::vector< MoveNotificationInfo * >::const_iterator mni, std::map< std::string, SUMOTime > &haltingVehicles, std::map< std::string, SUMOTime > &intervalHaltingVehicles)
checks whether the vehicle stands in a jam
int myMeanMaxJamInVehicles
The mean jam length [#veh].
double lastAccel
Last value of the acceleration.
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
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.
double getEstimateQueueLength() const
Returns an estimate of the lenght of the queue of vehicles currently stopped on the detector...
std::vector< MoveNotificationInfo * >::const_iterator firstStandingVehicle
The first standing vehicle.
std::vector< VehicleInfo * > getCurrentVehicles() const
Returns the VehicleInfos for the vehicles currently on the detector.
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
double myMeanMaxJamInMeters
The mean jam length [m].
bool onDetector
whether the vehicle is on the detector at the end of the current timestep
static bool compareMoveNotification(MoveNotificationInfo *mni1, MoveNotificationInfo *mni2)
MoveNotificationInfo * makeMoveNotification(const SUMOVehicle &veh, double oldPos, double newPos, double newSpeed, const VehicleInfo &vehInfo) const
Creates and returns a MoveNotificationInfo containing detector specific information on the vehicle's ...
double myMaxOccupancy
The maximum occupancy [%].
MSLink * getLinkTo(const MSLane *) const
returns the link to the given lane or 0, if it is not connected
double lastSpeed
Last value of the speed.
virtual ~MSE2Collector()
Destructor.
The vehicle arrived at a junction.
MSE2Collector(const std::string &id, DetectorUsage usage, MSLane *lane, double startPos, double endPos, double length, SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold, const std::string &vTypes)
Constructor with given end position and detector length.
Internal representation of a jam.
int myCurrentMaxJamLengthInVehicles
The current maximum jam length in vehicles.
void calculateTimeLossAndTimeOnDetector(const SUMOVehicle &veh, double oldPos, double newPos, const VehicleInfo &vi, double &timeOnDetector, double &timeLoss) const
Calculates the time spent on the detector in the last step and the timeloss suffered in the last step...
double getLength() const
Returns the length of this link.
bool onDetector
whether the vehicle is on the detector at the end of the current timestep
MSLane *const myLane
Lane on which the reminder works.
MSLane * getViaLane() const
Returns the following inner lane.
Values collected in notifyMove and needed in detectorUpdate() to calculate the accumulated quantities...
bool vehicleApplies(const SUMOVehicle &veh) const
Checks whether the detector measures vehicles of the given type.
double lengthOnDetector
The length of the part of the vehicle on the detector at the end of the last time step...
double myTotalTimeLoss
The total amount of all time losses [time x vehicle] since the last reset.
Notification
Definition of a vehicle state.
std::string time2string(SUMOTime t)
double timeOnDetector
Time spent on the detector during the last integration step.
double newPos
Position after the last integration step (relative to the vehicle's entry lane on the detector) ...
double getLength() const
Returns the lane's length.
std::string id
Vehicle's id.
std::vector< SUMOTime > myPastStandingDurations
Halting durations of ended halts [s].
virtual double getPositionOnLane() const =0
Get the vehicle's position along the lane.
double accel
Acceleration in the last integration step.
double getLength() const
Returns the length of the detector.
int myMeanVehicleNumber
The mean number of vehicles [#veh].
virtual bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane)
Adds the vehicle to known vehicles if not beyond the dector.
double totalTimeOnDetector
Accumulated time that this vehicle has spent on the detector since its last entry.
int myCurrentStartedHalts
The number of started halts in the last step.
VehicleInfo * makeVehicleInfo(const SUMOVehicle &veh, const MSLane *enteredLane) const
Creates and returns a VehicleInfo (called at the vehicle's entry)
std::vector< MoveNotificationInfo * > myMoveNotifications
Temporal storage for notifications from vehicles that did call the detector's notifyMove() in the las...
void processJams(std::vector< JamInfo * > &jams, JamInfo *currentJam)
Calculates aggregated values from the given jam structure, deletes all jam-pointers.
#define WRITE_WARNING(msg)
void aggregateOutputValues()
Aggregates and normalize some values for the detector output during detectorUpdate() ...
double myJamHaltingSpeedThreshold
A vehicle must driver slower than this to be counted as a part of a jam.
std::vector< std::string > myLanes
double mySpeedSum
The sum of collected vehicle speeds [m/s].
virtual double getAcceleration() const =0
Returns the vehicle's acceleration.
std::vector< MoveNotificationInfo * >::const_iterator lastStandingVehicle
The last standing vehicle.
void checkPositioning(bool posGiven=false, double desiredLength=0.)
Adjusts positioning if the detector length is less than POSITION_EPS and tests some assertions...
void recalculateDetectorLength()
Updates the detector length after myStartPos and myEndPos have been modified.
double myJamDistanceThreshold
Two standing vehicles must be closer than this to be counted into the same jam.
int myTimeSamples
The current aggregation duration [#steps].
const std::string & getID() const
Returns the id.
MSLane * getCanonicalSuccessorLane() const
A VehicleInfo stores values that are tracked for the individual vehicles on the detector, e.g., accumulated timeloss. These infos are stored in myVehicles. If a vehicle leaves the detector (may it be temporarily), the entry in myVehicles is discarded, i.e. all information on the vehicle is reset.
double myCurrentMeanLength
The current mean length.
virtual double getSpeed() const =0
Returns the vehicle's current speed.
static double snap(double value, double snapPoint, double snapDist)
Snaps value to snpPoint if they are closer than snapDist.
int myCurrentJamLengthInVehicles
The overall jam length in vehicles.
void buildJam(bool isInJam, std::vector< MoveNotificationInfo * >::const_iterator mni, JamInfo *¤tJam, std::vector< JamInfo * > &jams)
Either adds the vehicle to the end of an existing jam, or closes the last jam, and/or creates a new j...
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Representation of a vehicle.
int myNumberOfSeenVehicles
The number of vehicles, present on the detector at the last reset.
int myJamLengthInVehiclesSum
The sum of jam lengths [#veh].
double myStartedHalts
The number of started halts [#].
double distToDetectorEnd
Distance left till the detector end after the last integration step (may become negative if the vehic...
bool writeXMLHeader(const std::string &rootElement, const std::string &schemaFile, std::map< SumoXMLAttr, std::string > attrs=std::map< SumoXMLAttr, std::string >())
Writes an XML header with optional configuration.
std::vector< MSLane * > selectLanes(MSLane *endLane, double length, std::string dir)
This is called if no lane sequence is given to the constructor. Builds myLanes from the given informa...
double myJamLengthInMetersSum
The sum of jam lengths [m].
double myMaxJamInMeters
The max jam length [m].
MSLane * myFirstLane
The first lane of the detector's lane sequence.
std::string id
vehicle's ID
double myDetectorLength
The total detector length.
std::vector< MSLane * > getLanes()
Returns a vector containing pointers to the lanes covered by the detector ordered from its first to i...
void initAuxiliaries(std::vector< MSLane * > &lanes)
Checks integrity of myLanes, adds internal-lane information, inits myLength, myFirstLane, myLastLane, myOffsets Called once at construction. myLanes should form a continuous sequence.
virtual bool notifyLeave(SUMOVehicle &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Removes a known vehicle due to its lane-change.
double myCurrentMeanSpeed
The current mean speed.
int myCurrentJamNo
The current jam number.
int getCurrentVehicleNumber() const
Returns the number of vehicles currently on the detector.
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
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)
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
double myCurrentMaxJamLengthInMeters
the current maximum jam length in meters
double myEndPos
The position the detector ends at on the last lane.
MSLane * myLastLane
The last lane of the detector's lane sequence.
SUMOTime myJamHaltingTimeThreshold
A vehicle must be that long beyond myJamHaltingSpeedThreshold to be counted as a part of a jam...
MSLane * getCanonicalPredecessorLane() const
VehicleInfoMap myVehicleInfos
static double passingTime(const double lastPos, const double passedPos, const double currentPos, const double lastSpeed, const double currentSpeed)
Calculates the time at which the position passedPosition has been passed In case of a ballistic updat...
double accumulatedTimeLoss
Accumulated time loss that this vehicle suffered since it entered the detector.
bool hasEntered
Whether the vehicle has already entered the detector (don't count twice!)
double myStartPos
The position the detector starts at on the first lane.
virtual void detectorUpdate(const SUMOTime step)
Computes the detector values in each time step.
double getLength() const
Get vehicle's length [m].
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
std::string myID
The name of the object.
virtual double getPreviousSpeed() const =0
Returns the vehicle's previous speed.
void addDetectorToLanes(std::vector< MSLane * > &lanes)
This adds the detector as a MoveReminder to the associated lanes.
virtual void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime)
Write the generated output to the given device.
DetectorUsage myUsage
Information about how this detector is used.
virtual 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].
int myNumberOfLeftVehicles
The number of vehicles, which have left the detector since the last reset.
double distToDetectorEnd
Distance left till the detector end after the last integration step (may become negative if the vehic...
const std::string & getID() const
Returns the name of the vehicle type.
virtual const std::string & getID() const =0
Get the vehicle's ID.
double getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
double myOccupancySum
The sum of occupancies [%].
void integrateMoveNotification(VehicleInfo *vi, const MoveNotificationInfo *mni)
This updates the detector values and the VehicleInfo of a vehicle on the detector with the given Move...
Static storage of an output device and its base (abstract) implementation.
double myCurrentJamLengthInMeters
The overall jam length in meters.
int myCurrentHaltingsNumber
The number of halted vehicles [#].
int getEstimatedCurrentVehicleNumber(double speedThreshold) const
Returns an estimate of the number of vehicles currently on the detector.
double timeLoss
timeloss during the last integration step
virtual bool notifyMove(SUMOVehicle &veh, double oldPos, double newPos, double newSpeed)
Adds/removes vehicles from the list of vehicles to regard.
double myCurrentOccupancy
The current occupancy.
double speed
Speed after the last integration step.
std::set< std::string > myLeftVehicles
Keep track of vehicles that left the detector by a regular move along a junction (not lanechange...
Representation of a lane in the micro simulation.
int myNumberOfEnteredVehicles
Base of value-generating classes (detectors)
virtual void writeXMLDetectorProlog(OutputDevice &dev) const
Open the XML-output.
double length
vehicle's length