Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
NBTrafficLightLogicCont Class Reference

A container for traffic light definitions and built programs. More...

#include <NBTrafficLightLogicCont.h>

Public Types

typedef std::vector< NBTrafficLightDefinition * > Definitions
 Returns a list of all definitions (convenience for easier iteration)
 

Public Member Functions

void applyOpenDriveControllers (OptionsCont &oc)
 post processing of signal programs to group tl indices according to OpenDrive controllers (signal groups)
 
void applyOptions (OptionsCont &oc)
 Initialises the storage by applying given options.
 
std::pair< int, int > computeLogics (OptionsCont &oc)
 Computes the traffic light logics using the stored definitions and stores the results.
 
bool computeSingleLogic (OptionsCont &oc, NBTrafficLightDefinition *def)
 Computes a specific traffic light logic (using by netedit)
 
bool exist (const std::string &newID, bool requireComputed=true) const
 check if exists a definition with the given ID
 
void extract (NBTrafficLightDefinition *definition)
 Extracts a traffic light definition from myDefinitions but keeps it in myExtracted for eventual * deletion (used by netedit)
 
std::vector< NBTrafficLightLogic * > getComputed () const
 Returns a list of all computed logics.
 
NBTrafficLightDefinitiongetDefinition (const std::string &id, const std::string &programID) const
 Returns the named definition.
 
Definitions getDefinitions () const
 
NBTrafficLightLogicgetLogic (const std::string &id, const std::string &programID) const
 Returns the computed logic for the given name.
 
std::string getNextProgramID (const std::string &id) const
 Returns a new (unused) programID for the given traffic light.
 
int getNumExtracted () const
 return the number of extracted traffic light definitions
 
const std::map< std::string, NBTrafficLightDefinition * > & getPrograms (const std::string &id) const
 Returns all programs for the given tl-id.
 
bool insert (NBTrafficLightDefinition *logic, bool forceInsert=false)
 Adds a logic definition to the dictionary.
 
 NBTrafficLightLogicCont ()
 Constructor.
 
void remapRemoved (NBEdge *removed, const EdgeVector &incoming, const EdgeVector &outgoing)
 Replaces occurrences of the removed edge in incoming/outgoing edges of all definitions.
 
bool removeFully (const std::string id)
 Removes a logic definition (and all programs) from the dictionary.
 
bool removeProgram (const std::string id, const std::string programID, bool del=true)
 Removes a program of a logic definition from the dictionary.
 
void rename (NBTrafficLightDefinition *tlDef, const std::string &newID)
 rename traffic light
 
void replaceRemoved (NBEdge *removed, int removedLane, NBEdge *by, int byLane, bool incoming)
 Replaces occurrences of the removed edge/lane in all definitions by the given edge.
 
void setOpenDriveSignalParameters ()
 set OpenDRIVE signal reference parameters after all link indices are known
 
void setTLControllingInformation (const NBEdgeCont &ec, const NBNodeCont &nc)
 Informs the edges about being controlled by a tls.
 
 ~NBTrafficLightLogicCont ()
 Destructor.
 

Private Types

typedef std::map< std::string, Program2DefId2Defs
 
typedef std::map< std::string, Program2LogicId2Logics
 
typedef std::vector< NBTrafficLightLogic * > Logics
 
typedef std::map< std::string, NBTrafficLightDefinition * > Program2Def
 
typedef std::map< std::string, NBTrafficLightLogic * > Program2Logic
 Definition of internal the container types.
 

Private Member Functions

void clear ()
 Destroys all stored definitions and logics.
 

Private Attributes

Id2Logics myComputed
 The container for previously computed tl-logics.
 
Id2Defs myDefinitions
 The container for tl-ids to their definitions.
 
std::set< NBTrafficLightDefinition * > myExtracted
 The container for extracted definitions.
 
std::set< std::string > myHalfOffsetTLS
 List of tls which shall have an offset of T/2.
 
