![]() |
Eclipse SUMO - Simulation of Urban MObility
|
The main mesocopic simulation loop. More...
#include <MELoop.h>
Data Structures | |
| struct | LeaderEvent |
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. | |
| void | removeLeaderCar (MEVehicle *v) |
| Removes the given car from the leading vehicles. | |
| void | simulate (SUMOTime tMax) |
| Perform simulation up to the given time. | |
| 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 Types | |
| typedef std::priority_queue< LeaderEvent > | LeaderEventQeue |
| leader cars in the segments sorted by exit time | |
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, bool disconnected) |
| teleports a vehicle or continues a teleport | |
| bool | wasInvalidated (const LeaderEvent &e) |
| check whether the current car was invalidated and remove it from myInvalidatedLeaderCars | |
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) | |
| LeaderEventQeue | myInvalidatedLeaderCars |
| LeaderEventQeue | myLeaderCars |
| const SUMOTime | myLinkRecheckInterval |
| the interval at which to recheck at blocked junctions (<=0 means asap) | |
|
private |
| MELoop::MELoop | ( | const SUMOTime | recheckInterval | ) |
SUMO constructor.
Definition at line 48 of file MELoop.cpp.
| MELoop::~MELoop | ( | ) |
Definition at line 51 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 291 of file MELoop.cpp.
References 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 355 of file MELoop.cpp.
References MESegment::MesoEdgeType::edgeLength, OptionsCont::getBool(), MSEdge::getEdgeType(), Named::getID(), MSNet::getInstance(), MSEdge::getLanes(), MSEdge::getLength(), MSNet::getMesoType(), MSEdge::getNumericalID(), MSEdge::getNumSuccessors(), myEdges2FirstSegments, nextSegment(), numSegmentsFor(), and toString().
Referenced by MSEdgeControl::buildMesoSegments().
| 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 114 of file MELoop.cpp.
References MSEdge::allowedLanes(), MEVehicle::endTriggeredStop(), MSGlobals::gCheckRoutes, MEVehicle::getBlockTime(), MESegment::getEdge(), MSBaseVehicle::getEdge(), MEVehicle::getEventTime(), Named::getID(), MESegment::getIndex(), MSNet::getInstance(), MSEdge::getLanes(), MEVehicle::getLastEntryTime(), MESegment::getNextSegment(), MSEdge::getNumericalID(), MEVehicle::getQueIndex(), MEVehicle::getSegment(), MSBaseVehicle::getVClass(), MSNet::getVehicleControl(), MSGlobals::gTimeToGridlock, MSGlobals::gTimeToTeleportDisconnected, MESegment::hasSpaceFor(), MSBaseVehicle::ignoreTransientPermissions(), MESegment::isInvalid(), MSBaseVehicle::isParking(), MSBaseVehicle::isStopped(), MSBaseVehicle::isStoppedTriggered(), MAX2(), MEVehicle::mayProceed(), MIN2(), myEdges2FirstSegments, myLinkRecheckInterval, MSMoveReminder::NOTIFICATION_JUNCTION, MSMoveReminder::NOTIFICATION_SEGMENT, MSMoveReminder::NOTIFICATION_TELEPORT, MESegment::PARKING_QUEUE, MEVehicle::processStop(), MESegment::receive(), MSVehicleControl::scheduleVehicleRemoval(), MESegment::send(), MEVehicle::setSegment(), MSBaseVehicle::succEdge(), time2string(), TL, MEVehicle::updateDetectors(), MESegment::updateEntryBlockTime(), 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 185 of file MELoop.cpp.
References addLeaderCar(), MSEdge::allowedLanes(), changeSegment(), MEVehicle::getBlockTime(), MSBaseVehicle::getEdge(), MESegment::getEventTime(), MEVehicle::getEventTime(), MESegment::getLink(), MEVehicle::getQueIndex(), MEVehicle::getSegment(), MSBaseVehicle::getVClass(), MEVehicle::getWaitingTime(), MSGlobals::gTimeToGridlock, MSGlobals::gTimeToTeleportDisconnected, MSBaseVehicle::isStopped(), MSBaseVehicle::isStoppedParking(), MSBaseVehicle::isStoppedTriggered(), 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 298 of file MELoop.cpp.
References myInvalidatedLeaderCars, and 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 384 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(), MSTrafficLightLogic::initMesoTLSPenalties(), MSBaseVehicle::insertStop(), MSEdge::insertVehicle(), MESegment::limitedControlOverride(), MEVehicle::loadState(), MSInductLoop::MSInductLoop(), MSRouteProbe::MSRouteProbe(), MSTriggeredRerouter::MSTriggeredRerouter(), MSStateHandler::myStartElement(), MSBaseVehicle::replaceStop(), MSStop::replaceStoppingPlace(), MSMeanData::resetOnly(), MSLane::setMaxSpeed(), teleportVehicle(), MSMeanData::writeAggregated(), MSMeanData::writeAggregatedTAZ(), MSMeanData::writeEdge(), and MSXMLRawOut::writeEdge().
|
static |
whether the given edge is entering a roundabout
Definition at line 401 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 319 of file MELoop.cpp.
References MESegment::getEdge(), MSEdge::getInternalFollowingEdge(), MESegment::getNextSegment(), MSEdge::getNumericalID(), MSBaseVehicle::getVClass(), MSGlobals::gUsingInternalLanes, MSEdge::isNormal(), 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 344 of file MELoop.cpp.
Referenced by buildSegmentsFor(), and GUILane::splitAtSegments().
| void MELoop::removeLeaderCar | ( | MEVehicle * | v | ) |
Removes the given car from the leading vehicles.
| [in] | v | the car which was a leading one |
Definition at line 305 of file MELoop.cpp.
References myInvalidatedLeaderCars.
Referenced by MEVehicle::onRemovalFromNet(), MESegment::receive(), MEVehicle::resumeFromStopping(), 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 63 of file MELoop.cpp.
References checkCar(), DELTA_T, myInvalidatedLeaderCars, myLeaderCars, MELoop::LeaderEvent::time, MELoop::LeaderEvent::veh, and wasInvalidated().
Referenced by MSNet::simulationStep().
|
private |
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 228 of file MELoop.cpp.
References MSBaseVehicle::activateReminders(), addLeaderCar(), MESegment::addReminders(), changeSegment(), MESegment::getEdge(), MSBaseVehicle::getEdge(), MEVehicle::getEventTime(), Named::getID(), MESegment::getIndex(), MSNet::getInstance(), MEVehicle::getLastEntryTime(), 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, MEVehicle::updateDetectors(), and WRITE_WARNINGF.
Referenced by checkCar().
| void MELoop::vaporizeCar | ( | MEVehicle * | v, |
| MSMoveReminder::Notification | reason | ||
| ) |
remove the given car and clean up the relevant data structures
Definition at line 311 of file MELoop.cpp.
References MSNet::getInstance(), MEVehicle::getSegment(), removeLeaderCar(), and MESegment::send().
Referenced by GUIBaseVehicle::GUIBaseVehiclePopupMenu::onCmdRemoveObject().
|
private |
check whether the current car was invalidated and remove it from myInvalidatedLeaderCars
Definition at line 87 of file MELoop.cpp.
References myInvalidatedLeaderCars, and MELoop::LeaderEvent::time.
Referenced by simulate().
|
private |
mapping from internal edge ids to their initial segments
Definition at line 174 of file MELoop.h.
Referenced by buildSegmentsFor(), changeSegment(), getSegmentForEdge(), nextSegment(), and ~MELoop().
|
private |
the interval at which to recheck at full segments (<=0 means asap)
Definition at line 177 of file MELoop.h.
Referenced by checkCar().
|
private |
Definition at line 171 of file MELoop.h.
Referenced by clearState(), removeLeaderCar(), simulate(), and wasInvalidated().
|
private |
Definition at line 170 of file MELoop.h.
Referenced by addLeaderCar(), clearState(), and simulate().
|
private |
the interval at which to recheck at blocked junctions (<=0 means asap)
Definition at line 180 of file MELoop.h.
Referenced by changeSegment().