Eclipse 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-2019 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(SUMOTrafficObject& 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 
154  SUMOTime getPeriod() const {
155  return myPeriod;
156  }
157 
159  std::string getParameter(const std::string& key) const;
160 
162  void setParameter(const std::string& key, const std::string& value);
163 
164 
165 private:
166 
174  MSDevice_Routing(SUMOVehicle& holder, const std::string& id, SUMOTime period, SUMOTime preInsertionPeriod);
175 
187  SUMOTime preInsertionReroute(const SUMOTime currentTime);
188 
204 
205 
206 private:
209 
212 
215 
218 
221 
222 private:
225 
228 
229 
230 };
231 
232 
233 #endif
234 
235 /****************************************************************************/
236 
SUMOTrafficObject
Representation of a vehicle or person.
Definition: SUMOTrafficObject.h:48
MSDevice_Routing
A device that performs vehicle rerouting based on current edge speeds.
Definition: MSDevice_Routing.h:61
SUMOTime.h
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
MSDevice_Routing::getPeriod
SUMOTime getPeriod() const
Definition: MSDevice_Routing.h:154
MSVehicleDevice.h
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
WrappingCommand.h
MSDevice_Routing::~MSDevice_Routing
~MSDevice_Routing()
Destructor.
Definition: MSDevice_Routing.cpp:156
MSDevice_Routing::deviceName
const std::string deviceName() const
return the name for this type of device
Definition: MSDevice_Routing.h:122
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
SUMOVehicle
Representation of a vehicle.
Definition: SUMOVehicle.h:61
WrappingCommand< MSDevice_Routing >
MSDevice_Routing::myLastRouting
SUMOTime myLastRouting
The last time a routing took place.
Definition: MSDevice_Routing.h:214
MSDevice_Routing::myRerouteCommand
WrappingCommand< MSDevice_Routing > * myRerouteCommand
The (optional) command responsible for rerouting.
Definition: MSDevice_Routing.h:220
MSVehicle.h
MSDevice_Routing::operator=
MSDevice_Routing & operator=(const MSDevice_Routing &)
Invalidated assignment operator.
MSDevice_Routing::checkOptions
static bool checkOptions(OptionsCont &oc)
checks MSDevice_Routing-options
Definition: MSDevice_Routing.cpp:93
MSDevice_Routing::saveState
void saveState(OutputDevice &out) const
Saves the state of the device.
Definition: MSDevice_Routing.cpp:280
MSDevice_Routing::setParameter
void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this device. Throw exception for unsupported key
Definition: MSDevice_Routing.cpp:250
MSDevice_Routing::wrappedRerouteCommandExecute
SUMOTime wrappedRerouteCommandExecute(SUMOTime currentTime)
Performs rerouting after a period.
Definition: MSDevice_Routing.cpp:215
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:90
MSDevice_Routing::loadState
void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the device from the given description.
Definition: MSDevice_Routing.cpp:291
MSDevice_Routing::notifyEnter
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Computes a new route on vehicle insertion.
Definition: MSDevice_Routing.cpp:165
MSDevice_Routing::skipRouting
void skipRouting(const SUMOTime currentTime)
Labels the current time step as "unroutable".
Definition: MSDevice_Routing.h:150
MSDevice_Routing::myPreInsertionPeriod
SUMOTime myPreInsertionPeriod
The period with which a vehicle shall be rerouted before insertion.
Definition: MSDevice_Routing.h:211
MSDevice_Routing::insertOptions
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Routing-options.
Definition: MSDevice_Routing.cpp:50
MSDevice_Routing::myPeriod
SUMOTime myPeriod
The period with which a vehicle shall be rerouted.
Definition: MSDevice_Routing.h:208
config.h
MSDevice_Routing::reroute
void reroute(const SUMOTime currentTime, const bool onInit=false)
initiate the rerouting, create router / thread pool on first use
Definition: MSDevice_Routing.cpp:222
MSDevice_Routing::mySkipRouting
SUMOTime mySkipRouting
The time for which routing may be skipped because we cannot be inserted.
Definition: MSDevice_Routing.h:217
MSDevice_Routing::buildVehicleDevices
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
Definition: MSDevice_Routing.cpp:123
SUMOSAXAttributes
Encapsulated SAX-Attributes.
Definition: SUMOSAXAttributes.h:57
MSMoveReminder::Notification
Notification
Definition of a vehicle state.
Definition: MSMoveReminder.h:89
MSDevice_Routing::MSDevice_Routing
MSDevice_Routing(SUMOVehicle &holder, const std::string &id, SUMOTime period, SUMOTime preInsertionPeriod)
Constructor.
Definition: MSDevice_Routing.cpp:143
MSDevice_Routing::getParameter
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key
Definition: MSDevice_Routing.cpp:234
MSDevice_Routing::preInsertionReroute
SUMOTime preInsertionReroute(const SUMOTime currentTime)
Performs rerouting before insertion into the network.
Definition: MSDevice_Routing.cpp:187
MSVehicleDevice
Abstract in-vehicle device.
Definition: MSVehicleDevice.h:55