std::set< std::string > myQuarterOffsetTLS
 List of tls which shall have an offset of T/2.
 

Static Private Attributes

static const Program2Def EmptyDefinitions = NBTrafficLightLogicCont::Program2Def()
 empty definition
 

Detailed Description

A container for traffic light definitions and built programs.

This container class holds definitions of traffic light logics during the loading of the network. After all information has been loaded, these definitions are used to build the traffic light logics.

The built traffic light logics are kept stored within this container during their building and written to the network file at the end.

See also
NBTrafficLightDefinition
NBTrafficLightLogic

Definition at line 55 of file NBTrafficLightLogicCont.h.

Member Typedef Documentation

◆ Definitions

Returns a list of all definitions (convenience for easier iteration)

Definition at line 204 of file NBTrafficLightLogicCont.h.

◆ Id2Defs

typedef std::map<std::string, Program2Def> NBTrafficLightLogicCont::Id2Defs
private

Definition at line 219 of file NBTrafficLightLogicCont.h.

◆ Id2Logics

typedef std::map<std::string, Program2Logic> NBTrafficLightLogicCont::Id2Logics
private

Definition at line 217 of file NBTrafficLightLogicCont.h.

◆ Logics

Definition at line 220 of file NBTrafficLightLogicCont.h.

◆ Program2Def

typedef std::map<std::string, NBTrafficLightDefinition*> NBTrafficLightLogicCont::Program2Def
private

Definition at line 218 of file NBTrafficLightLogicCont.h.

◆ Program2Logic

typedef std::map<std::string, NBTrafficLightLogic*> NBTrafficLightLogicCont::Program2Logic
private

Definition of internal the container types.

Definition at line 216 of file NBTrafficLightLogicCont.h.

Constructor & Destructor Documentation

◆ NBTrafficLightLogicCont()

NBTrafficLightLogicCont::NBTrafficLightLogicCont ( )

Constructor.

Definition at line 47 of file NBTrafficLightLogicCont.cpp.

◆ ~NBTrafficLightLogicCont()

NBTrafficLightLogicCont::~NBTrafficLightLogicCont ( )

Destructor.

Definition at line 50 of file NBTrafficLightLogicCont.cpp.

References clear().

Member Function Documentation

◆ applyOpenDriveControllers()

void NBTrafficLightLogicCont::applyOpenDriveControllers ( OptionsCont oc)

post processing of signal programs to group tl indices according to OpenDrive controllers (signal groups)

Definition at line 393 of file NBTrafficLightLogicCont.cpp.

References NBLoadedSUMOTLDef::cleanupStates(), computeSingleLogic(), getComputed(), getDefinitions(), NBLoadedSUMOTLDef::getLogic(), NBTrafficLightDefinition::getNodes(), insert(), LINKSTATE_TL_GREEN_MAJOR, LINKSTATE_TL_GREEN_MINOR, removeProgram(), NBLoadedSUMOTLDef::replaceIndex(), NBTrafficLightDefinition::setParticipantsInformation(), NBTrafficLightLogic::setPhaseState(), TL, and WRITE_WARNINGF.

Referenced by NBNetBuilder::compute().

Here is the caller graph for this function:

◆ applyOptions()

void NBTrafficLightLogicCont::applyOptions ( OptionsCont oc)

Initialises the storage by applying given options.

Options, mainly setting offsets, are parsed and the according internal variables are set.

Parameters
[in]ocThe options container to read options from
Todo:
Recheck exceptions

Definition at line 56 of file NBTrafficLightLogicCont.cpp.

References OptionsCont::getStringVector(), OptionsCont::isSet(), myHalfOffsetTLS, and myQuarterOffsetTLS.

Referenced by NBNetBuilder::applyOptions().

Here is the caller graph for this function:

◆ clear()

void NBTrafficLightLogicCont::clear ( )
private

Destroys all stored definitions and logics.

Definition at line 265 of file NBTrafficLightLogicCont.cpp.

