SUMO - Simulation of Urban MObility
NBTrafficLightDefinition Class Reference

The base class for traffic light logic definitions. More...

#include <NBTrafficLightDefinition.h>

Inheritance diagram for NBTrafficLightDefinition:
Named NBLoadedSUMOTLDef NBLoadedTLDef NBOwnTLDef

Public Types

enum  TLColor {
  TLCOLOR_RED, TLCOLOR_YELLOW, TLCOLOR_REDYELLOW, TLCOLOR_GREEN,
  TLCOLOR_BLINK
}
 An enumeration of possible tl-signal states. More...

Public Member Functions

void addControlledInnerEdges (const std::vector< std::string > &edges)
 Adds the given ids into the list of edges not controlled by the tls.
NBTrafficLightLogiccompute (const NBEdgeCont &ec, OptionsCont &oc)
 Computes the traffic light logic.
bool foes (const NBEdge *const from1, const NBEdge *const to1, const NBEdge *const from2, const NBEdge *const to2) const
 Returns the information whether the given flows cross.
bool forbids (const NBEdge *const possProhibitorFrom, const NBEdge *const possProhibitorTo, const NBEdge *const possProhibitedFrom, const NBEdge *const possProhibitedTo, bool regardNonSignalisedLowerPriority) const
 Returns the information whether "prohibited" flow must let "prohibitor" flow pass.
const NBConnectionVectorgetControlledLinks () const
 returns the controlled links (depends on previous call to collectLinks)
const std::vector< NBNode * > & getControlledNodes () const
const std::string & getID () const
 Returns the id.
const EdgeVectorgetIncomingEdges () const
 Returns the list of incoming edges (must be build first)
const std::string & getProgramID () const
 Returns the ProgramID.
bool isLeftMover (const NBEdge *const from, const NBEdge *const to) const
 returns the information whether the given link is a left-mover
bool mustBrake (const NBEdge *const from, const NBEdge *const to) const
 Returns the information whether the described flow must let any other flow pass.
bool mustBrake (const NBConnection &possProhibited, const NBConnection &possProhibitor, bool regardNonSignalisedLowerPriority) const
 Returns the information whether the described flow must let the other flow pass.
bool mustBrake (const NBEdge *const possProhibitedFrom, const NBEdge *const possProhibitedTo, const NBEdge *const possProhibitorFrom, const NBEdge *const possProhibitorTo, bool regardNonSignalisedLowerPriority) const
 Returns the information whether the described flow must let any other flow pass.
 NBTrafficLightDefinition (const std::string &id, const std::vector< NBNode * > &junctions, const std::string &programID)
 Constructor.
 NBTrafficLightDefinition (const std::string &id, NBNode *junction, const std::string &programID)
 Constructor.
 NBTrafficLightDefinition (const std::string &id, const std::string &programID)
 Constructor.
virtual void remapRemoved (NBEdge *removed, const EdgeVector &incoming, const EdgeVector &outgoing)=0
 Replaces occurences of the removed edge in incoming/outgoing edges of all definitions.
virtual void replaceRemoved (NBEdge *removed, int removedLane, NBEdge *by, int byLane)=0
 Replaces a removed edge/lane.
void setID (const std::string &newID)
 resets the id
virtual void setParticipantsInformation ()
 Builds the list of participating nodes/edges/links.
void setProgramID (const std::string &programID)
virtual void setTLControllingInformation (const NBEdgeCont &ec) const =0
 Informs edges about being controlled by a tls.
virtual ~NBTrafficLightDefinition ()
 Destructor.
Access to controlled nodes
virtual void addNode (NBNode *node)
 Adds a node to the traffic light logic.
virtual void removeNode (NBNode *node)
 Removes the given node from the list of controlled nodes.
const std::vector< NBNode * > & getNodes () const
 Returns the list of controlled nodes.

Static Public Attributes

static const std::string DefaultProgramID = "0"

Protected Member Functions

virtual bool amInvalid () const
void collectEdges ()
 Build the list of participating edges.
virtual void collectLinks ()=0
 Collects the links participating in this traffic light

Exceptions:
ProcessErrorIf a link could not be found.

