SUMO - Simulation of Urban MObility
MSLink Class Reference

#include <MSLink.h>

Data Structures

struct  ApproachingVehicleInformation
 A structure holding the information about vehicles approaching a link. More...
 
struct  LinkLeader
 

Public Types

typedef std::vector< LinkLeaderLinkLeaders
 

Public Member Functions

void addBlockedLink (MSLink *link)
 
bool blockedAtTime (SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal arrivalSpeed, SUMOReal leaveSpeed, bool sameTargetLane, SUMOReal impatience, SUMOReal decel, SUMOTime waitingTime, std::vector< const SUMOVehicle * > *collectFoes=0) const
 Returns the information whether this link is blocked Valid after the vehicles have set their requests. More...
 
ApproachingVehicleInformation getApproaching (const SUMOVehicle *veh) const
 
MSLanegetApproachingLane () const
 Returns the lane leading to this link. More...
 
LinkDirection getDirection () const
 Returns the direction the vehicle passing this link take. More...
 
int getIndex () const
 Returns the respond index (for visualization) More...
 
const MSJunctiongetJunction () const
 return the junction to which this link belongs More...
 
MSLanegetLane () const
 Returns the connected lane. More...
 
SUMOTime getLastStateChange () const
 
SUMOTime getLeaveTime (const SUMOTime arrivalTime, const SUMOReal arrivalSpeed, const SUMOReal leaveSpeed, const SUMOReal vehicleLength) const
 return the expected time at which the given vehicle will clear the link More...
 
SUMOReal getLength () const
 Returns the length of this link. More...
 
LinkState getState () const
 Returns the current state of the link. More...
 
MSLanegetViaLaneOrLane () const
 return the via lane if it exists and the lane otherwise More...
 
bool hasApproachingFoe (SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal speed, SUMOReal decel) const
 Returns the information whether a vehicle is approaching on one of the link's foe streams. More...
 
bool hasFoes () const
 Returns whether this link belongs to a junction where more than one edge is incoming. More...
 
bool havePriority () const
 Returns whether this link is a major link. More...
 
bool haveRed () const
 Returns whether this link is blocked by a red (or redyellow) traffic light. More...
 
bool isBlockingAnyone () const
 
bool isCont () const
 
bool lastWasContMajor () const
 whether this is a link past an internal junction which currently has priority More...
 
 MSLink (MSLane *succLane, LinkDirection dir, LinkState state, SUMOReal length)
 Constructor for simulation not using internal lanes. More...
 
bool opened (SUMOTime arrivalTime, SUMOReal arrivalSpeed, SUMOReal leaveSpeed, SUMOReal vehicleLength, SUMOReal impatience, SUMOReal decel, SUMOTime waitingTime, std::vector< const SUMOVehicle * > *collectFoes=0) const
 Returns the information whether the link may be passed. More...
 
void removeApproaching (const SUMOVehicle *veh)
 removes the vehicle from myApproachingVehicles More...
 
void setApproaching (const SUMOVehicle *approaching, const SUMOTime arrivalTime, const SUMOReal arrivalSpeed, const SUMOReal leaveSpeed, const bool setRequest, const SUMOTime arrivalTimeBraking, const SUMOReal arrivalSpeedBraking, const SUMOTime waitingTime)
 Sets the information about an approaching vehicle. More...
 
void setRequestInformation (int index, bool hasFoes, bool isCont, const std::vector< MSLink * > &foeLinks, const std::vector< MSLane * > &foeLanes, MSLane *internalLaneBefore=0)
 Sets the request information. More...
 
void setTLState (LinkState state, SUMOTime t)
 Sets the current tl-state. More...
 
bool willHaveBlockedFoe () const
 
void writeApproaching (OutputDevice &od, const std::string fromLaneID) const
 write information about all approaching vehicles to the given output device More...
 
 ~MSLink ()
 Destructor. More...
 

Private Member Functions

 MSLink (const MSLink &s)
 invalidated copy constructor More...
 
