![]() |
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) More... | |
Public Member Functions | |
void | applyOptions (OptionsCont &oc) |
Initialises the storage by applying given options. More... | |
std::pair< int, int > | computeLogics (OptionsCont &oc) |
Computes the traffic light logics using the stored definitions and stores the results. More... | |
bool | computeSingleLogic (OptionsCont &oc, NBTrafficLightDefinition *def) |
Computes a specific traffic light logic (using by NETEDIT) More... | |
void | extract (NBTrafficLightDefinition *definition) |
Extracts a traffic light definition from myDefinitions but keeps it in myExtracted for eventual * deletion (used by NETEDIT) More... | |
std::vector< NBTrafficLightLogic * > | getComputed () const |
Returns a list of all computed logics. More... | |
NBTrafficLightDefinition * | getDefinition (const std::string &id, const std::string &programID) const |
Returns the named definition. More... | |
Definitions | getDefinitions () const |
NBTrafficLightLogic * | getLogic (const std::string &id, const std::string &programID) const |
Returns the computed logic for the given name. More... | |
int | getNumExtracted () const |
return the number of extracted traffic light definitions More... | |
const std::map< std::string, NBTrafficLightDefinition * > & | getPrograms (const std::string &id) const |
Returns all programs for the given tl-id. More... | |
bool | insert (NBTrafficLightDefinition *logic, bool forceInsert=false) |
Adds a logic definition to the dictionary. More... | |
NBTrafficLightLogicCont () | |
Constructor. More... | |
void | remapRemoved (NBEdge *removed, const EdgeVector &incoming, const EdgeVector &outgoing) |
Replaces occurences of the removed edge in incoming/outgoing edges of all definitions. More... | |
bool | removeFully (const std::string id) |
Removes a logic definition (and all programs) from the dictionary. More... | |
bool | removeProgram (const std::string id, const std::string programID, bool del=true) |
Removes a program of a logic definition from the dictionary. More... | |
void | replaceRemoved (NBEdge *removed, int removedLane, NBEdge *by, int byLane) |
Replaces occurences of the removed edge/lane in all definitions by the given edge. More... | |
void | setTLControllingInformation (const NBEdgeCont &ec, const NBNodeCont &nc) |
Informs the edges about being controlled by a tls. More... | |
~NBTrafficLightLogicCont () | |
Destructor. More... | |
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. More... | |
Private Member Functions | |
void | clear () |
Destroys all stored definitions and logics. More... | |
Private Attributes | |
Id2Logics | myComputed |
The container for previously computed tl-logics. More... | |
Id2Defs | myDefinitions |
The container for tl-ids to their definitions. More... | |
std::set< NBTrafficLightDefinition * > | myExtracted |
The container for extracted definitions. More... | |
std::set< std::string > | myHalfOffsetTLS |
List of tls which shall have an offset of T/2. More... | |
std::set< std::string > | myQuarterOffsetTLS |
List of tls which shall have an offset of T/2. More... | |
Static Private Attributes | |
static const Program2Def | EmptyDefinitions = NBTrafficLightLogicCont::Program2Def() |
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 58 of file NBTrafficLightLogicCont.h.
typedef std::vector<NBTrafficLightDefinition*> NBTrafficLightLogicCont::Definitions |
Returns a list of all definitions (convenience for easier iteration)
Definition at line 211 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 48 of file NBTrafficLightLogicCont.cpp.
NBTrafficLightLogicCont::~NBTrafficLightLogicCont | ( | ) |
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 57 of file NBTrafficLightLogicCont.cpp.
References OptionsCont::getStringVector(), OptionsCont::isSet(), and myHalfOffsetTLS.
Referenced by NBNetBuilder::applyOptions().
|
private |
Destroys all stored definitions and logics.
Definition at line 192 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 141 of file NBTrafficLightLogicCont.cpp.
References computeSingleLogic(), getComputed(), getDefinitions(), and myComputed.
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 161 of file NBTrafficLightLogicCont.cpp.
References NBTrafficLightDefinition::compute(), NBTrafficLightLogic::getDuration(), Named::getID(), NBTrafficLightDefinition::getNodes(), NBTrafficLightDefinition::getProgramID(), myComputed, myHalfOffsetTLS, myQuarterOffsetTLS, NBTrafficLightLogic::setOffset(), and WRITE_WARNING.
Referenced by GNENet::computeJunction(), and computeLogics().
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 134 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 296 of file NBTrafficLightLogicCont.cpp.
References myComputed.
Referenced by 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 231 of file NBTrafficLightLogicCont.cpp.
References myDefinitions.
Referenced by NIXMLTrafficLightsHandler::initTrafficLightLogic().
NBTrafficLightLogicCont::Definitions NBTrafficLightLogicCont::getDefinitions | ( | ) | const |
Definition at line 309 of file NBTrafficLightLogicCont.cpp.
References myDefinitions.
Referenced by clear(), computeLogics(), GNETLSEditorFrame::TLSFile::onCmdLoadTLSProgram(), GNETLSEditorFrame::parseTLSPrograms(), remapRemoved(), replaceRemoved(), 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 255 of file NBTrafficLightLogicCont.cpp.
References myComputed.
Referenced by GNETLSEditorFrame::onCmdDefSwitch(), and GNETLSEditorFrame::parseTLSPrograms().
|
inline |
return the number of extracted traffic light definitions
Definition at line 120 of file NBTrafficLightLogicCont.h.
References myExtracted.
Referenced by NILoader::load().
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 244 of file NBTrafficLightLogicCont.cpp.
References EmptyDefinitions, and myDefinitions.
Referenced by NIImporter_SUMO::_loadNetwork(), NIXMLTrafficLightsHandler::addTlConnection(), NIXMLTrafficLightsHandler::initTrafficLightLogic(), NBNodeCont::joinTLS(), 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 74 of file NBTrafficLightLogicCont.cpp.
References IDSupplier::avoid(), Named::getID(), IDSupplier::getNext(), NBTrafficLightDefinition::getProgramID(), myDefinitions, myExtracted, and NBTrafficLightDefinition::setProgramID().
Referenced by GNEJunction::addTrafficLight(), NIVisumTL::build(), NGNode::buildNBNode(), NIVissimTL::dict_SetSignals(), NBNodeCont::guessTLs(), NIXMLTrafficLightsHandler::initTrafficLightLogic(), NIImporter_OpenStreetMap::insertNodeChecking(), NBNode::invalidateTLS(), NBNodeCont::joinNodeCluster(), NBNodeCont::joinTLS(), NIImporter_OpenDrive::loadNetwork(), 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 occurences 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 211 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 98 of file NBTrafficLightLogicCont.cpp.
References myComputed, and myDefinitions.
Referenced by NBNodeCont::guessTLs(), NBNode::invalidateTLS(), NBNodeCont::joinTLS(), and NIXMLNodesHandler::processNodeType().
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 120 of file NBTrafficLightLogicCont.cpp.
References myDefinitions.
Referenced by extract(), NIXMLTrafficLightsHandler::initTrafficLightLogic(), GNETLSEditorFrame::TLSFile::onCmdLoadTLSProgram(), and GNETLSEditorFrame::parseTLSPrograms().
void NBTrafficLightLogicCont::replaceRemoved | ( | NBEdge * | removed, |
int | removedLane, | ||
NBEdge * | by, | ||
int | byLane | ||
) |
Replaces occurences 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 221 of file NBTrafficLightLogicCont.cpp.
References getDefinitions().
Referenced by NBEdgeCont::joinSameNodeConnectingEdges(), GNENet::GNEChange_ReplaceEdgeInTLS::redo(), NBNodeCont::removeUnwishedNodes(), and GNENet::GNEChange_ReplaceEdgeInTLS::undo().
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 269 of file NBTrafficLightLogicCont.cpp.
References NBNodeCont::begin(), NBEdgeCont::clearControllingTLInformation(), NBNodeCont::end(), getDefinitions(), Named::getID(), NBNode::getType(), NODETYPE_RAIL_CROSSING, NODETYPE_RAIL_SIGNAL, NBNode::removeTrafficLight(), NBNode::setCrossingTLIndices(), NBTrafficLightDefinition::setParticipantsInformation(), and TLTYPE_STATIC.
Referenced by NBNetBuilder::compute().
|
staticprivate |
Definition at line 237 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(), getComputed(), getLogic(), and removeFully().
|
private |
The container for tl-ids to their definitions.
Definition at line 226 of file NBTrafficLightLogicCont.h.
Referenced by clear(), getDefinition(), getDefinitions(), getPrograms(), insert(), removeFully(), and removeProgram().
|
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 computeSingleLogic().