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 std::string printStatistics();
76 
78  static double getAvgRouteLength();
79  static double getAvgDuration();
80  static double getAvgWaitingTime();
81  static double getAvgTimeLoss();
82  static double getAvgDepartDelay();
83 
84 public:
87 
88 
89 
92 
101  bool notifyMove(SUMOVehicle& veh, double oldPos, double newPos, double newSpeed);
102 
103 
112  bool notifyEnter(SUMOVehicle& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
113 
114 
123  bool notifyLeave(SUMOVehicle& veh, double lastPos, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
125 
126 
128  const std::string deviceName() const {
129  return "tripinfo";
130  }
131 
138  void generateOutput() const;
139 
144  void saveState(OutputDevice& out) const;
145 
150  void loadState(const SUMOSAXAttributes& attrs);
151 
152 
153 private:
159  MSDevice_Tripinfo(SUMOVehicle& holder, const std::string& id);
160 
161 
164 
165 
166  /* @brief compute trip length and duration (depending on whether the
167  vehicle arrived or not */
168  void computeLengthAndDuration(double& routeLength, SUMOTime& duration) const;
169 
170 protected:
174  void notifyMoveInternal(const SUMOVehicle& veh,
175  const double frontOnLane,
176  const double timeOnLane,
177  const double meanSpeedFrontOnLane,
178  const double meanSpeedVehicleOnLane,
179  const double travelledDistanceFrontOnLane,
180  const double travelledDistanceVehicleOnLane);
181 
182 private:
184  std::string myDepartLane;
185 
188 
191 
194 
197 
199  std::string myArrivalLane;
200 
202  double myArrivalPos;
203 
206 
209 
212 
214  typedef std::set<const MSDevice_Tripinfo*, Named::NamedLikeComparatorIdLess<MSDevice_Tripinfo> > DeviceSet;
215 
216  static DeviceSet myPendingOutput;
217 
219  static double myVehicleCount;
220  static double myTotalRouteLength;
225 
226 private:
229 
232 
233 
234 };
235 
236 
237 #endif
238 
239 /****************************************************************************/
240 
SUMOTime myArrivalTime
The vehicle&#39;s arrival time.
void computeLengthAndDuration(double &routeLength, SUMOTime &duration) const
static SUMOTime myTotalWaitingTime
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.
~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
static std::string printStatistics()
get statistics for printing to stdout
Representation of a vehicle.
Definition: SUMOVehicle.h:67
Encapsulated SAX-Attributes.
static SUMOTime myTotalDuration
double myArrivalPosLat
The lateral position on the lane the vehicle arrived at.
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.
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 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
void generateOutput() const
Called on writing tripinfo output.
void notifyMoveInternal(const SUMOVehicle &veh, const double frontOnLane, const double timeOnLane, const double meanSpeedFrontOnLane, const double meanSpeedVehicleOnLane, const double travelledDistanceFrontOnLane, const double travelledDistanceVehicleOnLane)
Internal notification about the vehicle moves, see MSMoveReminder::notifyMoveInternal() ...
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.
void saveState(OutputDevice &out) const
Saves the state of the device.