unsigned int computeBrakingTime (SUMOReal minDecel) const
 Computes the time vehicles may need to brake.
virtual NBTrafficLightLogicmyCompute (const NBEdgeCont &ec, unsigned int brakingTime)=0
 Computes the traffic light logic finally in dependence to the type.

Protected Attributes

std::set< std::string > myControlledInnerEdges
 Set of inner edges that shall be controlled, though.
NBConnectionVector myControlledLinks
 The list of controlled links.
std::vector< NBNode * > myControlledNodes
 The container with participating nodes.
EdgeVector myEdgesWithin
 The list of edges within the area controlled by the tls.
std::string myID
 The name of the object.
EdgeVector myIncomingEdges
 The list of incoming edges.
std::string mySubID
 The tls program's subid.

Detailed Description

The base class for traffic light logic definitions.

A base class is necessary, as we have two cases: a) the logic is given by the imported network, or b) the logic is not given and we have to compute it by ourselves. In the first case, NBLoadedTLDef should be used, in the second NBOwnTLDef.

See also:
NBLoadedTLDef
NBOwnTLDef

Definition at line 72 of file NBTrafficLightDefinition.h.


Member Enumeration Documentation

An enumeration of possible tl-signal states.

Enumerator:
TLCOLOR_RED 

Signal shows red.

TLCOLOR_YELLOW 

Signal shows yellow.

TLCOLOR_REDYELLOW 

Signal shows red/yellow (unused)

TLCOLOR_GREEN 

Signal shows green.

TLCOLOR_BLINK 

Signal is blinking yellow.

Definition at line 81 of file NBTrafficLightDefinition.h.


Constructor & Destructor Documentation

NBTrafficLightDefinition::NBTrafficLightDefinition ( const std::string &  id,
const std::vector< NBNode * > &  junctions,
const std::string &  programID 
)

Constructor.

Parameters:
[in]idThe id of the tls
[in]junctionsList of junctions controlled by this tls

Definition at line 59 of file NBTrafficLightDefinition.cpp.

References myControlledNodes.

NBTrafficLightDefinition::NBTrafficLightDefinition ( const std::string &  id,
NBNode junction,
const std::string &  programID 
)

Constructor.

Parameters:
[in]idThe id of the tls
[in]junctionThe (single) junction controlled by this tls

Definition at line 81 of file NBTrafficLightDefinition.cpp.

References addNode(), and NBNode::addTrafficLight().

NBTrafficLightDefinition::NBTrafficLightDefinition ( const std::string &  id,
const std::string &  programID 
)

Constructor.

Parameters:
[in]idThe id of the tls

Definition at line 90 of file NBTrafficLightDefinition.cpp.

Destructor.

Definition at line 94 of file NBTrafficLightDefinition.cpp.


Member Function Documentation

void NBTrafficLightDefinition::addControlledInnerEdges ( const std::vector< std::string > &  edges)

Adds the given ids into the list of edges not controlled by the tls.

Parameters:
[in]edgesThe list of edge ids to add the inner edges to

Definition at line 345 of file NBTrafficLightDefinition.cpp.

References myControlledInnerEdges.

void NBTrafficLightDefinition::addNode ( NBNode node) [virtual]

Adds a node to the traffic light logic.

Parameters:
[in]nodeA further node that shall be controlled by the tls

Definition at line 325 of file NBTrafficLightDefinition.cpp.

References NBNode::addTrafficLight(), and myControlledNodes.

Referenced by NBLoadedSUMOTLDef::addConnection(), NBLoadedTLDef::addToSignalGroup(), and NBTrafficLightDefinition().

bool NBTrafficLightDefinition::amInvalid ( ) const [protected, virtual]

Reimplemented in NBLoadedSUMOTLDef.

Definition at line 121 of file NBTrafficLightDefinition.cpp.

References myControlledLinks.

Referenced by compute().

virtual void NBTrafficLightDefinition::collectLinks ( ) [protected, pure virtual]

Collects the links participating in this traffic light

Exceptions:
ProcessErrorIf a link could not be found.

Implemented in NBLoadedTLDef, NBOwnTLDef, and NBLoadedSUMOTLDef.

