Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MELoop.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 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>
27
28
29// ===========================================================================
30// class declarations
31// ===========================================================================
32class MESegment;
33class MEVehicle;
34class MSEdge;
35class MSLink;
37class OptionsCont;
38
39
40// ===========================================================================
41// class definitions
42// ===========================================================================
47class MELoop {
48public:
50 MELoop(const SUMOTime recheckInterval);
51
52 ~MELoop();
53
60 void simulate(SUMOTime tMax);
61
67 void addLeaderCar(MEVehicle* veh, MSLink* link);
68
74
77
79 static bool isEnteringRoundabout(const MSEdge& e);
80
82 static int numSegmentsFor(const double length, const double slength);
83
88 void buildSegmentsFor(const MSEdge& e, const OptionsCont& oc);
89
94 void updateSegmentsForEdge(const MSEdge& e);
95
102 MESegment* getSegmentForEdge(const MSEdge& e, double pos = 0);
103
108 SUMOTime changeSegment(MEVehicle* veh, SUMOTime leaveTime, MESegment* const toSegment,
109 MSMoveReminder::Notification reason, const bool ignoreLink = false) const;
110
112 void clearState();
113
114private:
122 void checkCar(MEVehicle* veh);
123
136
137
142 void teleportVehicle(MEVehicle* veh, MESegment* const toSegment, bool disconnected);
143
144private:
146 std::map<SUMOTime, std::vector<MEVehicle*> > myLeaderCars;
147
149 std::vector<MESegment*> myEdges2FirstSegments;
150
153
156
157private:
159 MELoop(const MELoop&);
160
163};
long long int SUMOTime
Definition GUI.h:36
The main mesocopic simulation loop.
Definition MELoop.h:47
MESegment * nextSegment(MESegment *s, MEVehicle *v)
Retrieve next segment.
Definition MELoop.cpp:274
static bool isEnteringRoundabout(const MSEdge &e)
whether the given edge is entering a roundabout
Definition MELoop.cpp:357
MELoop(const MELoop &)
Invalidated copy constructor.
void updateSegmentsForEdge(const MSEdge &e)
Update segments after loading meso edge type parameters from additional file.
Definition MELoop.cpp:327
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:340
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 simulate(SUMOTime tMax)
Perform simulation up to the given time.
Definition MELoop.cpp:61
bool removeLeaderCar(MEVehicle *v)
Removes the given car from the leading vehicles.
Definition MELoop.cpp:251
const SUMOTime myFullRecheckInterval
the interval at which to recheck at full segments (<=0 means asap)
Definition MELoop.h:152
void vaporizeCar(MEVehicle *v, MSMoveReminder::Notification reason)
remove the given car and clean up the relevant data structures
Definition MELoop.cpp:266
void addLeaderCar(MEVehicle *veh, MSLink *link)
Adds the given car to the leading vehicles.
Definition MELoop.cpp:238
void clearState()
Remove all vehicles before quick-loading state.
Definition MELoop.cpp:245
std::vector< MESegment * > myEdges2FirstSegments
mapping from internal edge ids to their initial segments
Definition MELoop.h:149
std::map< SUMOTime, std::vector< MEVehicle * > > myLeaderCars
leader cars in the segments sorted by exit time
Definition MELoop.h:146
~MELoop()
Definition MELoop.cpp:49
void checkCar(MEVehicle *veh)
Check whether the vehicle may move.
Definition MELoop.cpp:135
void teleportVehicle(MEVehicle *veh, MESegment *const toSegment, bool disconnected)
teleports a vehicle or continues a teleport
Definition MELoop.cpp:177
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:293
void buildSegmentsFor(const MSEdge &e, const OptionsCont &oc)
Build the segments for a given edge.
Definition MELoop.cpp:304
A single mesoscopic segment (cell)
Definition MESegment.h:49
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