SUMO - Simulation of Urban MObility
MSTriggeredRerouter.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // Reroutes vehicles passing an edge
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2016 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 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  SUMOReal prob, const std::string& file, bool off);
84 
85 
87  virtual ~MSTriggeredRerouter();
88 
89 
94  struct RerouteInterval {
102  std::vector<MSLane*> closedLanes;
112  long id;
113  };
114 
130 
133 
142  bool notifyMove(SUMOVehicle& veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed);
143 
152  bool notifyLeave(SUMOVehicle& veh, SUMOReal lastPos, MSMoveReminder::Notification reason);
153 
155  const RerouteInterval* getCurrentReroute(SUMOTime time, SUMOVehicle& veh) const;
156 
158  SUMOTime setPermissions(const SUMOTime currentTime);
159 
161  const RerouteInterval* getCurrentReroute(SUMOTime time) const;
162 
164  void setUserMode(bool val);
165 
168 
170  bool inUserMode() const;
171 
173  SUMOReal getProbability() const;
174 
177 
178 protected:
180 
181 
189  virtual void myStartElement(int element,
190  const SUMOSAXAttributes& attrs);
191 
192 
199  virtual void myEndElement(int element);
201 
202 protected:
204  std::vector<RerouteInterval> myIntervals;
205 
208 
211 
213 
214 
220  std::vector<MSLane*> myCurrentClosedLanes;
228 
229 
233 
234 private:
237 
240 
241 
242 };
243 
244 
245 #endif
246 
247 /****************************************************************************/
248 
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. ...
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...
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.
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:93
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:66
Encapsulated SAX-Attributes.
virtual ~MSTriggeredRerouter()
Destructor.
SUMOTime begin
The begin time these definitions are valid.
RandomDistributor< const MSRoute * > myCurrentRouteProb
new routes with probabilities
static MSEdge mySpecialDest_keepDestination
special destination values
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
RandomDistributor< MSEdge * > myCurrentEdgeProb
new destinations with probabilities
Reroutes vehicles passing an edge.
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.
MSTriggeredRerouter(const std::string &id, const MSEdgeVector &edges, SUMOReal prob, const std::string &file, bool off)
Constructor.
#define SUMOReal
Definition: config.h:213
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
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
SUMOReal getProbability() const
Returns the rerouting probability.
MSEdgeVector closedLanesAffected
The list of edges that are affect by closed lanes.