SUMO - Simulation of Urban MObility
MELoop Class Reference

The main mesocopic simulation loop. More...

#include <MELoop.h>

Collaboration diagram for MELoop:
Collaboration graph

Public Member Functions

void addLeaderCar (MEVehicle *veh, MSLink *link)
 Adds the given car to the leading vehicles. More...
 
void buildSegmentsFor (const MSEdge &e, const OptionsCont &oc)
 Build the segments for a given edge. More...
 
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 route) and (leaving segment / finishing teleport) More...
 
MESegmentgetSegmentForEdge (const MSEdge &e, double pos=0)
 Get the segment for a given edge at a given position. More...
 
 MELoop (const SUMOTime recheckInterval)
 SUMO constructor. More...
 
void removeLeaderCar (MEVehicle *v)
 Removes the given car from the leading vehicles. More...
 
void simulate (SUMOTime tMax)
 Perform simulation up to the given time. More...
 
 ~MELoop ()
 

Static Public Member Functions

static int numSegmentsFor (const double length, const double slength)
 Compute number of segments per edge (best value stay close to the configured segment length) More...
 
static void setApproaching (MEVehicle *veh, MSLink *link)
 registers vehicle with the given link More...
 

Private Member Functions

void checkCar (MEVehicle *veh)
 Check whether the vehicle may move. More...
 
 MELoop (const MELoop &)
 Invalidated copy constructor. More...
 
MESegmentnextSegment (MESegment *s, MEVehicle *v)
 Retrieve next segment. More...
 
MELoopoperator= (const MELoop &)
 Invalidated assignment operator. More...
 
void teleportVehicle (MEVehicle *veh, MESegment *const toSegment)
 teleports a vehicle or continues a teleport More...
 

Private Attributes

std::vector< MESegment * > myEdges2FirstSegments
 mapping from internal edge ids to their initial segments More...
 
const SUMOTime myFullRecheckInterval
 the interval at which to recheck at full segments (<=0 means asap) More...
 
std::map< SUMOTime, std::vector< MEVehicle * > > myLeaderCars
 leader cars in the segments sorted by exit time More...
 
const SUMOTime myLinkRecheckInterval
 the interval at which to recheck at blocked junctions (<=0 means asap) More...
 

Detailed Description

The main mesocopic simulation loop.

Definition at line 56 of file MELoop.h.

Constructor & Destructor Documentation

◆ MELoop() [1/2]

MELoop::MELoop ( const SUMOTime  recheckInterval)

SUMO constructor.

Definition at line 54 of file MELoop.cpp.

◆ ~MELoop()

MELoop::~MELoop ( )

Definition at line 57 of file MELoop.cpp.

References MESegment::getNextSegment(), and myEdges2FirstSegments.

◆ MELoop() [2/2]

MELoop::MELoop ( const MELoop )
private

Invalidated copy constructor.

Member Function Documentation

◆ addLeaderCar()

void MELoop::addLeaderCar ( MEVehicle veh,
MSLink link 
)

Adds the given car to the leading vehicles.

Parameters
[in]vehthe car which became a leading one
[in]linkthe link on which the car shall register its approach

Definition at line 204 of file MELoop.cpp.

References MEVehicle::getEventTime(), myLeaderCars, and setApproaching().

Referenced by checkCar(), MESegment::loadState(), MEVehicle::loadState(), MESegment::receive(), MESegment::send(), MESegment::setSpeedForQueue(), and teleportVehicle().

◆ buildSegmentsFor()

void MELoop::buildSegmentsFor ( const MSEdge e,
const OptionsCont oc 
)

◆ changeSegment()

bool MELoop::changeSegment ( MEVehicle veh,
SUMOTime  leaveTime,
MESegment *const  toSegment,
const bool  ignoreLink = false 
)

◆ checkCar()

void MELoop::checkCar ( MEVehicle veh)
private

◆ getSegmentForEdge()

◆ nextSegment()

MESegment * MELoop::nextSegment ( MESegment s,
MEVehicle v 
)
private

Retrieve next segment.

If the segment is not the last on the current edge, its successor is returned. Otherwise, the first segment of the edge at which the vehicle continues his journey is returned.

Parameters
[in]sThe segment the vehicle is currently at
[in]vThe vehicle to get the next segment for
Returns
The vehicle's next segment
Todo:
Recheck the "quick and dirty" stuff (
See also
MESegment::saveState,
MESegment::loadState)

Definition at line 231 of file MELoop.cpp.

References MESegment::getNextSegment(), MSEdge::getNumericalID(), myEdges2FirstSegments, and MSBaseVehicle::succEdge().

Referenced by buildSegmentsFor(), and checkCar().

◆ numSegmentsFor()

int MELoop::numSegmentsFor ( const double  length,
const double  slength 
)
static

Compute number of segments per edge (best value stay close to the configured segment length)

Definition at line 250 of file MELoop.cpp.

Referenced by buildSegmentsFor(), and GUILane::splitAtSegments().

◆ operator=()

MELoop& MELoop::operator= ( const MELoop )
private

Invalidated assignment operator.

◆ removeLeaderCar()

void MELoop::removeLeaderCar ( MEVehicle v)

Removes the given car from the leading vehicles.

Parameters
[in]vthe car which was a leading one

Definition at line 224 of file MELoop.cpp.

References MEVehicle::getEventTime(), and myLeaderCars.

Referenced by MESegment::receive(), MESegment::setSpeedForQueue(), and MESegment::vaporizeAnyCar().

◆ setApproaching()

void MELoop::setApproaching ( MEVehicle veh,
MSLink link 
)
static

registers vehicle with the given link

Parameters
[in]vehthe car to register
[in]linkthe link on which the car shall register its approach

Definition at line 211 of file MELoop.cpp.

References MEVehicle::getEventTime(), MESegment::getLength(), MEVehicle::getSegment(), MEVehicle::getSpeed(), MSLink::getState(), MEVehicle::getWaitingTime(), LINKSTATE_ALLWAY_STOP, RandHelper::rand(), and MSLink::setApproaching().

Referenced by addLeaderCar(), and MEVehicle::replaceRoute().

◆ simulate()

void MELoop::simulate ( SUMOTime  tMax)

Perform simulation up to the given time.

Checks all vehicles with an event time less or equal than the given time.

Parameters
[in]tMaxthe end time for the sim step

Definition at line 69 of file MELoop.cpp.

References checkCar(), DELTA_T, and myLeaderCars.

Referenced by MSNet::simulationStep().

◆ teleportVehicle()

Field Documentation

◆ myEdges2FirstSegments

std::vector<MESegment*> MELoop::myEdges2FirstSegments
private

mapping from internal edge ids to their initial segments

Definition at line 150 of file MELoop.h.

Referenced by buildSegmentsFor(), changeSegment(), getSegmentForEdge(), nextSegment(), and ~MELoop().

◆ myFullRecheckInterval

const SUMOTime MELoop::myFullRecheckInterval
private

the interval at which to recheck at full segments (<=0 means asap)

Definition at line 153 of file MELoop.h.

Referenced by checkCar().

◆ myLeaderCars

std::map<SUMOTime, std::vector<MEVehicle*> > MELoop::myLeaderCars
private

leader cars in the segments sorted by exit time

Definition at line 147 of file MELoop.h.

Referenced by addLeaderCar(), removeLeaderCar(), and simulate().

◆ myLinkRecheckInterval

const SUMOTime MELoop::myLinkRecheckInterval
private

the interval at which to recheck at blocked junctions (<=0 means asap)

Definition at line 156 of file MELoop.h.

Referenced by checkCar().


The documentation for this class was generated from the following files: