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-2018 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 
36 // ===========================================================================
37 // class definitions
38 // ===========================================================================
48 public:
59  static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
60 
62  void updateStatistics(SUMOTime timeLoss) const;
63 
65  static void generateOutputForUnfinished();
66 
68  static void addPedestrianData(double walkLength, SUMOTime walkDuration, SUMOTime walkTimeLoss);
69 
71  static void addRideData(double rideLength, SUMOTime rideDuration, SUMOVehicleClass vClass, const std::string& line, SUMOTime waitingTime);
72 
74  static std::string printStatistics();
75 
77  static double getAvgRouteLength();
78  static double getAvgDuration();
79  static double getAvgWaitingTime();
80  static double getAvgTimeLoss();
81  static double getAvgDepartDelay();
82 
83  static double getAvgWalkRouteLength();
84  static double getAvgWalkDuration();
85  static double getAvgWalkTimeLoss();
86 
87  static double getAvgRideRouteLength();
88  static double getAvgRideWaitingTime();
89  static double getAvgRideDuration();
90 
91 public:
94 
95 
97  static void cleanup();
98 
99 
102 
111  bool notifyMove(SUMOVehicle& veh, double oldPos, double newPos, double newSpeed);
112 
113 
122  bool notifyEnter(SUMOVehicle& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
123 
124 
133  bool notifyLeave(SUMOVehicle& veh, double lastPos, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
135 
136 
138  const std::string deviceName() const {
139  return "tripinfo";
140  }
141 
148  void generateOutput() const;
149 
154  void saveState(OutputDevice& out) const;
155 
160  void loadState(const SUMOSAXAttributes& attrs);
161 
162 
163 private:
169  MSDevice_Tripinfo(SUMOVehicle& holder, const std::string& id);
170 
171 
174 
175 
176  /* @brief compute trip length and duration (depending on whether the
177  vehicle arrived or not */
178  void computeLengthAndDuration(double& routeLength, SUMOTime& duration) const;
179 
180 protected:
184  void notifyMoveInternal(const SUMOVehicle& veh,
185  const double frontOnLane,
186  const double timeOnLane,
187  const double meanSpeedFrontOnLane,
188  const double meanSpeedVehicleOnLane,
189  const double travelledDistanceFrontOnLane,
190  const double travelledDistanceVehicleOnLane,
191  const double /* meanLengthOnLane */);
192 
193 private:
195  std::string myDepartLane;
196 
199 
202 
205 
208 
211 
214 
217 
220 
222  std::string myArrivalLane;
223 
225  double myArrivalPos;
226 
229 
232 
235 
237  static std::set<const MSDevice_Tripinfo*, ComparatorNumericalIdLess> myPendingOutput;
238 
240  static double myVehicleCount;
241  static double myTotalRouteLength;
247 
248  static int myWalkCount;
249  static double myTotalWalkRouteLength;
252 
253  static int myRideCount;
254  static int myRideBusCount;
255  static int myRideRailCount;
256  static int myRideBikeCount;
257  static int myRideAbortCount;
258  static double myTotalRideWaitingTime;
259  static double myTotalRideRouteLength;
261 
262 private:
265 
268 
269 
270 };
271 
272 
273 #endif
274 
275 /****************************************************************************/
276 
static SUMOTime myTotalWalkDuration
static double getAvgRideRouteLength()
static int myRideBikeCount
static SUMOTime myTotalWalkTimeLoss
SUMOTime myArrivalTime
The vehicle&#39;s arrival time.
void computeLengthAndDuration(double &routeLength, SUMOTime &duration) const
long long int SUMOTime
Definition: SUMOTime.h:36
static void addPedestrianData(double walkLength, SUMOTime walkDuration, SUMOTime walkTimeLoss)
record tripinfo data for pedestrians
static SUMOTime myTotalWaitingTime
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves departure info on insertion.
void updateStatistics(SUMOTime timeLoss) const
update tripinfo statistics
static double myTotalRouteLength
bool notifyLeave(SUMOVehicle &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves arrival info.
A device which collects info on the vehicle trip (mainly on departure and arrival) ...
static double getAvgTimeLoss()
Notification
Definition of a vehicle state.
static void addRideData(double rideLength, SUMOTime rideDuration, SUMOVehicleClass vClass, const std::string &line, SUMOTime waitingTime)
record tripinfo data for rides
~MSDevice_Tripinfo()
Destructor.
static double myVehicleCount
global tripinfo statistics
static SUMOTime myWaitingDepartDelay
SUMOTime myStoppingTime
The overall intentional stopping time.
MSDevice_Tripinfo & operator=(const MSDevice_Tripinfo &)
Invalidated assignment operator.
static double getAvgRideWaitingTime()
static std::set< const MSDevice_Tripinfo *, ComparatorNumericalIdLess > myPendingOutput
devices which may still need to produce output
double myArrivalSpeed
The speed when arriving.
static double getAvgDuration()
SUMOTime myWaitingTime
The overall waiting time.
static double getAvgWalkTimeLoss()
int myWaitingCount
The overall number of unintended stops.
static void generateOutputForUnfinished()
generate output for vehicles which are still in the network
void notifyMoveInternal(const SUMOVehicle &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::string printStatistics()
get statistics for printing to stdout
Representation of a vehicle.
Definition: SUMOVehicle.h:60
static double getAvgWalkRouteLength()
Encapsulated SAX-Attributes.
SUMOTime myParkingStarted
The time when parking started.
static SUMOTime myTotalDuration
static double myTotalRideWaitingTime
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice *> &into)
Build devices for the given vehicle, if needed.
double myArrivalPosLat
The lateral position on the lane the vehicle arrived at.
static double getAvgWalkDuration()
std::string myDepartLane
The lane the vehicle departed at.
static void cleanup()
resets counters
static SUMOTime myTotalRideDuration
static double getAvgRideDuration()
static double getAvgWaitingTime()
bool notifyMove(SUMOVehicle &veh, double oldPos, double newPos, double newSpeed)
Checks for waiting steps when the vehicle moves.
static double myTotalWalkRouteLength
std::string myArrivalLane
The lane the vehicle arrived at.
const std::string deviceName() const
return the name for this type of device
double myDepartSpeed
The speed on departure.
MSDevice_Tripinfo()
dummy constructor
static SUMOTime myTotalDepartDelay
Abstract in-vehicle device.
static double getAvgRouteLength()
accessors for GUINet-Parameters
static double myTotalRideRouteLength
static double getAvgDepartDelay()
static int myRideAbortCount
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
static int myRideRailCount
void generateOutput() const
Called on writing tripinfo output.
static SUMOTime myTotalTimeLoss
SUMOTime myMesoTimeLoss
The time loss when compared to the desired and allowed speed.
double myDepartPosLat
The lateral depart position.
void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the device from the given description.
Representation of a lane in the micro simulation.
Definition: MSLane.h:78
double myArrivalPos
The position on the lane the vehicle arrived at.
void saveState(OutputDevice &out) const
Saves the state of the device.
bool myAmWaiting
Whether the vehicle is currently waiting.