SUMO - Simulation of Urban MObility
MSDevice_Routing.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2007-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // A device that performs vehicle rerouting based on current edge speeds
18 /****************************************************************************/
19 #ifndef MSDevice_Routing_h
20 #define MSDevice_Routing_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <set>
29 #include <vector>
30 #include <map>
31 #include <utils/common/SUMOTime.h>
33 #include <microsim/MSVehicle.h>
34 #include "MSVehicleDevice.h"
35 
36 
37 // ===========================================================================
38 // class declarations
39 // ===========================================================================
40 class MSLane;
41 
42 
43 // ===========================================================================
44 // class definitions
45 // ===========================================================================
62 public:
66  static void insertOptions(OptionsCont& oc);
67 
71  static bool checkOptions(OptionsCont& oc);
72 
73 
89  static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
90 
91 
94 
95 
96 
99 
118  bool notifyEnter(SUMOVehicle& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
120 
122  const std::string deviceName() const {
123  return "rerouting";
124  }
125 
130  void saveState(OutputDevice& out) const;
131 
136  void loadState(const SUMOSAXAttributes& attrs);
137 
139  void reroute(const SUMOTime currentTime, const bool onInit = false);
140 
141 
150  void skipRouting(const SUMOTime currentTime) {
151  mySkipRouting = currentTime;
152  }
153 
155  std::string getParameter(const std::string& key) const;
156 
158  void setParameter(const std::string& key, const std::string& value);
159 
160 
161 private:
162 
170  MSDevice_Routing(SUMOVehicle& holder, const std::string& id, SUMOTime period, SUMOTime preInsertionPeriod);
171 
183  SUMOTime preInsertionReroute(const SUMOTime currentTime);
184 
200 
201 
202 private:
205 
208 
211 
214 
217 
218 private:
221 
224 
225 
226 };
227 
228 
229 #endif
230 
231 /****************************************************************************/
232 
SUMOTime myPeriod
The period with which a vehicle shall be rerouted.
void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this device. Throw exception for unsupported key ...
long long int SUMOTime
Definition: SUMOTime.h:36
SUMOTime mySkipRouting
The time for which routing may be skipped because we cannot be inserted.
SUMOTime myLastRouting
The last time a routing took place.
MSDevice_Routing(SUMOVehicle &holder, const std::string &id, SUMOTime period, SUMOTime preInsertionPeriod)
Constructor.
Notification
Definition of a vehicle state.
A device that performs vehicle rerouting based on current edge speeds.
const std::string deviceName() const
return the name for this type of device
SUMOTime myPreInsertionPeriod
The period with which a vehicle shall be rerouted before insertion.
void saveState(OutputDevice &out) const
Saves the state of the device.
SUMOTime wrappedRerouteCommandExecute(SUMOTime currentTime)
Performs rerouting after a period.
void skipRouting(const SUMOTime currentTime)
Labels the current time step as "unroutable".
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Routing-options.
void reroute(const SUMOTime currentTime, const bool onInit=false)
initiate the rerouting, create router / thread pool on first use
Representation of a vehicle.
Definition: SUMOVehicle.h:60
Encapsulated SAX-Attributes.
MSDevice_Routing & operator=(const MSDevice_Routing &)
Invalidated assignment operator.
WrappingCommand< MSDevice_Routing > * myRerouteCommand
The (optional) command responsible for rerouting.
A storage for options typed value containers)
Definition: OptionsCont.h:92
Abstract in-vehicle device.
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Computes a new route on vehicle insertion.
void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the device from the given description.
~MSDevice_Routing()
Destructor.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
static bool checkOptions(OptionsCont &oc)
checks MSDevice_Routing-options
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice *> &into)
Build devices for the given vehicle, if needed.
Representation of a lane in the micro simulation.
Definition: MSLane.h:78
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key ...
SUMOTime preInsertionReroute(const SUMOTime currentTime)
Performs rerouting before insertion into the network.