SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSLink Class Reference

#include <MSLink.h>

Data Structures

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

Public Types

typedef std::vector< std::pair
< MSVehicle *, SUMOReal > > 
LinkLeaders
 

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
 
LinkDirection getDirection () const
 Returns the direction the vehicle passing this link take. More...
 
MSLanegetLane () const
 Returns the connected lane. More...
 
SUMOTime getLeaveTime (SUMOTime arrivalTime, SUMOReal arrivalSpeed, SUMOReal leaveSpeed, 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...
 
unsigned int getRespondIndex () const
 Returns the respond index (for visualization) 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=DEFAULT_VEH_DECEL) const
 Returns the information whether a vehicle is approaching on one of the link's foe streams. More...
 
bool havePriority () const
 Returns whether this link is a major link. More...
 
bool isBlockingAnyone () const
 
bool isCont () const
 
bool isCrossing () const
 Returns whether this link belongs to a junction where more than one edge is incoming. 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 (unsigned int requestIdx, unsigned int respondIdx, bool isCrossing, bool isCont, const std::vector< MSLink * > &foeLinks, const std::vector< MSLane * > &foeLanes)
 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
*, ApproachingVehicleInformation
myApproachingVehicles
 
std::set< MSLink * > myBlockedFoeLinks
 
LinkDirection myDirection
 An abstract (hopefully human readable) definition of the link's direction. More...
 
std::vector< MSLane * > myFoeLanes
 
std::vector< MSLink * > myFoeLinks
 
bool myIsCrossing
 Whether any foe links exist. More...
 
MSLanemyLane
 The lane approached by this link. More...
 
SUMOReal myLength
 The length of the link. More...
 
unsigned int myRequestIdx
 The position of the link within this request. More...
 
unsigned int myRespondIdx
 The position within this respond. More...
 
LinkState myState
 The state of the link. More...
 

Static Private Attributes

static SUMOTime myLookaheadTime = TIME2STEPS(1)
 

Detailed Description

Definition at line 74 of file MSLink.h.

Member Typedef Documentation

typedef std::vector<std::pair<MSVehicle*, SUMOReal> > MSLink::LinkLeaders

Definition at line 77 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 57 of file MSLink.cpp.

MSLink::~MSLink ( )

Destructor.

Definition at line 75 of file MSLink.cpp.

MSLink::MSLink ( const MSLink s)
private

invalidated copy constructor

Member Function Documentation

void MSLink::addBlockedLink ( MSLink link)

Definition at line 102 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 174 of file MSLink.cpp.

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

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

Definition at line 126 of file MSLink.cpp.

References myApproachingVehicles.

LinkDirection MSLink::getDirection ( ) const

Returns the direction the vehicle passing this link take.

Returns
The direction of this link

Definition at line 264 of file MSLink.cpp.

References myDirection.

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

MSLane * MSLink::getLane ( ) const

Returns the connected lane.

Returns
The lane approached by this link

Definition at line 276 of file MSLink.cpp.

References myLane.

Referenced by MSVehicle::checkRewindLinkLanes(), Command_SaveTLSSwitches::execute(), MSLinkContHelper::getConnectingLink(), TraCIServerAPI_TLS::processGet(), TraCIServerAPI_Lane::processGet(), and writeApproaching().

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

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

Definition at line 137 of file MSLink.cpp.

References getLength(), 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 282 of file MSLink.h.

References myLength.

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

unsigned int MSLink::getRespondIndex ( ) const

Returns the respond index (for visualization)

Returns
The respond index for this link

Definition at line 371 of file MSLink.cpp.

References myRespondIdx.

LinkState MSLink::getState ( ) const
inline

Returns the current state of the link.

Returns
The current state of this link

Definition at line 237 of file MSLink.h.

References myState.

Referenced by GUILane::drawLinkRules(), Command_SaveTLCoupledLaneDet::execute(), MSVehicle::executeMove(), and TraCIServerAPI_Lane::processGet().

MSLane * MSLink::getViaLaneOrLane ( ) const

return the via lane if it exists and the lane otherwise

Definition at line 360 of file MSLink.cpp.

References myLane.

Referenced by GUIVehicle::drawGLAdditional(), MSVehicle::estimateLeaveSpeed(), MSVehicle::executeMove(), and MSEdge::parallelLane().

bool MSLink::hasApproachingFoe ( SUMOTime  arrivalTime,
SUMOTime  leaveTime,
SUMOReal  speed,
SUMOReal  decel = DEFAULT_VEH_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 248 of file MSLink.cpp.

References myFoeLanes, myFoeLinks, and myLane.

Referenced by TraCIServerAPI_Lane::processGet().

bool MSLink::havePriority ( ) const
inline

Returns whether this link is a major link.

Returns
Whether the link has a large priority

Definition at line 273 of file MSLink.h.

References myState.

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

bool MSLink::isBlockingAnyone ( ) const
inline

Definition at line 212 of file MSLink.h.

References myApproachingVehicles.

bool MSLink::isCont ( ) const
inline

Definition at line 295 of file MSLink.h.

References myAmCont.

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

bool MSLink::isCrossing ( ) 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 290 of file MSLink.h.

References myIsCrossing.

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

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 143 of file MSLink.cpp.

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

Referenced by MSVehicle::checkRewindLinkLanes(), MSVehicle::executeMove(), 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 120 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 92 of file MSLink.cpp.

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

void MSLink::setRequestInformation ( unsigned int  requestIdx,
unsigned int  respondIdx,
bool  isCrossing,
bool  isCont,
const std::vector< MSLink * > &  foeLinks,
const std::vector< MSLane * > &  foeLanes 
)

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 79 of file MSLink.cpp.

References isCont(), isCrossing(), myAmCont, myFoeLanes, myFoeLinks, myIsCrossing, myRequestIdx, and myRespondIdx.

Referenced by MSRightOfWayJunction::postloadInit().

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

Sets the current tl-state.

Parameters
[in]stateThe current state of the link

Definition at line 270 of file MSLink.cpp.

References 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 328 of file MSLink.h.

Referenced by blockedAtTime().

bool MSLink::willHaveBlockedFoe ( ) const

Definition at line 109 of file MSLink.cpp.

References myBlockedFoeLinks.

Field Documentation

bool MSLink::myAmCont
private

Definition at line 361 of file MSLink.h.

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

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

Definition at line 341 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 353 of file MSLink.h.

Referenced by getDirection().

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

Definition at line 370 of file MSLink.h.

Referenced by hasApproachingFoe(), and setRequestInformation().

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

Definition at line 369 of file MSLink.h.

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

bool MSLink::myIsCrossing
private

Whether any foe links exist.

Definition at line 359 of file MSLink.h.

Referenced by isCrossing(), and setRequestInformation().

MSLane* MSLink::myLane
private

The lane approached by this link.

Definition at line 338 of file MSLink.h.

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

SUMOReal MSLink::myLength
private

The length of the link.

Definition at line 356 of file MSLink.h.

Referenced by getLength().

SUMOTime MSLink::myLookaheadTime = TIME2STEPS(1)
staticprivate

Definition at line 371 of file MSLink.h.

Referenced by blockedAtTime().

unsigned int MSLink::myRequestIdx
private

The position of the link within this request.

Definition at line 344 of file MSLink.h.

Referenced by setRequestInformation().

unsigned int MSLink::myRespondIdx
private

The position within this respond.

Definition at line 347 of file MSLink.h.

Referenced by getRespondIndex(), and setRequestInformation().

LinkState MSLink::myState
private

The state of the link.

Definition at line 350 of file MSLink.h.

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


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