References getComputed(), getDefinitions(), myComputed, myDefinitions, and myExtracted.

Referenced by ~NBTrafficLightLogicCont().

Here is the caller graph for this function:

◆ computeLogics()

std::pair< int, int > NBTrafficLightLogicCont::computeLogics ( OptionsCont oc)

Computes the traffic light logics using the stored definitions and stores the results.

Goes through all stored definitions and calls "NBTrafficLightDefinition::compute" for each. Stores the result using "insert".

Parameters
[in]ocOptions used during the computation
Returns
The number of computed tls and programs
See also
NBTrafficLightDefinition::compute

Definition at line 160 of file NBTrafficLightLogicCont.cpp.

References computeSingleLogic(), StringBijection< T >::get(), OptionsCont::getBool(), getComputed(), getDefinitions(), NBTrafficLightDefinition::getIncomingEdges(), NBTrafficLightDefinition::getNodes(), OptionsCont::getString(), NBTrafficLightDefinition::getType(), NBLoadedSUMOTLDef::groupSignals(), insert(), OptionsCont::isDefault(), myComputed, removeProgram(), NBTrafficLightDefinition::setParticipantsInformation(), NBTrafficLightDefinition::setProgramID(), NBOwnTLDef::setTLControllingInformation(), SUMOXMLDefinitions::TrafficLightTypes, NBLoadedSUMOTLDef::ungroupSignals(), and NBLoadedSUMOTLDef::usingSignalGroups().

Referenced by NBNetBuilder::compute().

Here is the caller graph for this function:

◆ computeSingleLogic()

bool NBTrafficLightLogicCont::computeSingleLogic ( OptionsCont oc,
NBTrafficLightDefinition def 
)

Computes a specific traffic light logic (using by netedit)

Parameters
[in]ocOptions used during the computation
Returns
whether the logic was computed successfully
See also
NBTrafficLightDefinition::compute

Definition at line 234 of file NBTrafficLightLogicCont.cpp.

References NBTrafficLightDefinition::compute(), NBTrafficLightLogic::getDuration(), Named::getID(), NBTrafficLightDefinition::getNodes(), NBTrafficLightDefinition::getProgramID(), myComputed, myHalfOffsetTLS, myQuarterOffsetTLS, NBTrafficLightLogic::setOffset(), STEPS2TIME, TIME2STEPS, TL, and WRITE_WARNINGF.

Referenced by applyOpenDriveControllers(), NBNetBuilder::compute(), GNENet::computeJunction(), computeLogics(), and NBNodeCont::recheckGuessedTLS().

Here is the caller graph for this function:

◆ exist()

bool NBTrafficLightLogicCont::exist ( const std::string &  newID,
bool  requireComputed = true 
) const

check if exists a definition with the given ID

Definition at line 148 of file NBTrafficLightLogicCont.cpp.

References myComputed, and myDefinitions.

Referenced by NBNodeCont::joinTLS(), GNEViewNet::onCmdAddJoinTLS(), and GNETLSEditorFrame::TLSJunction::onCmdDisjoinTLS().

Here is the caller graph for this function:

◆ extract()

void NBTrafficLightLogicCont::extract ( NBTrafficLightDefinition definition)

Extracts a traffic light definition from myDefinitions but keeps it in myExtracted for eventual * deletion (used by netedit)

Definition at line 141 of file NBTrafficLightLogicCont.cpp.

References Named::getID(), NBTrafficLightDefinition::getProgramID(), myExtracted, and removeProgram().

Referenced by NBNodeCont::discardTrafficLights(), and GNEJunction::removeTrafficLight().

Here is the caller graph for this function:

◆ getComputed()

NBTrafficLightLogicCont::Logics NBTrafficLightLogicCont::getComputed ( ) const

Returns a list of all computed logics.

Definition at line 500 of file NBTrafficLightLogicCont.cpp.

References myComputed.

Referenced by applyOpenDriveControllers(), clear(), computeLogics(), and NWWriter_SUMO::writeTrafficLights().