MSLinkoperator= (const MSLink &s)
 invalidated assignment operator More...
 

Static Private Member Functions

static bool maybeOccupied (MSLane *lane)
 returns whether the given lane may still be occupied by a vehicle currently on it More...
 
static bool unsafeMergeSpeeds (SUMOReal leaderSpeed, SUMOReal followerSpeed, SUMOReal leaderDecel, SUMOReal followerDecel)
 return whether the given vehicles may NOT merge safely More...
 

Private Attributes

bool myAmCont
 
std::map< const SUMOVehicle *, ApproachingVehicleInformationmyApproachingVehicles
 
std::set< MSLink * > myBlockedFoeLinks
 
LinkDirection myDirection
 An abstract (hopefully human readable) definition of the link's direction. More...
 
std::vector< const MSLane * > myFoeLanes
 
std::vector< MSLink * > myFoeLinks
 
bool myHasFoes
 Whether any foe links exist. More...
 
int myIndex
 The position within this respond. More...
 
const MSJunctionmyJunction
 the junction to which this link belongs More...
 
MSLanemyLane
 The lane (but the internal one) approached by this link. More...
 
SUMOTime myLastStateChange
 The time of the last state change. More...
 
SUMOReal myLength
 The length of the link. More...
 
LinkState myState
 The state of the link. More...
 

Static Private Attributes

static SUMOTime myLookaheadTime = TIME2STEPS(1)
 

Detailed Description

Definition at line 76 of file MSLink.h.

Member Typedef Documentation

typedef std::vector<LinkLeader> MSLink::LinkLeaders

Definition at line 88 of file MSLink.h.

Constructor & Destructor Documentation

MSLink::MSLink ( MSLane succLane,
LinkDirection  dir,
LinkState  state,
SUMOReal  length 
)

Constructor for simulation not using internal lanes.

Parameters
[in]succLaneThe lane approached by this link
[in]dirThe direction of this link
[in]stateThe state of this link
[in]lengthThe length of this link

Definition at line 62 of file MSLink.cpp.

MSLink::~MSLink ( )

Destructor.

Definition at line 89 of file MSLink.cpp.

MSLink::MSLink ( const MSLink s)
private

invalidated copy constructor

Member Function Documentation

void MSLink::addBlockedLink ( MSLink link)

Definition at line 242 of file MSLink.cpp.

References myBlockedFoeLinks.

bool MSLink::blockedAtTime ( SUMOTime  arrivalTime,
SUMOTime  leaveTime,
SUMOReal  arrivalSpeed,
SUMOReal  leaveSpeed,
bool  sameTargetLane,
SUMOReal  impatience,
SUMOReal  decel,
SUMOTime  waitingTime,
std::vector< const SUMOVehicle * > *  collectFoes = 0 
) const

Returns the information whether this link is blocked Valid after the vehicles have set their requests.

Parameters
[in]arrivalTimeThe arrivalTime of the vehicle who checks for an approaching foe
[in]leaveTimeThe leaveTime of the vehicle who checks for an approaching foe
[in]arrivalSpeedThe speed with which the checking vehicle plans to arrive at the link
[in]leaveSpeedThe speed with which the checking vehicle plans to leave the link
[in]sameTargetLaneWhether the link that calls this method has the same target lane as this link
[in]impatienceThe impatience of the checking vehicle
[in]decelThe maximum deceleration of the checking vehicle
[in]waitingTimeThe waiting time of the checking vehicle
[in]collectFoesIf a vector is passed the return value is always False, instead all blocking foes are collected and inserted into this vector
Returns
Whether this link is blocked
Note
Since this needs to be called without a SUMOVehicle (TraCI), we cannot simply pass the checking vehicle itself

Definition at line 315 of file MSLink.cpp.

References LINKSTATE_ALLWAY_STOP, myApproachingVehicles, myLookaheadTime, myState, and unsafeMergeSpeeds().

MSLink::ApproachingVehicleInformation MSLink::getApproaching ( const SUMOVehicle veh) const