Referenced by setParticipantsInformation().

Computes the traffic light logic.

Does some initialisation at first, then calls myCompute to finally build the tl-logic

Parameters:
[in]ecThe edge container in order to retrieve edge information
[in]ocThe options container holding options needed during the building
Returns:
The built logic (may be 0)

Definition at line 98 of file NBTrafficLightDefinition.cpp.

References amInvalid(), computeBrakingTime(), OptionsCont::getFloat(), Named::getID(), OptionsCont::getInt(), OptionsCont::isSet(), myCompute(), myControlledNodes, and WRITE_WARNING.

Referenced by NBTrafficLightLogicCont::computeSingleLogic().

unsigned int NBTrafficLightDefinition::computeBrakingTime ( SUMOReal  minDecel) const [protected]

Computes the time vehicles may need to brake.

This time depends on the maximum speed allowed on incoming junctions. It is computed as max_speed_allowed / minimum_vehicle_decleration

Definition at line 127 of file NBTrafficLightDefinition.cpp.

References NBContHelper::maxSpeed(), myIncomingEdges, and SUMOReal.

Referenced by compute().

bool NBTrafficLightDefinition::foes ( const NBEdge *const  from1,
const NBEdge *const  to1,
const NBEdge *const  from2,
const NBEdge *const  to2 
) const

Returns the information whether the given flows cross.

Parameters:
[in]from1The starting edge of the first stream
[in]to1The ending edge of the first stream
[in]from2The starting edge of the second stream
[in]to2The ending edge of the second stream
Returns:
Whether both stream are foes (cross)

Definition at line 302 of file NBTrafficLightDefinition.cpp.

References NBNode::foes(), and myControlledNodes.

Referenced by NBOwnTLDef::computeUnblockedWeightedStreamNumber().

bool NBTrafficLightDefinition::forbids ( const NBEdge *const  possProhibitorFrom,
const NBEdge *const  possProhibitorTo,
const NBEdge *const  possProhibitedFrom,
const NBEdge *const  possProhibitedTo,
bool  regardNonSignalisedLowerPriority 
) const

Returns the information whether "prohibited" flow must let "prohibitor" flow pass.

Parameters:
[in]possProhibitedFromThe maybe prohibited connection's begin
[in]possProhibitedToThe maybe prohibited connection's end
[in]possProhibitorFromThe maybe prohibiting connection's begin
[in]possProhibitorToThe maybe prohibiting connection's end
[in]regardNonSignalisedLowerPriorityWhether the right of way rules without traffic lights shall be regarded
Returns:
Whether the second flow prohibits the first one
See also:
forbids

Definition at line 225 of file NBTrafficLightDefinition.cpp.

References NBNode::foes(), NBNode::forbids(), NBEdge::getConnectedEdges(), and myControlledNodes.

Referenced by mustBrake(), and NBOwnTLDef::myCompute().

returns the controlled links (depends on previous call to collectLinks)

Definition at line 274 of file NBTrafficLightDefinition.h.

References myControlledLinks.

Referenced by NBLoadedSUMOTLDef::NBLoadedSUMOTLDef().

const std::vector<NBNode*>& NBTrafficLightDefinition::getControlledNodes ( ) const [inline]
const std::string& Named::getID ( ) const [inline, inherited]

Returns the id.

Returns:
The stored id

Reimplemented in MS_E2_ZS_CollectorOverLanes.

Definition at line 61 of file Named.h.

References Named::myID.

