SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSDevice_Vehroutes.h
Go to the documentation of this file.
1 /****************************************************************************/
8 // A device which collects info on the vehicle trip
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
11 // Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 #ifndef MSDevice_Vehroutes_h
22 #define MSDevice_Vehroutes_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include "MSDevice.h"
35 #include <microsim/MSNet.h>
36 #include <utils/common/SUMOTime.h>
37 
38 
39 // ===========================================================================
40 // class declarations
41 // ===========================================================================
42 class MSEdge;
43 class MSRoute;
44 
45 
46 // ===========================================================================
47 // class definitions
48 // ===========================================================================
57 class MSDevice_Vehroutes : public MSDevice {
58 public:
61  static void init();
62 
63 
74  static MSDevice_Vehroutes* buildVehicleDevices(SUMOVehicle& v, std::vector<MSDevice*>& into, unsigned int maxRoutes = INT_MAX);
75 
76 
78  static void generateOutputForUnfinished();
79 
80 
81 
82 public:
85 
86 
87 
90 
100 
101 
113  bool notifyLeave(SUMOVehicle& veh, SUMOReal lastPos, Notification reason);
115 
116 
123  void generateOutput() const;
124 
125 
131  const MSRoute* getRoute(int index) const;
132 
133 
134 
135 private:
141  MSDevice_Vehroutes(SUMOVehicle& holder, const std::string& id, unsigned int maxRoutes);
142 
143 
149  void writeXMLRoute(OutputDevice& os, int index = -1) const;
150 
151 
154  void addRoute();
155 
156 
157 
158 private:
160  static bool mySaveExits;
161 
163  static bool myLastRouteOnly;
164 
166  static bool mySorted;
167 
169  static bool myWithTaz;
170 
171 
176  public:
179 
184  void vehicleStateChanged(const SUMOVehicle* const vehicle, MSNet::VehicleState to);
185 
187  std::map<const SUMOVehicle*, MSDevice_Vehroutes*, Named::NamedLikeComparatorIdLess<SUMOVehicle> > myDevices;
188 
189  };
190 
191 
194 
196  static std::map<const SUMOTime, int> myDepartureCounts;
197 
199  static std::map<const SUMOTime, std::string> myRouteInfos;
200 
201 
212  public:
218  RouteReplaceInfo(const MSEdge* const edge_, const SUMOTime time_, const MSRoute* const route_)
219  : edge(edge_), time(time_), route(route_) {}
220 
223 
225  const MSEdge* edge;
226 
229 
231  const MSRoute* route;
232 
233  };
234 
237 
239  std::vector<RouteReplaceInfo> myReplacedRoutes;
240 
242  std::vector<SUMOTime> myExits;
243 
245  const unsigned int myMaxRoutes;
246 
249 
250 
251 private:
254 
257 
258 
259 };
260 
261 
262 #endif
263 
264 /****************************************************************************/
265 
static std::map< const SUMOTime, int > myDepartureCounts
Map needed to sort vehicles by departure time.
static bool myWithTaz
A shortcut for the Option "device.routing.with-taz".
Interface for objects listening to vehicle state changes.
Definition: MSNet.h:444
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.
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 void init()
Static intialization.
A road/street connecting two junctions.
Definition: MSEdge.h:73
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:63
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
VehicleState
Definition of a vehicle state.
Definition: MSNet.h:417
Abstract in-vehicle device.
Definition: MSDevice.h:68
static std::map< const SUMOTime, std::string > myRouteInfos
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:70
#define SUMOReal
Definition: config.h:215
SUMOTime time
The time the route was replaced.
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.