Eclipse SUMO - Simulation of Urban MObility
MSDevice_Tripinfo.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2009-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
21 // A device which collects info on the vehicle trip
22 /****************************************************************************/
23 #include <config.h>
24 
25 #include <microsim/MSGlobals.h>
26 #include <microsim/MSNet.h>
27 #include <microsim/MSLane.h>
28 #include <microsim/MSEdge.h>
29 #include <microsim/MSVehicle.h>
31 #include <mesosim/MEVehicle.h>
35 #include "MSDevice_Vehroutes.h"
36 #include "MSDevice_Tripinfo.h"
37 
38 #define NOT_ARRIVED TIME2STEPS(-1)
39 
40 
41 // ===========================================================================
42 // static members
43 // ===========================================================================
44 std::set<const MSDevice_Tripinfo*, ComparatorNumericalIdLess> MSDevice_Tripinfo::myPendingOutput;
45 
54 
59 std::vector<int> MSDevice_Tripinfo::myRideCount({0, 0});
60 std::vector<int> MSDevice_Tripinfo::myRideBusCount({0, 0});
61 std::vector<int> MSDevice_Tripinfo::myRideRailCount({0, 0});
62 std::vector<int> MSDevice_Tripinfo::myRideTaxiCount({0, 0});
63 std::vector<int> MSDevice_Tripinfo::myRideBikeCount({0, 0});
64 std::vector<int> MSDevice_Tripinfo::myRideAbortCount({0, 0});
65 std::vector<double> MSDevice_Tripinfo::myTotalRideWaitingTime({0., 0.});
66 std::vector<double> MSDevice_Tripinfo::myTotalRideRouteLength({0., 0.});
67 std::vector<SUMOTime> MSDevice_Tripinfo::myTotalRideDuration({0, 0});
68 
69 // ===========================================================================
70 // method definitions
71 // ===========================================================================
72 // ---------------------------------------------------------------------------
73 // static initialisation methods
74 // ---------------------------------------------------------------------------
75 void
77  oc.addOptionSubTopic("Tripinfo Device");
78  insertDefaultAssignmentOptions("tripinfo", "Tripinfo Device", oc);
79 }
80 
81 
82 void
83 MSDevice_Tripinfo::buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into) {
85  const bool enableByOutputOption = oc.isSet("tripinfo-output") || oc.getBool("duration-log.statistics");
86  if (equippedByDefaultAssignmentOptions(oc, "tripinfo", v, enableByOutputOption)) {
87  MSDevice_Tripinfo* device = new MSDevice_Tripinfo(v, "tripinfo_" + v.getID());
88  into.push_back(device);
89  myPendingOutput.insert(device);
90  }
91 }
92 
93 
94 // ---------------------------------------------------------------------------
95 // MSDevice_Tripinfo-methods
96 // ---------------------------------------------------------------------------
97 MSDevice_Tripinfo::MSDevice_Tripinfo(SUMOVehicle& holder, const std::string& id) :
98  MSVehicleDevice(holder, id),
99  myDepartLane(""),
100  myDepartSpeed(-1),
101  myDepartPosLat(0),
102  myWaitingTime(0),
103  myAmWaiting(false),
104  myWaitingCount(0),
105  myStoppingTime(0),
106  myParkingStarted(-1),
107  myArrivalTime(NOT_ARRIVED),
108  myArrivalLane(""),
109  myArrivalPos(-1),
110  myArrivalPosLat(0.),
111  myArrivalSpeed(-1),
112  myArrivalReason(MSMoveReminder::NOTIFICATION_ARRIVED),
113  myMesoTimeLoss(0),
114  myRouteLength(0.) {
115 }
116 
117 
119  // ensure clean up for vaporized vehicles which do not generate output
120  myPendingOutput.erase(this);
121 }
122 
123 void
125  myVehicleCount = 0;
126  myTotalRouteLength = 0;
127  myTotalSpeed = 0;
128  myTotalDuration = 0;
129  myTotalWaitingTime = 0;
130  myTotalTimeLoss = 0;
131  myTotalDepartDelay = 0;
133 
134  myWalkCount = 0;
138 
139  myRideCount = {0, 0};
140  myRideBusCount = {0, 0};
141  myRideRailCount = {0, 0};
142  myRideTaxiCount = {0, 0};
143  myRideBikeCount = {0, 0};
144  myRideAbortCount = {0, 0};
145  myTotalRideWaitingTime = {0., 0.};
146  myTotalRideRouteLength = {0., 0.};
147  myTotalRideDuration = {0, 0};
148 }
149 
150 bool
152  if (veh.isVehicle()) {
154  if (!myAmWaiting) {
155  myWaitingCount++;
156  myAmWaiting = true;
157  }
158  }
159  return true;
160 }
161 
162 
163 bool
165  double /*newPos*/, double newSpeed) {
166  if (veh.isStopped()) {
168  } else if (newSpeed <= SUMO_const_haltingSpeed) {
170  if (!myAmWaiting) {
171  myWaitingCount++;
172  myAmWaiting = true;
173  }
174  } else {
175  myAmWaiting = false;
176  }
177  return true;
178 }
179 
180 
181 void
183  const double /* frontOnLane */,
184  const double timeOnLane,
185  const double /* meanSpeedFrontOnLane */,
186  const double meanSpeedVehicleOnLane,
187  const double /* travelledDistanceFrontOnLane */,
188  const double /* travelledDistanceVehicleOnLane */,
189  const double /* meanLengthOnLane */) {
190 
191  // called by meso
192  const MEVehicle* mesoVeh = dynamic_cast<const MEVehicle*>(&veh);
193  assert(mesoVeh);
194  const double vmax = veh.getEdge()->getVehicleMaxSpeed(&veh);
195  if (vmax > 0) {
196  myMesoTimeLoss += TIME2STEPS(timeOnLane * (vmax - meanSpeedVehicleOnLane) / vmax);
197  }
198  myWaitingTime += veh.getWaitingTime();
200 }
201 
202 void
204  if (myParkingStarted >= 0) {
206  myParkingStarted = -1;
207  }
208 }
209 
210 bool
213  if (!MSGlobals::gUseMesoSim) {
214  myDepartLane = static_cast<MSVehicle&>(veh).getLane()->getID();
215  myDepartPosLat = static_cast<MSVehicle&>(veh).getLateralPositionOnLane();
216  }
217  myDepartSpeed = veh.getSpeed();
219  } else if (reason == MSMoveReminder::NOTIFICATION_PARKING) {
220  // notifyMove is not called while parking
221  // @note insertion delay when resuming after parking is included
223  }
224  return true;
225 }
226 
227 
228 bool
230  MSMoveReminder::Notification reason, const MSLane* /* enteredLane */) {
231  if (reason >= MSMoveReminder::NOTIFICATION_ARRIVED) {
233  myArrivalReason = reason;
234  if (!MSGlobals::gUseMesoSim) {
235  myArrivalLane = static_cast<MSVehicle&>(veh).getLane()->getID();
236  myArrivalPosLat = static_cast<MSVehicle&>(veh).getLateralPositionOnLane();
237  }
238  // @note vehicle may have moved past its arrivalPos during the last step
239  // due to non-zero arrivalspeed but we consider it as arrived at the desired position
240  // However, vaporization may happen anywhere (via TraCI)
242  // vaporized
244  } else {
246  }
247  myArrivalSpeed = veh.getSpeed();
249  } else if (reason == MSMoveReminder::NOTIFICATION_PARKING) {
251  } else if (reason == NOTIFICATION_JUNCTION || reason == NOTIFICATION_TELEPORT) {
254  } else {
255  const MSLane* lane = static_cast<MSVehicle&>(veh).getLane();
256  if (lane != nullptr) {
257  myRouteLength += lane->getLength();
258  }
259  }
260  }
261  return true;
262 }
263 
264 
265 void
267  const SUMOTime timeLoss = MSGlobals::gUseMesoSim ? myMesoTimeLoss : static_cast<MSVehicle&>(myHolder).getTimeLoss();
268  const double routeLength = myRouteLength + (myArrivalTime == NOT_ARRIVED ? myHolder.getPositionOnLane() : myArrivalPos);
270 
271  myVehicleCount++;
272  myTotalRouteLength += routeLength;
273  myTotalSpeed += routeLength / STEPS2TIME(duration);
274  myTotalDuration += duration;
276  myTotalTimeLoss += timeLoss;
278  myPendingOutput.erase(this);
279  if (tripinfoOut == nullptr) {
280  return;
281  }
282  // write
283  OutputDevice& os = *tripinfoOut;
284  os.openTag("tripinfo").writeAttr("id", myHolder.getID());
285  os.writeAttr("depart", time2string(myHolder.getDeparture()));
286  os.writeAttr("departLane", myDepartLane);
287  os.writeAttr("departPos", myHolder.getDepartPos());
289  os.writeAttr("departPosLat", myDepartPosLat);
290  }
291  os.writeAttr("departSpeed", myDepartSpeed);
292  os.writeAttr("departDelay", time2string(myHolder.getDepartDelay()));
293  os.writeAttr("arrival", time2string(myArrivalTime));
294  os.writeAttr("arrivalLane", myArrivalLane);
295  os.writeAttr("arrivalPos", myArrivalPos);
297  os.writeAttr("arrivalPosLat", myArrivalPosLat);
298  }
299  os.writeAttr("arrivalSpeed", myArrivalSpeed);
300  os.writeAttr("duration", time2string(duration));
301  os.writeAttr("routeLength", routeLength);
302  os.writeAttr("waitingTime", time2string(myWaitingTime));
303  os.writeAttr("waitingCount", myWaitingCount);
304  os.writeAttr("stopTime", time2string(myStoppingTime));
305  os.writeAttr("timeLoss", time2string(timeLoss));
306  os.writeAttr("rerouteNo", myHolder.getNumberReroutes());
307  os.writeAttr("devices", toString(myHolder.getDevices()));
308  os.writeAttr("vType", myHolder.getVehicleType().getID());
309  os.writeAttr("speedFactor", myHolder.getChosenSpeedFactor());
310  std::string vaporized;
311  switch (myArrivalReason) {
313  vaporized = "calibrator";
314  break;
316  vaporized = "gui";
317  break;
319  vaporized = "collision";
320  break;
322  vaporized = "vaporizer";
323  break;
325  vaporized = "traci";
326  break;
328  vaporized = "teleport";
329  break;
330  default:
331  vaporized = (myHolder.getEdge() == *(myHolder.getRoute().end() - 1) ? "" : "end");
332 
333  }
334  os.writeAttr("vaporized", vaporized);
335  // cannot close tag because emission device output might follow
336 }
337 
338 
339 void
341  MSNet* net = MSNet::getInstance();
342  OutputDevice* tripinfoOut = (OptionsCont::getOptions().isSet("tripinfo-output") ?
343  &OutputDevice::getDeviceByOption("tripinfo-output") : nullptr);
345  int undeparted = 0;
346  int departed = 0;
347  const SUMOTime t = net->getCurrentTimeStep();
348  while (myPendingOutput.size() > 0) {
349  const MSDevice_Tripinfo* d = *myPendingOutput.begin();
350  if (d->myHolder.hasDeparted()) {
351  departed++;
352  const_cast<MSDevice_Tripinfo*>(d)->updateParkingStopTime();
353  d->generateOutput(tripinfoOut);
354  if (tripinfoOut != nullptr) {
355  for (MSVehicleDevice* const dev : d->myHolder.getDevices()) {
356  if (typeid(*dev) == typeid(MSDevice_Tripinfo) || typeid(*dev) == typeid(MSDevice_Vehroutes)) {
357  // tripinfo is special and vehroute has it's own write-unfinished option
358  continue;
359  }
360  dev->generateOutput(tripinfoOut);
361  }
362  OutputDevice::getDeviceByOption("tripinfo-output").closeTag();
363  }
364  } else {
365  undeparted++;
367  myPendingOutput.erase(d);
368  }
369  }
370  if (myWaitingDepartDelay > 0) {
371  myWaitingDepartDelay /= undeparted;
372  }
373  // unfinished persons
374  if (net->hasPersons()) {
376  while (pc.loadedBegin() != pc.loadedEnd()) {
377  pc.erase(pc.loadedBegin()->second);
378  }
379  }
380 
381 }
382 
383 
384 void
385 MSDevice_Tripinfo::addPedestrianData(double walkLength, SUMOTime walkDuration, SUMOTime walkTimeLoss) {
386  myWalkCount++;
387  myTotalWalkRouteLength += walkLength;
388  myTotalWalkDuration += walkDuration;
389  myTotalWalkTimeLoss += walkTimeLoss;
390 }
391 
392 
393 void
394 MSDevice_Tripinfo::addRideTransportData(const bool isPerson, const double distance, const SUMOTime duration,
395  const SUMOVehicleClass vClass, const std::string& line, const SUMOTime waitingTime) {
396  const int index = isPerson ? 0 : 1;
397  myRideCount[index]++;
398  if (duration > 0) {
399  myTotalRideWaitingTime[index] += waitingTime;
400  myTotalRideRouteLength[index] += distance;
401  myTotalRideDuration[index] += duration;
402  if (vClass == SVC_BICYCLE) {
403  myRideBikeCount[index]++;
404  } else if (!line.empty()) {
405  if (isRailway(vClass)) {
406  myRideRailCount[index]++;
407  } else if (vClass == SVC_TAXI) {
408  myRideTaxiCount[index]++;
409  } else {
410  // some kind of road vehicle
411  myRideBusCount[index]++;
412  }
413  }
414  } else {
415  myRideAbortCount[index]++;
416  }
417 }
418 
419 
420 std::string
422  std::ostringstream msg;
423  msg.setf(msg.fixed);
424  msg.precision(gPrecision);
425  msg << "Statistics (avg):\n"
426  << " RouteLength: " << getAvgRouteLength() << "\n"
427  << " Speed: " << getAvgTripSpeed() << "\n"
428  << " Duration: " << getAvgDuration() << "\n"
429  << " WaitingTime: " << getAvgWaitingTime() << "\n"
430  << " TimeLoss: " << getAvgTimeLoss() << "\n"
431  << " DepartDelay: " << getAvgDepartDelay() << "\n";
432  if (myWaitingDepartDelay >= 0) {
433  msg << " DepartDelayWaiting: " << STEPS2TIME(myWaitingDepartDelay) << "\n";
434  }
435  if (myWalkCount > 0) {
436  msg << "Pedestrian Statistics (avg of " << myWalkCount << " walks):\n"
437  << " RouteLength: " << getAvgWalkRouteLength() << "\n"
438  << " Duration: " << getAvgWalkDuration() << "\n"
439  << " TimeLoss: " << getAvgWalkTimeLoss() << "\n";
440  }
441  printRideStatistics(msg, "Ride", "rides", 0);
442  printRideStatistics(msg, "Transport", "transports", 1);
443  return msg.str();
444 }
445 
446 void
447 MSDevice_Tripinfo::printRideStatistics(std::ostringstream& msg, const std::string& category, const std::string& modeName, const int index) {
448  if (myRideCount[index] > 0) {
449  msg << category << " Statistics (avg of " << myRideCount[index] << " " << modeName << "):\n";
450  msg << " WaitingTime: " << STEPS2TIME(myTotalRideWaitingTime[index] / myRideCount[index]) << "\n";
451  msg << " RouteLength: " << myTotalRideRouteLength[index] / myRideCount[index] << "\n";
452  msg << " Duration: " << STEPS2TIME(myTotalRideDuration[index] / myRideCount[index]) << "\n";
453  if (myRideBusCount[index] > 0) {
454  msg << " Bus: " << myRideBusCount[index] << "\n";
455  }
456  if (myRideRailCount[index] > 0) {
457  msg << " Train: " << myRideRailCount[index] << "\n";
458  }
459  if (myRideTaxiCount[index] > 0) {
460  msg << " Taxi: " << myRideTaxiCount[index] << "\n";
461  }
462  if (myRideBikeCount[index] > 0) {
463  msg << " Bike: " << myRideBikeCount[index] << "\n";
464  }
465  if (myRideAbortCount[index] > 0) {
466  msg << " Aborted: " << myRideAbortCount[index] << "\n";
467  }
468  }
469 
470 }
471 
472 
473 void
476  od.openTag("vehicleTripStatistics");
477  od.writeAttr("routeLength", getAvgRouteLength());
478  od.writeAttr("speed", getAvgTripSpeed());
479  od.writeAttr("duration", getAvgDuration());
480  od.writeAttr("waitingTime", getAvgWaitingTime());
481  od.writeAttr("timeLoss", getAvgTimeLoss());
482  od.writeAttr("departDelay", getAvgDepartDelay());
483  od.writeAttr("departDelayWaiting", myWaitingDepartDelay);
484  od.closeTag();
485  od.openTag("pedestrianStatistics");
486  od.writeAttr("number", myWalkCount);
487  od.writeAttr("routeLength", getAvgWalkRouteLength());
488  od.writeAttr("duration", getAvgWalkDuration());
489  od.writeAttr("timeLoss", getAvgWalkTimeLoss());
490  od.closeTag();
491  writeRideStatistics(od, "rideStatistics", 0);
492  writeRideStatistics(od, "transportStatistics", 1);
493 }
494 
495 void
496 MSDevice_Tripinfo::writeRideStatistics(OutputDevice& od, const std::string& category, const int index) {
497  od.openTag(category);
498  od.writeAttr("number", myRideCount[index]);
499  if (myRideCount[index] > 0) {
500  od.writeAttr("waitingTime", STEPS2TIME(myTotalRideWaitingTime[index] / myRideCount[index]));
501  od.writeAttr("routeLength", myTotalRideRouteLength[index] / myRideCount[index]);
502  od.writeAttr("duration", STEPS2TIME(myTotalRideDuration[index] / myRideCount[index]));
503  od.writeAttr("bus", myRideBusCount[index]);
504  od.writeAttr("train", myRideRailCount[index]);
505  od.writeAttr("taxi", myRideTaxiCount[index]);
506  od.writeAttr("bike", myRideBikeCount[index]);
507  od.writeAttr("aborted", myRideAbortCount[index]);
508  }
509  od.closeTag();
510 }
511 
512 
513 double
515  if (myVehicleCount > 0) {
517  } else {
518  return 0;
519  }
520 }
521 
522 double
524  if (myVehicleCount > 0) {
525  return myTotalSpeed / myVehicleCount;
526  } else {
527  return 0;
528  }
529 }
530 
531 double
533  if (myVehicleCount > 0) {
535  } else {
536  return 0;
537  }
538 }
539 
540 double
542  if (myVehicleCount > 0) {
544  } else {
545  return 0;
546  }
547 }
548 
549 
550 double
552  if (myVehicleCount > 0) {
554  } else {
555  return 0;
556  }
557 }
558 
559 
560 double
562  if (myVehicleCount > 0) {
564  } else {
565  return 0;
566  }
567 }
568 
569 
570 double
572  if (myWalkCount > 0) {
574  } else {
575  return 0;
576  }
577 }
578 
579 double
581  if (myWalkCount > 0) {
583  } else {
584  return 0;
585  }
586 }
587 
588 
589 double
591  if (myWalkCount > 0) {
593  } else {
594  return 0;
595  }
596 }
597 
598 
599 double
601  if (myRideCount[0] > 0) {
603  } else {
604  return 0;
605  }
606 }
607 
608 double
610  if (myRideCount[0] > 0) {
612  } else {
613  return 0;
614  }
615 }
616 
617 double
619  if (myRideCount[0] > 0) {
620  return myTotalRideRouteLength[0] / myRideCount[0];
621  } else {
622  return 0;
623  }
624 }
625 
626 
627 void
630  out.writeAttr(SUMO_ATTR_ID, getID());
631  std::ostringstream internals;
632  if (!MSGlobals::gUseMesoSim) {
633  internals << myDepartLane << " " << myDepartPosLat << " ";
634  }
635  internals << myDepartSpeed << " " << myRouteLength << " " << myWaitingTime << " " << myAmWaiting << " " << myWaitingCount << " ";
636  internals << myStoppingTime << " " << myParkingStarted;
637  out.writeAttr(SUMO_ATTR_STATE, internals.str());
638  out.closeTag();
639 }
640 
641 
642 void
644  std::istringstream bis(attrs.getString(SUMO_ATTR_STATE));
645  if (!MSGlobals::gUseMesoSim) {
646  bis >> myDepartLane >> myDepartPosLat;
647  }
650 }
651 
652 
653 /****************************************************************************/
#define NOT_ARRIVED
SUMOTime DELTA_T
Definition: SUMOTime.cpp:37
std::string time2string(SUMOTime t)
convert SUMOTime to string
Definition: SUMOTime.cpp:68
#define STEPS2TIME(x)
Definition: SUMOTime.h:53
#define SIMSTEP
Definition: SUMOTime.h:59
#define TIME2STEPS(x)
Definition: SUMOTime.h:55
long long int SUMOTime
Definition: SUMOTime.h:31
bool isRailway(SVCPermissions permissions)
Returns whether an edge with the given permission is a railway edge.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_BICYCLE
vehicle is a bicycle
@ SVC_TAXI
vehicle is a taxi
@ SUMO_TAG_DEVICE
@ SUMO_ATTR_ID
@ SUMO_ATTR_STATE
The state of a link.
int gPrecision
the precision for floating point outputs
Definition: StdDefs.cpp:25
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
Definition: StdDefs.h:60
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:44
A vehicle from the mesoscopic point of view.
Definition: MEVehicle.h:42
double getCurrentStoppingTimeSeconds() const
Returns the delay that is accrued due to option –meso-tls-penalty or –meso-minor-penalty.
Definition: MEVehicle.cpp:235
A device which collects info on the vehicle trip (mainly on departure and arrival)
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves departure info on insertion.
static SUMOTime myTotalDepartDelay
double myDepartSpeed
The speed on departure.
static std::vector< int > myRideAbortCount
static void writeStatistics(OutputDevice &od)
write statistic output to (xml) file
void saveState(OutputDevice &out) const
Saves the state of the device.
SUMOTime myArrivalTime
The vehicle's arrival time.
SUMOTime myWaitingTime
The overall waiting time.
void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the device from the given description.
static std::set< const MSDevice_Tripinfo *, ComparatorNumericalIdLess > myPendingOutput
devices which may still need to produce output
static SUMOTime myTotalWalkTimeLoss
static double getAvgRideWaitingTime()
SUMOTime myParkingStarted
The time when parking started.
static double getAvgWalkRouteLength()
std::string myArrivalLane
The lane the vehicle arrived at.
MSDevice_Tripinfo(SUMOVehicle &holder, const std::string &id)
Constructor.
static double getAvgTimeLoss()
static void printRideStatistics(std::ostringstream &msg, const std::string &category, const std::string &modeName, const int index)
double myArrivalSpeed
The speed when arriving.
static double getAvgRideRouteLength()
~MSDevice_Tripinfo()
Destructor.
static SUMOTime myTotalTimeLoss
static double getAvgRideDuration()
static std::vector< int > myRideRailCount
static double getAvgDepartDelay()
static double myTotalSpeed
static double myVehicleCount
global tripinfo statistics
static std::vector< SUMOTime > myTotalRideDuration
static double getAvgTripSpeed()
static double getAvgRouteLength()
accessors for GUINet-Parameters
static std::vector< double > myTotalRideWaitingTime
void updateParkingStopTime()
update stopping time after parking
static SUMOTime myTotalDuration
static SUMOTime myTotalWalkDuration
static std::string printStatistics()
get statistics for printing to stdout
static void generateOutputForUnfinished()
generate output for vehicles which are still in the network
static double getAvgWaitingTime()
static void addPedestrianData(double walkLength, SUMOTime walkDuration, SUMOTime walkTimeLoss)
record tripinfo data for pedestrians
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks for waiting steps when the vehicle moves.
std::string myDepartLane
The lane the vehicle departed at.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
static void writeRideStatistics(OutputDevice &od, const std::string &category, const int index)
double myRouteLength
The route length.
static SUMOTime myTotalWaitingTime
static double myTotalRouteLength
double myArrivalPosLat
The lateral position on the lane the vehicle arrived at.
static double getAvgDuration()
static void cleanup()
resets counters
int myWaitingCount
The overall number of unintended stops.
SUMOTime myStoppingTime
The overall intentional stopping time.
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves arrival info.
void generateOutput(OutputDevice *tripinfoOut) const
Called on writing tripinfo output.
static void addRideTransportData(const bool isPerson, const double distance, const SUMOTime duration, const SUMOVehicleClass vClass, const std::string &line, const SUMOTime waitingTime)
record tripinfo data for rides and transports
static std::vector< int > myRideCount
bool notifyIdle(SUMOTrafficObject &veh)
record idling as waiting time - cf issue 2233
static double getAvgWalkDuration()
SUMOTime myMesoTimeLoss
The time loss when compared to the desired and allowed speed.
static std::vector< int > myRideBusCount
double myDepartPosLat
The lateral depart position.
bool myAmWaiting
Whether the vehicle is currently waiting.
double myArrivalPos
The position on the lane the vehicle arrived at.
void notifyMoveInternal(const SUMOTrafficObject &veh, const double frontOnLane, const double timeOnLane, const double meanSpeedFrontOnLane, const double meanSpeedVehicleOnLane, const double travelledDistanceFrontOnLane, const double travelledDistanceVehicleOnLane, const double)
Internal notification about the vehicle moves, see MSMoveReminder::notifyMoveInternal()
static std::vector< int > myRideTaxiCount
static std::vector< int > myRideBikeCount
MSMoveReminder::Notification myArrivalReason
The reason for vehicle arrival.
static double getAvgWalkTimeLoss()
static double myTotalWalkRouteLength
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Tripinfo-options.
static SUMOTime myWaitingDepartDelay
static std::vector< double > myTotalRideRouteLength
A device which collects info on the vehicle trip (mainly on departure and arrival)
static void insertDefaultAssignmentOptions(const std::string &deviceName, const std::string &optionsTopic, OptionsCont &oc, const bool isPerson=false)
Adds common command options that allow to assign devices to vehicles.
Definition: MSDevice.cpp:134
static bool equippedByDefaultAssignmentOptions(const OptionsCont &oc, const std::string &deviceName, DEVICEHOLDER &v, bool outputOptionSet, const bool isPerson=false)
Determines whether a vehicle should get a certain device.
Definition: MSDevice.h:204
double getLength() const
return the length of the edge
Definition: MSEdge.h:630
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the maximum speed the vehicle may use on this edge.
Definition: MSEdge.cpp:931
static bool gUseMesoSim
Definition: MSGlobals.h:88
static double gLateralResolution
Definition: MSGlobals.h:82
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
double getLength() const
Returns the lane's length.
Definition: MSLane.h:539
Something on a lane to be noticed about vehicle movement.
const MSLane * getLane() const
Returns the lane the reminder works on.
Notification
Definition of a vehicle state.
@ NOTIFICATION_VAPORIZED_TRACI
The vehicle got removed via TraCI.
@ NOTIFICATION_ARRIVED
The vehicle arrived at its destination (is deleted)
@ NOTIFICATION_TELEPORT_ARRIVED
The vehicle was teleported out of the net.
@ NOTIFICATION_VAPORIZED_CALIBRATOR
The vehicle got removed by a calibrator.
@ NOTIFICATION_VAPORIZED_GUI
The vehicle got removed via the GUI.
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
@ NOTIFICATION_VAPORIZED_VAPORIZER
The vehicle got vaporized with a vaporizer.
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
@ NOTIFICATION_PARKING
The vehicle starts or ends parking.
@ NOTIFICATION_VAPORIZED_COLLISION
The vehicle got removed by a collision.
@ NOTIFICATION_TELEPORT
The vehicle is being teleported.
The simulated network and simulation perfomer.
Definition: MSNet.h:89
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:171
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:313
bool hasPersons() const
Returns whether persons are simulated.
Definition: MSNet.h:388
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:986
MSRouteIterator end() const
Returns the end of the list of edges to pass.
Definition: MSRoute.cpp:75
constVehIt loadedBegin() const
Returns the begin of the internal transportables map.
constVehIt loadedEnd() const
Returns the end of the internal transportables map.
virtual void erase(MSTransportable *transportable)
removes a single transportable
Abstract in-vehicle device.
SUMOVehicle & myHolder
The vehicle that stores the device.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:77
const std::string & getID() const
Returns the name of the vehicle type.
Definition: MSVehicleType.h:90
const std::string & getID() const
Returns the id.
Definition: Named.h:73
A storage for options typed value containers)
Definition: OptionsCont.h:89
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:60
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:239
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
void setPrecision(int precision=gPrecision)
Sets the precison or resets it to default.
Encapsulated SAX-Attributes.
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
Representation of a vehicle, person, or container.
virtual SUMOTime getWaitingTime() const =0
virtual bool isVehicle() const
Whether it is a vehicle.
virtual double getChosenSpeedFactor() const =0
virtual double getSpeed() const =0
Returns the object's current speed.
virtual bool isStopped() const =0
Returns whether the object is at a stop.
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
virtual const MSEdge * getEdge() const =0
Returns the edge the object is currently at.
virtual double getPositionOnLane() const =0
Get the object's position along the lane.
Representation of a vehicle.
Definition: SUMOVehicle.h:58
virtual const MSRoute & getRoute() const =0
Returns the current route.
virtual SUMOTime getDeparture() const =0
Returns this vehicle's real departure time.
virtual bool hasDeparted() const =0
Returns whether this vehicle has departed.
virtual int getNumberReroutes() const =0
Returns the number of new routes this vehicle got.
virtual double getArrivalPos() const =0
Returns this vehicle's desired arrivalPos for its current route (may change on reroute)
virtual double getDepartPos() const =0
Returns this vehicle's real departure position.
virtual SUMOTime getDepartDelay() const =0
virtual const std::vector< MSVehicleDevice * > & getDevices() const =0
Returns this vehicle's devices.