Definition at line 266 of file MSLink.cpp.

References myApproachingVehicles.

MSLane * MSLink::getApproachingLane ( ) const

Returns the lane leading to this link.

Returns
The lane leading to this link

Definition at line 425 of file MSLink.cpp.

References MSLane::getIncomingLanes(), getIndex(), MSLane::getLinkCont(), myLane, toString(), and WRITE_WARNING.

Referenced by MSRailSignal::init().

LinkDirection MSLink::getDirection ( ) const

Returns the direction the vehicle passing this link take.

Returns
The direction of this link

Definition at line 405 of file MSLink.cpp.

References myDirection.

Referenced by MSVehicle::executeMove(), and TraCIServerAPI_Lane::processGet().

int MSLink::getIndex ( ) const
inline

Returns the respond index (for visualization)

Returns
The respond index for this link

Definition at line 292 of file MSLink.h.

References myIndex.

Referenced by GUILane::drawLinkNo(), and getApproachingLane().

const MSJunction* MSLink::getJunction ( ) const
inline

return the junction to which this link belongs

Definition at line 367 of file MSLink.h.

References myJunction.

Referenced by MSVehicle::executeMove(), MSRailSignal::init(), and GUIVehicle::selectBlockingFoes().

SUMOTime MSLink::getLastStateChange ( ) const
inline

Definition at line 254 of file MSLink.h.

References myLastStateChange.

SUMOTime MSLink::getLeaveTime ( const SUMOTime  arrivalTime,
const SUMOReal  arrivalSpeed,
const SUMOReal  leaveSpeed,
const SUMOReal  vehicleLength 
) const

return the expected time at which the given vehicle will clear the link

Definition at line 277 of file MSLink.cpp.

References getLength(), MAX2(), NUMERICAL_EPS, SUMOReal, and TIME2STEPS.

Referenced by opened(), and setApproaching().

SUMOReal MSLink::getLength ( ) const
inline

Returns the length of this link.

Returns
The length of this link

Definition at line 316 of file MSLink.h.

References myLength.

Referenced by MSVehicle::estimateLeaveSpeed(), getLeaveTime(), and TraCIServerAPI_Lane::processGet().

LinkState MSLink::getState ( ) const
inline

Returns the current state of the link.

Returns
The current state of this link

Definition at line 248 of file MSLink.h.

References myState.

Referenced by GUILane::drawLinkRule(), Command_SaveTLCoupledLaneDet::execute(), MSVehicle::executeMove(), MSLane::getIncomingLinkState(), and TraCIServerAPI_Lane::processGet().

MSLane * MSLink::getViaLaneOrLane ( ) const
bool MSLink::hasApproachingFoe ( SUMOTime  arrivalTime,
SUMOTime  leaveTime,
SUMOReal  speed,
SUMOReal  decel 
) const

Returns the information whether a vehicle is approaching on one of the link's foe streams.

Valid after the vehicles have set their requests

Parameters
[in]arrivalTimeThe arrivalTime of the vehicle who checks for an approaching foe
[in]leaveTimeThe leaveTime of the vehicle who checks for an approaching foe
[in]speedThe speed with which the checking vehicle plans to leave the link
[in]decelThe maximum deceleration of the checking vehicle
Returns
Whether a foe of this link is approaching

Definition at line 389 of file MSLink.cpp.

References myFoeLanes, myFoeLinks, and myLane.

Referenced by TraCIServerAPI_Lane::processGet().

bool MSLink::hasFoes ( ) const
inline

Returns whether this link belongs to a junction where more than one edge is incoming.

Returns
Whether any foe links exist

Definition at line 324 of file MSLink.h.

References myHasFoes.

Referenced by MSVehicle::checkRewindLinkLanes(), and setRequestInformation().

bool MSLink::havePriority ( ) const
inline

Returns whether this link is a major link.

Returns
Whether the link has a large priority

Definition at line 300 of file MSLink.h.

References myState.

