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 /****************************************************************************/
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  void vaporizeCar(MEVehicle* v);
79 
81  static int numSegmentsFor(const double length, const double slength);
82 
87  void buildSegmentsFor(const MSEdge& e, const OptionsCont& oc);
88 
95  MESegment* getSegmentForEdge(const MSEdge& e, double pos = 0);
96 
101  bool changeSegment(MEVehicle* veh, SUMOTime leaveTime, MESegment* const toSegment, const bool ignoreLink = false);
102 
108  static void setApproaching(MEVehicle* veh, MSLink* link);
109 
110 
111 private:
119  void checkCar(MEVehicle* veh);
120 
133 
134 
139  void teleportVehicle(MEVehicle* veh, MESegment* const toSegment);
140 
142  static bool isEnteringRoundabout(const MSEdge& e);
143 
144 private:
146  std::map<SUMOTime, std::vector<MEVehicle*> > myLeaderCars;
147 
149  std::vector<MESegment*> myEdges2FirstSegments;
150 
153 
156 
157 private:
159  MELoop(const MELoop&);
160 
162  MELoop& operator=(const MELoop&);
163 };
164 
165 
166 #endif
167 
168 /****************************************************************************/
169 
MELoop::myFullRecheckInterval
const SUMOTime myFullRecheckInterval
the interval at which to recheck at full segments (<=0 means asap)
Definition: MELoop.h:152
MEVehicle
A vehicle from the mesoscopic point of view.
Definition: MEVehicle.h:45
MELoop::MELoop
MELoop(const SUMOTime recheckInterval)
SUMO constructor.
Definition: MELoop.cpp:48
MESegment
A single mesoscopic segment (cell)
Definition: MESegment.h:50
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:81
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
MELoop::myEdges2FirstSegments
std::vector< MESegment * > myEdges2FirstSegments
mapping from internal edge ids to their initial segments
Definition: MELoop.h:149
MELoop::addLeaderCar
void addLeaderCar(MEVehicle *veh, MSLink *link)
Adds the given car to the leading vehicles.
Definition: MELoop.cpp:198
MELoop
The main mesocopic simulation loop.
Definition: MELoop.h:49
MELoop::nextSegment
MESegment * nextSegment(MESegment *s, MEVehicle *v)
Retrieve next segment.
Definition: MELoop.cpp:235
MELoop::getSegmentForEdge
MESegment * getSegmentForEdge(const MSEdge &e, double pos=0)
Get the segment for a given edge at a given position.
Definition: MELoop.cpp:293
MELoop::vaporizeCar
void vaporizeCar(MEVehicle *v)
remove the given car and clean up the relevant data structures
Definition: MELoop.cpp:224
MELoop::myLinkRecheckInterval
const SUMOTime myLinkRecheckInterval
the interval at which to recheck at blocked junctions (<=0 means asap)
Definition: MELoop.h:155
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:90
MSEdge
A road/street connecting two junctions.
Definition: MSEdge.h:76
MELoop::myLeaderCars
std::map< SUMOTime, std::vector< MEVehicle * > > myLeaderCars
leader cars in the segments sorted by exit time
Definition: MELoop.h:146
MELoop::isEnteringRoundabout
static bool isEnteringRoundabout(const MSEdge &e)
whether the given edge is entering a roundabout
Definition: MELoop.cpp:310
MELoop::setApproaching
static void setApproaching(MEVehicle *veh, MSLink *link)
registers vehicle with the given link
Definition: MELoop.cpp:205
MELoop::teleportVehicle
void teleportVehicle(MEVehicle *veh, MESegment *const toSegment)
teleports a vehicle or continues a teleport
Definition: MELoop.cpp:146
MELoop::~MELoop
~MELoop()
Definition: MELoop.cpp:51
MELoop::buildSegmentsFor
void buildSegmentsFor(const MSEdge &e, const OptionsCont &oc)
Build the segments for a given edge.
Definition: MELoop.cpp:265
config.h
MSVehicleControl
The class responsible for building and deletion of vehicles.
Definition: MSVehicleControl.h:72
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:254
MELoop::simulate
void simulate(SUMOTime tMax)
Perform simulation up to the given time.
Definition: MELoop.cpp:63
MELoop::operator=
MELoop & operator=(const MELoop &)
Invalidated assignment operator.
MELoop::checkCar
void checkCar(MEVehicle *veh)
Check whether the vehicle may move.
Definition: MELoop.cpp:112
BinaryInputDevice
Encapsulates binary reading operations on a file.
Definition: BinaryInputDevice.h:58
MELoop::removeLeaderCar
void removeLeaderCar(MEVehicle *v)
Removes the given car from the leading vehicles.
Definition: MELoop.cpp:218