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, SUMOReal 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 SUMOReal length, const SUMOReal 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::MELoop ( const SUMOTime  recheckInterval)

SUMO constructor.

Definition at line 58 of file MELoop.cpp.

MELoop::~MELoop ( )

Definition at line 61 of file MELoop.cpp.

References MESegment::getNextSegment(), and myEdges2FirstSegments.

MELoop::MELoop ( const MELoop )
private

Invalidated copy constructor.

Member Function Documentation

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 208 of file MELoop.cpp.

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

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

void MELoop::buildSegmentsFor ( const MSEdge e,
const OptionsCont oc 
)
bool MELoop::changeSegment ( MEVehicle veh,
SUMOTime  leaveTime,
MESegment *const  toSegment,
const bool  ignoreLink = false 
)
void MELoop::checkCar ( MEVehicle veh)
private
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 235 of file MELoop.cpp.

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

Referenced by buildSegmentsFor(), and checkCar().

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

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

Definition at line 254 of file MELoop.cpp.

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

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

Invalidated assignment operator.

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 228 of file MELoop.cpp.

References MEVehicle::getEventTime(), and myLeaderCars.

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

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 215 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().

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 73 of file MELoop.cpp.

References checkCar(), DELTA_T, and myLeaderCars.

Referenced by MSNet::simulationStep().

Field Documentation

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().

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().

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().

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: