Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSDevice_Tripinfo.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2009-2026 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/****************************************************************************/
20// A device which collects info on the vehicle trip
21/****************************************************************************/
22#pragma once
23#include <config.h>
24
25#include "MSVehicleDevice.h"
27
28// ===========================================================================
29// class declarations
30// ===========================================================================
31class SUMOVehicle;
33
34// ===========================================================================
35// class definitions
36// ===========================================================================
46public:
50 static void insertOptions(OptionsCont& oc);
51
62 static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
63
65 static void generateOutputForUnfinished();
66
68 static void addPedestrianData(double walkLength, SUMOTime walkDuration, SUMOTime walkTimeLoss);
69
71 static void addRideTransportData(const bool isPerson, const double distance, const SUMOTime duration,
72 const SUMOVehicleClass vClass, const std::string& line, const SUMOTime waitingTime);
73
75 static std::string printStatistics();
76
78 static void writeStatistics(OutputDevice& od);
79
81 static double getAvgRouteLength();
82 static double getAvgTripSpeed();
83 static double getAvgDuration();
84 static double getAvgWaitingTime();
85 static double getAvgTimeLoss();
86 static double getAvgDepartDelay();
87 static double getAvgDepartDelayWaiting();
88 static double getTotalDepartDelay();
89
90 static double getAvgBikeRouteLength();
91 static double getAvgBikeTripSpeed();
92 static double getAvgBikeDuration();
93 static double getAvgBikeWaitingTime();
94 static double getAvgBikeTimeLoss();
95 static double getAvgBikeDepartDelay();
96 static double getTotalBikeDepartDelay();
97
98 static double getAvgWalkRouteLength();
99 static double getAvgWalkDuration();
100 static double getAvgWalkTimeLoss();
101
102 static double getAvgRideRouteLength();
103 static double getAvgRideWaitingTime();
104 static double getAvgRideDuration();
105
106public:
109
110
112 static void cleanup();
113
114
117
126 bool notifyMove(SUMOTrafficObject& veh, double oldPos, double newPos, double newSpeed);
127
135 bool notifyIdle(SUMOTrafficObject& veh);
136
145 bool notifyEnter(SUMOTrafficObject& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
146
147
156 bool notifyLeave(SUMOTrafficObject& veh, double lastPos, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
158
159
161 const std::string deviceName() const {
162 return "tripinfo";
163 }
164
171 void generateOutput(OutputDevice* tripinfoOut) const;
172
177 void saveState(OutputDevice& out) const;
178
183 void loadState(const SUMOSAXAttributes& attrs);
184
186 void updateStopTime(const SUMOTime time) {
187 myStoppingTime += time;
188 }
189
190
192 std::string getParameter(const std::string& key) const;
193
195 static std::string getGlobalParameter(const std::string& prefixedKey);
196
197 void recordMesoParkingTimeLoss(SUMOTime waitingTime);
198
199private:
205 MSDevice_Tripinfo(SUMOVehicle& holder, const std::string& id);
206
207
208protected:
213 const double frontOnLane,
214 const double timeOnLane,
215 const double meanSpeedFrontOnLane,
216 const double meanSpeedVehicleOnLane,
217 const double travelledDistanceFrontOnLane,
218 const double travelledDistanceVehicleOnLane,
219 const double meanLengthOnLane);
220
223
224 static void printRideStatistics(std::ostringstream& msg, const std::string& category, const std::string& modeName, const int index);
225
226 static void writeRideStatistics(OutputDevice& od, const std::string& category, const int index);
227
228 static bool lowAcceleration(const SUMOTrafficObject& veh);
229
230private:
232 std::string myDepartLane;
233
236
239
242
245
248
251
254
257
259 std::string myArrivalLane;
260
263
266
269
272
275
278
280 static std::set<const MSDevice_Tripinfo*, ComparatorNumericalIdLess> myPendingOutput;
281
283 static int myVehicleCount;
285 static double myTotalRouteLength;
286 static double myTotalSpeed;
292
294 static int myBikeCount;
296 static double myTotalBikeSpeed;
301
302 static int myWalkCount;
306
307 static std::vector<int> myRideCount;
308 static std::vector<int> myRideBusCount;
309 static std::vector<int> myRideRailCount;
310 static std::vector<int> myRideTaxiCount;
311 static std::vector<int> myRideBikeCount;
312 static std::vector<int> myRideAbortCount;
313 static std::vector<SUMOTime> myTotalRideWaitingTime;
314 static std::vector<double> myTotalRideRouteLength;
315 static std::vector<SUMOTime> myTotalRideDuration;
316
317private:
320
323
324
325};
long long int SUMOTime
Definition GUI.h:36
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
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
const std::string deviceName() const
return the name for this type of device
double myDepartSpeed
The speed on departure.
void updateStopTime(const SUMOTime time)
update stopping time for meso
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.
static double getAvgDepartDelayWaiting()
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.
MSDevice_Tripinfo(const MSDevice_Tripinfo &)
Invalidated copy constructor.
static SUMOTime myTotalTimeLoss
static double getTotalDepartDelay()
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()
MSDevice_Tripinfo & operator=(const MSDevice_Tripinfo &)
Invalidated assignment operator.
static std::string getGlobalParameter(const std::string &prefixedKey)
try to retrieve the given parameter from the global statistics. Throw exception for unsupported key
void recordMesoParkingTimeLoss(SUMOTime waitingTime)
static double getAvgRouteLength()
accessors for GUINet-Parameters
void updateParkingStopTime()
update stopping time after parking
static SUMOTime myTotalBikeDepartDelay
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()
static double getTotalBikeDepartDelay()
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 bool lowAcceleration(const SUMOTrafficObject &veh)
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.
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key
static SUMOTime myWaitingDepartDelay
static std::vector< double > myTotalRideRouteLength
static double getAvgBikeDepartDelay()
Representation of a lane in the micro simulation.
Definition MSLane.h:84
Notification
Definition of a vehicle state.
Abstract in-vehicle device.
A storage for options typed value containers)
Definition OptionsCont.h:89
Static storage of an output device and its base (abstract) implementation.
Encapsulated SAX-Attributes.
Representation of a vehicle, person, or container.
Representation of a vehicle.
Definition SUMOVehicle.h:63