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-2024 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>
42
45//#define THREAD_POOL
46#ifdef THREAD_POOL
48#else
49#ifdef HAVE_FOX
51#endif
52#endif
53
54
55// ===========================================================================
56// class declarations
57// ===========================================================================
58class OutputDevice;
59
60
61// ===========================================================================
62// class definitions
63// ===========================================================================
79
80public:
88 MSEdgeControl(const std::vector< MSEdge* >& edges);
89
90
93
94
101 void patchActiveLanes();
102
103
106
114 void planMovements(SUMOTime t);
115
122
123
137
142
143
152 void changeLanes(const SUMOTime t);
153
154
165 void detectCollisions(SUMOTime timestep, const std::string& stage);
166
167
173 const MSEdgeVector& getEdges() const {
174 return myEdges;
175 }
176
177
183 void gotActive(MSLane* l);
184
187
190
192 void setMesoTypes();
193
196 void saveState(OutputDevice& out);
197
200 void setActiveLanes(std::list<MSLane*> lanes);
201
202
203#ifndef THREAD_POOL
204#ifdef HAVE_FOX
205 MFXWorkerThread::Pool& getThreadPool() {
206 return myThreadPool;
207 }
208#endif
209#endif
210
211public:
231
232#ifdef HAVE_FOX
237 class WorkerThread : public MFXWorkerThread {
238 public:
239 WorkerThread(MFXWorkerThread::Pool& pool)
240 : MFXWorkerThread(pool), myRouterProvider(nullptr) {}
241
242 bool setRouterProvider(MSRouterProvider* routerProvider) {
243 if (myRouterProvider == nullptr) {
244 myRouterProvider = routerProvider;
245 return true;
246 }
247 return false;
248 }
249 MSVehicleRouter& getRouter(SUMOVehicleClass svc) const {
250 return myRouterProvider->getVehicleRouter(svc);
251 }
252 MSTransportableRouter& getIntermodalRouter() const {
253 return myRouterProvider->getIntermodalRouter();
254 }
255 virtual ~WorkerThread() {
256 stop();
257 delete myRouterProvider;
258 }
259 private:
260 MSRouterProvider* myRouterProvider;
261 };
262#endif
263
264private:
267
269 typedef std::vector<LaneUsage> LaneUsageVector;
270
273
275 std::list<MSLane*> myActiveLanes;
276
279
281 std::set<MSLane*, ComparatorNumericalIdLess> myChangedStateLanes;
282
284 std::vector<SUMOTime> myLastLaneChange;
285
288
290
291#ifdef THREAD_POOL
292 WorkStealingThreadPool<> myThreadPool;
293#else
294#ifdef HAVE_FOX
295 MFXWorkerThread::Pool myThreadPool;
296#endif
297#endif
298
299 std::vector<StopWatch<std::chrono::nanoseconds> > myStopWatch;
300
301private:
304
307
308};
long long int SUMOTime
Definition GUI.h:36
std::vector< MSEdge * > MSEdgeVector
Definition MSEdge.h:73
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.
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
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.