SUMO - Simulation of Urban MObility
MSDevice_Tripinfo.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // A device which collects info on the vehicle trip
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2009-2017 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef MSDevice_Tripinfo_h
23 #define MSDevice_Tripinfo_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include "MSDevice.h"
36 #include <utils/common/SUMOTime.h>
37 
38 // ===========================================================================
39 // class declarations
40 // ===========================================================================
41 class SUMOVehicle;
42 
43 // ===========================================================================
44 // class definitions
45 // ===========================================================================
54 class MSDevice_Tripinfo : public MSDevice {
55 public:
66  static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSDevice*>& into);
67 
69  void updateStatistics(SUMOTime timeLoss) const;
70 
72  static void generateOutputForUnfinished();
73 
75  static void addPedestrianData(double walkLength, SUMOTime walkDuration);
76 
78  static std::string printStatistics();
79 
81  static double getAvgRouteLength();
82  static double getAvgDuration();
83  static double getAvgWaitingTime();
84  static double getAvgTimeLoss();
85  static double getAvgDepartDelay();
86 
87  static double getAvgWalkRouteLength();
88  static double getAvgWalkDuration();
89 
90 public:
93 
94 
95 
98 
107  bool notifyMove(SUMOVehicle& veh, double oldPos, double newPos, double newSpeed);
108 
109 
118  bool notifyEnter(SUMOVehicle& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
119 
120 
129  bool notifyLeave(SUMOVehicle& veh, double lastPos, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
131 
132 
134  const std::string deviceName() const {
135  return "tripinfo";
136  }
137 
144  void generateOutput() const;
145 
150  void saveState(OutputDevice& out) const;
151 
156  void loadState(const SUMOSAXAttributes& attrs);
157 
158 
159 private:
165  MSDevice_Tripinfo(SUMOVehicle& holder, const std::string& id);
166 
167 
170 
171 
172  /* @brief compute trip length and duration (depending on whether the
173  vehicle arrived or not */
174  void computeLengthAndDuration(double& routeLength, SUMOTime& duration) const;
175 
176 protected:
180  void notifyMoveInternal(const SUMOVehicle& veh,
181  const double frontOnLane,
182  const double timeOnLane,
183  const double meanSpeedFrontOnLane,
184  const double meanSpeedVehicleOnLane,
185  const double travelledDistanceFrontOnLane,
186  const double travelledDistanceVehicleOnLane,
187  const double /* meanLengthOnLane */);
188 
189 private:
191  std::string myDepartLane;
192 
195 
198 
201 
204 
206  std::string myArrivalLane;
207 
209  double myArrivalPos;
210 
213 
216 
219 
221  typedef std::set<const MSDevice_Tripinfo*, Named::NamedLikeComparatorIdLess<MSDevice_Tripinfo> > DeviceSet;
222 
223  static DeviceSet myPendingOutput;
224 
226  static double myVehicleCount;
227  static double myTotalRouteLength;
232 
233  static int myWalkCount;
234  static double myTotalWalkRouteLength;
236 
237 private:
240 
243 
244 
245 };
246 
247 
248 #endif
249 
250 /****************************************************************************/
251 
static SUMOTime myTotalWalkDuration
SUMOTime myArrivalTime
The vehicle&#39;s arrival time.
static SUMOTime myTotalWaitingTime
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves departure info on insertion.
static double myTotalRouteLength
void computeLengthAndDuration(double &routeLength, SUMOTime &duration) const
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.
void generateOutput() const
Called on writing tripinfo output.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice * > &into)
Build devices for the given vehicle, if needed.
~MSDevice_Tripinfo()
Destructor.
static double myVehicleCount
global tripinfo statistics
MSDevice_Tripinfo & operator=(const MSDevice_Tripinfo &)
Invalidated assignment operator.
double myArrivalSpeed
The speed when arriving.
static double getAvgDuration()
SUMOTime myWaitingTime
The overall waiting time.
static DeviceSet myPendingOutput
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:67
void updateStatistics(SUMOTime timeLoss) const
update tripinfo statistics
static double getAvgWalkRouteLength()
Encapsulated SAX-Attributes.
static SUMOTime myTotalDuration
static void addPedestrianData(double walkLength, SUMOTime walkDuration)
record tripinfo data for pedestrians
void saveState(OutputDevice &out) const
Saves the state of the device.
double myArrivalPosLat
The lateral position on the lane the vehicle arrived at.
static double getAvgWalkDuration()
std::string myDepartLane
The lane the vehicle departed at.
Abstract in-vehicle device.
Definition: MSDevice.h:71
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.
double myDepartSpeed
The speed on departure.
MSDevice_Tripinfo()
dummy constructor
const std::string deviceName() const
return the name for this type of device
static SUMOTime myTotalDepartDelay
static double getAvgRouteLength()
accessors for GUINet-Parameters
static double getAvgDepartDelay()
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
long long int SUMOTime
Definition: TraCIDefs.h:52
std::set< const MSDevice_Tripinfo *, Named::NamedLikeComparatorIdLess< MSDevice_Tripinfo > > DeviceSet
devices which may still need to produce 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:79
double myArrivalPos
The position on the lane the vehicle arrived at.