SUMO - Simulation of Urban MObility
MELoop.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-2018 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 /****************************************************************************/
15 // The main mesocopic simulation loop
16 /****************************************************************************/
17 #ifndef MELoop_h
18 #define MELoop_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <vector>
27 #include <map>
28 
29 
30 // ===========================================================================
31 // class declarations
32 // ===========================================================================
33 class MESegment;
34 class MEVehicle;
35 class MSEdge;
36 class MSLink;
37 class MSVehicleControl;
38 class BinaryInputDevice;
39 class OptionsCont;
40 
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
49 class MELoop {
50 public:
52  MELoop(const SUMOTime recheckInterval);
53 
54  ~MELoop();
55 
62  void simulate(SUMOTime tMax);
63 
69  void addLeaderCar(MEVehicle* veh, MSLink* link);
70 
75  void removeLeaderCar(MEVehicle* v);
76 
78  static int numSegmentsFor(const double length, const double slength);
79 
84  void buildSegmentsFor(const MSEdge& e, const OptionsCont& oc);
85 
92  MESegment* getSegmentForEdge(const MSEdge& e, double pos = 0);
93 
98  bool changeSegment(MEVehicle* veh, SUMOTime leaveTime, MESegment* const toSegment, const bool ignoreLink = false);
99 
105  static void setApproaching(MEVehicle* veh, MSLink* link);
106 
107 
108 private:
116  void checkCar(MEVehicle* veh);
117 
130 
131 
136  void teleportVehicle(MEVehicle* veh, MESegment* const toSegment);
137 
139  static bool isEnteringRoundabout(const MSEdge& e);
140 
141 private:
143  std::map<SUMOTime, std::vector<MEVehicle*> > myLeaderCars;
144 
146  std::vector<MESegment*> myEdges2FirstSegments;
147 
150 
153 
154 private:
156  MELoop(const MELoop&);
157 
159  MELoop& operator=(const MELoop&);
160 };
161 
162 
163 #endif
164 
165 /****************************************************************************/
166 
bool changeSegment(MEVehicle *veh, SUMOTime leaveTime, MESegment *const toSegment, const bool ignoreLink=false)
change to the next segment this handles combinations of the following cases: (ending / continuing rou...
Definition: MELoop.cpp:81
MELoop(const SUMOTime recheckInterval)
SUMO constructor.
Definition: MELoop.cpp:48
long long int SUMOTime
Definition: SUMOTime.h:36
MESegment * nextSegment(MESegment *s, MEVehicle *v)
Retrieve next segment.
Definition: MELoop.cpp:225
A vehicle from the mesoscopic point of view.
Definition: MEVehicle.h:45
MESegment * getSegmentForEdge(const MSEdge &e, double pos=0)
Get the segment for a given edge at a given position.
Definition: MELoop.cpp:283
~MELoop()
Definition: MELoop.cpp:51
const SUMOTime myFullRecheckInterval
the interval at which to recheck at full segments (<=0 means asap)
Definition: MELoop.h:149
std::vector< MESegment * > myEdges2FirstSegments
mapping from internal edge ids to their initial segments
Definition: MELoop.h:146
void buildSegmentsFor(const MSEdge &e, const OptionsCont &oc)
Build the segments for a given edge.
Definition: MELoop.cpp:255
void teleportVehicle(MEVehicle *veh, MESegment *const toSegment)
teleports a vehicle or continues a teleport
Definition: MELoop.cpp:146
void removeLeaderCar(MEVehicle *v)
Removes the given car from the leading vehicles.
Definition: MELoop.cpp:218
A road/street connecting two junctions.
Definition: MSEdge.h:75
The main mesocopic simulation loop.
Definition: MELoop.h:49
std::map< SUMOTime, std::vector< MEVehicle * > > myLeaderCars
leader cars in the segments sorted by exit time
Definition: MELoop.h:143
static bool isEnteringRoundabout(const MSEdge &e)
whether the given edge is entering a roundabout
Definition: MELoop.cpp:297
static void setApproaching(MEVehicle *veh, MSLink *link)
registers vehicle with the given link
Definition: MELoop.cpp:205
A single mesoscopic segment (cell)
Definition: MESegment.h:50
A storage for options typed value containers)
Definition: OptionsCont.h:92
MELoop & operator=(const MELoop &)
Invalidated assignment operator.
const SUMOTime myLinkRecheckInterval
the interval at which to recheck at blocked junctions (<=0 means asap)
Definition: MELoop.h:152
void checkCar(MEVehicle *veh)
Check whether the vehicle may move.
Definition: MELoop.cpp:112
The class responsible for building and deletion of vehicles.
static int numSegmentsFor(const double length, const double slength)
Compute number of segments per edge (best value stay close to the configured segment length) ...
Definition: MELoop.cpp:244
void simulate(SUMOTime tMax)
Perform simulation up to the given time.
Definition: MELoop.cpp:63
Encapsulates binary reading operations on a file.
void addLeaderCar(MEVehicle *veh, MSLink *link)
Adds the given car to the leading vehicles.
Definition: MELoop.cpp:198