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-2022 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// ===========================================================================
44std::set<const MSDevice_Tripinfo*, ComparatorNumericalIdLess> MSDevice_Tripinfo::myPendingOutput;
45
55
62
67std::vector<int> MSDevice_Tripinfo::myRideCount({0, 0});
68std::vector<int> MSDevice_Tripinfo::myRideBusCount({0, 0});
69std::vector<int> MSDevice_Tripinfo::myRideRailCount({0, 0});
70std::vector<int> MSDevice_Tripinfo::myRideTaxiCount({0, 0});
71std::vector<int> MSDevice_Tripinfo::myRideBikeCount({0, 0});
72std::vector<int> MSDevice_Tripinfo::myRideAbortCount({0, 0});
73std::vector<SUMOTime> MSDevice_Tripinfo::myTotalRideWaitingTime({0, 0});
74std::vector<double> MSDevice_Tripinfo::myTotalRideRouteLength({0., 0.});
75std::vector<SUMOTime> MSDevice_Tripinfo::myTotalRideDuration({0, 0});
76
77// ===========================================================================
78// method definitions
79// ===========================================================================
80// ---------------------------------------------------------------------------
81// static initialisation methods
82// ---------------------------------------------------------------------------
83void
85 oc.addOptionSubTopic("Tripinfo Device");
86 insertDefaultAssignmentOptions("tripinfo", "Tripinfo Device", oc);
87}
88
89
90void
91MSDevice_Tripinfo::buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into) {
93 const bool enableByOutputOption = oc.isSet("tripinfo-output") || oc.getBool("duration-log.statistics");
94 if (equippedByDefaultAssignmentOptions(oc, "tripinfo", v, enableByOutputOption)) {
95 MSDevice_Tripinfo* device = new MSDevice_Tripinfo(v, "tripinfo_" + v.getID());
96 into.push_back(device);
97 myPendingOutput.insert(device);
98 }
99}
100
101
102// ---------------------------------------------------------------------------
103// MSDevice_Tripinfo-methods
104// ---------------------------------------------------------------------------
105MSDevice_Tripinfo::MSDevice_Tripinfo(SUMOVehicle& holder, const std::string& id) :
106 MSVehicleDevice(holder, id),
107 myDepartLane(""),
108 myDepartSpeed(-1),
109 myDepartPosLat(0),
110 myWaitingTime(0),
111 myAmWaiting(false),
112 myWaitingCount(0),
113 myStoppingTime(0),
114 myParkingStarted(-1),
115 myArrivalTime(NOT_ARRIVED),
116 myArrivalLane(""),
117 myArrivalPos(-1),
118 myArrivalPosLat(0.),
119 myArrivalSpeed(-1),
120 myArrivalReason(MSMoveReminder::NOTIFICATION_ARRIVED),
121 myMesoTimeLoss(0),
122 myRouteLength(0.) {
123}
124
125
127 // ensure clean up for vaporized vehicles which do not generate output
128 myPendingOutput.erase(this);
129}
130
131void
133 myVehicleCount = 0;
135 myTotalSpeed = 0;
136 myTotalDuration = 0;
138 myTotalTimeLoss = 0;
141
142 myBikeCount = 0;
148
149 myWalkCount = 0;
153
154 myRideCount = {0, 0};
155 myRideBusCount = {0, 0};
156 myRideRailCount = {0, 0};
157 myRideTaxiCount = {0, 0};
158 myRideBikeCount = {0, 0};
159 myRideAbortCount = {0, 0};
160 myTotalRideWaitingTime = {0, 0};
161 myTotalRideRouteLength = {0., 0.};
162 myTotalRideDuration = {0, 0};
163}
164
165bool
167 if (veh.isVehicle()) {
169 if (!myAmWaiting) {
171 myAmWaiting = true;
172 }
173 }
174 return true;
175}
176
177
178bool
180 double /*newPos*/, double newSpeed) {
181 if (veh.isStopped()) {
183 } else if (newSpeed <= SUMO_const_haltingSpeed) {
185 if (!myAmWaiting) {
187 myAmWaiting = true;
188 }
189 } else {
190 myAmWaiting = false;
191 }
192 return true;
193}
194
195
196void
198 const double /* frontOnLane */,
199 const double timeOnLane,
200 const double /* meanSpeedFrontOnLane */,
201 const double meanSpeedVehicleOnLane,
202 const double /* travelledDistanceFrontOnLane */,
203 const double /* travelledDistanceVehicleOnLane */,
204 const double /* meanLengthOnLane */) {
205
206 // called by meso
207 const double vmax = veh.getEdge()->getVehicleMaxSpeed(&veh);
208 if (vmax > 0) {
209 myMesoTimeLoss += TIME2STEPS(timeOnLane * (vmax - meanSpeedVehicleOnLane) / vmax);
210 }
212}
213
214
215void
217 if (myParkingStarted >= 0) {
219 myParkingStarted = -1;
220 }
221}
222
223bool
227 myDepartLane = static_cast<MSVehicle&>(veh).getLane()->getID();
228 myDepartPosLat = static_cast<MSVehicle&>(veh).getLateralPositionOnLane();
229 }
230 myDepartSpeed = veh.getSpeed();
232 } else if (reason == MSMoveReminder::NOTIFICATION_PARKING) {
233 // notifyMove is not called while parking
234 // @note insertion delay when resuming after parking is included
236 }
237 return true;
238}
239
240
241bool
243 MSMoveReminder::Notification reason, const MSLane* /* enteredLane */) {
246 myArrivalReason = reason;
248 myArrivalLane = static_cast<MSVehicle&>(veh).getLane()->getID();
249 myArrivalPosLat = static_cast<MSVehicle&>(veh).getLateralPositionOnLane();
250 }
251 // @note vehicle may have moved past its arrivalPos during the last step
252 // due to non-zero arrivalspeed but we consider it as arrived at the desired position
253 // However, vaporization may happen anywhere (via TraCI)
255 // vaporized
257 } else {
259 }
260 myArrivalSpeed = veh.getSpeed();
262 } else if (reason == MSMoveReminder::NOTIFICATION_PARKING) {
264 } else if (reason == NOTIFICATION_JUNCTION || reason == NOTIFICATION_TELEPORT) {
267 } else {
268 const MSLane* lane = static_cast<MSVehicle&>(veh).getLane();
269 if (lane != nullptr) {
270 myRouteLength += lane->getLength();
271 }
272 }
273 }
274 return true;
275}
276
277
278void
280 const SUMOTime timeLoss = MSGlobals::gUseMesoSim ? myMesoTimeLoss : static_cast<MSVehicle&>(myHolder).getTimeLoss();
281 const double routeLength = myRouteLength + (myArrivalTime == NOT_ARRIVED ? myHolder.getPositionOnLane() : myArrivalPos);
282 SUMOTime duration = 0;
283 if (myHolder.hasDeparted()) {
285 if (myHolder.getVClass() == SVC_BICYCLE) {
286 myBikeCount++;
287 myTotalBikeRouteLength += routeLength;
288 myTotalBikeSpeed += routeLength / STEPS2TIME(duration);
289 myTotalBikeDuration += duration;
291 myTotalBikeTimeLoss += timeLoss;
292 } else {
294 myTotalRouteLength += routeLength;
295 myTotalSpeed += routeLength / STEPS2TIME(duration);
296 myTotalDuration += duration;
298 myTotalTimeLoss += timeLoss;
299 }
301 }
302
303 myPendingOutput.erase(this);
304 if (tripinfoOut == nullptr) {
305 return;
306 }
307 // write
308 OutputDevice& os = *tripinfoOut;
309 os.openTag("tripinfo").writeAttr("id", myHolder.getID());
311 os.writeAttr("departLane", myDepartLane);
312 os.writeAttr("departPos", myHolder.getDepartPos());
314 os.writeAttr("departPosLat", myDepartPosLat);
315 }
316 os.writeAttr("departSpeed", myDepartSpeed);
317 SUMOTime departDelay = myHolder.getDepartDelay();
319 if (!myHolder.hasDeparted()) {
320 assert(param.depart <= SIMSTEP || param.departProcedure != DepartDefinition::GIVEN);
321 departDelay = SIMSTEP - param.depart;
322 }
323 os.writeAttr("departDelay", time2string(departDelay));
324 os.writeAttr("arrival", time2string(myArrivalTime));
325 os.writeAttr("arrivalLane", myArrivalLane);
326 os.writeAttr("arrivalPos", myArrivalPos);
328 os.writeAttr("arrivalPosLat", myArrivalPosLat);
329 }
330 os.writeAttr("arrivalSpeed", myArrivalSpeed);
331 os.writeAttr("duration", time2string(duration));
332 os.writeAttr("routeLength", routeLength);
333 os.writeAttr("waitingTime", time2string(myWaitingTime));
334 os.writeAttr("waitingCount", myWaitingCount);
335 os.writeAttr("stopTime", time2string(myStoppingTime));
336 os.writeAttr("timeLoss", time2string(timeLoss));
337 os.writeAttr("rerouteNo", myHolder.getNumberReroutes());
338 os.writeAttr("devices", toString(myHolder.getDevices()));
339 os.writeAttr("vType", myHolder.getVehicleType().getID());
340 os.writeAttr("speedFactor", myHolder.getChosenSpeedFactor());
341 std::string vaporized;
342 switch (myArrivalReason) {
344 vaporized = "calibrator";
345 break;
347 vaporized = "gui";
348 break;
350 vaporized = "collision";
351 break;
353 vaporized = "vaporizer";
354 break;
356 vaporized = "traci";
357 break;
359 vaporized = "teleport";
360 break;
361 default:
363 (param.arrivalEdge >= 0 && myHolder.getRoutePosition() >= param.arrivalEdge)) {
364 vaporized = "";
365 } else {
366 vaporized = "end";
367 }
368 break;
369 }
370 os.writeAttr("vaporized", vaporized);
371 // cannot close tag because emission device output might follow
372}
373
374
375void
377 MSNet* net = MSNet::getInstance();
378 OutputDevice* tripinfoOut = (OptionsCont::getOptions().isSet("tripinfo-output") ?
379 &OutputDevice::getDeviceByOption("tripinfo-output") : nullptr);
382 const bool writeUndeparted = OptionsCont::getOptions().getBool("tripinfo-output.write-undeparted");
383 const SUMOTime t = net->getCurrentTimeStep();
384 while (myPendingOutput.size() > 0) {
385 const MSDevice_Tripinfo* d = *myPendingOutput.begin();
386 const bool departed = d->myHolder.hasDeparted();
387 const bool departDelayed = d->myHolder.getParameter().depart <= t;
388 if (!departed && departDelayed) {
391 }
392 if (departed || (writeUndeparted && departDelayed)) {
393 const_cast<MSDevice_Tripinfo*>(d)->updateParkingStopTime();
394 d->generateOutput(tripinfoOut);
395 if (tripinfoOut != nullptr) {
396 for (MSVehicleDevice* const dev : d->myHolder.getDevices()) {
397 if (typeid(*dev) == typeid(MSDevice_Tripinfo) || typeid(*dev) == typeid(MSDevice_Vehroutes)) {
398 // tripinfo is special and vehroute has it's own write-unfinished option
399 continue;
400 }
401 dev->generateOutput(tripinfoOut);
402 }
403 OutputDevice::getDeviceByOption("tripinfo-output").closeTag();
404 }
405 } else {
406 myPendingOutput.erase(d);
407 }
408 }
409 // unfinished persons
410 if (net->hasPersons()) {
412 while (pc.loadedBegin() != pc.loadedEnd()) {
413 pc.erase(pc.loadedBegin()->second);
414 }
415 }
416
417}
418
419
420void
421MSDevice_Tripinfo::addPedestrianData(double walkLength, SUMOTime walkDuration, SUMOTime walkTimeLoss) {
422 myWalkCount++;
423 myTotalWalkRouteLength += walkLength;
424 myTotalWalkDuration += walkDuration;
425 myTotalWalkTimeLoss += walkTimeLoss;
426}
427
428
429void
430MSDevice_Tripinfo::addRideTransportData(const bool isPerson, const double distance, const SUMOTime duration,
431 const SUMOVehicleClass vClass, const std::string& line, const SUMOTime waitingTime) {
432 const int index = isPerson ? 0 : 1;
433 myRideCount[index]++;
434 if (duration > 0) {
435 myTotalRideWaitingTime[index] += waitingTime;
436 myTotalRideRouteLength[index] += distance;
437 myTotalRideDuration[index] += duration;
438 if (vClass == SVC_BICYCLE) {
439 myRideBikeCount[index]++;
440 } else if (!line.empty()) {
441 if (isRailway(vClass)) {
442 myRideRailCount[index]++;
443 } else if (vClass == SVC_TAXI) {
444 myRideTaxiCount[index]++;
445 } else {
446 // some kind of road vehicle
447 myRideBusCount[index]++;
448 }
449 }
450 } else {
451 myRideAbortCount[index]++;
452 }
453}
454
455
456std::string
458 std::ostringstream msg;
459 msg.setf(msg.fixed);
460 msg.precision(gPrecision);
461 if (myBikeCount == 0 || myVehicleCount > 0) {
462 msg << "Statistics (avg of " << myVehicleCount << "):\n";
463 msg << " RouteLength: " << getAvgRouteLength() << "\n"
464 << " Speed: " << getAvgTripSpeed() << "\n"
465 << " Duration: " << getAvgDuration() << "\n"
466 << " WaitingTime: " << getAvgWaitingTime() << "\n"
467 << " TimeLoss: " << getAvgTimeLoss() << "\n";
468 }
469 if (myBikeCount > 0) {
470 msg << "Bike Statistics (avg of " << myBikeCount << "):\n"
471 << " RouteLength: " << getAvgBikeRouteLength() << "\n"
472 << " Speed: " << getAvgBikeTripSpeed() << "\n"
473 << " Duration: " << getAvgBikeDuration() << "\n"
474 << " WaitingTime: " << getAvgBikeWaitingTime() << "\n"
475 << " TimeLoss: " << getAvgBikeTimeLoss() << "\n";
476 if (myVehicleCount > 0) {
477 msg << "Statistics (avg of " << (myVehicleCount + myBikeCount) << "):\n";
478 }
479 }
480 msg << " DepartDelay: " << getAvgDepartDelay() << "\n";
481 if (myWaitingDepartDelay >= 0) {
482 msg << " DepartDelayWaiting: " << STEPS2TIME(myWaitingDepartDelay / MAX2(1, myUndepartedVehicleCount)) << "\n";
483 }
484 if (myWalkCount > 0) {
485 msg << "Pedestrian Statistics (avg of " << myWalkCount << " walks):\n"
486 << " RouteLength: " << getAvgWalkRouteLength() << "\n"
487 << " Duration: " << getAvgWalkDuration() << "\n"
488 << " TimeLoss: " << getAvgWalkTimeLoss() << "\n";
489 }
490 printRideStatistics(msg, "Ride", "rides", 0);
491 printRideStatistics(msg, "Transport", "transports", 1);
492 return msg.str();
493}
494
495void
496MSDevice_Tripinfo::printRideStatistics(std::ostringstream& msg, const std::string& category, const std::string& modeName, const int index) {
497 if (myRideCount[index] > 0) {
498 msg << category << " Statistics (avg of " << myRideCount[index] << " " << modeName << "):\n";
499 msg << " WaitingTime: " << STEPS2TIME(myTotalRideWaitingTime[index] / myRideCount[index]) << "\n";
500 msg << " RouteLength: " << myTotalRideRouteLength[index] / myRideCount[index] << "\n";
501 msg << " Duration: " << STEPS2TIME(myTotalRideDuration[index] / myRideCount[index]) << "\n";
502 if (myRideBusCount[index] > 0) {
503 msg << " Bus: " << myRideBusCount[index] << "\n";
504 }
505 if (myRideRailCount[index] > 0) {
506 msg << " Train: " << myRideRailCount[index] << "\n";
507 }
508 if (myRideTaxiCount[index] > 0) {
509 msg << " Taxi: " << myRideTaxiCount[index] << "\n";
510 }
511 if (myRideBikeCount[index] > 0) {
512 msg << " Bike: " << myRideBikeCount[index] << "\n";
513 }
514 if (myRideAbortCount[index] > 0) {
515 msg << " Aborted: " << myRideAbortCount[index] << "\n";
516 }
517 }
518
519}
520
521
522void
525 od.openTag("vehicleTripStatistics");
526 od.writeAttr("count", myVehicleCount);
527 od.writeAttr("routeLength", getAvgRouteLength());
528 od.writeAttr("speed", getAvgTripSpeed());
529 od.writeAttr("duration", getAvgDuration());
530 od.writeAttr("waitingTime", getAvgWaitingTime());
531 od.writeAttr("timeLoss", getAvgTimeLoss());
532 od.writeAttr("departDelay", getAvgDepartDelay());
534 od.writeAttr("totalTravelTime", time2string(myTotalDuration));
536 od.writeAttr("totalDepartDelay", time2string(totalDepartDelay));
537 od.closeTag();
538 if (myBikeCount > 0) {
539 od.openTag("bikeTripStatistics");
540 od.writeAttr("count", myBikeCount);
541 od.writeAttr("routeLength", getAvgBikeRouteLength());
542 od.writeAttr("speed", getAvgBikeTripSpeed());
543 od.writeAttr("duration", getAvgBikeDuration());
544 od.writeAttr("waitingTime", getAvgBikeWaitingTime());
545 od.writeAttr("timeLoss", getAvgBikeTimeLoss());
546 od.writeAttr("totalTravelTime", time2string(myTotalBikeDuration));
547 od.closeTag();
548 }
549 od.openTag("pedestrianStatistics");
550 od.writeAttr("number", myWalkCount);
551 od.writeAttr("routeLength", getAvgWalkRouteLength());
552 od.writeAttr("duration", getAvgWalkDuration());
553 od.writeAttr("timeLoss", getAvgWalkTimeLoss());
554 od.closeTag();
555 writeRideStatistics(od, "rideStatistics", 0);
556 writeRideStatistics(od, "transportStatistics", 1);
557}
558
559void
560MSDevice_Tripinfo::writeRideStatistics(OutputDevice& od, const std::string& category, const int index) {
561 od.openTag(category);
562 od.writeAttr("number", myRideCount[index]);
563 if (myRideCount[index] > 0) {
564 od.writeAttr("waitingTime", STEPS2TIME(myTotalRideWaitingTime[index] / myRideCount[index]));
565 od.writeAttr("routeLength", myTotalRideRouteLength[index] / myRideCount[index]);
566 od.writeAttr("duration", STEPS2TIME(myTotalRideDuration[index] / myRideCount[index]));
567 od.writeAttr("bus", myRideBusCount[index]);
568 od.writeAttr("train", myRideRailCount[index]);
569 od.writeAttr("taxi", myRideTaxiCount[index]);
570 od.writeAttr("bike", myRideBikeCount[index]);
571 od.writeAttr("aborted", myRideAbortCount[index]);
572 }
573 od.closeTag();
574}
575
576
577double
579 if (myVehicleCount > 0) {
581 } else {
582 return 0;
583 }
584}
585
586double
588 if (myVehicleCount > 0) {
590 } else {
591 return 0;
592 }
593}
594
595double
597 if (myVehicleCount > 0) {
599 } else {
600 return 0;
601 }
602}
603
604double
606 if (myVehicleCount > 0) {
608 } else {
609 return 0;
610 }
611}
612
613
614double
616 if (myVehicleCount > 0) {
618 } else {
619 return 0;
620 }
621}
622
623
624double
626 if (myVehicleCount > 0) {
628 } else {
629 return 0;
630 }
631}
632
633double
635 if (myBikeCount > 0) {
637 } else {
638 return 0;
639 }
640}
641
642double
644 if (myBikeCount > 0) {
646 } else {
647 return 0;
648 }
649}
650
651double
653 if (myBikeCount > 0) {
655 } else {
656 return 0;
657 }
658}
659
660double
662 if (myBikeCount > 0) {
664 } else {
665 return 0;
666 }
667}
668
669
670double
672 if (myBikeCount > 0) {
674 } else {
675 return 0;
676 }
677}
678
679
680
681double
683 if (myWalkCount > 0) {
685 } else {
686 return 0;
687 }
688}
689
690double
692 if (myWalkCount > 0) {
694 } else {
695 return 0;
696 }
697}
698
699
700double
702 if (myWalkCount > 0) {
704 } else {
705 return 0;
706 }
707}
708
709
710double
712 if (myRideCount[0] > 0) {
714 } else {
715 return 0;
716 }
717}
718
719double
721 if (myRideCount[0] > 0) {
723 } else {
724 return 0;
725 }
726}
727
728double
730 if (myRideCount[0] > 0) {
731 return myTotalRideRouteLength[0] / myRideCount[0];
732 } else {
733 return 0;
734 }
735}
736
737
738void
740 if (myHolder.hasDeparted()) {
743 std::ostringstream internals;
745 internals << myDepartLane << " " << myDepartPosLat << " ";
746 }
747 internals << myDepartSpeed << " " << myRouteLength << " " << myWaitingTime << " " << myAmWaiting << " " << myWaitingCount << " ";
748 internals << myStoppingTime << " " << myParkingStarted;
749 out.writeAttr(SUMO_ATTR_STATE, internals.str());
750 out.closeTag();
751 }
752}
753
754
755void
757 std::istringstream bis(attrs.getString(SUMO_ATTR_STATE));
760 }
763}
764
765
766/****************************************************************************/
long long int SUMOTime
Definition: GUI.h:36
#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:54
#define SIMSTEP
Definition: SUMOTime.h:60
#define TIME2STEPS(x)
Definition: SUMOTime.h:56
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
@ GIVEN
The time is given.
@ 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:58
T MAX2(T a, T b)
Definition: StdDefs.h:77
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
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 double getAvgBikeTripSpeed()
static std::vector< SUMOTime > myTotalRideWaitingTime
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 myTotalBikeDuration
static SUMOTime myTotalWalkTimeLoss
static double getAvgRideWaitingTime()
SUMOTime myParkingStarted
The time when parking started.
static double getAvgBikeDuration()
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()
static double getAvgBikeTimeLoss()
~MSDevice_Tripinfo()
Destructor.
static SUMOTime myTotalTimeLoss
static double getAvgRideDuration()
static std::vector< int > myRideRailCount
static double getAvgDepartDelay()
static double myTotalBikeRouteLength
static double myTotalSpeed
static double getAvgBikeRouteLength()
static std::vector< SUMOTime > myTotalRideDuration
static SUMOTime myTotalBikeTimeLoss
static double getAvgTripSpeed()
static double getAvgRouteLength()
accessors for GUINet-Parameters
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 myTotalBikeSpeed
static double getAvgWaitingTime()
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 meanLengthOnLane)
Internal notification about the vehicle moves, see MSMoveReminder::notifyMoveInternal()
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
static double getAvgBikeWaitingTime()
double myArrivalPosLat
The lateral position on the lane the vehicle arrived at.
static double getAvgDuration()
static SUMOTime myTotalBikeWaitingTime
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.
static int myUndepartedVehicleCount
static int myVehicleCount
global tripinfo statistics
double myArrivalPos
The position on the lane the vehicle arrived at.
static std::vector< int > myRideTaxiCount
static std::vector< int > myRideBikeCount
static int myBikeCount
separate values for bicycles
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:144
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:202
double getLength() const
return the length of the edge
Definition: MSEdge.h:658
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the maximum speed the vehicle may use on this edge.
Definition: MSEdge.cpp:1068
static bool gUseMesoSim
Definition: MSGlobals.h:103
static double gLateralResolution
Definition: MSGlobals.h:97
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
double getLength() const
Returns the lane's length.
Definition: MSLane.h:575
Something on a lane to be noticed about vehicle movement.
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.
const MSLane * getLane() const
Returns the lane the reminder works on.
The simulated network and simulation perfomer.
Definition: MSNet.h:88
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:183
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:321
bool hasPersons() const
Returns whether persons are simulated.
Definition: MSNet.h:396
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:1096
const MSEdge * getLastEdge() const
returns the destination edge
Definition: MSRoute.cpp:92
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:91
const std::string & getID() const
Returns the id.
Definition: Named.h:74
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:59
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:251
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
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 precision or resets it to default.
Encapsulated SAX-Attributes.
virtual std::string getString(int id, bool *isPresent=nullptr) 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 const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
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 SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
virtual SUMOVehicleClass getVClass() const =0
Returns the object's access class.
virtual int getRoutePosition() const =0
return index of edge within route
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:60
virtual SUMOTime getDeparture() const =0
Returns this vehicle's real departure time.
virtual const std::vector< MSVehicleDevice * > & getDevices() const =0
Returns this vehicle's devices.
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 MSRoute & getRoute() const =0
Returns the current route.
Structure representing possible vehicle parameter.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
int arrivalEdge
(optional) The final edge within the route of the vehicle