Referenced by MSDetectorControl::add(), ShapeContainer::add(), RORouteDef_Alternatives::addAlternative(), MSNet::addBusStop(), NBLoadedSUMOTLDef::addConnection(), NLHandler::addConnection(), NIImporter_OpenDrive::addE2EConnectionsSecure(), RONet::addNode(), NIImporter_SUMO::addPhase(), RONet::addRouteDef(), NBDistrict::addSink(), NBDistrict::addSource(), MSRouteHandler::addStop(), NIXMLTrafficLightsHandler::addTlConnection(), NIVissimDisturbance::addToNode(), MSVehicle::addTraciStop(), NIVisumTL::build(), MS_E2_ZS_CollectorOverLanes::buildCollector(), NIImporter_VISUM::buildDistrictNode(), NIVissimConnection::buildEdgeConnections(), NBEdge::buildInnerEdges(), NIVissimEdge::buildNBEdge(), NBNodeCont::buildOffRamp(), NBNodeCont::buildOnRamp(), ODDistrictHandler::closeDistrict(), collectEdges(), NBOwnTLDef::collectLinks(), compute(), NBNode::computeInternalLaneShape(), NBEdge::computeLaneShapes(), NBNode::computeLogic(), NBNode::computeNodeShape(), NBTrafficLightLogicCont::computeSingleLogic(), NBTurningDirectionsComputer::computeTurnDirectionsForNode(), NBEdge::connections_sorter(), MSLane::detectCollisions(), NIVissimDistrictConnection::dict_BuildDistricts(), MSE3Collector::enter(), Command_SaveTLSSwitches::execute(), MSVTypeProbe::execute(), NBNodeCont::extract(), NBTrafficLightLogicCont::extract(), NBEdgeCont::extract(), MSNet::getBusStopID(), NIImporter_VISUM::getNamedEdgeContinuating(), NLTriggerBuilder::getPosition(), NBNode::getPossiblySplittedIncoming(), NBNode::getPossiblySplittedOutgoing(), NIImporter_VISUM::getReversedContinuating(), NBEdgeCont::ignoreFilterMatch(), MSActuatedTrafficLightLogic::init(), MSAgentbasedTrafficLightLogic::init(), NIImporter_SUMO::initTrafficLightLogic(), NIXMLTrafficLightsHandler::initTrafficLightLogic(), NBDistrictCont::insert(), NBTrafficLightLogicCont::insert(), NBNodeCont::insert(), NBEdgeCont::insert(), NBEdgeCont::joinSameNodeConnectingEdges(), MSE3Collector::leave(), NIImporter_OpenDrive::loadNetwork(), MSLane::moveCritical(), MSVehicle::MSVehicle(), RORDLoader_SUMOBase::myCharacters(), NBOwnTLDef::myCompute(), NBLoadedTLDef::myCompute(), NIXMLTrafficLightsHandler::myEndElement(), NIXMLEdgesHandler::myEndElement(), NIImporter_SUMO::myEndElement(), NIXMLConnectionsHandler::myStartElement(), MSLaneSpeedTrigger::myStartElement(), MSTriggeredRerouter::myStartElement(), NBConnection::NBConnection(), NBRequest::NBRequest(), MSDevice_Tripinfo::notifyEnter(), MSDevice_Tripinfo::notifyLeave(), Named::ComparatorIdLess::operator()(), NBTurningDirectionsComputer::combination_by_angle_sorter::operator()(), NBOwnTLDef::edge_by_incoming_priority_sorter::operator()(), NBNetBuilder::by_id_sorter::operator()(), NBContHelper::same_connection_edge_sorter::operator()(), NBNode::nodes_by_id_sorter::operator()(), NIImporter_VISUM::parse_EdgePolys(), NIImporter_VISUM::parse_Lanes(), NIImporter_VISUM::parse_LanesConnections(), NIImporter_VISUM::parse_Turns(), NIImporter_VISUM::parse_TurnsToSignalGroups(), NIXMLConnectionsHandler::parseDeprecatedLaneDefinition(), NIXMLConnectionsHandler::parseLaneBound(), NBLoadedTLDef::SignalGroup::patchTYellow(), RORouteDef_Complete::preComputeCurrentRoute(), TraCIServerAPI_Lane::processGet(), TraCIServerAPI_TLS::processGet(), TraCIServerAPI_InductionLoop::processGet(), TraCIServerAPI_Vehicle::processGet(), NWWriter_SUMO::prohibitionConnection(), NBLoadedTLDef::SignalGroup::remapIncoming(), NBLoadedTLDef::SignalGroup::remapOutgoing(), NBLoadedSUMOTLDef::removeConnection(), NBNode::removeSelfLoops(), NBEdgeCont::removeUnwishedEdges(), NBNodeCont::removeUnwishedNodes(), NBNodeCont::rename(), NBEdgeCont::rename(), NBConnection::replaceFrom(), MSBaseVehicle::replaceRouteEdges(), NBConnection::replaceTo(), NIXMLTrafficLightsHandler::retrieveLaneIndex(), NBNodeCont::setAsTLControlled(), NBEdge::setControllingTLInformation(), MSLane::setCritical(), NIXMLEdgesHandler::setNodes(), NBOwnTLDef::setTLControllingInformation(), NBLoadedSUMOTLDef::setTLControllingInformation(), NBLoadedTLDef::setTLControllingInformation(), NBEdgeCont::splitAt(), RORDLoader_SUMOBase::startRoute(), NBEdge::startShapeAt(), NIXMLConnectionsHandler::validateLaneInfo(), MSInstantInductLoop::write(), NWWriter_SUMO::writeConnection(), NWWriter_SUMO::writeDistrict(), NWWriter_SUMO::writeEdge(), MSMeanData::writeEdge(), NWWriter_XML::writeEdgesAndConnections(), NWWriter_SUMO::writeInternalConnections(), NWWriter_SUMO::writeJunction(), NWWriter_OpenDrive::writeNetwork(), NWWriter_XML::writeNodes(), MSInductLoop::writeTypedXMLOutput(), MSRouteProbe::writeXMLOutput(), and MSE2Collector::writeXMLOutput().