Here is the caller graph for this function:

◆ getDefinition()

NBTrafficLightDefinition * NBTrafficLightLogicCont::getDefinition ( const std::string &  id,
const std::string &  programID 
) const

Returns the named definition.

Parameters
[in]idThe id of the definition to return
[in]programIDThe id of the program to return
Returns
The named definition, 0 if it is not known

Definition at line 304 of file NBTrafficLightLogicCont.cpp.

References myDefinitions.

Referenced by NIXMLTrafficLightsHandler::initTrafficLightLogic(), and NWWriter_SUMO::writeTrafficLights().

Here is the caller graph for this function:

◆ getDefinitions()

NBTrafficLightLogicCont::Definitions NBTrafficLightLogicCont::getDefinitions ( ) const

Definition at line 513 of file NBTrafficLightLogicCont.cpp.

References myDefinitions.

Referenced by applyOpenDriveControllers(), clear(), computeLogics(), GNETLSEditorFrame::TLSFile::onCmdLoadTLSProgram(), GNETLSEditorFrame::parseTLSPrograms(), remapRemoved(), replaceRemoved(), setOpenDriveSignalParameters(), and setTLControllingInformation().

Here is the caller graph for this function:

◆ getLogic()

NBTrafficLightLogic * NBTrafficLightLogicCont::getLogic ( const std::string &  id,
const std::string &  programID 
) const

Returns the computed logic for the given name.

Parameters
[in]idThe id of the logic to return
[in]programIDThe id of the program to return
Returns
The named definition, 0 if it is not known

Definition at line 328 of file NBTrafficLightLogicCont.cpp.

References myComputed.

Referenced by GNETLSEditorFrame::parseTLSPrograms(), and GNETLSEditorFrame::TLSDefinition::switchProgram().

Here is the caller graph for this function:

◆ getNextProgramID()

std::string NBTrafficLightLogicCont::getNextProgramID ( const std::string &  id) const

Returns a new (unused) programID for the given traffic light.

Parameters
[in]idThe id of the traffic light
Returns
A new programID that isn't jet used by that traffic light

Definition at line 73 of file NBTrafficLightLogicCont.cpp.

References IDSupplier::avoid(), IDSupplier::getNext(), and myDefinitions.

Referenced by GNETLSEditorFrame::TLSDefinition::createTLS(), and insert().

Here is the caller graph for this function:

◆ getNumExtracted()

int NBTrafficLightLogicCont::getNumExtracted ( ) const

return the number of extracted traffic light definitions

Definition at line 547 of file NBTrafficLightLogicCont.cpp.

References myExtracted.

Referenced by NILoader::load(), and main().

Here is the caller graph for this function:

◆ getPrograms()

const NBTrafficLightLogicCont::Program2Def & NBTrafficLightLogicCont::getPrograms ( const std::string &  id) const

Returns all programs for the given tl-id.

Parameters
[in]idThe tl-id for which to return all programs
Returns
The map of programIDs to definitions

Definition at line 317 of file NBTrafficLightLogicCont.cpp.

References EmptyDefinitions, and myDefinitions.

Referenced by NIImporter_SUMO::_loadNetwork(), NIXMLTrafficLightsHandler::addTlConnection(), NIXMLTrafficLightsHandler::initTrafficLightLogic(), GNETLSEditorFrame::TLSFile::onCmdLoadTLSProgram(), NIXMLNodesHandler::processTrafficLightDefinitions(), NIXMLTrafficLightsHandler::removeTlConnection(), and GNEJunction::setAttribute().

Here is the caller graph for this function:

◆ insert()

bool NBTrafficLightLogicCont::insert ( NBTrafficLightDefinition logic,
bool  forceInsert = false 
)

Adds a logic definition to the dictionary.

"true" is returned if the logic is accepted - no logic with the same name and programID exists within this container.

Parameters
[in]logicThe logic to add
[in]forceInsertIf true, rename the program to make insertion succeed
Returns
Whether the logic was valid (no logic with the same id and programID is already known)

