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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
20 // A device that performs vehicle rerouting based on current edge speeds
21 /****************************************************************************/
22 #pragma once
23 #include <config.h>
24 
25 #include <set>
26 #include <vector>
27 #include <map>
28 #include <utils/common/SUMOTime.h>
30 #include <microsim/MSVehicle.h>
31 #include "MSVehicleDevice.h"
32 
33 
34 // ===========================================================================
35 // class declarations
36 // ===========================================================================
37 class MSLane;
38 
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
59 public:
63  static void insertOptions(OptionsCont& oc);
64 
68  static bool checkOptions(OptionsCont& oc);
69 
70 
86  static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
87 
88 
91 
92 
93 
96 
115  bool notifyEnter(SUMOTrafficObject& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
117 
119  const std::string deviceName() const {
120  return "rerouting";
121  }
122 
127  void saveState(OutputDevice& out) const;
128 
133  void loadState(const SUMOSAXAttributes& attrs);
134 
136  void reroute(const SUMOTime currentTime, const bool onInit = false);
137 
138 
147  void skipRouting(const SUMOTime currentTime) {
148  mySkipRouting = currentTime;
149  }
150 
151  SUMOTime getPeriod() const {
152  return myPeriod;
153  }
154 
156  bool mayRerouteRailSignal() const {
157  return myRerouteRailSignal;
158  }
159 
161  std::string getParameter(const std::string& key) const;
162 
164  void setParameter(const std::string& key, const std::string& value);
165 
166 
167 private:
168 
176  MSDevice_Routing(SUMOVehicle& holder, const std::string& id, SUMOTime period, SUMOTime preInsertionPeriod);
177 
189  SUMOTime preInsertionReroute(const SUMOTime currentTime);
190 
206 
207 
208 private:
211 
214 
217 
220 
223 
226 
227 private:
230 
233 
234 
235 };
long long int SUMOTime
Definition: SUMOTime.h:31
A device that performs vehicle rerouting based on current edge speeds.
const std::string deviceName() const
return the name for this type of device
void saveState(OutputDevice &out) const
Saves the state of the device.
SUMOTime getPeriod() const
SUMOTime wrappedRerouteCommandExecute(SUMOTime currentTime)
Performs rerouting after a period.
SUMOTime mySkipRouting
The time for which routing may be skipped because we cannot be inserted.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Routing-options.
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Computes a new route on vehicle insertion.
SUMOTime myPreInsertionPeriod
The period with which a vehicle shall be rerouted before insertion.
SUMOTime myPeriod
The period with which a vehicle shall be rerouted.
void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the device from the given description.
void reroute(const SUMOTime currentTime, const bool onInit=false)
initiate the rerouting, create router / thread pool on first use
bool myRerouteRailSignal
Whether the equipped vehicle may receive dispatch information at a rail signal.
static bool checkOptions(OptionsCont &oc)
checks MSDevice_Routing-options
bool mayRerouteRailSignal() const
return whether the equipped vehicle may receive dispatch information at a rail signal
MSDevice_Routing(const MSDevice_Routing &)
Invalidated copy constructor.
MSDevice_Routing & operator=(const MSDevice_Routing &)
Invalidated assignment operator.
MSDevice_Routing(SUMOVehicle &holder, const std::string &id, SUMOTime period, SUMOTime preInsertionPeriod)
Constructor.
WrappingCommand< MSDevice_Routing > * myRerouteCommand
The (optional) command responsible for rerouting.
void skipRouting(const SUMOTime currentTime)
Labels the current time step as "unroutable".
~MSDevice_Routing()
Destructor.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
SUMOTime myLastRouting
The last time a routing took place.
void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this device. Throw exception for unsupported key
SUMOTime preInsertionReroute(const SUMOTime currentTime)
Performs rerouting before insertion into the network.
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
Notification
Definition of a vehicle state.
Abstract in-vehicle device.
A storage for options typed value containers)
Definition: OptionsCont.h:89
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:60
Encapsulated SAX-Attributes.
Representation of a vehicle, person, or container.
Representation of a vehicle.
Definition: SUMOVehicle.h:58