Eclipse 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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
20 // A device which collects info on the vehicle trip
21 /****************************************************************************/
22 #pragma once
23 #include <config.h>
24 
25 #include "MSVehicleDevice.h"
26 #include <utils/common/SUMOTime.h>
27 
28 // ===========================================================================
29 // class declarations
30 // ===========================================================================
31 class SUMOVehicle;
32 class SUMOTrafficObject;
33 
34 // ===========================================================================
35 // class definitions
36 // ===========================================================================
46 public:
50  static void insertOptions(OptionsCont& oc);
51 
62  static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
63 
65  static void generateOutputForUnfinished();
66 
68  static void addPedestrianData(double walkLength, SUMOTime walkDuration, SUMOTime walkTimeLoss);
69 
71  static void addRideTransportData(const bool isPerson, const double distance, const SUMOTime duration,
72  const SUMOVehicleClass vClass, const std::string& line, const SUMOTime waitingTime);
73 
75  static std::string printStatistics();
76 
78  static void writeStatistics(OutputDevice& od);
79 
81  static double getAvgRouteLength();
82  static double getAvgTripSpeed();
83  static double getAvgDuration();
84  static double getAvgWaitingTime();
85  static double getAvgTimeLoss();
86  static double getAvgDepartDelay();
87 
88  static double getAvgWalkRouteLength();
89  static double getAvgWalkDuration();
90  static double getAvgWalkTimeLoss();
91 
92  static double getAvgRideRouteLength();
93  static double getAvgRideWaitingTime();
94  static double getAvgRideDuration();
95 
96 public:
99 
100 
102  static void cleanup();
103 
104 
107 
116  bool notifyMove(SUMOTrafficObject& veh, double oldPos, double newPos, double newSpeed);
117 
125  bool notifyIdle(SUMOTrafficObject& veh);
126 
135  bool notifyEnter(SUMOTrafficObject& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
136 
137 
146  bool notifyLeave(SUMOTrafficObject& veh, double lastPos, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
148 
149 
151  const std::string deviceName() const {
152  return "tripinfo";
153  }
154 
161  void generateOutput(OutputDevice* tripinfoOut) const;
162 
167  void saveState(OutputDevice& out) const;
168 
173  void loadState(const SUMOSAXAttributes& attrs);
174 
175 
176 private:
182  MSDevice_Tripinfo(SUMOVehicle& holder, const std::string& id);
183 
184 
185 protected:
189  void notifyMoveInternal(const SUMOTrafficObject& veh,
190  const double frontOnLane,
191  const double timeOnLane,
192  const double meanSpeedFrontOnLane,
193  const double meanSpeedVehicleOnLane,
194  const double travelledDistanceFrontOnLane,
195  const double travelledDistanceVehicleOnLane,
196  const double /* meanLengthOnLane */);
197 
199  void updateParkingStopTime();
200 
201  static void printRideStatistics(std::ostringstream& msg, const std::string& category, const std::string& modeName, const int index);
202 
203  static void writeRideStatistics(OutputDevice& od, const std::string& category, const int index);
204 
205 private:
207  std::string myDepartLane;
208 
211 
214 
217 
220 
223 
226 
229 
232 
234  std::string myArrivalLane;
235 
237  double myArrivalPos;
238 
241 
244 
247 
250 
253 
255  static std::set<const MSDevice_Tripinfo*, ComparatorNumericalIdLess> myPendingOutput;
256 
258  static double myVehicleCount;
259  static double myTotalRouteLength;
260  static double myTotalSpeed;
266 
267  static int myWalkCount;
268  static double myTotalWalkRouteLength;
271 
272  static std::vector<int> myRideCount;
273  static std::vector<int> myRideBusCount;
274  static std::vector<int> myRideRailCount;
275  static std::vector<int> myRideTaxiCount;
276  static std::vector<int> myRideBikeCount;
277  static std::vector<int> myRideAbortCount;
278  static std::vector<double> myTotalRideWaitingTime;
279  static std::vector<double> myTotalRideRouteLength;
280  static std::vector<SUMOTime> myTotalRideDuration;
281 
282 private:
285 
288 
289 
290 };
long long int SUMOTime
Definition: SUMOTime.h:31
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
A device which collects info on the vehicle trip (mainly on departure and arrival)
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves departure info on insertion.
static SUMOTime myTotalDepartDelay
const std::string deviceName() const
return the name for this type of device
double myDepartSpeed
The speed on departure.
static std::vector< int > myRideAbortCount
static void writeStatistics(OutputDevice &od)
write statistic output to (xml) file
void saveState(OutputDevice &out) const
Saves the state of the device.
SUMOTime myArrivalTime
The vehicle's arrival time.
SUMOTime myWaitingTime
The overall waiting time.
void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the device from the given description.
static std::set< const MSDevice_Tripinfo *, ComparatorNumericalIdLess > myPendingOutput
devices which may still need to produce output
static SUMOTime myTotalWalkTimeLoss
static double getAvgRideWaitingTime()
SUMOTime myParkingStarted
The time when parking started.
static double getAvgWalkRouteLength()
std::string myArrivalLane
The lane the vehicle arrived at.
MSDevice_Tripinfo(SUMOVehicle &holder, const std::string &id)
Constructor.
static double getAvgTimeLoss()
static void printRideStatistics(std::ostringstream &msg, const std::string &category, const std::string &modeName, const int index)
double myArrivalSpeed
The speed when arriving.
static double getAvgRideRouteLength()
~MSDevice_Tripinfo()
Destructor.
MSDevice_Tripinfo(const MSDevice_Tripinfo &)
Invalidated copy constructor.
static SUMOTime myTotalTimeLoss
static double getAvgRideDuration()
static std::vector< int > myRideRailCount
static double getAvgDepartDelay()
static double myTotalSpeed
static double myVehicleCount
global tripinfo statistics
static std::vector< SUMOTime > myTotalRideDuration
static double getAvgTripSpeed()
static double getAvgRouteLength()
accessors for GUINet-Parameters
static std::vector< double > myTotalRideWaitingTime
void updateParkingStopTime()
update stopping time after parking
static SUMOTime myTotalDuration
static SUMOTime myTotalWalkDuration
static std::string printStatistics()
get statistics for printing to stdout
static void generateOutputForUnfinished()
generate output for vehicles which are still in the network
MSDevice_Tripinfo & operator=(const MSDevice_Tripinfo &)
Invalidated assignment operator.
static double getAvgWaitingTime()
static void addPedestrianData(double walkLength, SUMOTime walkDuration, SUMOTime walkTimeLoss)
record tripinfo data for pedestrians
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks for waiting steps when the vehicle moves.
std::string myDepartLane
The lane the vehicle departed at.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
static void writeRideStatistics(OutputDevice &od, const std::string &category, const int index)
double myRouteLength
The route length.
static SUMOTime myTotalWaitingTime
static double myTotalRouteLength
double myArrivalPosLat
The lateral position on the lane the vehicle arrived at.
static double getAvgDuration()
static void cleanup()
resets counters
int myWaitingCount
The overall number of unintended stops.
SUMOTime myStoppingTime
The overall intentional stopping time.
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves arrival info.
void generateOutput(OutputDevice *tripinfoOut) const
Called on writing tripinfo output.
static void addRideTransportData(const bool isPerson, const double distance, const SUMOTime duration, const SUMOVehicleClass vClass, const std::string &line, const SUMOTime waitingTime)
record tripinfo data for rides and transports
static std::vector< int > myRideCount
bool notifyIdle(SUMOTrafficObject &veh)
record idling as waiting time - cf issue 2233
static double getAvgWalkDuration()
SUMOTime myMesoTimeLoss
The time loss when compared to the desired and allowed speed.
static std::vector< int > myRideBusCount
double myDepartPosLat
The lateral depart position.
bool myAmWaiting
Whether the vehicle is currently waiting.
double myArrivalPos
The position on the lane the vehicle arrived at.
void notifyMoveInternal(const SUMOTrafficObject &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::vector< int > myRideTaxiCount
static std::vector< int > myRideBikeCount
MSMoveReminder::Notification myArrivalReason
The reason for vehicle arrival.
static double getAvgWalkTimeLoss()
static double myTotalWalkRouteLength
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Tripinfo-options.
static SUMOTime myWaitingDepartDelay
static std::vector< double > myTotalRideRouteLength
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
Notification
Definition of a vehicle state.
Abstract in-vehicle device.
A storage for options typed value containers)
Definition: OptionsCont.h:89
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:60
Encapsulated SAX-Attributes.
Representation of a vehicle, person, or container.
Representation of a vehicle.
Definition: SUMOVehicle.h:58