Eclipse SUMO - Simulation of Urban MObility
|
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. | |
NBTrafficLightDefinition * | getDefinition (const std::string &id, const std::string &programID) const |
Returns the named definition. | |
Definitions | getDefinitions () const |
NBTrafficLightLogic * | getLogic (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, Program2Def > | Id2Defs |
typedef std::map< std::string, Program2Logic > | Id2Logics |
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 | |
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.
Definition at line 55 of file NBTrafficLightLogicCont.h.
typedef std::vector<NBTrafficLightDefinition*> NBTrafficLightLogicCont::Definitions |
Returns a list of all definitions (convenience for easier iteration)
Definition at line 204 of file NBTrafficLightLogicCont.h.
|
private |
Definition at line 219 of file NBTrafficLightLogicCont.h.
|
private |
Definition at line 217 of file NBTrafficLightLogicCont.h.
|
private |
Definition at line 220 of file NBTrafficLightLogicCont.h.
|
private |
Definition at line 218 of file NBTrafficLightLogicCont.h.
|
private |
Definition of internal the container types.
Definition at line 216 of file NBTrafficLightLogicCont.h.
NBTrafficLightLogicCont::NBTrafficLightLogicCont | ( | ) |
Constructor.
Definition at line 47 of file NBTrafficLightLogicCont.cpp.
NBTrafficLightLogicCont::~NBTrafficLightLogicCont | ( | ) |
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().
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.
[in] | oc | The options container to read options from |
Definition at line 56 of file NBTrafficLightLogicCont.cpp.
References OptionsCont::getStringVector(), OptionsCont::isSet(), myHalfOffsetTLS, and myQuarterOffsetTLS.
Referenced by NBNetBuilder::applyOptions().
|
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().
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".
[in] | oc | Options used during the computation |
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().
bool NBTrafficLightLogicCont::computeSingleLogic | ( | OptionsCont & | oc, |
NBTrafficLightDefinition * | def | ||
) |
Computes a specific traffic light logic (using by netedit)
[in] | oc | Options used during the computation |
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().
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().
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().
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().
NBTrafficLightDefinition * NBTrafficLightLogicCont::getDefinition | ( | const std::string & | id, |
const std::string & | programID | ||
) | const |
Returns the named definition.
[in] | id | The id of the definition to return |
[in] | programID | The id of the program to return |
Definition at line 304 of file NBTrafficLightLogicCont.cpp.
References myDefinitions.
Referenced by NIXMLTrafficLightsHandler::initTrafficLightLogic(), and NWWriter_SUMO::writeTrafficLights().
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().
NBTrafficLightLogic * NBTrafficLightLogicCont::getLogic | ( | const std::string & | id, |
const std::string & | programID | ||
) | const |
Returns the computed logic for the given name.
[in] | id | The id of the logic to return |
[in] | programID | The id of the program to return |
Definition at line 328 of file NBTrafficLightLogicCont.cpp.
References myComputed.
Referenced by GNETLSEditorFrame::parseTLSPrograms(), and GNETLSEditorFrame::TLSDefinition::switchProgram().
std::string NBTrafficLightLogicCont::getNextProgramID | ( | const std::string & | id | ) | const |
Returns a new (unused) programID for the given traffic light.
[in] | id | The id of the traffic light |
Definition at line 73 of file NBTrafficLightLogicCont.cpp.
References IDSupplier::avoid(), IDSupplier::getNext(), and myDefinitions.
Referenced by GNETLSEditorFrame::TLSDefinition::createTLS(), and insert().
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().
const NBTrafficLightLogicCont::Program2Def & NBTrafficLightLogicCont::getPrograms | ( | const std::string & | id | ) | const |
Returns all programs for the given tl-id.
[in] | id | The tl-id for which to return all programs |
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().
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.
[in] | logic | The logic to add |
[in] | forceInsert | If true, rename the program to make insertion succeed |
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().
void NBTrafficLightLogicCont::remapRemoved | ( | NBEdge * | removed, |
const EdgeVector & | incoming, | ||
const EdgeVector & | outgoing | ||
) |
Replaces occurrences of the removed edge in incoming/outgoing edges of all definitions.
[in] | removed | The removed edge |
[in] | incoming | The edges to use instead if an incoming edge was removed |
[in] | outgoing | The edges to use instead if an outgoing edge was removed |
Definition at line 284 of file NBTrafficLightLogicCont.cpp.
References getDefinitions().
Referenced by NBNode::remapRemoved().
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".
[in] | id | The id of the logic to remove |
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().
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".
[in] | id | The id of the logic |
[in] | programID | The id of the program to remove |
[in] | del | Whether the definition shall be deleted |
Definition at line 127 of file NBTrafficLightLogicCont.cpp.
References myDefinitions.
Referenced by applyOpenDriveControllers(), computeLogics(), extract(), NIXMLTrafficLightsHandler::initTrafficLightLogic(), GNETLSEditorFrame::TLSFile::onCmdLoadTLSProgram(), and GNETLSEditorFrame::parseTLSPrograms().
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().
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.
[in] | removed | The removed edge |
[in] | removed | The removed lane |
[in] | by | The edge to use instead |
[in] | byLane | The lane to use instead |
Definition at line 294 of file NBTrafficLightLogicCont.cpp.
References getDefinitions().
Referenced by NBEdgeCont::joinSameNodeConnectingEdges().
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().
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.
[in] | ec | The ede control to set information into |
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().
|
staticprivate |
empty definition
Definition at line 238 of file NBTrafficLightLogicCont.h.
Referenced by getPrograms().
|
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().
|
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().
|
private |
The container for extracted definitions.
Definition at line 229 of file NBTrafficLightLogicCont.h.
Referenced by clear(), extract(), getNumExtracted(), and insert().
|
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().
|
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().