SUMO - Simulation of Urban MObility
MSTriggeredRerouter.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
20 // Reroutes vehicles passing an edge
21 /****************************************************************************/
22 #ifndef MSTriggeredRerouter_h
23 #define MSTriggeredRerouter_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 <string>
36 #include <vector>
37 #include <utils/common/Command.h>
39 #include "MSTrigger.h"
42 
43 
44 // ===========================================================================
45 // class declarations
46 // ===========================================================================
47 class MSNet;
48 class MSLane;
49 class MSRoute;
50 class SUMOVehicle;
51 
52 
53 // ===========================================================================
54 // class definitions
55 // ===========================================================================
68  public MSTrigger, public MSMoveReminder,
69  public SUMOSAXHandler {
70 
71  friend class GUIEdge; // dynamic instantiation
72 
73 public:
81  MSTriggeredRerouter(const std::string& id,
82  const MSEdgeVector& edges,
83  double prob, const std::string& file, bool off,
84  SUMOTime timeThreshold);
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  SUMOVehicle& veh, bool& newDestination) const;
185 
186 protected:
188 
189 
197  virtual void myStartElement(int element,
198  const SUMOSAXAttributes& attrs);
199 
200 
207  virtual void myEndElement(int element);
209 
210 protected:
212  std::vector<RerouteInterval> myIntervals;
213 
216 
219 
220  // @brief waiting time threshold for activation
222 
224 
225 
231  std::vector<MSLane*> myCurrentClosedLanes;
241 
242 
246 
247 private:
250 
253 
254 
255 };
256 
257 
258 #endif
259 
260 /****************************************************************************/
261 
A lane area vehicles can halt at.
Definition: MSParkingArea.h:65
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. ...
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.
double myProbability
The probability and the user-given probability.
The simulated network and simulation perfomer.
Definition: MSNet.h:90
A road/street connecting two junctions (gui-version)
Definition: GUIEdge.h:59
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.
MSTriggeredRerouter(const std::string &id, const MSEdgeVector &edges, double prob, const std::string &file, bool off, SUMOTime timeThreshold)
Constructor.
An abstract device that changes the state of the micro simulation.
Definition: MSTrigger.h:47
double getWeight(SUMOVehicle &veh, const std::string param, const double defaultWeight) const
Representation of a vehicle.
Definition: SUMOVehicle.h:66
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
MSParkingArea * rerouteParkingArea(const MSTriggeredRerouter::RerouteInterval *rerouteDef, SUMOVehicle &veh, bool &newDestination) const
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:51
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:77
MSEdgeVector closedLanesAffected
The list of edges that are affect by closed lanes.