SUMO - Simulation of Urban MObility
MELoop.h
Go to the documentation of this file.
1 /****************************************************************************/
7 // The main mesocopic simulation loop
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 #ifndef MELoop_h
21 #define MELoop_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <vector>
34 #include <map>
35 
36 
37 // ===========================================================================
38 // class declarations
39 // ===========================================================================
40 class MESegment;
41 class MEVehicle;
42 class MSEdge;
43 class MSLink;
44 class MSVehicleControl;
45 class BinaryInputDevice;
46 class OptionsCont;
47 
48 
49 // ===========================================================================
50 // class definitions
51 // ===========================================================================
56 class MELoop {
57 public:
59  MELoop(const SUMOTime recheckInterval);
60 
61  ~MELoop();
62 
69  void simulate(SUMOTime tMax);
70 
76  void addLeaderCar(MEVehicle* veh, MSLink* link);
77 
82  void removeLeaderCar(MEVehicle* v);
83 
85  static int numSegmentsFor(const double length, const double slength);
86 
91  void buildSegmentsFor(const MSEdge& e, const OptionsCont& oc);
92 
99  MESegment* getSegmentForEdge(const MSEdge& e, double pos = 0);
100 
105  bool changeSegment(MEVehicle* veh, SUMOTime leaveTime, MESegment* const toSegment, const bool ignoreLink = false);
106 
112  static void setApproaching(MEVehicle* veh, MSLink* link);
113 
114 
115 private:
123  void checkCar(MEVehicle* veh);
124 
137 
138 
143  void teleportVehicle(MEVehicle* veh, MESegment* const toSegment);
144 
145 private:
147  std::map<SUMOTime, std::vector<MEVehicle*> > myLeaderCars;
148 
150  std::vector<MESegment*> myEdges2FirstSegments;
151 
154 
157 
158 private:
160  MELoop(const MELoop&);
161 
163  MELoop& operator=(const MELoop&);
164 };
165 
166 
167 #endif
168 
169 /****************************************************************************/
170 
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:52
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:153
std::vector< MESegment * > myEdges2FirstSegments
mapping from internal edge ids to their initial segments
Definition: MELoop.h:150
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:56
std::map< SUMOTime, std::vector< MEVehicle * > > myLeaderCars
leader cars in the segments sorted by exit time
Definition: MELoop.h:147
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:57
A storage for options typed value containers)
Definition: OptionsCont.h:99
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:156
void checkCar(MEVehicle *veh)
Check whether the vehicle may move.
Definition: MELoop.cpp:118
long long int SUMOTime
Definition: TraCIDefs.h:52
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