Eclipse SUMO - Simulation of Urban MObility
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-2024 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"
26 #include <utils/common/SUMOTime.h>
27 
28 // ===========================================================================
29 // class declarations
30 // ===========================================================================
31 class SUMOVehicle;
32 class SUMOTrafficObject;
33 
34 // ===========================================================================
35 // class definitions
36 // ===========================================================================
46 public:
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 
96  static double getAvgWalkRouteLength();
97  static double getAvgWalkDuration();
98  static double getAvgWalkTimeLoss();
99 
100  static double getAvgRideRouteLength();
101  static double getAvgRideWaitingTime();
102  static double getAvgRideDuration();
103 
104 public:
107 
108 
110  static void cleanup();
111 
112 
115 
124  bool notifyMove(SUMOTrafficObject& veh, double oldPos, double newPos, double newSpeed);
125 
133  bool notifyIdle(SUMOTrafficObject& veh);
134 
143  bool notifyEnter(SUMOTrafficObject& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
144 
145 
154  bool notifyLeave(SUMOTrafficObject& veh, double lastPos, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
156 
157 
159  const std::string deviceName() const {
160  return "tripinfo";
161  }
162 
169  void generateOutput(OutputDevice* tripinfoOut) const;
170 
175  void saveState(OutputDevice& out) const;
176 
181  void loadState(const SUMOSAXAttributes& attrs);
182 
184  void updateStopTime(const SUMOTime time) {
185  myStoppingTime += time;
186  }
187 
188 
190  std::string getParameter(const std::string& key) const;
191 
193  static std::string getGlobalParameter(const std::string& prefixedKey);
194 
195 private:
201  MSDevice_Tripinfo(SUMOVehicle& holder, const std::string& id);
202 
203 
204 protected:
208  void notifyMoveInternal(const SUMOTrafficObject& veh,
209  const double frontOnLane,
210  const double timeOnLane,
211  const double meanSpeedFrontOnLane,
212  const double meanSpeedVehicleOnLane,
213  const double travelledDistanceFrontOnLane,
214  const double travelledDistanceVehicleOnLane,
215  const double meanLengthOnLane);
216 
218  void updateParkingStopTime();
219 
220  static void printRideStatistics(std::ostringstream& msg, const std::string& category, const std::string& modeName, const int index);
221 
222  static void writeRideStatistics(OutputDevice& od, const std::string& category, const int index);
223 
224  static bool lowAcceleration(const SUMOTrafficObject& veh);
225 
226 private:
228  std::string myDepartLane;
229 
232 
235 
238 
241 
244 
247 
250 
253 
255  std::string myArrivalLane;
256 
258  double myArrivalPos;
259 
262 
265 
268 
271 
274 
276  static std::set<const MSDevice_Tripinfo*, ComparatorNumericalIdLess> myPendingOutput;
277 
279  static int myVehicleCount;
281  static double myTotalRouteLength;
282  static double myTotalSpeed;
288 
290  static int myBikeCount;
291  static double myTotalBikeRouteLength;
292  static double myTotalBikeSpeed;
296 
297  static int myWalkCount;
298  static double myTotalWalkRouteLength;
301 
302  static std::vector<int> myRideCount;
303  static std::vector<int> myRideBusCount;
304  static std::vector<int> myRideRailCount;
305  static std::vector<int> myRideTaxiCount;
306  static std::vector<int> myRideBikeCount;
307  static std::vector<int> myRideAbortCount;
308  static std::vector<SUMOTime> myTotalRideWaitingTime;
309  static std::vector<double> myTotalRideRouteLength;
310  static std::vector<SUMOTime> myTotalRideDuration;
311 
312 private:
315 
318 
319 
320 };
long long int SUMOTime
Definition: GUI.h:35
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()
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.
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()
static std::string getGlobalParameter(const std::string &prefixedKey)
try to retrieve the given parameter from the global statistics. Throw exception for unsupported key
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
MSDevice_Tripinfo & operator=(const MSDevice_Tripinfo &)
Invalidated assignment operator.
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 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
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.
Definition: OutputDevice.h:61
Encapsulated SAX-Attributes.
Representation of a vehicle, person, or container.
Representation of a vehicle.
Definition: SUMOVehicle.h:60