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.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 /****************************************************************************/
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 
88  static double getAvgBikeRouteLength();
89  static double getAvgBikeTripSpeed();
90  static double getAvgBikeDuration();
91  static double getAvgBikeWaitingTime();
92  static double getAvgBikeTimeLoss();
93 
94  static double getAvgWalkRouteLength();
95  static double getAvgWalkDuration();
96  static double getAvgWalkTimeLoss();
97 
98  static double getAvgRideRouteLength();
99  static double getAvgRideWaitingTime();
100  static double getAvgRideDuration();
101 
102 public:
105 
106 
108  static void cleanup();
109 
110 
113 
122  bool notifyMove(SUMOTrafficObject& veh, double oldPos, double newPos, double newSpeed);
123 
131  bool notifyIdle(SUMOTrafficObject& veh);
132 
141  bool notifyEnter(SUMOTrafficObject& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
142 
143 
152  bool notifyLeave(SUMOTrafficObject& veh, double lastPos, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
154 
155 
157  const std::string deviceName() const {
158  return "tripinfo";
159  }
160 
167  void generateOutput(OutputDevice* tripinfoOut) const;
168 
173  void saveState(OutputDevice& out) const;
174 
179  void loadState(const SUMOSAXAttributes& attrs);
180 
182  void updateStopTime(const SUMOTime time) {
183  myStoppingTime += time;
184  }
185 
186 
187 private:
193  MSDevice_Tripinfo(SUMOVehicle& holder, const std::string& id);
194 
195 
196 protected:
200  void notifyMoveInternal(const SUMOTrafficObject& veh,
201  const double frontOnLane,
202  const double timeOnLane,
203  const double meanSpeedFrontOnLane,
204  const double meanSpeedVehicleOnLane,
205  const double travelledDistanceFrontOnLane,
206  const double travelledDistanceVehicleOnLane,
207  const double /* meanLengthOnLane */);
208 
210  void updateParkingStopTime();
211 
212  static void printRideStatistics(std::ostringstream& msg, const std::string& category, const std::string& modeName, const int index);
213 
214  static void writeRideStatistics(OutputDevice& od, const std::string& category, const int index);
215 
216 private:
218  std::string myDepartLane;
219 
222 
225 
228 
231 
234 
237 
240 
243 
245  std::string myArrivalLane;
246 
248  double myArrivalPos;
249 
252 
255 
258 
261 
264 
266  static std::set<const MSDevice_Tripinfo*, ComparatorNumericalIdLess> myPendingOutput;
267 
269  static long myVehicleCount;
271  static double myTotalRouteLength;
272  static double myTotalSpeed;
278 
280  static long myBikeCount;
281  static double myTotalBikeRouteLength;
282  static double myTotalBikeSpeed;
286 
287  static long myWalkCount;
288  static double myTotalWalkRouteLength;
291 
292  static std::vector<int> myRideCount;
293  static std::vector<int> myRideBusCount;
294  static std::vector<int> myRideRailCount;
295  static std::vector<int> myRideTaxiCount;
296  static std::vector<int> myRideBikeCount;
297  static std::vector<int> myRideAbortCount;
298  static std::vector<double> myTotalRideWaitingTime;
299  static std::vector<double> myTotalRideRouteLength;
300  static std::vector<SUMOTime> myTotalRideDuration;
301 
302 private:
305 
308 
309 
310 };
long long int SUMOTime
Definition: SUMOTime.h:32
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
static long myVehicleCount
global tripinfo statistics
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 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 long myUndepartedVehicleCount
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.
MSDevice_Tripinfo(const MSDevice_Tripinfo &)
Invalidated copy constructor.
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
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
MSDevice_Tripinfo & operator=(const MSDevice_Tripinfo &)
Invalidated assignment operator.
static double myTotalBikeSpeed
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
static double getAvgBikeWaitingTime()
double myArrivalPosLat
The lateral position on the lane the vehicle arrived at.
static long myBikeCount
separate values for bicycles
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.
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
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
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