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

A SUMO-compliant built logic for a traffic light. More...

#include <NBTrafficLightLogic.h>

Inheritance diagram for NBTrafficLightLogic:
Named

Data Structures

class  PhaseDefinition
 The definition of a single phase of the logic. More...

Public Member Functions

void addStep (SUMOTime duration, const std::string &state, int index=-1)
 Adds a phase to the logic.
void closeBuilding ()
 closes the building process
void deletePhase (unsigned int index)
SUMOTime getDuration () const
 Returns the duration of the complete cycle.
const std::string & getID () const
 Returns the id.
unsigned int getNumLinks ()
 Returns the number of participating links.
SUMOTime getOffset () const
 Returns the offset of first switch.
const std::vector
< PhaseDefinition > & 
getPhases () const
 Returns the phases.
const std::string & getProgramID () const
 Returns the ProgramID.
 NBTrafficLightLogic (const std::string &id, const std::string &subid, unsigned int noLinks)
 Constructor.
 NBTrafficLightLogic (const NBTrafficLightLogic *logic)
 Copy Constructor.
void resetPhases ()
void setID (const std::string &newID)
 resets the id
void setOffset (SUMOTime offset)
 Sets the offset of this tls.
void setPhaseDuration (unsigned int phaseIndex, SUMOTime duration)
 Modifies the duration for an existing phase (used by NETEDIT)
void setPhaseState (unsigned int phaseIndex, int tlIndex, LinkState linkState)
 Modifies the state for an existing phase (used by NETEDIT)
 ~NBTrafficLightLogic ()
 Destructor.

Protected Attributes

std::string myID
 The name of the object.

Private Types

typedef std::vector
< PhaseDefinition
PhaseDefinitionVector
 Definition of a vector of traffic light phases.

Private Attributes

unsigned int myNumLinks
 The number of participating links.
SUMOTime myOffset
 The tls program's offset.
PhaseDefinitionVector myPhases
 The junction logic's storage for traffic light phase list.
const std::string mySubID
 The tls program's subid.

Static Private Attributes

static const std::string ALLOWED_STATES
static const char allowedStatesInitializer []
 all allowed characters for phase state (see SUMOXMLDefinitions)

Detailed Description

A SUMO-compliant built logic for a traffic light.

Definition at line 58 of file NBTrafficLightLogic.h.


Member Typedef Documentation

Definition of a vector of traffic light phases.

Definition at line 207 of file NBTrafficLightLogic.h.


Constructor & Destructor Documentation

NBTrafficLightLogic::NBTrafficLightLogic ( const std::string &  id,
const std::string &  subid,
unsigned int  noLinks 
)

Constructor.

Parameters:
[in]idThe id of the traffic light
[in]subidThe id of the program
[in]noLinksNumber of links that are controlled by this tls. 0 means the value is not known beforehand

Definition at line 70 of file NBTrafficLightLogic.cpp.

NBTrafficLightLogic::NBTrafficLightLogic ( const NBTrafficLightLogic logic)

Copy Constructor.

Parameters:
[in]logicThe logic to copy

Definition at line 75 of file NBTrafficLightLogic.cpp.

NBTrafficLightLogic::~NBTrafficLightLogic ( )

Destructor.

Definition at line 83 of file NBTrafficLightLogic.cpp.


Member Function Documentation

void NBTrafficLightLogic::addStep ( SUMOTime  duration,
const std::string &  state,
int  index = -1 
)

Adds a phase to the logic.

Parameters:
[in]durationThe duration of the phase to add
[in]stateThe state definition of a tls phase
[in]indexThe index of the new phase (-1 means append to end)
Note:
: the length of the state has to match the number of links and the length given in previous calls to addStep (throws ProcessError)

Definition at line 87 of file NBTrafficLightLogic.cpp.

References ALLOWED_STATES, myNumLinks, myPhases, and toString().

Referenced by NBLoadedSUMOTLDef::addPhase(), NBOwnTLDef::myCompute(), NBLoadedTLDef::myCompute(), and NBLoadedSUMOTLDef::removeConnection().

void NBTrafficLightLogic::closeBuilding ( )

closes the building process

Joins equal steps.

Definition at line 138 of file NBTrafficLightLogic.cpp.

References myPhases.

Referenced by NBLoadedSUMOTLDef::myCompute(), and NBLoadedTLDef::myCompute().

void NBTrafficLightLogic::deletePhase ( unsigned int  index)

Definition at line 111 of file NBTrafficLightLogic.cpp.

References myPhases, and toString().

SUMOTime NBTrafficLightLogic::getDuration ( ) const