Referenced by MSEdge::changeLanes(), MSVehicle::checkRewindLinkLanes(), GUILane::drawGL(), MSVehicle::executeMove(), lastWasContMajor(), and TraCIServerAPI_Lane::processGet().

bool MSLink::haveRed ( ) const
inline

Returns whether this link is blocked by a red (or redyellow) traffic light.

Returns
Whether the link has a red light

Definition at line 307 of file MSLink.h.

References LINKSTATE_TL_RED, LINKSTATE_TL_REDYELLOW, and myState.

Referenced by opened().

bool MSLink::isBlockingAnyone ( ) const
inline

Definition at line 224 of file MSLink.h.

References myApproachingVehicles.

bool MSLink::isCont ( ) const
inline

Definition at line 329 of file MSLink.h.

References myAmCont.

Referenced by MSVehicle::checkRewindLinkLanes(), MSVehicle::executeMove(), and setRequestInformation().

bool MSLink::lastWasContMajor ( ) const

whether this is a link past an internal junction which currently has priority

Definition at line 453 of file MSLink.cpp.

References MSEdge::EDGEFUNCTION_INTERNAL, MSLinkContHelper::getConnectingLink(), MSLane::getEdge(), MSLane::getLogicalPredecessorLane(), MSEdge::getPurpose(), havePriority(), and myAmCont.

Referenced by MSVehicle::executeMove().

bool MSLink::maybeOccupied ( MSLane lane)
staticprivate
bool MSLink::opened ( SUMOTime  arrivalTime,
SUMOReal  arrivalSpeed,
SUMOReal  leaveSpeed,
SUMOReal  vehicleLength,
SUMOReal  impatience,
SUMOReal  decel,
SUMOTime  waitingTime,
std::vector< const SUMOVehicle * > *  collectFoes = 0 
) const

Returns the information whether the link may be passed.

Valid after the junctions have set their reponds

Parameters
[in]collectFoesIf a vector is passed, all blocking foes are collected and inserted into this vector
Returns
Whether this link may be passed.

Definition at line 284 of file MSLink.cpp.

References getLeaveTime(), MSGlobals::gUseMesoSim, MSGlobals::gUsingInternalLanes, haveRed(), LINKSTATE_ALLWAY_STOP, LINKSTATE_STOP, myAmCont, myFoeLinks, myLane, and myState.

Referenced by MSVehicle::checkRewindLinkLanes(), MSVehicle::executeMove(), MSPModel_Striping::moveInDirectionOnLane(), TraCIServerAPI_Lane::processGet(), and GUIVehicle::selectBlockingFoes().

MSLink& MSLink::operator= ( const MSLink s)
private

invalidated assignment operator

void MSLink::removeApproaching ( const SUMOVehicle veh)

removes the vehicle from myApproachingVehicles

Definition at line 260 of file MSLink.cpp.

References myApproachingVehicles.

Referenced by MSVehicle::executeMove().

void MSLink::setApproaching ( const SUMOVehicle approaching,
const SUMOTime  arrivalTime,
const SUMOReal  arrivalSpeed,
const SUMOReal  leaveSpeed,
const bool  setRequest,
const SUMOTime  arrivalTimeBraking,
const SUMOReal  arrivalSpeedBraking,
const SUMOTime  waitingTime 
)

Sets the information about an approaching vehicle.

The information is stored in myApproachingVehicles.

Definition at line 232 of file MSLink.cpp.

References getLeaveTime(), MSVehicleType::getLength(), SUMOVehicle::getVehicleType(), and myApproachingVehicles.

void MSLink::setRequestInformation ( int  index,
bool  hasFoes,
bool  isCont,
const std::vector< MSLink * > &  foeLinks,
const std::vector< MSLane * > &  foeLanes,
MSLane internalLaneBefore = 0 
)

Sets the request information.

Because traffic lights and junction logics are loaded after links, we have to assign the information about the right-of-way requests and responses after the initialisation.

Todo:
Unsecure!

Definition at line 93 of file MSLink.cpp.

