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  double 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 
132  bool notifyEnter(SUMOVehicle& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
133 
136 
145  bool notifyMove(SUMOVehicle& veh, double oldPos, double newPos, double newSpeed);
146 
155  bool notifyLeave(SUMOVehicle& veh, double lastPos, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
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 
170  void setUserUsageProbability(double prob);
171 
173  bool inUserMode() const;
174 
176  double getProbability() const;
177 
179  double getUserProbability() const;
180 
181  double getWeight(SUMOVehicle& veh, const std::string param, const double 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
double getProbability() const
Returns the rerouting probability.
MSEdgeVector closed
The list of closed edges.
const RerouteInterval * getCurrentReroute(SUMOTime time, SUMOVehicle &veh) const
Returns the rerouting definition valid for the given time and vehicle, 0 if none. ...
MSParkingArea * rerouteParkingZone(const MSTriggeredRerouter::RerouteInterval *rerouteDef, SUMOVehicle &veh) const
double getUserProbability() const
Returns the rerouting probability given by the user.
Represents a generic random distribution.
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.
std::vector< MSLane * > myCurrentClosedLanes
List of closed lanes.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
Notification
Definition of a vehicle state.
void setUserUsageProbability(double prob)
Sets the probability with which a vehicle is rerouted given by the user.
long id
unique ID for this interval
void setUserMode(bool val)
Sets whether the process is currently steered by the user.
SAX-handler base for SUMO-files.
MSTriggeredRerouter(const std::string &id, const MSEdgeVector &edges, double prob, const std::string &file, bool off)
Constructor.
double myProbability
The probability and the user-given probability.
The simulated network and simulation perfomer.
Definition: MSNet.h:94
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
double getWeight(SUMOVehicle &veh, const std::string param, const double defaultWeight) const
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
Something on a lane to be noticed about vehicle movement.
static MSEdge mySpecialDest_terminateRoute
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Tries to reroute the vehicle.
bool notifyLeave(SUMOVehicle &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Removes the reminder.
RandomDistributor< MSEdge * > myCurrentEdgeProb
new destinations with probabilities
Reroutes vehicles passing an edge.
RandomDistributor< MSParkingArea * > parkProbs
The distributions of new parking areas to use as destinations.
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.
bool inUserMode() const
Returns whether the user is setting the rerouting probability.
MSEdgeVector myCurrentClosed
List of closed edges.
bool myAmInUserMode
Information whether the current rerouting probability is the user-given.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
long long int SUMOTime
Definition: TraCIDefs.h:52
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:77
bool notifyMove(SUMOVehicle &veh, double oldPos, double newPos, double newSpeed)
Triggers rerouting (once) for vehicles that are already on the edge when the rerouter activates...
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.