Definition at line 86 of file NBTrafficLightLogicCont.cpp.

References Named::getID(), getNextProgramID(), NBTrafficLightDefinition::getProgramID(), myDefinitions, myExtracted, and NBTrafficLightDefinition::setProgramID().

Referenced by GNEJunction::addTrafficLight(), applyOpenDriveControllers(), NIVisumTL::build(), NGNode::buildNBNode(), computeLogics(), NIVissimTL::dict_SetSignals(), NIImporter_OpenDrive::getTLSSecure(), NBNodeCont::guessTLs(), NIXMLTrafficLightsHandler::initTrafficLightLogic(), NIImporter_OpenStreetMap::insertNodeChecking(), NBNode::invalidateTLS(), NBNodeCont::joinNodeCluster(), NBNodeCont::joinTLS(), NIImporter_SUMO::myEndElement(), GNETLSEditorFrame::TLSFile::onCmdLoadTLSProgram(), GNETLSEditorFrame::parseTLSPrograms(), NIXMLNodesHandler::processTrafficLightDefinitions(), NBNodeCont::setAsTLControlled(), and NBNodeTypeComputer::validateRailCrossings().

Here is the caller graph for this function:

◆ remapRemoved()

void NBTrafficLightLogicCont::remapRemoved ( NBEdge removed,
const EdgeVector incoming,
const EdgeVector outgoing 
)

Replaces occurrences 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
Todo:
Recheck usage

Definition at line 284 of file NBTrafficLightLogicCont.cpp.

References getDefinitions().

Referenced by NBNode::remapRemoved().

Here is the caller graph for this function:

◆ removeFully()

bool NBTrafficLightLogicCont::removeFully ( const std::string  id)

Removes a logic definition (and all programs) from the dictionary.

"true" is returned if the logic existed in the dictionary, otherwise "false".

Parameters
[in]idThe id of the logic to remove
Returns
Whether the named logic was within the dictionary

Definition at line 105 of file NBTrafficLightLogicCont.cpp.

References myComputed, and myDefinitions.

Referenced by NBNodeCont::guessTLs(), NBNode::invalidateTLS(), NBNodeCont::joinTLS(), NIXMLNodesHandler::processNodeType(), and NBNodeCont::recheckGuessedTLS().

Here is the caller graph for this function:

◆ removeProgram()

bool NBTrafficLightLogicCont::removeProgram ( const std::string  id,
const std::string  programID,
bool  del = true 
)

Removes a program of a logic definition from the dictionary.

"true" is returned if the program existed in the dictionary, otherwise "false".

Parameters
[in]idThe id of the logic
[in]programIDThe id of the program to remove
[in]delWhether the definition shall be deleted
Returns
Whether the program was within the dictionary

Definition at line 127 of file NBTrafficLightLogicCont.cpp.

References myDefinitions.

Referenced by applyOpenDriveControllers(), computeLogics(), extract(), NIXMLTrafficLightsHandler::initTrafficLightLogic(), GNETLSEditorFrame::TLSFile::onCmdLoadTLSProgram(), and GNETLSEditorFrame::parseTLSPrograms().

Here is the caller graph for this function:

◆ rename()

void NBTrafficLightLogicCont::rename ( NBTrafficLightDefinition tlDef,
const std::string &  newID 
)

rename traffic light

Definition at line 526 of file NBTrafficLightLogicCont.cpp.

References Named::getID(), myComputed, and myDefinitions.

Referenced by GNEChange_TLS::redo(), NBNodeCont::remapIDs(), and GNEChange_TLS::undo().

Here is the caller graph for this function:

◆ replaceRemoved()

void NBTrafficLightLogicCont::replaceRemoved ( NBEdge removed,
int  removedLane,
NBEdge by,
int  byLane,
bool  incoming 
)

Replaces occurrences of the removed edge/lane in all definitions by the given edge.

