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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // The main mesocopic simulation loop
18 /****************************************************************************/
19 #ifndef MELoop_h
20 #define MELoop_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include <vector>
33 #include <map>
34 
35 
36 // ===========================================================================
37 // class declarations
38 // ===========================================================================
39 class MESegment;
40 class MEVehicle;
41 class MSEdge;
42 class MSLink;
43 class MSVehicleControl;
44 class BinaryInputDevice;
45 class OptionsCont;
46 
47 
48 // ===========================================================================
49 // class definitions
50 // ===========================================================================
55 class MELoop {
56 public:
58  MELoop(const SUMOTime recheckInterval);
59 
60  ~MELoop();
61 
68  void simulate(SUMOTime tMax);
69 
75  void addLeaderCar(MEVehicle* veh, MSLink* link);
76 
81  void removeLeaderCar(MEVehicle* v);
82 
84  static int numSegmentsFor(const double length, const double slength);
85 
90  void buildSegmentsFor(const MSEdge& e, const OptionsCont& oc);
91 
98  MESegment* getSegmentForEdge(const MSEdge& e, double pos = 0);
99 
104  bool changeSegment(MEVehicle* veh, SUMOTime leaveTime, MESegment* const toSegment, const bool ignoreLink = false);
105 
111  static void setApproaching(MEVehicle* veh, MSLink* link);
112 
113 
114 private:
122  void checkCar(MEVehicle* veh);
123 
136 
137 
142  void teleportVehicle(MEVehicle* veh, MESegment* const toSegment);
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 
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:87
MELoop(const SUMOTime recheckInterval)
SUMO constructor.
Definition: MELoop.cpp:54
MESegment * nextSegment(MESegment *s, MEVehicle *v)
Retrieve next segment.
Definition: MELoop.cpp:231
A vehicle from the mesoscopic point of view.
Definition: MEVehicle.h:51
MESegment * getSegmentForEdge(const MSEdge &e, double pos=0)
Get the segment for a given edge at a given position.
Definition: MELoop.cpp:289
~MELoop()
Definition: MELoop.cpp:57
const SUMOTime myFullRecheckInterval
the interval at which to recheck at full segments (<=0 means asap)
Definition: MELoop.h:152
std::vector< MESegment * > myEdges2FirstSegments
mapping from internal edge ids to their initial segments
Definition: MELoop.h:149
void buildSegmentsFor(const MSEdge &e, const OptionsCont &oc)
Build the segments for a given edge.
Definition: MELoop.cpp:261
void teleportVehicle(MEVehicle *veh, MESegment *const toSegment)
teleports a vehicle or continues a teleport
Definition: MELoop.cpp:152
void removeLeaderCar(MEVehicle *v)
Removes the given car from the leading vehicles.
Definition: MELoop.cpp:224
A road/street connecting two junctions.
Definition: MSEdge.h:80
The main mesocopic simulation loop.
Definition: MELoop.h:55
std::map< SUMOTime, std::vector< MEVehicle * > > myLeaderCars
leader cars in the segments sorted by exit time
Definition: MELoop.h:146
static void setApproaching(MEVehicle *veh, MSLink *link)
registers vehicle with the given link
Definition: MELoop.cpp:211
A single mesoscopic segment (cell)
Definition: MESegment.h:56
A storage for options typed value containers)
Definition: OptionsCont.h:98
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:155
void checkCar(MEVehicle *veh)
Check whether the vehicle may move.
Definition: MELoop.cpp:118
long long int SUMOTime
Definition: TraCIDefs.h:51
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:250
void simulate(SUMOTime tMax)
Perform simulation up to the given time.
Definition: MELoop.cpp:69
Encapsulates binary reading operations on a file.
void addLeaderCar(MEVehicle *veh, MSLink *link)
Adds the given car to the leading vehicles.
Definition: MELoop.cpp:204