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 /****************************************************************************/
16 // A device that performs vehicle rerouting based on current edge speeds
17 /****************************************************************************/
18 #ifndef MSDevice_Routing_h
19 #define MSDevice_Routing_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <set>
28 #include <vector>
29 #include <map>
30 #include <utils/common/SUMOTime.h>
32 #include <microsim/MSVehicle.h>
33 #include "MSVehicleDevice.h"
34 
35 
36 // ===========================================================================
37 // class declarations
38 // ===========================================================================
39 class MSLane;
40 
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
61 public:
65  static void insertOptions(OptionsCont& oc);
66 
70  static bool checkOptions(OptionsCont& oc);
71 
72 
88  static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
89 
90 
93 
94 
95 
98 
117  bool notifyEnter(SUMOTrafficObject& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
119 
121  const std::string deviceName() const {
122  return "rerouting";
123  }
124 
129  void saveState(OutputDevice& out) const;
130 
135  void loadState(const SUMOSAXAttributes& attrs);
136 
138  void reroute(const SUMOTime currentTime, const bool onInit = false);
139 
140 
149  void skipRouting(const SUMOTime currentTime) {
150  mySkipRouting = currentTime;
151  }
152 
153  SUMOTime getPeriod() const {
154  return myPeriod;
155  }
156 
158  std::string getParameter(const std::string& key) const;
159 
161  void setParameter(const std::string& key, const std::string& value);
162 
163 
164 private:
165 
173  MSDevice_Routing(SUMOVehicle& holder, const std::string& id, SUMOTime period, SUMOTime preInsertionPeriod);
174 
186  SUMOTime preInsertionReroute(const SUMOTime currentTime);
187 
203 
204 
205 private:
208 
211 
214 
217 
220 
221 private:
224 
227 
228 
229 };
230 
231 
232 #endif
233 
234 /****************************************************************************/
235 
SUMOTrafficObject
Representation of a vehicle or person.
Definition: SUMOTrafficObject.h:47
MSDevice_Routing
A device that performs vehicle rerouting based on current edge speeds.
Definition: MSDevice_Routing.h:60
SUMOTime.h
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
MSDevice_Routing::getPeriod
SUMOTime getPeriod() const
Definition: MSDevice_Routing.h:153
MSVehicleDevice.h
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
WrappingCommand.h
MSDevice_Routing::~MSDevice_Routing
~MSDevice_Routing()
Destructor.
Definition: MSDevice_Routing.cpp:158
MSDevice_Routing::deviceName
const std::string deviceName() const
return the name for this type of device
Definition: MSDevice_Routing.h:121
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
SUMOVehicle
Representation of a vehicle.
Definition: SUMOVehicle.h:60
WrappingCommand< MSDevice_Routing >
MSDevice_Routing::myLastRouting
SUMOTime myLastRouting
The last time a routing took place.
Definition: MSDevice_Routing.h:213
MSDevice_Routing::myRerouteCommand
WrappingCommand< MSDevice_Routing > * myRerouteCommand
The (optional) command responsible for rerouting.
Definition: MSDevice_Routing.h:219
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:92
MSDevice_Routing::saveState
void saveState(OutputDevice &out) const
Saves the state of the device.
Definition: MSDevice_Routing.cpp:291
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:261
MSDevice_Routing::wrappedRerouteCommandExecute
SUMOTime wrappedRerouteCommandExecute(SUMOTime currentTime)
Performs rerouting after a period.
Definition: MSDevice_Routing.cpp:226
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:89
MSDevice_Routing::loadState
void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the device from the given description.
Definition: MSDevice_Routing.cpp:302
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:167
MSDevice_Routing::skipRouting
void skipRouting(const SUMOTime currentTime)
Labels the current time step as "unroutable".
Definition: MSDevice_Routing.h:149
MSDevice_Routing::myPreInsertionPeriod
SUMOTime myPreInsertionPeriod
The period with which a vehicle shall be rerouted before insertion.
Definition: MSDevice_Routing.h:210
MSDevice_Routing::MSDevice_Routing
MSDevice_Routing(const MSDevice_Routing &)
Invalidated copy constructor.
MSDevice_Routing::insertOptions
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Routing-options.
Definition: MSDevice_Routing.cpp:49
MSDevice_Routing::myPeriod
SUMOTime myPeriod
The period with which a vehicle shall be rerouted.
Definition: MSDevice_Routing.h:207
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:233
MSDevice_Routing::mySkipRouting
SUMOTime mySkipRouting
The time for which routing may be skipped because we cannot be inserted.
Definition: MSDevice_Routing.h:216
MSDevice_Routing::buildVehicleDevices
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
Definition: MSDevice_Routing.cpp:125
SUMOSAXAttributes
Encapsulated SAX-Attributes.
Definition: SUMOSAXAttributes.h:56
MSMoveReminder::Notification
Notification
Definition of a vehicle state.
Definition: MSMoveReminder.h:91
MSDevice_Routing::MSDevice_Routing
MSDevice_Routing(SUMOVehicle &holder, const std::string &id, SUMOTime period, SUMOTime preInsertionPeriod)
Constructor.
Definition: MSDevice_Routing.cpp:145
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:245
MSDevice_Routing::preInsertionReroute
SUMOTime preInsertionReroute(const SUMOTime currentTime)
Performs rerouting before insertion into the network.
Definition: MSDevice_Routing.cpp:192
MSVehicleDevice
Abstract in-vehicle device.
Definition: MSVehicleDevice.h:54