Eclipse SUMO - Simulation of Urban MObility
|
The main mesocopic simulation loop. More...
#include <MELoop.h>
Public Member Functions | |
void | addLeaderCar (MEVehicle *veh, MSLink *link) |
Adds the given car to the leading vehicles. | |
void | buildSegmentsFor (const MSEdge &e, const OptionsCont &oc) |
Build the segments for a given edge. | |
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 route) and (leaving segment / finishing teleport) | |
void | clearState () |
Remove all vehicles before quick-loading state. | |
MESegment * | getSegmentForEdge (const MSEdge &e, double pos=0) |
Get the segment for a given edge at a given position. | |
MELoop (const SUMOTime recheckInterval) | |
SUMO constructor. | |
bool | removeLeaderCar (MEVehicle *v) |
Removes the given car from the leading vehicles. | |
void | simulate (SUMOTime tMax) |
Perform simulation up to the given time. | |
void | updateSegmentsForEdge (const MSEdge &e) |
Update segments after loading meso edge type parameters from additional file. | |
void | vaporizeCar (MEVehicle *v, MSMoveReminder::Notification reason) |
remove the given car and clean up the relevant data structures | |
~MELoop () | |
Static Public Member Functions | |
static bool | isEnteringRoundabout (const MSEdge &e) |
whether the given edge is entering a roundabout | |
static int | numSegmentsFor (const double length, const double slength) |
Compute number of segments per edge (best value stay close to the configured segment length) | |
Private Member Functions | |
void | checkCar (MEVehicle *veh) |
Check whether the vehicle may move. | |
MELoop (const MELoop &) | |
Invalidated copy constructor. | |
MESegment * | nextSegment (MESegment *s, MEVehicle *v) |
Retrieve next segment. | |
MELoop & | operator= (const MELoop &) |
Invalidated assignment operator. | |
void | teleportVehicle (MEVehicle *veh, MESegment *const toSegment) |
teleports a vehicle or continues a teleport | |
Private Attributes | |
std::vector< MESegment * > | myEdges2FirstSegments |
mapping from internal edge ids to their initial segments | |
const SUMOTime | myFullRecheckInterval |
the interval at which to recheck at full segments (<=0 means asap) | |
std::map< SUMOTime, std::vector< MEVehicle * > > | myLeaderCars |
leader cars in the segments sorted by exit time | |
const SUMOTime | myLinkRecheckInterval |
the interval at which to recheck at blocked junctions (<=0 means asap) | |
MELoop::MELoop | ( | const SUMOTime | recheckInterval | ) |
SUMO constructor.
Definition at line 46 of file MELoop.cpp.
MELoop::~MELoop | ( | ) |
Definition at line 49 of file MELoop.cpp.
References MESegment::getNextSegment(), and myEdges2FirstSegments.
|
private |
Invalidated copy constructor.
Adds the given car to the leading vehicles.
[in] | veh | the car which became a leading one |
[in] | link | the link on which the car shall register its approach |
Definition at line 231 of file MELoop.cpp.
References MEVehicle::getEventTime(), myLeaderCars, and MEVehicle::setApproaching().
Referenced by checkCar(), MESegment::loadState(), MEVehicle::loadState(), MESegment::receive(), MEVehicle::resumeFromStopping(), MESegment::send(), MESegment::setSpeedForQueue(), and teleportVehicle().
void MELoop::buildSegmentsFor | ( | const MSEdge & | e, |
const OptionsCont & | oc | ||
) |
Build the segments for a given edge.
[in] | e | the edge to build for |
Definition at line 297 of file MELoop.cpp.
References OptionsCont::getBool(), MSEdge::getEdgeType(), OptionsCont::getFloat(), Named::getID(), MSNet::getInstance(), MSEdge::getLanes(), MSEdge::getLength(), MSNet::getMesoType(), MSEdge::getNumericalID(), MSEdge::getNumSuccessors(), myEdges2FirstSegments, nextSegment(), numSegmentsFor(), and toString().
Referenced by NLEdgeControlBuilder::build().
SUMOTime MELoop::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 route) and (leaving segment / finishing teleport)
Definition at line 79 of file MELoop.cpp.
References MESegment::getEdge(), MSBaseVehicle::getEdge(), Named::getID(), MESegment::getIndex(), MSNet::getInstance(), MSEdge::getLanes(), MEVehicle::getLastEntryTime(), MESegment::getNextSegment(), MSEdge::getNumericalID(), MEVehicle::getQueIndex(), MEVehicle::getSegment(), MSNet::getVehicleControl(), MESegment::hasSpaceFor(), MESegment::isInvalid(), MSBaseVehicle::isParking(), MSBaseVehicle::isStoppedTriggered(), MAX2(), MEVehicle::mayProceed(), myEdges2FirstSegments, myLinkRecheckInterval, MSMoveReminder::NOTIFICATION_JUNCTION, MSMoveReminder::NOTIFICATION_SEGMENT, MSMoveReminder::NOTIFICATION_TELEPORT, MESegment::PARKING_QUEUE, MEVehicle::processStop(), MESegment::receive(), MSVehicleControl::scheduleVehicleRemoval(), MESegment::send(), MEVehicle::setSegment(), time2string(), TL, MEVehicle::updateDetectors(), and WRITE_WARNINGF.
Referenced by checkCar(), MEVehicle::onRemovalFromNet(), teleportVehicle(), and MESegment::vaporizeAnyCar().
|
private |
Check whether the vehicle may move.
This method is called when the vehicle reaches its event time and checks whether it may proceed to the next segment.
[in] | veh | The vehicle to check |
Definition at line 129 of file MELoop.cpp.
References addLeaderCar(), MSEdge::allowedLanes(), changeSegment(), DELTA_T, MEVehicle::getBlockTime(), MSBaseVehicle::getEdge(), MESegment::getEventTime(), MEVehicle::getEventTime(), MESegment::getLink(), MEVehicle::getQueIndex(), MEVehicle::getSegment(), MSBaseVehicle::getVClass(), MEVehicle::getWaitingTime(), MSGlobals::gTimeToGridlock, MSGlobals::gTimeToTeleportDisconnected, MSBaseVehicle::isStopped(), MAX2(), MAX3(), MIN2(), myFullRecheckInterval, nextSegment(), MSMoveReminder::NOTIFICATION_ARRIVED, MESegment::PARKING_QUEUE, MEVehicle::setBlockTime(), MEVehicle::setEventTime(), MSBaseVehicle::succEdge(), SUMOTime_MAX, and teleportVehicle().
Referenced by simulate().
void MELoop::clearState | ( | ) |
Remove all vehicles before quick-loading state.
Definition at line 238 of file MELoop.cpp.
References myLeaderCars.
Referenced by MSNet::clearState().
Get the segment for a given edge at a given position.
[in] | e | the edge to get the segment for |
[in] | pos | the position to get the segment for |
Definition at line 333 of file MELoop.cpp.
References MESegment::getLength(), MESegment::getNextSegment(), MSEdge::getNumericalID(), and myEdges2FirstSegments.
Referenced by MSBaseVehicle::addStop(), NLTriggerBuilder::buildMECalibrator(), MSDriveWay::buildRoute(), GUIEdge::getSegmentAtPosition(), MSIdling_Stop::idle(), MSMeanData::init(), MSBaseVehicle::insertStop(), MSEdge::insertVehicle(), MESegment::limitedControlOverride(), MEVehicle::loadState(), MSRouteProbe::MSRouteProbe(), MSTriggeredRerouter::MSTriggeredRerouter(), MSStateHandler::myStartElement(), MSBaseVehicle::replaceStop(), MSMeanData::resetOnly(), MSLane::setMaxSpeed(), teleportVehicle(), MSMeanData::writeAggregated(), MSMeanData::writeEdge(), and MSXMLRawOut::writeEdge().
|
static |
whether the given edge is entering a roundabout
Definition at line 350 of file MELoop.cpp.
References MSEdge::getSuccessors().
Referenced by MESegment::initSegment().
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.
[in] | s | The segment the vehicle is currently at |
[in] | v | The vehicle to get the next segment for |
Definition at line 267 of file MELoop.cpp.
References MESegment::getNextSegment(), MSEdge::getNumericalID(), myEdges2FirstSegments, and MSBaseVehicle::succEdge().
Referenced by buildSegmentsFor(), and checkCar().
|
static |
Compute number of segments per edge (best value stay close to the configured segment length)
Definition at line 286 of file MELoop.cpp.
Referenced by buildSegmentsFor(), and GUILane::splitAtSegments().
bool MELoop::removeLeaderCar | ( | MEVehicle * | v | ) |
Removes the given car from the leading vehicles.
[in] | v | the car which was a leading one |
Definition at line 244 of file MELoop.cpp.
References MEVehicle::getEventTime(), and myLeaderCars.
Referenced by MEVehicle::onRemovalFromNet(), MESegment::receive(), MESegment::setSpeedForQueue(), MESegment::vaporizeAnyCar(), and vaporizeCar().
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.
[in] | tMax | the end time for the sim step |
Definition at line 61 of file MELoop.cpp.
References checkCar(), DELTA_T, and myLeaderCars.
Referenced by MSNet::simulationStep().
teleports a vehicle or continues a teleport
[in] | veh | The vehicle to teleport |
[in] | toSegment | The first segment where the vehicle may reenter the network |
Definition at line 171 of file MELoop.cpp.
References MSBaseVehicle::activateReminders(), addLeaderCar(), MESegment::addReminders(), changeSegment(), MESegment::getEdge(), MSBaseVehicle::getEdge(), MEVehicle::getEventTime(), Named::getID(), MESegment::getIndex(), MSNet::getInstance(), MSEdge::getLength(), MESegment::getNextSegment(), MEVehicle::getSegment(), getSegmentForEdge(), MSEdge::getSpeedLimit(), MSNet::getVehicleControl(), MSGlobals::gRemoveGridlocked, MAX2(), MEVehicle::moveRoutePointer(), MSMoveReminder::NOTIFICATION_JUNCTION, MSMoveReminder::NOTIFICATION_TELEPORT, MSMoveReminder::NOTIFICATION_TELEPORT_ARRIVED, MSVehicleControl::registerTeleportJam(), MSVehicleControl::scheduleVehicleRemoval(), MESegment::send(), MEVehicle::setEventTime(), MEVehicle::setSegment(), TIME2STEPS, time2string(), TL, and WRITE_WARNINGF.
Referenced by checkCar().
void MELoop::updateSegmentsForEdge | ( | const MSEdge & | e | ) |
Update segments after loading meso edge type parameters from additional file.
[in] | e | the edge to update |
Definition at line 320 of file MELoop.cpp.
References MESegment::getCapacity(), MSEdge::getEdgeType(), MSNet::getInstance(), MSNet::getMesoType(), MESegment::getNextSegment(), MSEdge::getNumericalID(), MESegment::initSegment(), and myEdges2FirstSegments.
Referenced by MSEdge::updateMesoType().
void MELoop::vaporizeCar | ( | MEVehicle * | v, |
MSMoveReminder::Notification | reason | ||
) |
remove the given car and clean up the relevant data structures
Definition at line 259 of file MELoop.cpp.
References MSNet::getInstance(), MEVehicle::getSegment(), removeLeaderCar(), and MESegment::send().
Referenced by GUIBaseVehicle::GUIBaseVehiclePopupMenu::onCmdRemoveObject().
|
private |
mapping from internal edge ids to their initial segments
Definition at line 149 of file MELoop.h.
Referenced by buildSegmentsFor(), changeSegment(), getSegmentForEdge(), nextSegment(), updateSegmentsForEdge(), and ~MELoop().
|
private |
the interval at which to recheck at full segments (<=0 means asap)
Definition at line 152 of file MELoop.h.
Referenced by checkCar().
leader cars in the segments sorted by exit time
Definition at line 146 of file MELoop.h.
Referenced by addLeaderCar(), clearState(), removeLeaderCar(), and simulate().
|
private |
the interval at which to recheck at blocked junctions (<=0 means asap)
Definition at line 155 of file MELoop.h.
Referenced by changeSegment().