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-2019 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 /****************************************************************************/
14 // The main mesocopic simulation loop
15 /****************************************************************************/
16 #ifndef MELoop_h
17 #define MELoop_h
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
25 #include <vector>
26 #include <map>
27 
28 
29 // ===========================================================================
30 // class declarations
31 // ===========================================================================
32 class MESegment;
33 class MEVehicle;
34 class MSEdge;
35 class MSLink;
36 class MSVehicleControl;
37 class BinaryInputDevice;
38 class OptionsCont;
39 
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
48 class MELoop {
49 public:
51  MELoop(const SUMOTime recheckInterval);
52 
53  ~MELoop();
54 
61  void simulate(SUMOTime tMax);
62 
68  void addLeaderCar(MEVehicle* veh, MSLink* link);
69 
74  void removeLeaderCar(MEVehicle* v);
75 
77  void vaporizeCar(MEVehicle* v);
78 
80  static int numSegmentsFor(const double length, const double slength);
81 
86  void buildSegmentsFor(const MSEdge& e, const OptionsCont& oc);
87 
94  MESegment* getSegmentForEdge(const MSEdge& e, double pos = 0);
95 
100  bool changeSegment(MEVehicle* veh, SUMOTime leaveTime, MESegment* const toSegment, const bool ignoreLink = false);
101 
107  static void setApproaching(MEVehicle* veh, MSLink* link);
108 
109 
110 private:
118  void checkCar(MEVehicle* veh);
119 
132 
133 
138  void teleportVehicle(MEVehicle* veh, MESegment* const toSegment);
139 
141  static bool isEnteringRoundabout(const MSEdge& e);
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 };
163 
164 
165 #endif
166 
167 /****************************************************************************/
168 
MELoop::myFullRecheckInterval
const SUMOTime myFullRecheckInterval
the interval at which to recheck at full segments (<=0 means asap)
Definition: MELoop.h:151
MEVehicle
A vehicle from the mesoscopic point of view.
Definition: MEVehicle.h:44
MELoop::MELoop
MELoop(const SUMOTime recheckInterval)
SUMO constructor.
Definition: MELoop.cpp:47
MESegment
A single mesoscopic segment (cell)
Definition: MESegment.h:49
MELoop::changeSegment
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:80
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
MELoop::myEdges2FirstSegments
std::vector< MESegment * > myEdges2FirstSegments
mapping from internal edge ids to their initial segments
Definition: MELoop.h:148
MELoop::addLeaderCar
void addLeaderCar(MEVehicle *veh, MSLink *link)
Adds the given car to the leading vehicles.
Definition: MELoop.cpp:197
MELoop
The main mesocopic simulation loop.
Definition: MELoop.h:48
MELoop::nextSegment
MESegment * nextSegment(MESegment *s, MEVehicle *v)
Retrieve next segment.
Definition: MELoop.cpp:234
MELoop::MELoop
MELoop(const MELoop &)
Invalidated copy constructor.
MELoop::getSegmentForEdge
MESegment * getSegmentForEdge(const MSEdge &e, double pos=0)
Get the segment for a given edge at a given position.
Definition: MELoop.cpp:292
MELoop::vaporizeCar
void vaporizeCar(MEVehicle *v)
remove the given car and clean up the relevant data structures
Definition: MELoop.cpp:223
MELoop::myLinkRecheckInterval
const SUMOTime myLinkRecheckInterval
the interval at which to recheck at blocked junctions (<=0 means asap)
Definition: MELoop.h:154
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:89
MSEdge
A road/street connecting two junctions.
Definition: MSEdge.h:78
MELoop::myLeaderCars
std::map< SUMOTime, std::vector< MEVehicle * > > myLeaderCars
leader cars in the segments sorted by exit time
Definition: MELoop.h:145
MELoop::isEnteringRoundabout
static bool isEnteringRoundabout(const MSEdge &e)
whether the given edge is entering a roundabout
Definition: MELoop.cpp:309
MELoop::setApproaching
static void setApproaching(MEVehicle *veh, MSLink *link)
registers vehicle with the given link
Definition: MELoop.cpp:204
MELoop::teleportVehicle
void teleportVehicle(MEVehicle *veh, MESegment *const toSegment)
teleports a vehicle or continues a teleport
Definition: MELoop.cpp:145
MELoop::~MELoop
~MELoop()
Definition: MELoop.cpp:50
MELoop::buildSegmentsFor
void buildSegmentsFor(const MSEdge &e, const OptionsCont &oc)
Build the segments for a given edge.
Definition: MELoop.cpp:264
config.h
MSVehicleControl
The class responsible for building and deletion of vehicles.
Definition: MSVehicleControl.h:71
MELoop::numSegmentsFor
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:253
MELoop::simulate
void simulate(SUMOTime tMax)
Perform simulation up to the given time.
Definition: MELoop.cpp:62
MELoop::operator=
MELoop & operator=(const MELoop &)
Invalidated assignment operator.
MELoop::checkCar
void checkCar(MEVehicle *veh)
Check whether the vehicle may move.
Definition: MELoop.cpp:111
BinaryInputDevice
Encapsulates binary reading operations on a file.
Definition: BinaryInputDevice.h:57
MELoop::removeLeaderCar
void removeLeaderCar(MEVehicle *v)
Removes the given car from the leading vehicles.
Definition: MELoop.cpp:217