Returns the list of incoming edges (must be build first)

Returns:
The edges which are incoming into the tls

Definition at line 351 of file NBTrafficLightDefinition.cpp.

References myIncomingEdges.

Referenced by NBOwnTLDef::myCompute().

const std::vector<NBNode*>& NBTrafficLightDefinition::getNodes ( ) const [inline]

Returns the list of controlled nodes.

Returns:
Controlled nodes

Definition at line 154 of file NBTrafficLightDefinition.h.

References myControlledNodes.

bool NBTrafficLightDefinition::isLeftMover ( const NBEdge *const  from,
const NBEdge *const  to 
) const

returns the information whether the given link is a left-mover

Parameters:
[in]fromThe connection's start edge
[in]toThe connection's end edge
Returns:
Whether the connection is a left-mover

Definition at line 173 of file NBTrafficLightDefinition.cpp.

References NBNode::isLeftMover(), and myControlledNodes.

Referenced by NBOwnTLDef::myCompute().

bool NBTrafficLightDefinition::mustBrake ( const NBEdge *const  from,
const NBEdge *const  to 
) const

Returns the information whether the described flow must let any other flow pass.

If the from/to connection passes only one junction (from is incoming into same node as to outgoes from) the node is asked whether the flow must brake- Otherwise true is returned (recheck!) "from" must be an incoming edge into one of the participating nodes!

Parameters:
[in]fromThe connection's start edge
[in]toThe connection's end edge
Returns:
Whether the described connection must brake (has higher priorised foes)

Definition at line 189 of file NBTrafficLightDefinition.cpp.

References NBNode::mustBrake(), and myControlledNodes.

Referenced by NBLoadedTLDef::mustBrake().

bool NBTrafficLightDefinition::mustBrake ( const NBConnection possProhibited,
const NBConnection possProhibitor,
bool  regardNonSignalisedLowerPriority 
) const

Returns the information whether the described flow must let the other flow pass.

Parameters:
[in]possProhibitedThe maybe prohibited connection
[in]possProhibitorThe maybe prohibiting connection
[in]regardNonSignalisedLowerPriorityWhether the right of way rules without traffic lights shall be regarded
Returns:
Whether the second flow prohibits the first one
See also:
forbids

Definition at line 215 of file NBTrafficLightDefinition.cpp.

References forbids(), NBConnection::getFrom(), and NBConnection::getTo().

bool NBTrafficLightDefinition::mustBrake ( const NBEdge *const  possProhibitedFrom,
const NBEdge *const  possProhibitedTo,
const NBEdge *const  possProhibitorFrom,
const NBEdge *const  possProhibitorTo,
bool  regardNonSignalisedLowerPriority 
) const

Returns the information whether the described flow must let any other flow pass.

