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-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:
162  void notifyMoveInternal(SUMOVehicle& veh, SUMOReal timeOnLane,
163  SUMOReal speed);
164 
165 private:
167  std::string myDepartLane;
168 
171 
174 
177 
179  std::string myArrivalLane;
180 
183 
186 
189 
191  typedef std::set<const MSDevice_Tripinfo*, Named::NamedLikeComparatorIdLess<MSDevice_Tripinfo> > DeviceSet;
192 
193  static DeviceSet myPendingOutput;
194 
202 
203 private:
206 
209 
210 
211 };
212 
213 
214 #endif
215 
216 /****************************************************************************/
217 
SUMOTime myArrivalTime
The vehicle&#39;s arrival time.
long long int SUMOTime
Definition: SUMOTime.h:43
static SUMOTime myTotalWaitingTime
static SUMOReal getAvgDepartDelay()
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.
void notifyMoveInternal(SUMOVehicle &veh, SUMOReal timeOnLane, SUMOReal speed)
Internal notification about the vehicle moves.
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.
static DeviceSet myPendingOutput
void updateStatistics() const
update tripinfo statistics
static SUMOReal getAvgRouteLength()
accessors for GUINet-Parameters
int myWaitingSteps
The overall number of waiting steps.
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
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:213
std::set< const MSDevice_Tripinfo *, Named::NamedLikeComparatorIdLess< MSDevice_Tripinfo > > DeviceSet
devices which may still need to produce output
static SUMOTime myTotalTimeLoss