SUMO - Simulation of Urban MObility
MSDevice_Vehroutes.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-2015 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_Vehroutes_h
23 #define MSDevice_Vehroutes_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 <microsim/MSNet.h>
37 #include <utils/common/SUMOTime.h>
38 
39 
40 // ===========================================================================
41 // class declarations
42 // ===========================================================================
43 class MSEdge;
44 class MSRoute;
45 
46 
47 // ===========================================================================
48 // class definitions
49 // ===========================================================================
58 class MSDevice_Vehroutes : public MSDevice {
59 public:
62  static void init();
63 
64 
75  static MSDevice_Vehroutes* buildVehicleDevices(SUMOVehicle& v, std::vector<MSDevice*>& into, unsigned int maxRoutes = INT_MAX);
76 
77 
79  static void generateOutputForUnfinished();
80 
81 
82 
83 public:
86 
87 
88 
91 
101 
102 
114  bool notifyLeave(SUMOVehicle& veh, SUMOReal lastPos, Notification reason);
116 
117 
124  void generateOutput() const;
125 
126 
132  const MSRoute* getRoute(int index) const;
133 
134 
135 
136 private:
142  MSDevice_Vehroutes(SUMOVehicle& holder, const std::string& id, unsigned int maxRoutes);
143 
144 
150  void writeXMLRoute(OutputDevice& os, int index = -1) const;
151 
152 
155  void addRoute();
156 
157 
158 
159 private:
161  static bool mySaveExits;
162 
164  static bool myLastRouteOnly;
165 
167  static bool myDUAStyle;
168 
170  static bool mySorted;
171 
173  static bool myIntendedDepart;
174 
176  static bool myRouteLength;
177 
178 
183  public:
186 
191  void vehicleStateChanged(const SUMOVehicle* const vehicle, MSNet::VehicleState to);
192 
194  std::map<const SUMOVehicle*, MSDevice_Vehroutes*, Named::NamedLikeComparatorIdLess<SUMOVehicle> > myDevices;
195 
196  };
197 
198 
201 
203  static std::map<const SUMOTime, int> myDepartureCounts;
204 
206  static std::map<const SUMOTime, std::map<const std::string, std::string> > myRouteInfos;
207 
208 
219  public:
225  RouteReplaceInfo(const MSEdge* const edge_, const SUMOTime time_, const MSRoute* const route_)
226  : edge(edge_), time(time_), route(route_) {}
227 
230 
232  const MSEdge* edge;
233 
236 
238  const MSRoute* route;
239 
240  };
241 
244 
247 
249  std::vector<RouteReplaceInfo> myReplacedRoutes;
250 
252  std::vector<SUMOTime> myExits;
253 
255  const unsigned int myMaxRoutes;
256 
259 
260 
261 private:
264 
267 
268 
269 };
270 
271 
272 #endif
273 
274 /****************************************************************************/
275 
static std::map< const SUMOTime, int > myDepartureCounts
Map needed to sort vehicles by departure time.
long long int SUMOTime
Definition: SUMOTime.h:43
Interface for objects listening to vehicle state changes.
Definition: MSNet.h:553
const MSRoute * myCurrentRoute
The currently used route.
MSDevice_Vehroutes(SUMOVehicle &holder, const std::string &id, unsigned int maxRoutes)
Constructor.
static StateListener myStateListener
A class that is notified about reroutings.
void vehicleStateChanged(const SUMOVehicle *const vehicle, MSNet::VehicleState to)
Called if a vehicle changes its state.
static bool myDUAStyle
A shortcut for the Option "vehroute-output.dua".
Notification
Definition of a vehicle state.
RouteReplaceInfo(const MSEdge *const edge_, const SUMOTime time_, const MSRoute *const route_)
Constructor.
std::vector< SUMOTime > myExits
The times the vehicle exites an edge.
static bool mySorted
A shortcut for the Option "vehroute-output.sorted".
static bool mySaveExits
A shortcut for the Option "vehroute-output.exit-times".
bool notifyLeave(SUMOVehicle &veh, SUMOReal lastPos, Notification reason)
Saves exit times if needed.
static bool myIntendedDepart
A shortcut for the Option "vehroute-output.intended-depart".
static void init()
Static intialization.
A road/street connecting two junctions.
Definition: MSEdge.h:81
SUMOReal myDepartPos
The position on the lane the vehicle departed at.
MSDevice_Vehroutes & operator=(const MSDevice_Vehroutes &)
Invalidated assignment operator.
static bool myLastRouteOnly
A shortcut for the Option "vehroute-output.last-route".
void addRoute()
Called on route change.
Representation of a vehicle.
Definition: SUMOVehicle.h:65
const MSRoute * route
The prior route.
std::vector< RouteReplaceInfo > myReplacedRoutes
Prior routes.
A class that is notified about reroutings.
const unsigned int myMaxRoutes
The maximum number of routes to report.
static void generateOutputForUnfinished()
generate vehroute output for vehicles which are still in the network
static bool myRouteLength
A shortcut for the Option "vehroute-output.route-length".
VehicleState
Definition of a vehicle state.
Definition: MSNet.h:526
Abstract in-vehicle device.
Definition: MSDevice.h:69
const MSEdge * edge
The edge the vehicle was on when the route was replaced.
static MSDevice_Vehroutes * buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice * > &into, unsigned int maxRoutes=INT_MAX)
Build devices for the given vehicle, if needed.
void writeXMLRoute(OutputDevice &os, int index=-1) const
Called on route output.
A device which collects info on the vehicle trip (mainly on departure and arrival) ...
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
#define SUMOReal
Definition: config.h:214
SUMOTime time
The time the route was replaced.
static std::map< const SUMOTime, std::map< const std::string, std::string > > myRouteInfos
std::map< const SUMOVehicle *, MSDevice_Vehroutes *, Named::NamedLikeComparatorIdLess< SUMOVehicle > > myDevices
A map for internal notification.
void generateOutput() const
Called on writing tripinfo output.
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason)
Does nothing, returns true only if exit times should be collected.
const MSRoute * getRoute(int index) const
Called on route retrieval.
const MSEdge * myLastSavedAt
The last edge the exit time was saved for.
~MSDevice_Vehroutes()
Destructor.
Information about a replaced route.