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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // A device which collects info on the vehicle trip
18 /****************************************************************************/
19 #ifndef MSDevice_Tripinfo_h
20 #define MSDevice_Tripinfo_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include "MSVehicleDevice.h"
29 #include <utils/common/SUMOTime.h>
30 
31 // ===========================================================================
32 // class declarations
33 // ===========================================================================
34 class SUMOVehicle;
35 class SUMOTrafficObject;
36 
37 // ===========================================================================
38 // class definitions
39 // ===========================================================================
49 public:
60  static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
61 
63  static void generateOutputForUnfinished();
64 
66  static void addPedestrianData(double walkLength, SUMOTime walkDuration, SUMOTime walkTimeLoss);
67 
69  static void addRideData(double rideLength, SUMOTime rideDuration, SUMOVehicleClass vClass, const std::string& line, SUMOTime waitingTime);
70 
72  static std::string printStatistics();
73 
75  static double getAvgRouteLength();
76  static double getAvgDuration();
77  static double getAvgWaitingTime();
78  static double getAvgTimeLoss();
79  static double getAvgDepartDelay();
80 
81  static double getAvgWalkRouteLength();
82  static double getAvgWalkDuration();
83  static double getAvgWalkTimeLoss();
84 
85  static double getAvgRideRouteLength();
86  static double getAvgRideWaitingTime();
87  static double getAvgRideDuration();
88 
89 public:
92 
93 
95  static void cleanup();
96 
97 
100 
109  bool notifyMove(SUMOTrafficObject& veh, double oldPos, double newPos, double newSpeed);
110 
111 
120  bool notifyEnter(SUMOTrafficObject& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
121 
122 
131  bool notifyLeave(SUMOTrafficObject& veh, double lastPos, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
133 
134 
136  const std::string deviceName() const {
137  return "tripinfo";
138  }
139 
146  void generateOutput() const;
147 
152  void saveState(OutputDevice& out) const;
153 
158  void loadState(const SUMOSAXAttributes& attrs);
159 
160 
161 private:
167  MSDevice_Tripinfo(SUMOVehicle& holder, const std::string& id);
168 
169 
170 protected:
174  void notifyMoveInternal(const SUMOTrafficObject& veh,
175  const double frontOnLane,
176  const double timeOnLane,
177  const double meanSpeedFrontOnLane,
178  const double meanSpeedVehicleOnLane,
179  const double travelledDistanceFrontOnLane,
180  const double travelledDistanceVehicleOnLane,
181  const double /* meanLengthOnLane */);
182 
183 private:
185  std::string myDepartLane;
186 
189 
192 
195 
198 
201 
204 
207 
210 
212  std::string myArrivalLane;
213 
215  double myArrivalPos;
216 
219 
222 
225 
228 
230  static std::set<const MSDevice_Tripinfo*, ComparatorNumericalIdLess> myPendingOutput;
231 
233  static double myVehicleCount;
234  static double myTotalRouteLength;
240 
241  static int myWalkCount;
242  static double myTotalWalkRouteLength;
245 
246  static int myRideCount;
247  static int myRideBusCount;
248  static int myRideRailCount;
249  static int myRideBikeCount;
250  static int myRideAbortCount;
251  static double myTotalRideWaitingTime;
252  static double myTotalRideRouteLength;
254 
255 private:
258 
261 
262 
263 };
264 
265 
266 #endif
267 
268 /****************************************************************************/
269 
MSDevice_Tripinfo::myTotalDepartDelay
static SUMOTime myTotalDepartDelay
Definition: MSDevice_Tripinfo.h:238
MSDevice_Tripinfo::getAvgRideDuration
static double getAvgRideDuration()
Definition: MSDevice_Tripinfo.cpp:459
MSDevice_Tripinfo::cleanup
static void cleanup()
resets counters
Definition: MSDevice_Tripinfo.cpp:113
SUMOTrafficObject
Representation of a vehicle or person.
Definition: SUMOTrafficObject.h:48
SUMOVehicleClass
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
Definition: SUMOVehicleClass.h:134
MSDevice_Tripinfo::myStoppingTime
SUMOTime myStoppingTime
The overall intentional stopping time.
Definition: MSDevice_Tripinfo.h:203
MSDevice_Tripinfo::getAvgWaitingTime
static double getAvgWaitingTime()
Definition: MSDevice_Tripinfo.cpp:400
MSDevice_Tripinfo::myWaitingCount
int myWaitingCount
The overall number of unintended stops.
Definition: MSDevice_Tripinfo.h:200
MSDevice_Tripinfo::myArrivalSpeed
double myArrivalSpeed
The speed when arriving.
Definition: MSDevice_Tripinfo.h:221
SUMOTime.h
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
MSDevice_Tripinfo::myRouteLength
double myRouteLength
The route length.
Definition: MSDevice_Tripinfo.h:227
MSDevice_Tripinfo::myWaitingTime
SUMOTime myWaitingTime
The overall waiting time.
Definition: MSDevice_Tripinfo.h:194
MSDevice_Tripinfo::getAvgWalkRouteLength
static double getAvgWalkRouteLength()
Definition: MSDevice_Tripinfo.cpp:430
MSVehicleDevice.h
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
MSDevice_Tripinfo::myDepartSpeed
double myDepartSpeed
The speed on departure.
Definition: MSDevice_Tripinfo.h:188
MSDevice_Tripinfo::myWalkCount
static int myWalkCount
Definition: MSDevice_Tripinfo.h:241
MSDevice_Tripinfo::myDepartPosLat
double myDepartPosLat
The lateral depart position.
Definition: MSDevice_Tripinfo.h:191
MSDevice_Tripinfo::myArrivalPos
double myArrivalPos
The position on the lane the vehicle arrived at.
Definition: MSDevice_Tripinfo.h:215
MSDevice_Tripinfo::myRideRailCount
static int myRideRailCount
Definition: MSDevice_Tripinfo.h:248
MSDevice_Tripinfo::loadState
void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the device from the given description.
Definition: MSDevice_Tripinfo.cpp:503
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
SUMOVehicle
Representation of a vehicle.
Definition: SUMOVehicle.h:61
MSDevice_Tripinfo::myParkingStarted
SUMOTime myParkingStarted
The time when parking started.
Definition: MSDevice_Tripinfo.h:206
MSDevice_Tripinfo::saveState
void saveState(OutputDevice &out) const
Saves the state of the device.
Definition: MSDevice_Tripinfo.cpp:487
MSDevice_Tripinfo::myArrivalTime
SUMOTime myArrivalTime
The vehicle's arrival time.
Definition: MSDevice_Tripinfo.h:209
MSDevice_Tripinfo::myMesoTimeLoss
SUMOTime myMesoTimeLoss
The time loss when compared to the desired and allowed speed.
Definition: MSDevice_Tripinfo.h:224
MSDevice_Tripinfo::myTotalRideDuration
static SUMOTime myTotalRideDuration
Definition: MSDevice_Tripinfo.h:253
MSDevice_Tripinfo::addPedestrianData
static void addPedestrianData(double walkLength, SUMOTime walkDuration, SUMOTime walkTimeLoss)
record tripinfo data for pedestrians
Definition: MSDevice_Tripinfo.cpp:316
MSDevice_Tripinfo::getAvgRideRouteLength
static double getAvgRideRouteLength()
Definition: MSDevice_Tripinfo.cpp:477
MSDevice_Tripinfo::getAvgWalkDuration
static double getAvgWalkDuration()
Definition: MSDevice_Tripinfo.cpp:439
MSDevice_Tripinfo
A device which collects info on the vehicle trip (mainly on departure and arrival)
Definition: MSDevice_Tripinfo.h:48
MSDevice_Tripinfo::myTotalRouteLength
static double myTotalRouteLength
Definition: MSDevice_Tripinfo.h:234
MSDevice_Tripinfo::notifyEnter
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves departure info on insertion.
Definition: MSDevice_Tripinfo.cpp:178
MSDevice_Tripinfo::getAvgTimeLoss
static double getAvgTimeLoss()
Definition: MSDevice_Tripinfo.cpp:410
MSDevice_Tripinfo::notifyLeave
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves arrival info.
Definition: MSDevice_Tripinfo.cpp:196
MSDevice_Tripinfo::myArrivalLane
std::string myArrivalLane
The lane the vehicle arrived at.
Definition: MSDevice_Tripinfo.h:212
MSDevice_Tripinfo::buildVehicleDevices
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
Definition: MSDevice_Tripinfo.cpp:75
MSDevice_Tripinfo::myTotalRideRouteLength
static double myTotalRideRouteLength
Definition: MSDevice_Tripinfo.h:252
MSDevice_Tripinfo::deviceName
const std::string deviceName() const
return the name for this type of device
Definition: MSDevice_Tripinfo.h:136
MSDevice_Tripinfo::getAvgRouteLength
static double getAvgRouteLength()
accessors for GUINet-Parameters
Definition: MSDevice_Tripinfo.cpp:382
MSDevice_Tripinfo::myRideAbortCount
static int myRideAbortCount
Definition: MSDevice_Tripinfo.h:250
MSDevice_Tripinfo::notifyMove
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks for waiting steps when the vehicle moves.
Definition: MSDevice_Tripinfo.cpp:138
MSDevice_Tripinfo::myTotalTimeLoss
static SUMOTime myTotalTimeLoss
Definition: MSDevice_Tripinfo.h:237
MSDevice_Tripinfo::myVehicleCount
static double myVehicleCount
global tripinfo statistics
Definition: MSDevice_Tripinfo.h:233
MSDevice_Tripinfo::notifyMoveInternal
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()
Definition: MSDevice_Tripinfo.cpp:156
MSDevice_Tripinfo::myPendingOutput
static std::set< const MSDevice_Tripinfo *, ComparatorNumericalIdLess > myPendingOutput
devices which may still need to produce output
Definition: MSDevice_Tripinfo.h:230
MSDevice_Tripinfo::getAvgDepartDelay
static double getAvgDepartDelay()
Definition: MSDevice_Tripinfo.cpp:420
MSDevice_Tripinfo::myRideBusCount
static int myRideBusCount
Definition: MSDevice_Tripinfo.h:247
MSDevice_Tripinfo::generateOutput
void generateOutput() const
Called on writing tripinfo output.
Definition: MSDevice_Tripinfo.cpp:227
MSDevice_Tripinfo::operator=
MSDevice_Tripinfo & operator=(const MSDevice_Tripinfo &)
Invalidated assignment operator.
MSDevice_Tripinfo::myRideBikeCount
static int myRideBikeCount
Definition: MSDevice_Tripinfo.h:249
MSDevice_Tripinfo::generateOutputForUnfinished
static void generateOutputForUnfinished()
generate output for vehicles which are still in the network
Definition: MSDevice_Tripinfo.cpp:277
MSDevice_Tripinfo::getAvgRideWaitingTime
static double getAvgRideWaitingTime()
Definition: MSDevice_Tripinfo.cpp:468
MSDevice_Tripinfo::myAmWaiting
bool myAmWaiting
Whether the vehicle is currently waiting.
Definition: MSDevice_Tripinfo.h:197
MSDevice_Tripinfo::printStatistics
static std::string printStatistics()
get statistics for printing to stdout
Definition: MSDevice_Tripinfo.cpp:348
MSDevice_Tripinfo::myTotalWalkDuration
static SUMOTime myTotalWalkDuration
Definition: MSDevice_Tripinfo.h:243
MSDevice_Tripinfo::getAvgWalkTimeLoss
static double getAvgWalkTimeLoss()
Definition: MSDevice_Tripinfo.cpp:449
MSDevice_Tripinfo::myTotalWalkTimeLoss
static SUMOTime myTotalWalkTimeLoss
Definition: MSDevice_Tripinfo.h:244
MSDevice_Tripinfo::myTotalDuration
static SUMOTime myTotalDuration
Definition: MSDevice_Tripinfo.h:235
MSDevice_Tripinfo::myTotalWaitingTime
static SUMOTime myTotalWaitingTime
Definition: MSDevice_Tripinfo.h:236
config.h
MSDevice_Tripinfo::myTotalRideWaitingTime
static double myTotalRideWaitingTime
Definition: MSDevice_Tripinfo.h:251
MSDevice_Tripinfo::MSDevice_Tripinfo
MSDevice_Tripinfo(SUMOVehicle &holder, const std::string &id)
Constructor.
Definition: MSDevice_Tripinfo.cpp:87
MSDevice_Tripinfo::~MSDevice_Tripinfo
~MSDevice_Tripinfo()
Destructor.
Definition: MSDevice_Tripinfo.cpp:107
MSDevice_Tripinfo::myDepartLane
std::string myDepartLane
The lane the vehicle departed at.
Definition: MSDevice_Tripinfo.h:185
SUMOSAXAttributes
Encapsulated SAX-Attributes.
Definition: SUMOSAXAttributes.h:57
MSMoveReminder::Notification
Notification
Definition of a vehicle state.
Definition: MSMoveReminder.h:89
MSDevice_Tripinfo::addRideData
static void addRideData(double rideLength, SUMOTime rideDuration, SUMOVehicleClass vClass, const std::string &line, SUMOTime waitingTime)
record tripinfo data for rides
Definition: MSDevice_Tripinfo.cpp:325
MSDevice_Tripinfo::myArrivalPosLat
double myArrivalPosLat
The lateral position on the lane the vehicle arrived at.
Definition: MSDevice_Tripinfo.h:218
MSDevice_Tripinfo::myWaitingDepartDelay
static SUMOTime myWaitingDepartDelay
Definition: MSDevice_Tripinfo.h:239
MSDevice_Tripinfo::myRideCount
static int myRideCount
Definition: MSDevice_Tripinfo.h:246
MSDevice_Tripinfo::myTotalWalkRouteLength
static double myTotalWalkRouteLength
Definition: MSDevice_Tripinfo.h:242
MSDevice_Tripinfo::getAvgDuration
static double getAvgDuration()
Definition: MSDevice_Tripinfo.cpp:391
MSVehicleDevice
Abstract in-vehicle device.
Definition: MSVehicleDevice.h:55