Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSEdgeControl.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2023 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/****************************************************************************/
23// Stores edges and lanes, performs moving of vehicle
24/****************************************************************************/
25#pragma once
26#include <config.h>
27
28#include <vector>
29#include <map>
30#include <string>
31#include <iostream>
32#include <list>
33#include <set>
34#include <queue>
36#include <utils/common/Named.h>
41
44//#define THREAD_POOL
45#ifdef THREAD_POOL
47#else
48#ifdef HAVE_FOX
50#endif
51#endif
52
53
54// ===========================================================================
55// class declarations
56// ===========================================================================
57class MSEdge;
58class MSLane;
59class MSJunction;
60class OutputDevice;
61
62typedef std::vector<MSEdge*> MSEdgeVector;
63
64// ===========================================================================
65// class definitions
66// ===========================================================================
82
83public:
85
93 MSEdgeControl(const std::vector< MSEdge* >& edges);
94
95
98
99
106 void patchActiveLanes();
107
108
111
119 void planMovements(SUMOTime t);
120
127
128
142
147
148
157 void changeLanes(const SUMOTime t);
158
159
170 void detectCollisions(SUMOTime timestep, const std::string& stage);
171
172
178 const MSEdgeVector& getEdges() const {
179 return myEdges;
180 }
181
182
188 void gotActive(MSLane* l);
189
192
195
197 void setMesoTypes();
198
201 void saveState(OutputDevice& out);
202
205 void setActiveLanes(std::list<MSLane*> lanes);
206
207
208#ifndef THREAD_POOL
209#ifdef HAVE_FOX
210 MFXWorkerThread::Pool& getThreadPool() {
211 return myThreadPool;
212 }
213#endif
214#endif
215
216public:
236
237#ifdef HAVE_FOX
242 class WorkerThread : public MFXWorkerThread {
243 public:
244 WorkerThread(MFXWorkerThread::Pool& pool)
245 : MFXWorkerThread(pool), myRouterProvider(nullptr) {}
246
247 bool setRouterProvider(MSRouterProvider* routerProvider) {
248 if (myRouterProvider == nullptr) {
249 myRouterProvider = routerProvider;
250 return true;
251 }
252 return false;
253 }
255 return myRouterProvider->getVehicleRouter(svc);
256 }
257 virtual ~WorkerThread() {
258 stop();
259 delete myRouterProvider;
260 }
261 private:
262 MSRouterProvider* myRouterProvider;
263 };
264#endif
265
266private:
269
271 typedef std::vector<LaneUsage> LaneUsageVector;
272
275
277 std::list<MSLane*> myActiveLanes;
278
281
283 std::set<MSLane*, ComparatorNumericalIdLess> myChangedStateLanes;
284
286 std::vector<SUMOTime> myLastLaneChange;
287
290
292
293#ifdef THREAD_POOL
294 WorkStealingThreadPool<> myThreadPool;
295#else
296#ifdef HAVE_FOX
297 MFXWorkerThread::Pool myThreadPool;
298#endif
299#endif
300
301 std::vector<StopWatch<std::chrono::nanoseconds> > myStopWatch;
302
303private:
306
309
310};
long long int SUMOTime
Definition GUI.h:36
std::vector< MSEdge * > MSEdgeVector
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
void push_back(T what)
A pool of worker threads which distributes the tasks and collects the results.
A thread repeatingly calculating incoming tasks.
Stores edges and lanes, performs moving of vehicle.
void patchActiveLanes()
Resets information whether a lane is active for all lanes.
std::vector< StopWatch< std::chrono::nanoseconds > > myStopWatch
MSEdgeControl & operator=(const MSEdgeControl &)
Assignment operator.
~MSEdgeControl()
Destructor.
void setMesoTypes()
update meso edge type parameters
void setActiveLanes(std::list< MSLane * > lanes)
Reconstruct the current state.
void setAdditionalRestrictions()
apply additional restrictions
MSEdgeControl(const MSEdgeControl &)
Copy constructor.
std::list< MSLane * > myActiveLanes
The list of active (not empty) lanes.
void detectCollisions(SUMOTime timestep, const std::string &stage)
Detect collisions.
MFXSynchQue< MSLane *, std::vector< MSLane * > > myWithVehicles2Integrate
A storage for lanes which shall be integrated because vehicles have moved onto them.
std::vector< LaneUsage > LaneUsageVector
Definition of a container about a lane's number of vehicles and neighbors.
MSEdgeVector myEdges
Loaded edges.
RouterProvider< MSEdge, MSLane, MSJunction, SUMOVehicle > MSRouterProvider
void setJunctionApproaches(SUMOTime t)
Register junction approaches for all vehicles after velocities have been planned. This is a prerequis...
void executeMovements(SUMOTime t)
Executes planned vehicle movements with regards to right-of-way.
const MSEdgeVector & getEdges() const
Returns loaded edges.
MFXSynchSet< MSLane *, std::set< MSLane *, ComparatorNumericalIdLess > > myInactiveCheckCollisions
Additional lanes for which collision checking must be performed.
LaneUsageVector myLanes
Information about lanes' number of vehicles and neighbors.
void gotActive(MSLane *l)
Informs the control that the given lane got active.
void checkCollisionForInactive(MSLane *l)
trigger collision checking for inactive lane
std::vector< SUMOTime > myLastLaneChange
The list of active (not empty) lanes.
std::set< MSLane *, ComparatorNumericalIdLess > myChangedStateLanes
Lanes which changed the state without informing the control.
void planMovements(SUMOTime t)
Compute safe velocities for all vehicles based on positions and speeds from the last time step....
void saveState(OutputDevice &out)
Saves the current state into the given stream.
void changeLanes(const SUMOTime t)
Moves (precomputes) critical vehicles.
void needsVehicleIntegration(MSLane *const l)
double myMinLengthGeometryFactor
A road/street connecting two junctions.
Definition MSEdge.h:77
The base class for an intersection.
Definition MSJunction.h:58
Representation of a lane in the micro simulation.
Definition MSLane.h:84
Static storage of an output device and its base (abstract) implementation.
A structure holding some basic information about a simulated lane.
bool amActive
Information whether this lane is active.
bool haveNeighbors
Information whether this lane belongs to a multi-lane edge.
MSLane * lane
The described lane.