Returns the duration of the complete cycle.

Returns:
The duration of this logic's cycle

Definition at line 128 of file NBTrafficLightLogic.cpp.

References myPhases.

Referenced by NBTrafficLightLogicCont::computeSingleLogic(), and NBOwnTLDef::myCompute().

const std::string& Named::getID ( ) const
inlineinherited

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(), NBTrafficLightDefinition::collectEdges(), NBOwnTLDef::collectLinks(), NBTrafficLightDefinition::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_TLS::processGet(), TraCIServerAPI_Lane::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().

unsigned int NBTrafficLightLogic::getNumLinks ( )
inline

Returns the number of participating links.

Definition at line 191 of file NBTrafficLightLogic.h.

References myNumLinks.

Referenced by NBLoadedSUMOTLDef::addConnection(), and NBLoadedSUMOTLDef::setTLControllingInformation().

SUMOTime NBTrafficLightLogic::getOffset ( ) const
inline

Returns the offset of first switch.

Returns:
The switch offset

Definition at line 184 of file NBTrafficLightLogic.h.

References myOffset.

Referenced by NBLoadedSUMOTLDef::removeConnection().

const std::vector<PhaseDefinition>& NBTrafficLightLogic::getPhases ( ) const
inline

Returns the phases.

Returns:
The phase list

Definition at line 176 of file NBTrafficLightLogic.h.

References myPhases.

Referenced by NBLoadedSUMOTLDef::removeConnection().

const std::string& NBTrafficLightLogic::getProgramID ( ) const
inline

Returns the ProgramID.

Returns:
The ID of the program (subID)

Definition at line 168 of file NBTrafficLightLogic.h.

References mySubID.

void NBTrafficLightLogic::resetPhases ( )

Definition at line 121 of file NBTrafficLightLogic.cpp.

References myNumLinks, and myPhases.

Referenced by NIXMLTrafficLightsHandler::myStartElement().

void Named::setID ( const std::string &  newID)
inlineinherited

resets the id

Definition at line 67 of file Named.h.

References Named::myID.

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

void NBTrafficLightLogic::setOffset ( SUMOTime  offset)
inline

Sets the offset of this tls.

Parameters:
[in]offsetThe offset of this cycle

Definition at line 160 of file NBTrafficLightLogic.h.

References myOffset.

Referenced by NBTrafficLightLogicCont::computeSingleLogic(), NIXMLTrafficLightsHandler::initTrafficLightLogic(), NBLoadedSUMOTLDef::NBLoadedSUMOTLDef(), and NBLoadedSUMOTLDef::removeConnection().

void NBTrafficLightLogic::setPhaseDuration ( unsigned int  phaseIndex,
SUMOTime  duration 
)

Modifies the duration for an existing phase (used by NETEDIT)

Parameters:
[in]phaseIndexThe index of the phase to modify
[in]durationThe new duration for this phase

Definition at line 160 of file NBTrafficLightLogic.cpp.

References myPhases.

void NBTrafficLightLogic::setPhaseState ( unsigned int  phaseIndex,
int  tlIndex,
LinkState  linkState 
)

Modifies the state for an existing phase (used by NETEDIT)

Parameters:
[in]phaseIndexThe index of the phase to modify
[in]tlIndexThe index at which to modify the state
[in]linkStateThe new link state for the given index

Definition at line 151 of file NBTrafficLightLogic.cpp.

References myPhases.


Field Documentation

const std::string NBTrafficLightLogic::ALLOWED_STATES
staticprivate

Definition at line 214 of file NBTrafficLightLogic.h.

Referenced by addStep().

const char NBTrafficLightLogic::allowedStatesInitializer
staticprivate
unsigned int NBTrafficLightLogic::myNumLinks
private

The number of participating links.

Definition at line 198 of file NBTrafficLightLogic.h.

Referenced by addStep(), getNumLinks(), and resetPhases().

SUMOTime NBTrafficLightLogic::myOffset
private

The tls program's offset.

Definition at line 204 of file NBTrafficLightLogic.h.

Referenced by getOffset(), and setOffset().

PhaseDefinitionVector NBTrafficLightLogic::myPhases
private

The junction logic's storage for traffic light phase list.

Definition at line 210 of file NBTrafficLightLogic.h.

Referenced by addStep(), closeBuilding(), deletePhase(), getDuration(), getPhases(), resetPhases(), setPhaseDuration(), and setPhaseState().

const std::string NBTrafficLightLogic::mySubID
private

The tls program's subid.

Definition at line 201 of file NBTrafficLightLogic.h.

Referenced by getProgramID().


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