SUMO - Simulation of Urban MObility
MSTriggeredRerouter.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // Reroutes vehicles passing an edge
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef MSTriggeredRerouter_h
24 #define MSTriggeredRerouter_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <string>
37 #include <vector>
38 #include <utils/common/Command.h>
40 #include "MSTrigger.h"
43 
44 
45 // ===========================================================================
46 // class declarations
47 // ===========================================================================
48 class MSNet;
49 class MSLane;
50 class MSRoute;
51 class SUMOVehicle;
52 
53 
54 // ===========================================================================
55 // class definitions
56 // ===========================================================================
69  public MSTrigger, public MSMoveReminder,
70  public SUMOSAXHandler {
71 
72  friend class GUIEdge; // dynamic instantiation
73 
74 public:
82  MSTriggeredRerouter(const std::string& id,
83  const MSEdgeVector& edges,
84  SUMOReal prob, const std::string& file, bool off);
85 
86 
88  virtual ~MSTriggeredRerouter();
89 
90 
95  struct RerouteInterval {
97  long id;
105  std::vector<MSLane*> closedLanes;
116  };
117 
133 
136 
145  bool notifyMove(SUMOVehicle& veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed);
146 
155  bool notifyLeave(SUMOVehicle& veh, SUMOReal lastPos, MSMoveReminder::Notification reason);
156 
158  const RerouteInterval* getCurrentReroute(SUMOTime time, SUMOVehicle& veh) const;
159 
161  SUMOTime setPermissions(const SUMOTime currentTime);
162 
164  const RerouteInterval* getCurrentReroute(SUMOTime time) const;
165 
167  void setUserMode(bool val);
168 
171 
173  bool inUserMode() const;
174 
176  SUMOReal getProbability() const;
177 
180 
181  SUMOReal getWeight(SUMOVehicle& veh, const std::string param, const SUMOReal defaultWeight) const;
182 
184 
185 protected:
187 
188 
196  virtual void myStartElement(int element,
197  const SUMOSAXAttributes& attrs);
198 
199 
206  virtual void myEndElement(int element);
208 
209 protected:
211  std::vector<RerouteInterval> myIntervals;
212 
215 
218 
220 
221 
227  std::vector<MSLane*> myCurrentClosedLanes;
237 
238 
242 
243 private:
246 
249 
250 
251 };
252 
253 
254 #endif
255 
256 /****************************************************************************/
257 
A lane area vehicles can halt at.
Definition: MSParkingArea.h:66
MSEdgeVector closed
The list of closed edges.
long long int SUMOTime
Definition: SUMOTime.h:43
bool notifyMove(SUMOVehicle &veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed)
Triggers rerouting (once) for vehicles that are already on the edge when the rerouter activates...
SUMOTime setPermissions(const SUMOTime currentTime)
Sets the edge permission if there are any defined in the closingEdge.
SVCPermissions myCurrentPermissions
List of permissions for closed edges.
RandomDistributor< MSEdge * > edgeProbs
The distributions of new destinations to use.
SUMOTime myCurrentIntervalBegin
The first and the last time steps of the interval.
bool notifyLeave(SUMOVehicle &veh, SUMOReal lastPos, MSMoveReminder::Notification reason)
Removes the reminder.
std::vector< MSLane * > myCurrentClosedLanes
List of closed lanes.
int SVCPermissions
Notification
Definition of a vehicle state.
void setUserUsageProbability(SUMOReal prob)
Sets the probability with which a vehicle is rerouted given by the user.
long id
unique ID for this interval
SUMOReal getUserProbability() const
Returns the rerouting probability given by the user.
void setUserMode(bool val)
Sets whether the process is currently steered by the user.
SAX-handler base for SUMO-files.
The simulated network and simulation perfomer.
Definition: MSNet.h:94
SUMOReal myProbability
The probability and the user-given probability.
A road/street connecting two junctions (gui-version)
Definition: GUIEdge.h:60
A road/street connecting two junctions.
Definition: MSEdge.h:80
MSTriggeredRerouter & operator=(const MSTriggeredRerouter &)
Invalidated assignment operator.
virtual void myEndElement(int element)
Called when a closing tag occurs.
An abstract device that changes the state of the micro simulation.
Definition: MSTrigger.h:48
Representation of a vehicle.
Definition: SUMOVehicle.h:67
Encapsulated SAX-Attributes.
virtual ~MSTriggeredRerouter()
Destructor.
SUMOTime begin
The begin time these definitions are valid.
RandomDistributor< MSParkingArea * > myCurrentParkProb
new destinations with probabilities
RandomDistributor< const MSRoute * > myCurrentRouteProb
new routes with probabilities
static MSEdge mySpecialDest_keepDestination
special destination values
SUMOReal getProbability() const
Returns the rerouting probability.
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason)
Tries to reroute the vehicle.
Something on a lane to be noticed about vehicle movement.
static MSEdge mySpecialDest_terminateRoute
const RerouteInterval * getCurrentReroute(SUMOTime time, SUMOVehicle &veh) const
Returns the rerouting definition valid for the given time and vehicle, 0 if none. ...
RandomDistributor< MSEdge * > myCurrentEdgeProb
new destinations with probabilities
Reroutes vehicles passing an edge.
SUMOReal getWeight(SUMOVehicle &veh, const std::string param, const SUMOReal defaultWeight) const
RandomDistributor< MSParkingArea * > parkProbs
The distributions of new parking areas to use as destinations.
bool inUserMode() const
Returns whether the user is setting the rerouting probability.
SUMOTime end
The end time these definitions are valid.
std::vector< MSLane * > closedLanes
The list of closed lanes.
RandomDistributor< const MSRoute * > routeProbs
The distributions of new routes to use.
std::vector< RerouteInterval > myIntervals
List of rerouting definition intervals.
MSEdgeVector myCurrentClosed
List of closed edges.
bool myAmInUserMode
Information whether the current rerouting probability is the user-given.
MSTriggeredRerouter(const std::string &id, const MSEdgeVector &edges, SUMOReal prob, const std::string &file, bool off)
Constructor.
#define SUMOReal
Definition: config.h:208
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
MSParkingArea * rerouteParkingZone(const MSTriggeredRerouter::RerouteInterval *rerouteDef, SUMOVehicle &veh) const
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:77
SVCPermissions permissions
The permissions to use.
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
MSEdgeVector closedLanesAffected
The list of edges that are affect by closed lanes.