Parameters
[in]removedThe removed edge
[in]removedThe removed lane
[in]byThe edge to use instead
[in]byLaneThe lane to use instead
Todo:
Recheck usage

Definition at line 294 of file NBTrafficLightLogicCont.cpp.

References getDefinitions().

Referenced by NBEdgeCont::joinSameNodeConnectingEdges().

Here is the caller graph for this function:

◆ setOpenDriveSignalParameters()

void NBTrafficLightLogicCont::setOpenDriveSignalParameters ( )

set OpenDRIVE signal reference parameters after all link indices are known

Definition at line 369 of file NBTrafficLightLogicCont.cpp.

References getDefinitions(), Parameterised::getParameter(), Parameterised::hasParameter(), TL, toString(), and WRITE_WARNINGF.

Referenced by NBNetBuilder::compute().

Here is the caller graph for this function:

◆ setTLControllingInformation()

void NBTrafficLightLogicCont::setTLControllingInformation ( const NBEdgeCont ec,
const NBNodeCont nc 
)

Informs the edges about being controlled by a tls.

Goes through all definition, calling eachs "setParticipantsInformation" method. Goes through all definition, calling eachs "setTLControllingInformation" method.

Parameters
[in]ecThe ede control to set information into
See also
NBTrafficLightDefinition::setParticipantsInformation
NBTrafficLightDefinition::setTLControllingInformation

Definition at line 342 of file NBTrafficLightLogicCont.cpp.

References NBNodeCont::begin(), NBEdgeCont::clearControllingTLInformation(), NBNodeCont::end(), NBTrafficLightDefinition::getControlledLinks(), getDefinitions(), Named::getID(), NBNode::getType(), RAIL_CROSSING, RAIL_SIGNAL, NBNode::removeTrafficLight(), NBNode::setCrossingTLIndices(), NBTrafficLightDefinition::setParticipantsInformation(), NBOwnTLDef::setTLControllingInformation(), and STATIC.

Referenced by NBNetBuilder::compute().

Here is the caller graph for this function:

Field Documentation

◆ EmptyDefinitions

const NBTrafficLightLogicCont::Program2Def NBTrafficLightLogicCont::EmptyDefinitions = NBTrafficLightLogicCont::Program2Def()
staticprivate

empty definition

Definition at line 238 of file NBTrafficLightLogicCont.h.

Referenced by getPrograms().

◆ myComputed

Id2Logics NBTrafficLightLogicCont::myComputed
private

The container for previously computed tl-logics.

Definition at line 223 of file NBTrafficLightLogicCont.h.

Referenced by clear(), computeLogics(), computeSingleLogic(), exist(), getComputed(), getLogic(), removeFully(), and rename().

◆ myDefinitions

Id2Defs NBTrafficLightLogicCont::myDefinitions
private

The container for tl-ids to their definitions.

Definition at line 226 of file NBTrafficLightLogicCont.h.

Referenced by clear(), exist(), getDefinition(), getDefinitions(), getNextProgramID(), getPrograms(), insert(), removeFully(), removeProgram(), and rename().

◆ myExtracted

std::set<NBTrafficLightDefinition*> NBTrafficLightLogicCont::myExtracted
private

The container for extracted definitions.

Definition at line 229 of file NBTrafficLightLogicCont.h.

Referenced by clear(), extract(), getNumExtracted(), and insert().

◆ myHalfOffsetTLS

std::set<std::string> NBTrafficLightLogicCont::myHalfOffsetTLS
private

List of tls which shall have an offset of T/2.

Definition at line 232 of file NBTrafficLightLogicCont.h.

Referenced by applyOptions(), and computeSingleLogic().

◆ myQuarterOffsetTLS

std::set<std::string> NBTrafficLightLogicCont::myQuarterOffsetTLS
private

List of tls which shall have an offset of T/2.

Definition at line 235 of file NBTrafficLightLogicCont.h.

Referenced by applyOptions(), and computeSingleLogic().


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