SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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-2016 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() const;
70 
72  static void generateOutputForUnfinished();
73 
75  static std::string printStatistics();
76 
78  static SUMOReal getAvgRouteLength();
79  static SUMOReal getAvgDuration();
80  static SUMOReal getAvgWaitingTime();
81  static SUMOReal getAvgTimeLoss();
82  static SUMOReal getAvgDepartDelay();
83 
84 public:
87 
88 
89 
92 
101  bool notifyMove(SUMOVehicle& veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed);
102 
103 
113 
114 
123  bool notifyLeave(SUMOVehicle& veh, SUMOReal lastPos, MSMoveReminder::Notification reason);
125 
126 
127 
134  void generateOutput() const;
135 
136 
137 
138 private:
144  MSDevice_Tripinfo(SUMOVehicle& holder, const std::string& id);
145 
146 
149 
150 
151  /* @brief compute trip length and duration (depending on whether the
152  vehicle arrived or not */
153  void computeLengthAndDuration(SUMOReal& routeLength, SUMOTime& duration) const;
154 
155 protected:
159  void notifyMoveInternal(const SUMOVehicle& veh,
160  const SUMOReal frontOnLane,
161  const SUMOReal timeOnLane,
162  const SUMOReal meanSpeedFrontOnLane,
163  const SUMOReal meanSpeedVehicleOnLane,
164  const SUMOReal travelledDistanceFrontOnLane,
165  const SUMOReal travelledDistanceVehicleOnLane);
166 
167 private:
169  std::string myDepartLane;
170 
173 
176 
179 
182 
184  std::string myArrivalLane;
185 
188 
191 
194 
197 
199  typedef std::set<const MSDevice_Tripinfo*, Named::NamedLikeComparatorIdLess<MSDevice_Tripinfo> > DeviceSet;
200 
201  static DeviceSet myPendingOutput;
202 
210 
211 private:
214 
217 
218 
219 };
220 
221 
222 #endif
223 
224 /****************************************************************************/
225 
SUMOTime myArrivalTime
The vehicle's arrival time.
long long int SUMOTime
Definition: SUMOTime.h:43
static SUMOTime myTotalWaitingTime
static SUMOReal getAvgDepartDelay()
void notifyMoveInternal(const SUMOVehicle &veh, const SUMOReal frontOnLane, const SUMOReal timeOnLane, const SUMOReal meanSpeedFrontOnLane, const SUMOReal meanSpeedVehicleOnLane, const SUMOReal travelledDistanceFrontOnLane, const SUMOReal travelledDistanceVehicleOnLane)
Internal notification about the vehicle moves, see MSMoveReminder::notifyMoveInternal() ...
A device which collects info on the vehicle trip (mainly on departure and arrival) ...
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.
SUMOTime myTimeLoss
The time loss when compared to the desired and allowed speed.
SUMOReal myArrivalPos
The position on the lane the vehicle arrived at.
~MSDevice_Tripinfo()
Destructor.
MSDevice_Tripinfo & operator=(const MSDevice_Tripinfo &)
Invalidated assignment operator.
bool notifyMove(SUMOVehicle &veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed)
Checks for waiting steps when the vehicle moves.
SUMOReal myDepartSpeed
The speed on departure.
SUMOReal myArrivalSpeed
The speed when arriving.
SUMOTime myWaitingTime
The overall waiting time.
SUMOReal myArrivalPosLat
The lateral position on the lane the vehicle arrived at.
static DeviceSet myPendingOutput
void updateStatistics() const
update tripinfo statistics
static SUMOReal getAvgRouteLength()
accessors for GUINet-Parameters
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason)
Saves departure info on insertion.
void computeLengthAndDuration(SUMOReal &routeLength, SUMOTime &duration) const
static SUMOReal getAvgDuration()
static void generateOutputForUnfinished()
generate output for vehicles which are still in the network
SUMOReal myDepartPosLat
The lateral depart position.
static std::string printStatistics()
get statistics for printing to stdout
Representation of a vehicle.
Definition: SUMOVehicle.h:66
static SUMOReal getAvgWaitingTime()
static SUMOTime myTotalDuration
static SUMOReal myTotalRouteLength
static SUMOReal myVehicleCount
global tripinfo statistics
std::string myDepartLane
The lane the vehicle departed at.
Abstract in-vehicle device.
Definition: MSDevice.h:69
std::string myArrivalLane
The lane the vehicle arrived at.
MSDevice_Tripinfo()
dummy constructor
static SUMOTime myTotalDepartDelay
static SUMOReal getAvgTimeLoss()
bool notifyLeave(SUMOVehicle &veh, SUMOReal lastPos, MSMoveReminder::Notification reason)
Saves arrival info.
#define SUMOReal
Definition: config.h:214
std::set< const MSDevice_Tripinfo *, Named::NamedLikeComparatorIdLess< MSDevice_Tripinfo > > DeviceSet
devices which may still need to produce output
static SUMOTime myTotalTimeLoss