Eclipse 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-2020 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 /****************************************************************************/
18 // The main mesocopic simulation loop
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
23 #include <vector>
24 #include <map>
25 #include <utils/common/SUMOTime.h>
26 
27 
28 // ===========================================================================
29 // class declarations
30 // ===========================================================================
31 class MESegment;
32 class MEVehicle;
33 class MSEdge;
34 class MSLink;
35 class MSVehicleControl;
36 class OptionsCont;
37 
38 
39 // ===========================================================================
40 // class definitions
41 // ===========================================================================
46 class MELoop {
47 public:
49  MELoop(const SUMOTime recheckInterval);
50 
51  ~MELoop();
52 
59  void simulate(SUMOTime tMax);
60 
66  void addLeaderCar(MEVehicle* veh, MSLink* link);
67 
72  void removeLeaderCar(MEVehicle* v);
73 
76 
78  static bool isEnteringRoundabout(const MSEdge& e);
79 
81  static int numSegmentsFor(const double length, const double slength);
82 
87  void buildSegmentsFor(const MSEdge& e, const OptionsCont& oc);
88 
93  void updateSegementsForEdge(const MSEdge& e);
94 
101  MESegment* getSegmentForEdge(const MSEdge& e, double pos = 0);
102 
107  SUMOTime changeSegment(MEVehicle* veh, SUMOTime leaveTime, MESegment* const toSegment,
108  MSMoveReminder::Notification reason, const bool ignoreLink = false) const;
109 
111  void clearState();
112 
113 private:
121  void checkCar(MEVehicle* veh);
122 
135 
136 
141  void teleportVehicle(MEVehicle* veh, MESegment* const toSegment);
142 
143 private:
145  std::map<SUMOTime, std::vector<MEVehicle*> > myLeaderCars;
146 
148  std::vector<MESegment*> myEdges2FirstSegments;
149 
152 
155 
156 private:
158  MELoop(const MELoop&);
159 
162 };
long long int SUMOTime
Definition: SUMOTime.h:31
The main mesocopic simulation loop.
Definition: MELoop.h:46
void updateSegementsForEdge(const MSEdge &e)
Update segments after loading meso edge type parameters from additional file.
Definition: MELoop.cpp:289
MESegment * nextSegment(MESegment *s, MEVehicle *v)
Retrieve next segment.
Definition: MELoop.cpp:236
static bool isEnteringRoundabout(const MSEdge &e)
whether the given edge is entering a roundabout
Definition: MELoop.cpp:319
MELoop(const MELoop &)
Invalidated copy constructor.
MELoop(const SUMOTime recheckInterval)
SUMO constructor.
Definition: MELoop.cpp:46
SUMOTime changeSegment(MEVehicle *veh, SUMOTime leaveTime, MESegment *const toSegment, MSMoveReminder::Notification reason, const bool ignoreLink=false) const
change to the next segment this handles combinations of the following cases: (ending / continuing rou...
Definition: MELoop.cpp:79
MESegment * getSegmentForEdge(const MSEdge &e, double pos=0)
Get the segment for a given edge at a given position.
Definition: MELoop.cpp:302
const SUMOTime myLinkRecheckInterval
the interval at which to recheck at blocked junctions (<=0 means asap)
Definition: MELoop.h:154
void simulate(SUMOTime tMax)
Perform simulation up to the given time.
Definition: MELoop.cpp:61
const SUMOTime myFullRecheckInterval
the interval at which to recheck at full segments (<=0 means asap)
Definition: MELoop.h:151
void vaporizeCar(MEVehicle *v, MSMoveReminder::Notification reason)
remove the given car and clean up the relevant data structures
Definition: MELoop.cpp:224
void teleportVehicle(MEVehicle *veh, MESegment *const toSegment)
teleports a vehicle or continues a teleport
Definition: MELoop.cpp:152
void addLeaderCar(MEVehicle *veh, MSLink *link)
Adds the given car to the leading vehicles.
Definition: MELoop.cpp:203
void clearState()
Remove all vehicles before quick-loading state.
Definition: MELoop.cpp:210
void removeLeaderCar(MEVehicle *v)
Removes the given car from the leading vehicles.
Definition: MELoop.cpp:215
std::vector< MESegment * > myEdges2FirstSegments
mapping from internal edge ids to their initial segments
Definition: MELoop.h:148
std::map< SUMOTime, std::vector< MEVehicle * > > myLeaderCars
leader cars in the segments sorted by exit time
Definition: MELoop.h:145
~MELoop()
Definition: MELoop.cpp:49
void checkCar(MEVehicle *veh)
Check whether the vehicle may move.
Definition: MELoop.cpp:118
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:255
void buildSegmentsFor(const MSEdge &e, const OptionsCont &oc)
Build the segments for a given edge.
Definition: MELoop.cpp:266
MELoop & operator=(const MELoop &)
Invalidated assignment operator.
A single mesoscopic segment (cell)
Definition: MESegment.h:47
A vehicle from the mesoscopic point of view.
Definition: MEVehicle.h:42
A road/street connecting two junctions.
Definition: MSEdge.h:77
Notification
Definition of a vehicle state.
The class responsible for building and deletion of vehicles.
A storage for options typed value containers)
Definition: OptionsCont.h:89