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 /****************************************************************************/
16 // A device which collects info on the vehicle trip
17 /****************************************************************************/
18 #ifndef MSDevice_Tripinfo_h
19 #define MSDevice_Tripinfo_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include "MSVehicleDevice.h"
28 #include <utils/common/SUMOTime.h>
29 
30 // ===========================================================================
31 // class declarations
32 // ===========================================================================
33 class SUMOVehicle;
34 class SUMOTrafficObject;
35 
36 // ===========================================================================
37 // class definitions
38 // ===========================================================================
48 public:
52  static void insertOptions(OptionsCont& oc);
53 
64  static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
65 
67  static void generateOutputForUnfinished();
68 
70  static void addPedestrianData(double walkLength, SUMOTime walkDuration, SUMOTime walkTimeLoss);
71 
73  static void addRideData(double rideLength, SUMOTime rideDuration, SUMOVehicleClass vClass, const std::string& line, SUMOTime waitingTime);
74 
76  static std::string printStatistics();
77 
79  static double getAvgRouteLength();
80  static double getAvgDuration();
81  static double getAvgWaitingTime();
82  static double getAvgTimeLoss();
83  static double getAvgDepartDelay();
84 
85  static double getAvgWalkRouteLength();
86  static double getAvgWalkDuration();
87  static double getAvgWalkTimeLoss();
88 
89  static double getAvgRideRouteLength();
90  static double getAvgRideWaitingTime();
91  static double getAvgRideDuration();
92 
93 public:
96 
97 
99  static void cleanup();
100 
101 
104 
113  bool notifyMove(SUMOTrafficObject& veh, double oldPos, double newPos, double newSpeed);
114 
115 
124  bool notifyEnter(SUMOTrafficObject& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
125 
126 
135  bool notifyLeave(SUMOTrafficObject& veh, double lastPos, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
137 
138 
140  const std::string deviceName() const {
141  return "tripinfo";
142  }
143 
150  void generateOutput() const;
151 
156  void saveState(OutputDevice& out) const;
157 
162  void loadState(const SUMOSAXAttributes& attrs);
163 
164 
165 private:
171  MSDevice_Tripinfo(SUMOVehicle& holder, const std::string& id);
172 
173 
174 protected:
178  void notifyMoveInternal(const SUMOTrafficObject& veh,
179  const double frontOnLane,
180  const double timeOnLane,
181  const double meanSpeedFrontOnLane,
182  const double meanSpeedVehicleOnLane,
183  const double travelledDistanceFrontOnLane,
184  const double travelledDistanceVehicleOnLane,
185  const double /* meanLengthOnLane */);
186 
187 private:
189  std::string myDepartLane;
190 
193 
196 
199 
202 
205 
208 
211 
214 
216  std::string myArrivalLane;
217 
219  double myArrivalPos;
220 
223 
226 
229 
232 
234  static std::set<const MSDevice_Tripinfo*, ComparatorNumericalIdLess> myPendingOutput;
235 
237  static double myVehicleCount;
238  static double myTotalRouteLength;
244 
245  static int myWalkCount;
246  static double myTotalWalkRouteLength;
249 
250  static int myRideCount;
251  static int myRideBusCount;
252  static int myRideRailCount;
253  static int myRideBikeCount;
254  static int myRideAbortCount;
255  static double myTotalRideWaitingTime;
256  static double myTotalRideRouteLength;
258 
259 private:
262 
265 
266 
267 };
268 
269 
270 #endif
271 
272 /****************************************************************************/
273 
MSDevice_Tripinfo::myTotalDepartDelay
static SUMOTime myTotalDepartDelay
Definition: MSDevice_Tripinfo.h:242
MSDevice_Tripinfo::getAvgRideDuration
static double getAvgRideDuration()
Definition: MSDevice_Tripinfo.cpp:467
MSDevice_Tripinfo::cleanup
static void cleanup()
resets counters
Definition: MSDevice_Tripinfo.cpp:121
SUMOTrafficObject
Representation of a vehicle or person.
Definition: SUMOTrafficObject.h:47
SUMOVehicleClass
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
Definition: SUMOVehicleClass.h:133
MSDevice_Tripinfo::myStoppingTime
SUMOTime myStoppingTime
The overall intentional stopping time.
Definition: MSDevice_Tripinfo.h:207
MSDevice_Tripinfo::getAvgWaitingTime
static double getAvgWaitingTime()
Definition: MSDevice_Tripinfo.cpp:408
MSDevice_Tripinfo::myWaitingCount
int myWaitingCount
The overall number of unintended stops.
Definition: MSDevice_Tripinfo.h:204
MSDevice_Tripinfo::myArrivalSpeed
double myArrivalSpeed
The speed when arriving.
Definition: MSDevice_Tripinfo.h:225
SUMOTime.h
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
MSDevice_Tripinfo::myRouteLength
double myRouteLength
The route length.
Definition: MSDevice_Tripinfo.h:231
MSDevice_Tripinfo::myWaitingTime
SUMOTime myWaitingTime
The overall waiting time.
Definition: MSDevice_Tripinfo.h:198
MSDevice_Tripinfo::getAvgWalkRouteLength
static double getAvgWalkRouteLength()
Definition: MSDevice_Tripinfo.cpp:438
MSVehicleDevice.h
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
MSDevice_Tripinfo::myDepartSpeed
double myDepartSpeed
The speed on departure.
Definition: MSDevice_Tripinfo.h:192
MSDevice_Tripinfo::myWalkCount
static int myWalkCount
Definition: MSDevice_Tripinfo.h:245
MSDevice_Tripinfo::myDepartPosLat
double myDepartPosLat
The lateral depart position.
Definition: MSDevice_Tripinfo.h:195
MSDevice_Tripinfo::myArrivalPos
double myArrivalPos
The position on the lane the vehicle arrived at.
Definition: MSDevice_Tripinfo.h:219
MSDevice_Tripinfo::myRideRailCount
static int myRideRailCount
Definition: MSDevice_Tripinfo.h:252
MSDevice_Tripinfo::loadState
void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the device from the given description.
Definition: MSDevice_Tripinfo.cpp:511
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
SUMOVehicle
Representation of a vehicle.
Definition: SUMOVehicle.h:60
MSDevice_Tripinfo::myParkingStarted
SUMOTime myParkingStarted
The time when parking started.
Definition: MSDevice_Tripinfo.h:210
MSDevice_Tripinfo::saveState
void saveState(OutputDevice &out) const
Saves the state of the device.
Definition: MSDevice_Tripinfo.cpp:495
MSDevice_Tripinfo::myArrivalTime
SUMOTime myArrivalTime
The vehicle's arrival time.
Definition: MSDevice_Tripinfo.h:213
MSDevice_Tripinfo::myMesoTimeLoss
SUMOTime myMesoTimeLoss
The time loss when compared to the desired and allowed speed.
Definition: MSDevice_Tripinfo.h:228
MSDevice_Tripinfo::myTotalRideDuration
static SUMOTime myTotalRideDuration
Definition: MSDevice_Tripinfo.h:257
MSDevice_Tripinfo::addPedestrianData
static void addPedestrianData(double walkLength, SUMOTime walkDuration, SUMOTime walkTimeLoss)
record tripinfo data for pedestrians
Definition: MSDevice_Tripinfo.cpp:324
MSDevice_Tripinfo::getAvgRideRouteLength
static double getAvgRideRouteLength()
Definition: MSDevice_Tripinfo.cpp:485
MSDevice_Tripinfo::getAvgWalkDuration
static double getAvgWalkDuration()
Definition: MSDevice_Tripinfo.cpp:447
MSDevice_Tripinfo
A device which collects info on the vehicle trip (mainly on departure and arrival)
Definition: MSDevice_Tripinfo.h:47
MSDevice_Tripinfo::insertOptions
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Tripinfo-options.
Definition: MSDevice_Tripinfo.cpp:74
MSDevice_Tripinfo::myTotalRouteLength
static double myTotalRouteLength
Definition: MSDevice_Tripinfo.h:238
MSDevice_Tripinfo::notifyEnter
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves departure info on insertion.
Definition: MSDevice_Tripinfo.cpp:186
MSDevice_Tripinfo::getAvgTimeLoss
static double getAvgTimeLoss()
Definition: MSDevice_Tripinfo.cpp:418
MSDevice_Tripinfo::notifyLeave
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves arrival info.
Definition: MSDevice_Tripinfo.cpp:204
MSDevice_Tripinfo::myArrivalLane
std::string myArrivalLane
The lane the vehicle arrived at.
Definition: MSDevice_Tripinfo.h:216
MSDevice_Tripinfo::buildVehicleDevices
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
Definition: MSDevice_Tripinfo.cpp:81
MSDevice_Tripinfo::myTotalRideRouteLength
static double myTotalRideRouteLength
Definition: MSDevice_Tripinfo.h:256
MSDevice_Tripinfo::deviceName
const std::string deviceName() const
return the name for this type of device
Definition: MSDevice_Tripinfo.h:140
MSDevice_Tripinfo::getAvgRouteLength
static double getAvgRouteLength()
accessors for GUINet-Parameters
Definition: MSDevice_Tripinfo.cpp:390
MSDevice_Tripinfo::myRideAbortCount
static int myRideAbortCount
Definition: MSDevice_Tripinfo.h:254
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:146
MSDevice_Tripinfo::myTotalTimeLoss
static SUMOTime myTotalTimeLoss
Definition: MSDevice_Tripinfo.h:241
MSDevice_Tripinfo::myVehicleCount
static double myVehicleCount
global tripinfo statistics
Definition: MSDevice_Tripinfo.h:237
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:89
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:164
MSDevice_Tripinfo::myPendingOutput
static std::set< const MSDevice_Tripinfo *, ComparatorNumericalIdLess > myPendingOutput
devices which may still need to produce output
Definition: MSDevice_Tripinfo.h:234
MSDevice_Tripinfo::getAvgDepartDelay
static double getAvgDepartDelay()
Definition: MSDevice_Tripinfo.cpp:428
MSDevice_Tripinfo::myRideBusCount
static int myRideBusCount
Definition: MSDevice_Tripinfo.h:251
MSDevice_Tripinfo::generateOutput
void generateOutput() const
Called on writing tripinfo output.
Definition: MSDevice_Tripinfo.cpp:235
MSDevice_Tripinfo::operator=
MSDevice_Tripinfo & operator=(const MSDevice_Tripinfo &)
Invalidated assignment operator.
MSDevice_Tripinfo::myRideBikeCount
static int myRideBikeCount
Definition: MSDevice_Tripinfo.h:253
MSDevice_Tripinfo::generateOutputForUnfinished
static void generateOutputForUnfinished()
generate output for vehicles which are still in the network
Definition: MSDevice_Tripinfo.cpp:285
MSDevice_Tripinfo::getAvgRideWaitingTime
static double getAvgRideWaitingTime()
Definition: MSDevice_Tripinfo.cpp:476
MSDevice_Tripinfo::myAmWaiting
bool myAmWaiting
Whether the vehicle is currently waiting.
Definition: MSDevice_Tripinfo.h:201
MSDevice_Tripinfo::printStatistics
static std::string printStatistics()
get statistics for printing to stdout
Definition: MSDevice_Tripinfo.cpp:356
MSDevice_Tripinfo::myTotalWalkDuration
static SUMOTime myTotalWalkDuration
Definition: MSDevice_Tripinfo.h:247
MSDevice_Tripinfo::getAvgWalkTimeLoss
static double getAvgWalkTimeLoss()
Definition: MSDevice_Tripinfo.cpp:457
MSDevice_Tripinfo::myTotalWalkTimeLoss
static SUMOTime myTotalWalkTimeLoss
Definition: MSDevice_Tripinfo.h:248
MSDevice_Tripinfo::myTotalDuration
static SUMOTime myTotalDuration
Definition: MSDevice_Tripinfo.h:239
MSDevice_Tripinfo::myTotalWaitingTime
static SUMOTime myTotalWaitingTime
Definition: MSDevice_Tripinfo.h:240
config.h
MSDevice_Tripinfo::myTotalRideWaitingTime
static double myTotalRideWaitingTime
Definition: MSDevice_Tripinfo.h:255
MSDevice_Tripinfo::MSDevice_Tripinfo
MSDevice_Tripinfo(SUMOVehicle &holder, const std::string &id)
Constructor.
Definition: MSDevice_Tripinfo.cpp:95
MSDevice_Tripinfo::~MSDevice_Tripinfo
~MSDevice_Tripinfo()
Destructor.
Definition: MSDevice_Tripinfo.cpp:115
MSDevice_Tripinfo::myDepartLane
std::string myDepartLane
The lane the vehicle departed at.
Definition: MSDevice_Tripinfo.h:189
SUMOSAXAttributes
Encapsulated SAX-Attributes.
Definition: SUMOSAXAttributes.h:56
MSMoveReminder::Notification
Notification
Definition of a vehicle state.
Definition: MSMoveReminder.h:91
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:333
MSDevice_Tripinfo::myArrivalPosLat
double myArrivalPosLat
The lateral position on the lane the vehicle arrived at.
Definition: MSDevice_Tripinfo.h:222
MSDevice_Tripinfo::myWaitingDepartDelay
static SUMOTime myWaitingDepartDelay
Definition: MSDevice_Tripinfo.h:243
MSDevice_Tripinfo::myRideCount
static int myRideCount
Definition: MSDevice_Tripinfo.h:250
MSDevice_Tripinfo::myTotalWalkRouteLength
static double myTotalWalkRouteLength
Definition: MSDevice_Tripinfo.h:246
MSDevice_Tripinfo::getAvgDuration
static double getAvgDuration()
Definition: MSDevice_Tripinfo.cpp:399
MSVehicleDevice
Abstract in-vehicle device.
Definition: MSVehicleDevice.h:54