Eclipse SUMO - Simulation of Urban MObility
MSEdgeControl.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-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 /****************************************************************************/
19 // Stores edges and lanes, performs moving of vehicle
20 /****************************************************************************/
21 #ifndef MSEdgeControl_h
22 #define MSEdgeControl_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #include <config.h>
29 
30 #include <vector>
31 #include <map>
32 #include <string>
33 #include <iostream>
34 #include <list>
35 #include <set>
36 #include <queue>
37 #include <utils/common/SUMOTime.h>
38 #include <utils/common/Named.h>
41 
43 #ifdef HAVE_FOX
45 #endif
46 
47 
48 // ===========================================================================
49 // class declarations
50 // ===========================================================================
51 class MSEdge;
52 class MSLane;
53 class OutputDevice;
54 
55 typedef std::vector<MSEdge*> MSEdgeVector;
56 
57 // ===========================================================================
58 // class definitions
59 // ===========================================================================
75 
76 public:
84  MSEdgeControl(const std::vector< MSEdge* >& edges);
85 
86 
89 
90 
97  void patchActiveLanes();
98 
99 
102 
110  void planMovements(SUMOTime t);
111 
118 
119 
132  void executeMovements(SUMOTime t);
133 
136  }
138 
139 
148  void changeLanes(const SUMOTime t);
149 
150 
161  void detectCollisions(SUMOTime timestep, const std::string& stage);
162 
163 
169  const MSEdgeVector& getEdges() const {
170  return myEdges;
171  }
172 
173 
179  void gotActive(MSLane* l);
180 
183 
186 
187 #ifdef HAVE_FOX
188  FXWorkerThread::Pool& getThreadPool() {
189  return myThreadPool;
190  }
191 #endif
192 
193 public:
205  struct LaneUsage {
209  bool amActive;
212  };
213 
214 #ifdef HAVE_FOX
215 
219  class WorkerThread : public FXWorkerThread {
220  public:
221  WorkerThread(FXWorkerThread::Pool& pool)
222  : FXWorkerThread(pool), myRouter(nullptr) {}
223  bool setRouter(SUMOAbstractRouter<MSEdge, SUMOVehicle>* router) {
224  if (myRouter == nullptr) {
225  myRouter = router;
226  return true;
227  }
228  return false;
229  }
230  SUMOAbstractRouter<MSEdge, SUMOVehicle>& getRouter() const {
231  return *myRouter;
232  }
233  virtual ~WorkerThread() {
234  stop();
235  delete myRouter;
236  }
237  private:
239  };
240 #endif
241 
242 private:
245 
247  typedef std::vector<LaneUsage> LaneUsageVector;
248 
251 
253  std::list<MSLane*> myActiveLanes;
254 
257 
259  std::set<MSLane*, ComparatorNumericalIdLess> myChangedStateLanes;
260 
262  std::vector<SUMOTime> myLastLaneChange;
263 
265  std::set<MSLane*, ComparatorNumericalIdLess> myInactiveCheckCollisions;
266 
268 
269 #ifdef HAVE_FOX
270  FXWorkerThread::Pool myThreadPool;
271 #endif
272 
273  std::priority_queue<std::pair<int, int> > myRNGLoad;
274 
275 private:
278 
281 
282 };
283 
284 
285 #endif
286 
287 /****************************************************************************/
288 
MSEdgeControl::myInactiveCheckCollisions
std::set< MSLane *, ComparatorNumericalIdLess > myInactiveCheckCollisions
Additional lanes for which collision checking must be performed.
Definition: MSEdgeControl.h:265
MSEdgeControl::LaneUsageVector
std::vector< LaneUsage > LaneUsageVector
Definition of a container about a lane's number of vehicles and neighbors.
Definition: MSEdgeControl.h:247
MSEdgeControl::gotActive
void gotActive(MSLane *l)
Informs the control that the given lane got active.
Definition: MSEdgeControl.cpp:313
MSEdgeControl::LaneUsage::haveNeighbors
bool haveNeighbors
Information whether this lane belongs to a multi-lane edge.
Definition: MSEdgeControl.h:211
MSEdgeControl::myMinLengthGeometryFactor
double myMinLengthGeometryFactor
Definition: MSEdgeControl.h:267
SUMOTime.h
MSEdgeControl::setAdditionalRestrictions
void setAdditionalRestrictions()
apply additional restrictions
Definition: MSEdgeControl.cpp:323
MSEdgeControl::LaneUsage::lane
MSLane * lane
The described lane.
Definition: MSEdgeControl.h:207
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
MSEdgeControl::needsVehicleIntegration
void needsVehicleIntegration(MSLane *const l)
Definition: MSEdgeControl.h:134
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
FXSynchQue.h
MSEdgeControl::changeLanes
void changeLanes(const SUMOTime t)
Moves (precomputes) critical vehicles.
Definition: MSEdgeControl.cpp:225
MSEdgeControl::myChangedStateLanes
std::set< MSLane *, ComparatorNumericalIdLess > myChangedStateLanes
Lanes which changed the state without informing the control.
Definition: MSEdgeControl.h:259
MSEdgeControl::myLanes
LaneUsageVector myLanes
Information about lanes' number of vehicles and neighbors.
Definition: MSEdgeControl.h:250
MSEdgeControl::myLastLaneChange
std::vector< SUMOTime > myLastLaneChange
The list of active (not empty) lanes.
Definition: MSEdgeControl.h:262
MSEdgeControl::checkCollisionForInactive
void checkCollisionForInactive(MSLane *l)
trigger collision checking for inactive lane
Definition: MSEdgeControl.cpp:318
SUMOVehicle.h
MSEdgeVector
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdgeControl.h:53
Named.h
MSEdgeControl::myWithVehicles2Integrate
FXSynchQue< MSLane *, std::vector< MSLane * > > myWithVehicles2Integrate
A storage for lanes which shall be integrated because vehicles have moved onto them.
Definition: MSEdgeControl.h:256
MSEdgeControl::MSEdgeControl
MSEdgeControl(const MSEdgeControl &)
Copy constructor.
MSEdge
A road/street connecting two junctions.
Definition: MSEdge.h:78
FXWorkerThread.h
MSEdgeControl::detectCollisions
void detectCollisions(SUMOTime timestep, const std::string &stage)
Detect collisions.
Definition: MSEdgeControl.cpp:296
FXSynchQue
Definition: FXSynchQue.h:41
MSEdgeControl::setJunctionApproaches
void setJunctionApproaches(SUMOTime t)
Register junction approaches for all vehicles after velocities have been planned. This is a prerequis...
Definition: MSEdgeControl.cpp:147
SUMOAbstractRouter< MSEdge, SUMOVehicle >
MSEdgeControl::MSEdgeControl
MSEdgeControl(const std::vector< MSEdge * > &edges)
Constructor.
Definition: MSEdgeControl.cpp:44
MSEdgeControl::myRNGLoad
std::priority_queue< std::pair< int, int > > myRNGLoad
Definition: MSEdgeControl.h:273
FXWorkerThread::Pool
A pool of worker threads which distributes the tasks and collects the results.
Definition: FXWorkerThread.h:88
MSEdgeVector
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:74
MSEdgeControl::myActiveLanes
std::list< MSLane * > myActiveLanes
The list of active (not empty) lanes.
Definition: MSEdgeControl.h:253
MSEdgeControl::LaneUsage::amActive
bool amActive
Information whether this lane is active.
Definition: MSEdgeControl.h:209
MSEdgeControl::myEdges
MSEdgeVector myEdges
Loaded edges.
Definition: MSEdgeControl.h:244
FXSynchQue::push_back
void push_back(T what)
Definition: FXSynchQue.h:115
config.h
MSEdgeControl::~MSEdgeControl
~MSEdgeControl()
Destructor.
Definition: MSEdgeControl.cpp:80
MSEdgeControl
Stores edges and lanes, performs moving of vehicle.
Definition: MSEdgeControl.h:74
MSEdgeControl::executeMovements
void executeMovements(SUMOTime t)
Executes planned vehicle movements with regards to right-of-way.
Definition: MSEdgeControl.cpp:155
MSEdgeControl::planMovements
void planMovements(SUMOTime t)
Compute safe velocities for all vehicles based on positions and speeds from the last time step....
Definition: MSEdgeControl.cpp:107
MSEdgeControl::patchActiveLanes
void patchActiveLanes()
Resets information whether a lane is active for all lanes.
Definition: MSEdgeControl.cpp:88
SUMOAbstractRouter.h
MSEdgeControl::operator=
MSEdgeControl & operator=(const MSEdgeControl &)
Assignment operator.
MSEdgeControl::getEdges
const MSEdgeVector & getEdges() const
Returns loaded edges.
Definition: MSEdgeControl.h:169
FXWorkerThread
A thread repeatingly calculating incoming tasks.
Definition: FXWorkerThread.h:48
MSEdgeControl::LaneUsage
A structure holding some basic information about a simulated lane.
Definition: MSEdgeControl.h:205