SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MSEdgeControl.h
Go to the documentation of this file.
1 /****************************************************************************/
12 // Stores edges and lanes, performs moving of vehicle
13 /****************************************************************************/
14 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
15 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
16 /****************************************************************************/
17 //
18 // This file is part of SUMO.
19 // SUMO is free software: you can redistribute it and/or modify
20 // it under the terms of the GNU General Public License as published by
21 // the Free Software Foundation, either version 3 of the License, or
22 // (at your option) any later version.
23 //
24 /****************************************************************************/
25 #ifndef MSEdgeControl_h
26 #define MSEdgeControl_h
27 
28 
29 // ===========================================================================
30 // included modules
31 // ===========================================================================
32 #ifdef _MSC_VER
33 #include <windows_config.h>
34 #else
35 #include <config.h>
36 #endif
37 
38 #include <vector>
39 #include <map>
40 #include <string>
41 #include <iostream>
42 #include <list>
43 #include <set>
44 #include <utils/common/SUMOTime.h>
45 #include <utils/common/Named.h>
46 
47 
48 // ===========================================================================
49 // class declarations
50 // ===========================================================================
51 class MSEdge;
52 class MSLane;
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 
112 
126  void executeMovements(SUMOTime t);
128 
129 
138  void changeLanes(SUMOTime t);
139 
140 
151  void detectCollisions(SUMOTime timestep, const std::string& stage);
152 
153 
159  const MSEdgeVector& getEdges() const {
160  return myEdges;
161  }
162 
163 
168  std::vector<std::string> getEdgeNames() const;
169 
170 
176  void gotActive(MSLane* l);
177 
178 
179 public:
191  struct LaneUsage {
195  std::vector<MSLane*>::const_iterator firstNeigh;
197  std::vector<MSLane*>::const_iterator lastNeigh;
199  bool amActive;
202  };
203 
204 private:
207 
209  typedef std::vector<LaneUsage> LaneUsageVector;
210 
212  LaneUsageVector myLanes;
213 
215  std::list<MSLane*> myActiveLanes;
216 
218  std::vector<MSLane*> myWithVehicles2Integrate;
219 
221  std::set<MSLane*, Named::ComparatorIdLess> myChangedStateLanes;
222 
224  std::vector<SUMOTime> myLastLaneChange;
225 
226 private:
229 
232 
233 };
234 
235 
236 #endif
237 
238 /****************************************************************************/
239 
std::list< MSLane * > myActiveLanes
The list of active (not empty) lanes.
~MSEdgeControl()
Destructor.
std::vector< std::string > getEdgeNames() const
Returns the list of names of all known edges.
void patchActiveLanes()
Resets information whether a lane is active for all lanes.
MSLane * lane
The described lane.
std::vector< LaneUsage > LaneUsageVector
Definition of a container about a lane's number of vehicles and neighbors.
std::set< MSLane *, Named::ComparatorIdLess > myChangedStateLanes
Lanes which changed the state without informing the control.
LaneUsageVector myLanes
Information about lanes' number of vehicles and neighbors.
MSEdgeControl & operator=(const MSEdgeControl &)
Assignment operator.
void changeLanes(SUMOTime t)
Moves (precomputes) critical vehicles.
std::vector< MSLane * >::const_iterator firstNeigh
The lane left to the described lane (==lastNeigh if none)
bool amActive
Information whether this lane is active.
A structure holding some basic information about a simulated lane.
void gotActive(MSLane *l)
Informs the control that the given lane got active.
void detectCollisions(SUMOTime timestep, const std::string &stage)
Detect collisions.
A road/street connecting two junctions.
Definition: MSEdge.h:81
std::vector< SUMOTime > myLastLaneChange
The list of active (not empty) lanes.
Stores edges and lanes, performs moving of vehicle.
Definition: MSEdgeControl.h:74
MSEdgeVector myEdges
Loaded edges.
void planMovements(SUMOTime t)
Compute safe velocities for all vehicles based on positions and speeds from the last time step...
void executeMovements(SUMOTime t)
Executes planned vehicle movements with regards to right-of-way.
int SUMOTime
Definition: SUMOTime.h:43
bool haveNeighbors
Information whether this lane belongs to a multi-lane edge.
std::vector< MSLane * > myWithVehicles2Integrate
A storage for lanes which shall be integrated because vehicles have moved onto them.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
std::vector< MSLane * >::const_iterator lastNeigh
The end of this lane's edge's lane container.
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:78
MSEdgeControl(const std::vector< MSEdge * > &edges)
Constructor.
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
const MSEdgeVector & getEdges() const
Returns loaded edges.
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdgeControl.h:53