Parameters:
[in]possProhibitedFromThe maybe prohibited connection's begin
[in]possProhibitedToThe maybe prohibited connection's end
[in]possProhibitorFromThe maybe prohibiting connection's begin
[in]possProhibitorToThe maybe prohibiting connection's end
[in]regardNonSignalisedLowerPriorityWhether the right of way rules without traffic lights shall be regarded
Returns:
Whether the second flow prohibits the first one
See also:
forbids

Definition at line 203 of file NBTrafficLightDefinition.cpp.

References forbids().

virtual NBTrafficLightLogic* NBTrafficLightDefinition::myCompute ( const NBEdgeCont ec,
unsigned int  brakingTime 
) [protected, pure virtual]

Computes the traffic light logic finally in dependence to the type.

Parameters:
[in]ecThe edge container
[in]brakingTimeDuration a vehicle needs for braking in front of the tls
Returns:
The computed logic

Implemented in NBLoadedTLDef, NBLoadedSUMOTLDef, and NBOwnTLDef.

Referenced by compute().

virtual void NBTrafficLightDefinition::remapRemoved ( NBEdge removed,
const EdgeVector incoming,
const EdgeVector outgoing 
) [pure virtual]

Replaces occurences of the removed edge in incoming/outgoing edges of all definitions.

Parameters:
[in]removedThe removed edge
[in]incomingThe edges to use instead if an incoming edge was removed
[in]outgoingThe edges to use instead if an outgoing edge was removed

Implemented in NBLoadedTLDef, NBOwnTLDef, and NBLoadedSUMOTLDef.

void NBTrafficLightDefinition::removeNode ( NBNode node) [virtual]

Removes the given node from the list of controlled nodes.

Parameters:
[in]nodeThe node that shall not be controlled by the tls any more

Definition at line 335 of file NBTrafficLightDefinition.cpp.

References myControlledNodes.

Referenced by NBNode::removeTrafficLight().

virtual void NBTrafficLightDefinition::replaceRemoved ( NBEdge removed,
int  removedLane,
NBEdge by,
int  byLane 
) [pure virtual]

Replaces a removed edge/lane.

Parameters:
[in]removedThe edge to replace
[in]removedLaneThe lane of this edge to replace
[in]byThe edge to insert instead
[in]byLaneThis edge's lane to insert instead

Implemented in NBLoadedTLDef, NBOwnTLDef, and NBLoadedSUMOTLDef.

void Named::setID ( const std::string &  newID) [inline, inherited]

resets the id

Definition at line 67 of file Named.h.

References Named::myID.

Referenced by NBNodeCont::rename(), and NBEdgeCont::rename().

Builds the list of participating nodes/edges/links.

Reimplemented in NBOwnTLDef.

Definition at line 134 of file NBTrafficLightDefinition.cpp.

References collectEdges(), and collectLinks().

void NBTrafficLightDefinition::setProgramID ( const std::string &  programID) [inline]

Definition at line 293 of file NBTrafficLightDefinition.h.

References mySubID.

Referenced by NBTrafficLightLogicCont::insert().

virtual void NBTrafficLightDefinition::setTLControllingInformation ( const NBEdgeCont ec) const [pure virtual]

Informs edges about being controlled by a tls.

Parameters:
[in]ecThe container of edges

Implemented in NBLoadedTLDef, NBOwnTLDef, and NBLoadedSUMOTLDef.


Field Documentation

const std::string NBTrafficLightDefinition::DefaultProgramID = "0" [static]
std::set<std::string> NBTrafficLightDefinition::myControlledInnerEdges [protected]

Set of inner edges that shall be controlled, though.

Definition at line 345 of file NBTrafficLightDefinition.h.

Referenced by NBLoadedSUMOTLDef::addConnection(), addControlledInnerEdges(), and collectEdges().

The list of edges within the area controlled by the tls.

Definition at line 339 of file NBTrafficLightDefinition.h.

Referenced by collectEdges().

std::string NBTrafficLightDefinition::mySubID [protected]

The tls program's subid.

Definition at line 348 of file NBTrafficLightDefinition.h.

Referenced by getProgramID(), and setProgramID().


The documentation for this class was generated from the following files:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines