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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // A device which collects info on the vehicle trip
20 /****************************************************************************/
21 #ifndef MSDevice_Tripinfo_h
22 #define MSDevice_Tripinfo_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include "MSDevice.h"
35 #include <utils/common/SUMOTime.h>
36 
37 // ===========================================================================
38 // class declarations
39 // ===========================================================================
40 class SUMOVehicle;
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
53 class MSDevice_Tripinfo : public MSDevice {
54 public:
65  static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSDevice*>& into);
66 
68  void updateStatistics(SUMOTime timeLoss) const;
69 
71  static void generateOutputForUnfinished();
72 
74  static void addPedestrianData(double walkLength, SUMOTime walkDuration, SUMOTime walkTimeLoss);
75 
77  static void addRideData(double rideLength, SUMOTime rideDuration, SUMOVehicleClass vClass, const std::string& line, SUMOTime waitingTime);
78 
80  static std::string printStatistics();
81 
83  static double getAvgRouteLength();
84  static double getAvgDuration();
85  static double getAvgWaitingTime();
86  static double getAvgTimeLoss();
87  static double getAvgDepartDelay();
88 
89  static double getAvgWalkRouteLength();
90  static double getAvgWalkDuration();
91  static double getAvgWalkTimeLoss();
92 
93  static double getAvgRideRouteLength();
94  static double getAvgRideWaitingTime();
95  static double getAvgRideDuration();
96 
97 public:
100 
101 
103  static void cleanup();
104 
105 
108 
117  bool notifyMove(SUMOVehicle& veh, double oldPos, double newPos, double newSpeed);
118 
119 
128  bool notifyEnter(SUMOVehicle& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
129 
130 
139  bool notifyLeave(SUMOVehicle& veh, double lastPos, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
141 
142 
144  const std::string deviceName() const {
145  return "tripinfo";
146  }
147 
154  void generateOutput() const;
155 
160  void saveState(OutputDevice& out) const;
161 
166  void loadState(const SUMOSAXAttributes& attrs);
167 
168 
169 private:
175  MSDevice_Tripinfo(SUMOVehicle& holder, const std::string& id);
176 
177 
180 
181 
182  /* @brief compute trip length and duration (depending on whether the
183  vehicle arrived or not */
184  void computeLengthAndDuration(double& routeLength, SUMOTime& duration) const;
185 
186 protected:
190  void notifyMoveInternal(const SUMOVehicle& veh,
191  const double frontOnLane,
192  const double timeOnLane,
193  const double meanSpeedFrontOnLane,
194  const double meanSpeedVehicleOnLane,
195  const double travelledDistanceFrontOnLane,
196  const double travelledDistanceVehicleOnLane,
197  const double /* meanLengthOnLane */);
198 
199 private:
201  std::string myDepartLane;
202 
205 
208 
211 
214 
216  std::string myArrivalLane;
217 
219  double myArrivalPos;
220 
223 
226 
229 
231  typedef std::set<const MSDevice_Tripinfo*, ComparatorIdLess > DeviceSet;
232 
233  static DeviceSet myPendingOutput;
234 
236  static double myVehicleCount;
237  static double myTotalRouteLength;
242 
243  static int myWalkCount;
244  static double myTotalWalkRouteLength;
247 
248  static int myRideCount;
249  static int myRideBusCount;
250  static int myRideRailCount;
251  static int myRideBikeCount;
252  static int myRideAbortCount;
253  static double myTotalRideWaitingTime;
254  static double myTotalRideRouteLength;
256 
257 private:
260 
263 
264 
265 };
266 
267 
268 #endif
269 
270 /****************************************************************************/
271 
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
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()
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice *> &into)
Build devices for the given vehicle, if needed.
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
MSDevice_Tripinfo & operator=(const MSDevice_Tripinfo &)
Invalidated assignment operator.
static double getAvgRideWaitingTime()
std::set< const MSDevice_Tripinfo *, ComparatorIdLess > DeviceSet
devices which may still need to produce output
double myArrivalSpeed
The speed when arriving.
static double getAvgDuration()
SUMOTime myWaitingTime
The overall waiting time.
static DeviceSet myPendingOutput
static double getAvgWalkTimeLoss()
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:66
static double getAvgWalkRouteLength()
Encapsulated SAX-Attributes.
static SUMOTime myTotalDuration
static double myTotalRideWaitingTime
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()
Abstract in-vehicle device.
Definition: MSDevice.h:70
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
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:70
static int myRideRailCount
long long int SUMOTime
Definition: TraCIDefs.h:51
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:77
double myArrivalPos
The position on the lane the vehicle arrived at.
void saveState(OutputDevice &out) const
Saves the state of the device.