References MSLane::getEdge(), MSEdge::getFromJunction(), Named::getID(), MSLane::getIncomingLanes(), MSLane::getLength(), MSLane::getLinkCont(), MSLane::getLogicalPredecessorLane(), MSLane::getShape(), getViaLaneOrLane(), MSLane::getWidth(), hasFoes(), MSLane::interpolateGeometryPosToLanePos(), PositionVector::intersectsAtLengths2D(), isCont(), MSEdge::isInternal(), myAmCont, myFoeLanes, myFoeLinks, myHasFoes, myIndex, myJunction, myLane, NUMERICAL_EPS, toString(), and UNUSED_PARAMETER.

Referenced by MSRightOfWayJunction::postloadInit().

void MSLink::setTLState ( LinkState  state,
SUMOTime  t 
)

Sets the current tl-state.

Parameters
[in]stateThe current state of the link
[in]tThe time of the state change

Definition at line 411 of file MSLink.cpp.

References myLastStateChange, and myState.

Referenced by MSTrafficLightLogic::addLink().

static bool MSLink::unsafeMergeSpeeds ( SUMOReal  leaderSpeed,
SUMOReal  followerSpeed,
SUMOReal  leaderDecel,
SUMOReal  followerDecel 
)
inlinestaticprivate

return whether the given vehicles may NOT merge safely

Definition at line 373 of file MSLink.h.

Referenced by blockedAtTime().

bool MSLink::willHaveBlockedFoe ( ) const

Definition at line 249 of file MSLink.cpp.

References myBlockedFoeLinks.

Field Documentation

bool MSLink::myAmCont
private

Definition at line 406 of file MSLink.h.

Referenced by isCont(), lastWasContMajor(), opened(), and setRequestInformation().

std::map<const SUMOVehicle*, ApproachingVehicleInformation> MSLink::myApproachingVehicles
private
std::set<MSLink*> MSLink::myBlockedFoeLinks
private

Definition at line 386 of file MSLink.h.

Referenced by addBlockedLink(), and willHaveBlockedFoe().

LinkDirection MSLink::myDirection
private

An abstract (hopefully human readable) definition of the link's direction.

Definition at line 398 of file MSLink.h.

Referenced by getDirection().

std::vector<const MSLane*> MSLink::myFoeLanes
private

Definition at line 427 of file MSLink.h.

Referenced by hasApproachingFoe(), and setRequestInformation().

std::vector<MSLink*> MSLink::myFoeLinks
private

Definition at line 426 of file MSLink.h.

Referenced by hasApproachingFoe(), opened(), and setRequestInformation().

bool MSLink::myHasFoes
private

Whether any foe links exist.

Definition at line 404 of file MSLink.h.

Referenced by hasFoes(), and setRequestInformation().

int MSLink::myIndex
private

The position within this respond.

Definition at line 389 of file MSLink.h.

Referenced by getIndex(), and setRequestInformation().

const MSJunction* MSLink::myJunction
private

the junction to which this link belongs

Definition at line 424 of file MSLink.h.

Referenced by getJunction(), and setRequestInformation().

MSLane* MSLink::myLane
private

The lane (but the internal one) approached by this link.

Definition at line 383 of file MSLink.h.

Referenced by getApproachingLane(), getLane(), getViaLaneOrLane(), hasApproachingFoe(), opened(), and setRequestInformation().

SUMOTime MSLink::myLastStateChange
private

The time of the last state change.

Definition at line 395 of file MSLink.h.

Referenced by getLastStateChange(), and setTLState().

SUMOReal MSLink::myLength
private

The length of the link.

Definition at line 401 of file MSLink.h.

Referenced by getLength().

SUMOTime MSLink::myLookaheadTime = TIME2STEPS(1)
staticprivate

Definition at line 428 of file MSLink.h.

Referenced by blockedAtTime().

LinkState MSLink::myState
private

The state of the link.

Definition at line 392 of file MSLink.h.

Referenced by blockedAtTime(), getState(), havePriority(), haveRed(), opened(), and setTLState().


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