SUMO - Simulation of Urban MObility
MSE2Collector.cpp
Go to the documentation of this file.
1 /****************************************************************************/
13 // An areal (along a single lane) detector
14 /****************************************************************************/
15 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
16 // Copyright (C) 2014 DLR (http://www.dlr.de/) and contributors
17 /****************************************************************************/
18 //
19 // This file is part of SUMO.
20 // SUMO is free software: you can redistribute it and/or modify
21 // it under the terms of the GNU General Public License as published by
22 // the Free Software Foundation, either version 3 of the License, or
23 // (at your option) any later version.
24 //
25 /****************************************************************************/
26 
27 
28 // ===========================================================================
29 // included modules
30 // ===========================================================================
31 #ifdef _MSC_VER
32 #include <windows_config.h>
33 #else
34 #include <config.h>
35 #endif
36 
37 #include <cassert>
38 #include <algorithm>
39 #include "MSE2Collector.h"
40 #include <microsim/MSLane.h>
41 #include <microsim/MSVehicle.h>
42 #include <microsim/MSVehicleType.h>
43 
44 #ifdef CHECK_MEMORY_LEAKS
45 #include <foreign/nvwa/debug_new.h>
46 #endif // CHECK_MEMORY_LEAKS
47 
48 
49 // ===========================================================================
50 // method definitions
51 // ===========================================================================
52 MSE2Collector::MSE2Collector(const std::string& id, DetectorUsage usage,
53  MSLane* const lane, SUMOReal startPos, SUMOReal detLength,
54  SUMOTime haltingTimeThreshold,
55  SUMOReal haltingSpeedThreshold,
56  SUMOReal jamDistThreshold) :
57  MSMoveReminder(id, lane),
59  myJamHaltingSpeedThreshold(haltingSpeedThreshold),
60  myJamHaltingTimeThreshold(haltingTimeThreshold),
61  myJamDistanceThreshold(jamDistThreshold),
62  myStartPos(startPos), myEndPos(startPos + detLength),
63  myUsage(usage),
64  myCurrentOccupancy(0), myCurrentMeanSpeed(-1), myCurrentJamNo(0),
65  myCurrentMaxJamLengthInMeters(0), myCurrentMaxJamLengthInVehicles(0),
66  myCurrentJamLengthInMeters(0), myCurrentJamLengthInVehicles(0), myCurrentStartedHalts(0),
67  myCurrentHaltingsNumber(0), myPassedVeh(0)
68 
69 {
70  assert(myLane != 0);
71  assert(myStartPos >= 0 && myStartPos < myLane->getLength());
72  assert(myEndPos - myStartPos > 0 && myEndPos <= myLane->getLength());
73  reset();
74 }
75 
76 
78  myKnownVehicles.clear();
79 }
80 
81 
82 bool
84  SUMOReal newPos, SUMOReal) {
85  if (newPos <= myStartPos) {
86  // detector not yet reached
87  return true;
88  }
89  if (newPos > myStartPos && oldPos <= myStartPos) {
90  if (find(myKnownVehicles.begin(), myKnownVehicles.end(), &veh) == myKnownVehicles.end()) {
91  std::string type = veh.getVehicleType().getID(); // get vehicle's type
92  if (type.find("COLOMBO_undetectable") == std::string::npos) {
93  myKnownVehicles.push_back(&veh);
94  //Detection entering the sensor
95  myPassedVeh++;
96  DBG(
97  std::ostringstream str;
98  str << time2string(MSNet::getInstance()->getCurrentTimeStep())
99  << " MSE2Collector::notifyMove::"
100  << " lane " << myLane->getID()
101  << " passedVeh " << myPassedVeh ;
102  WRITE_MESSAGE(str.str());
103  )
104  }
105  }
106  }
107  if (newPos - veh.getVehicleType().getLength() > myEndPos) {
108  std::list<SUMOVehicle*>::iterator i = find(myKnownVehicles.begin(), myKnownVehicles.end(), &veh);
109  if (i != myKnownVehicles.end()) {
110  myKnownVehicles.erase(i);
111  }
112  return false;
113  }
114  return true;
115 }
116 
117 
118 bool
120  if (reason != MSMoveReminder::NOTIFICATION_JUNCTION || (lastPos > myStartPos && lastPos - veh.getVehicleType().getLength() < myEndPos)) {
121  std::list<SUMOVehicle*>::iterator i = find(myKnownVehicles.begin(), myKnownVehicles.end(), &veh);
122  if (i != myKnownVehicles.end()) {
123  myKnownVehicles.erase(i);
124  }
125  return false;
126  }
127  return true;
128 }
129 
130 
131 bool
133  if (!veh.isOnRoad()) {
134  // vehicle is teleporting over the edge
135  return false;
136  }
137  if (veh.getBackPositionOnLane(myLane) >= myEndPos) {
138  // vehicle is beyond the detector
139  return false;
140  }
142  // the junction case is handled in the notifyMove
143  // vehicle is on the detector, being already beyond was checked before
144  std::string type = veh.getVehicleType().getID(); // get vehicle's type
145  if (type.find("COLOMBO_undetectable") == std::string::npos) {
146  myKnownVehicles.push_back(&veh);
147  //Detection entering the sensor
148  myPassedVeh++;
149  DBG(
150  std::ostringstream str;
151  str << time2string(MSNet::getInstance()->getCurrentTimeStep())
152  << " MSE2Collector::notifyEnter::"
153  << " lane " << myLane->getID()
154  << " passedVeh " << myPassedVeh ;
155  WRITE_MESSAGE(str.str());
156  )
157  return true;
158  }
159  }
160  if (veh.getPositionOnLane() - veh.getVehicleType().getLength() > myEndPos) {
161  // vehicle is beyond detector
162  return false;
163  }
164  // vehicle is in front of the detector
165  return true;
166 }
167 
168 
169 void
171  mySpeedSum = 0;
172  myStartedHalts = 0;
175  myVehicleSamples = 0;
176  myOccupancySum = 0;
177  myMaxOccupancy = 0;
180  myMaxJamInVehicles = 0;
181  myMaxJamInMeters = 0;
182  myTimeSamples = 0;
184  myMaxVehicleNumber = 0;
185  for (std::map<const SUMOVehicle*, SUMOTime>::iterator i = myIntervalHaltingVehicleDurations.begin(); i != myIntervalHaltingVehicleDurations.end(); ++i) {
186  (*i).second = 0;
187  }
188  myPastStandingDurations.clear();
190  myPassedVeh = 0;
191 }
192 
193 
194 
195 void
197  JamInfo* currentJam = 0;
198  std::map<const SUMOVehicle*, SUMOTime> haltingVehicles;
199  std::map<const SUMOVehicle*, SUMOTime> intervalHaltingVehicles;
200  std::vector<JamInfo*> jams;
201 
202  SUMOReal lengthSum = 0;
203  myCurrentMeanSpeed = 0;
207 
208  // go through the (sorted) list of vehicles positioned on the detector
209  // sum up values and prepare the list of jams
211  for (std::list<SUMOVehicle*>::const_iterator i = myKnownVehicles.begin(); i != myKnownVehicles.end(); ++i) {
212  const MSVehicle* const veh = static_cast<MSVehicle*>(*i);
213 
214  SUMOReal length = veh->getVehicleType().getLength();
215  if (veh->getLane() == getLane()) {
217  // vehicle entered detector partially
218  length -= (veh->getVehicleType().getLength() - (veh->getPositionOnLane() - myStartPos));
219  }
220  if (veh->getPositionOnLane() > myEndPos && veh->getPositionOnLane() - veh->getVehicleType().getLength() <= myEndPos) {
221  // vehicle left detector partially
222  length -= (veh->getPositionOnLane() - myEndPos);
223  }
224  } else {
225  // ok, the vehicle is only partially still on the detector, has already moved to the
226  // next lane; still, we do not know how far away it is
227  length = myEndPos - veh->getBackPositionOnLane(myLane);
228  }
229  assert(length >= 0);
230 
231  mySpeedSum += veh->getSpeed();
232  myCurrentMeanSpeed += veh->getSpeed();
233  lengthSum += length;
234  myCurrentMeanLength += length;
235 
236  // jam-checking begins
237  bool isInJam = false;
238  // first, check whether the vehicle is slow enough to be states as halting
239  if (veh->getSpeed() < myJamHaltingSpeedThreshold) {
241  // we have to track the time it was halting;
242  // so let's look up whether it was halting before and compute the overall halting time
243  bool wasHalting = myHaltingVehicleDurations.find(veh) != myHaltingVehicleDurations.end();
244  if (wasHalting) {
245  haltingVehicles[veh] = myHaltingVehicleDurations[veh] + DELTA_T;
246  intervalHaltingVehicles[veh] = myIntervalHaltingVehicleDurations[veh] + DELTA_T;
247  } else {
248  haltingVehicles[veh] = DELTA_T;
249  intervalHaltingVehicles[veh] = DELTA_T;
251  myStartedHalts++;
252  }
253  // we now check whether the halting time is large enough
254  if (haltingVehicles[veh] > myJamHaltingTimeThreshold) {
255  // yep --> the vehicle is a part of a jam
256  isInJam = true;
257  }
258  } else {
259  // is not standing anymore; keep duration information
260  std::map<const SUMOVehicle*, SUMOTime>::iterator v = myHaltingVehicleDurations.find(veh);
261  if (v != myHaltingVehicleDurations.end()) {
262  myPastStandingDurations.push_back((*v).second);
263  myHaltingVehicleDurations.erase(v);
264  }
265  v = myIntervalHaltingVehicleDurations.find(veh);
266  if (v != myIntervalHaltingVehicleDurations.end()) {
267  myPastIntervalStandingDurations.push_back((*v).second);
269  }
270  }
271 
272  // jam-building
273  if (isInJam) {
274  // the vehicle is in a jam;
275  // it may be a new one or already an existing one
276  if (currentJam == 0) {
277  // the vehicle is the first vehicle in a jam
278  currentJam = new JamInfo();
279  currentJam->firstStandingVehicle = i;
280  } else {
281  // ok, we have a jam already. But - maybe it is too far away
282  // ... honestly, I can hardly find a reason for doing this,
283  // but jams were defined this way in an earlier version...
284  if (veh->getPositionOnLane() - (*currentJam->lastStandingVehicle)->getPositionOnLane() > myJamDistanceThreshold) {
285  // yep, yep, yep - it's a new one...
286  // close the frist, build a new
287  jams.push_back(currentJam);
288  currentJam = new JamInfo;
289  currentJam->firstStandingVehicle = i;
290  }
291  }
292  currentJam->lastStandingVehicle = i;
293  } else {
294  // the vehicle is not part of a jam...
295  // maybe we have to close an already computed jam
296  if (currentJam != 0) {
297  jams.push_back(currentJam);
298  currentJam = 0;
299  }
300  }
301  }
302  if (currentJam != 0) {
303  jams.push_back(currentJam);
304  currentJam = 0;
305  }
306 
311  // process jam information
312  for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
313  // compute current jam's values
314  SUMOReal jamLengthInMeters =
315  (*(*i)->firstStandingVehicle)->getPositionOnLane()
316  - (*(*i)->lastStandingVehicle)->getPositionOnLane()
317  + (*(*i)->lastStandingVehicle)->getVehicleType().getLengthWithGap();
318  if ((*(*i)->firstStandingVehicle)->getLane() != myLane) {
319  // vehicle is partial occupator, discount the length that is not on
320  // this lane
321  jamLengthInMeters -= ((*(*i)->firstStandingVehicle)->getVehicleType().getLengthWithGap() -
322  (myLane->getLength() - (*(*i)->firstStandingVehicle)->getBackPositionOnLane(myLane)));
323  }
324  int jamLengthInVehicles = (int)distance((*i)->firstStandingVehicle, (*i)->lastStandingVehicle) + 1;
325  // apply them to the statistics
328  myJamLengthInMetersSum += jamLengthInMeters;
329  myJamLengthInVehiclesSum += jamLengthInVehicles;
330  myCurrentJamLengthInMeters += jamLengthInMeters;
331  myCurrentJamLengthInVehicles += jamLengthInVehicles;
332  }
333  myCurrentJamNo = (int) jams.size();
334 
335  const int numVehicles = (int) myKnownVehicles.size();
336  myVehicleSamples += numVehicles;
337  myTimeSamples += 1;
338  // compute occupancy values
339  SUMOReal currentOccupancy = lengthSum / (myEndPos - myStartPos) * (SUMOReal) 100.;
340  myCurrentOccupancy = currentOccupancy;
341  myOccupancySum += currentOccupancy;
342  myMaxOccupancy = MAX2(myMaxOccupancy, currentOccupancy);
343  // compute jam values
348  // save information about halting vehicles
349  myHaltingVehicleDurations = haltingVehicles;
350  myIntervalHaltingVehicleDurations = intervalHaltingVehicles;
351  // compute information about vehicle numbers
352  myMeanVehicleNumber += numVehicles;
354  // norm current values
355  myCurrentMeanSpeed = numVehicles != 0 ? myCurrentMeanSpeed / (SUMOReal) numVehicles : -1;
356  myCurrentMeanLength = numVehicles != 0 ? myCurrentMeanLength / (SUMOReal) numVehicles : -1;
357 
358  // clean up
359  for (std::vector<JamInfo*>::iterator i = jams.begin(); i != jams.end(); ++i) {
360  delete *i;
361  }
362  jams.clear();
363 }
364 
365 
366 
367 void
369  dev << " <interval begin=\"" << time2string(startTime) << "\" end=\"" << time2string(stopTime) << "\" " << "id=\"" << getID() << "\" ";
370 
371  const SUMOReal meanSpeed = myVehicleSamples != 0 ? mySpeedSum / (SUMOReal) myVehicleSamples : -1;
372  const SUMOReal meanOccupancy = myTimeSamples != 0 ? myOccupancySum / (SUMOReal) myTimeSamples : 0;
373  const SUMOReal meanJamLengthInMeters = myTimeSamples != 0 ? myMeanMaxJamInMeters / (SUMOReal) myTimeSamples : 0;
374  const SUMOReal meanJamLengthInVehicles = myTimeSamples != 0 ? myMeanMaxJamInVehicles / (SUMOReal) myTimeSamples : 0;
375  const SUMOReal meanVehicleNumber = myTimeSamples != 0 ? (SUMOReal) myMeanVehicleNumber / (SUMOReal) myTimeSamples : 0;
376 
377  SUMOTime haltingDurationSum = 0;
378  SUMOTime maxHaltingDuration = 0;
379  int haltingNo = 0;
380  for (std::vector<SUMOTime>::iterator i = myPastStandingDurations.begin(); i != myPastStandingDurations.end(); ++i) {
381  haltingDurationSum += (*i);
382  maxHaltingDuration = MAX2(maxHaltingDuration, (*i));
383  haltingNo++;
384  }
385  for (std::map<const SUMOVehicle*, SUMOTime> ::iterator i = myHaltingVehicleDurations.begin(); i != myHaltingVehicleDurations.end(); ++i) {
386  haltingDurationSum += (*i).second;
387  maxHaltingDuration = MAX2(maxHaltingDuration, (*i).second);
388  haltingNo++;
389  }
390  const SUMOTime meanHaltingDuration = haltingNo != 0 ? haltingDurationSum / haltingNo : 0;
391 
392  SUMOTime intervalHaltingDurationSum = 0;
393  SUMOTime intervalMaxHaltingDuration = 0;
394  int intervalHaltingNo = 0;
395  for (std::vector<SUMOTime>::iterator i = myPastIntervalStandingDurations.begin(); i != myPastIntervalStandingDurations.end(); ++i) {
396  intervalHaltingDurationSum += (*i);
397  intervalMaxHaltingDuration = MAX2(intervalMaxHaltingDuration, (*i));
398  intervalHaltingNo++;
399  }
400  for (std::map<const SUMOVehicle*, SUMOTime> ::iterator i = myIntervalHaltingVehicleDurations.begin(); i != myIntervalHaltingVehicleDurations.end(); ++i) {
401  intervalHaltingDurationSum += (*i).second;
402  intervalMaxHaltingDuration = MAX2(intervalMaxHaltingDuration, (*i).second);
403  intervalHaltingNo++;
404  }
405  const SUMOTime intervalMeanHaltingDuration = intervalHaltingNo != 0 ? intervalHaltingDurationSum / intervalHaltingNo : 0;
406 
407  dev << "nSamples=\"" << myVehicleSamples << "\" "
408  << "meanSpeed=\"" << meanSpeed << "\" "
409  << "meanOccupancy=\"" << meanOccupancy << "\" "
410  << "maxOccupancy=\"" << myMaxOccupancy << "\" "
411  << "meanMaxJamLengthInVehicles=\"" << meanJamLengthInVehicles << "\" "
412  << "meanMaxJamLengthInMeters=\"" << meanJamLengthInMeters << "\" "
413  << "maxJamLengthInVehicles=\"" << myMaxJamInVehicles << "\" "
414  << "maxJamLengthInMeters=\"" << myMaxJamInMeters << "\" "
415  << "jamLengthInVehiclesSum=\"" << myJamLengthInVehiclesSum << "\" "
416  << "jamLengthInMetersSum=\"" << myJamLengthInMetersSum << "\" "
417  << "meanHaltingDuration=\"" << STEPS2TIME(meanHaltingDuration) << "\" "
418  << "maxHaltingDuration=\"" << STEPS2TIME(maxHaltingDuration) << "\" "
419  << "haltingDurationSum=\"" << STEPS2TIME(haltingDurationSum) << "\" "
420  << "meanIntervalHaltingDuration=\"" << STEPS2TIME(intervalMeanHaltingDuration) << "\" "
421  << "maxIntervalHaltingDuration=\"" << STEPS2TIME(intervalMaxHaltingDuration) << "\" "
422  << "intervalHaltingDurationSum=\"" << STEPS2TIME(intervalHaltingDurationSum) << "\" "
423  << "startedHalts=\"" << myStartedHalts << "\" "
424  << "meanVehicleNumber=\"" << meanVehicleNumber << "\" "
425  << "maxVehicleNumber=\"" << myMaxVehicleNumber << "\" "
426  << "/>\n";
427  reset();
428 }
429 
430 
431 void
433  dev.writeXMLHeader("detector", "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo.dlr.de/xsd/det_e2_file.xsd\"");
434 }
435 
436 
437 int
439  return (int) myKnownVehicles.size();
440 }
441 
442 int
444 
445  SUMOReal distance = 0;
446  SUMOReal thresholdSpeed = myLane->getSpeedLimit() / speedThreshold;
447 
448  int count = 0;
449  for (std::list<SUMOVehicle*>::const_iterator it = myKnownVehicles.begin();
450  it != myKnownVehicles.end(); it++) {
451  MSVehicle* veh = static_cast<MSVehicle*>(*it);
452  SUMOReal acceleration = veh->getAcceleration();
453  if (distance == 0) {
454  distance = veh->getPositionOnLane();
455  }
456  if (veh->getPositionOnLane() < distance) {
457  distance = veh->getPositionOnLane();
458  }
459  SUMOReal carLength = veh->getVehicleType().getLengthWithGap();
460  SUMOReal vel = veh->getSpeed();
461  SUMOReal realDistance = myLane->getLength() - distance; // the closer vehicle get to the light the greater is the distance
462  if (vel <= thresholdSpeed || acceleration > 0) { //TODO speed less than half of the maximum speed for the lane NEED TUNING
463  count = (int)(realDistance / carLength) + 1;
464  }
465  }
466 
467  return count;
468 }
469 
470 SUMOReal
472 
473  if (myKnownVehicles.empty()) {
474  return -1;
475  }
476 
477  SUMOReal distance = 0;
478  SUMOReal realDistance = 0;
479  bool flowing = true;
480  for (std::list<SUMOVehicle*>::const_iterator it = myKnownVehicles.begin();
481  it != myKnownVehicles.end(); it++) {
482  MSVehicle* veh = static_cast<MSVehicle*>(*it);
483  if (distance == 0) {
484  distance = veh->getPositionOnLane();
485  }
486  if (veh->getPositionOnLane() < distance) {
487  distance = veh->getPositionOnLane();
488  }
489  SUMOReal carLength = veh->getVehicleType().getLengthWithGap();
490  SUMOReal vel = veh->getSpeed();
491  // SUMOReal distanceTemp = myLane->getLength() - distance;
492  if (vel <= 0.5) {
493  realDistance = distance - carLength;
494  flowing = false;
495  }
496  DBG(
497  std::ostringstream str;
498  str << time2string(MSNet::getInstance()->getCurrentTimeStep())
499  << " MSE2Collector::getEstimateQueueLength::"
500  << " lane " << myLane->getID()
501  << " vehicle " << veh->getID()
502  << " positionOnLane " << veh->getPositionOnLane()
503  << " vel " << veh->getSpeed()
504  << " realDistance " << realDistance;
505  WRITE_MESSAGE(str.str());
506  )
507  }
508  if (flowing) {
509  return 0;
510  } else {
511  return myLane->getLength() - realDistance;
512  }
513 }
514 
515 
516 SUMOReal
518  return myCurrentOccupancy;
519 }
520 
521 
522 SUMOReal
524  return myCurrentMeanSpeed;
525 }
526 
527 
528 SUMOReal
530  return myCurrentMeanLength;
531 }
532 
533 
534 int
536  return myCurrentJamNo;
537 }
538 
539 
540 int
543 }
544 
545 
546 SUMOReal
549 }
550 
551 
552 int
555 }
556 
557 
558 SUMOReal
561 }
562 
563 
564 int
566  return myCurrentStartedHalts;
567 }
568 
569 
570 int
572  if (!v1->isFrontOnLane(myLane)) {
573  return true;
574  }
575  if (!v2->isFrontOnLane(myLane)) {
576  return false;
577  }
578  return v1->getPositionOnLane() > v2->getPositionOnLane();
579 }
580 
581 int
584 }
585 
586 
587 std::vector<std::string>
589  std::vector<std::string> ret;
590  for (std::list<SUMOVehicle*>::const_iterator i = myKnownVehicles.begin(); i != myKnownVehicles.end(); ++i) {
591  MSVehicle* veh = static_cast<MSVehicle*>(*i);
592  ret.push_back(veh->getID());
593  }
594  std::sort(ret.begin(), ret.end());
595  return ret;
596 }
597 
598 const std::list<SUMOVehicle*>& MSE2Collector::getCurrentVehicles() const {
599  return myKnownVehicles;
600 }
601 
602 /****************************************************************************/
603 
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.
Definition: MSVehicle.h:81
long long int SUMOTime
Definition: SUMOTime.h:43
SUMOReal myMaxJamInMeters
The max jam length [m].
virtual ~MSE2Collector()
Destructor.
SUMOReal getLengthWithGap() const
Get vehicle&#39;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&#39;s length.
Definition: MSLane.h:475
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&#39;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)
Definition: SUMOTime.cpp:59
SUMOReal getLength() const
Get vehicle&#39;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).
Definition: MSNet.cpp:159
T MAX2(T a, T b)
Definition: StdDefs.h:75
int myVehicleSamples
The number of collected samples [#].
std::vector< SUMOTime > myPastStandingDurations
Halting durations of ended halts [s].
SUMOTime DELTA_T
Definition: SUMOTime.cpp:39
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&#39;s position along the lane.
Definition: MSVehicle.h:350
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.
Definition: Named.h:66
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.
Definition: SUMOVehicle.h:66
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.
#define STEPS2TIME(x)
Definition: SUMOTime.h:65
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&#39;s maximum allowed speed.
Definition: MSLane.h:467
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.
#define DBG(X)
Definition: SwarmDebug.h:30
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&#39;s acceleration in m/s.
Definition: MSVehicle.h:418
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&#39;s type definition.
Definition: MSBaseVehicle.h:97
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&#39;s back position along the given lane.
SUMOReal getSpeed() const
Returns the vehicle&#39;s current speed.
Definition: MSVehicle.h:410
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&#39;s position relative to the given lane.
Definition: MSVehicle.cpp:1962
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.
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.
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.
Definition: MSVehicle.h:447
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:201
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.
Definition: MSLane.h:79
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&#39;s type.
void writeXMLDetectorProlog(OutputDevice &dev) const
Opens the XML-output using "detector" as root element.