SUMO - Simulation of Urban MObility
NBTrafficLightLogic Class Reference

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

#include <NBTrafficLightLogic.h>

Inheritance diagram for NBTrafficLightLogic:
Named Parameterised

Data Structures

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

Public Member Functions

void addParameter (const std::string &key, const std::string &value)
 Adds a parameter. More...
 
void addParameter (const std::map< std::string, std::string > &mapArg)
 Adds all given parameter. More...
 
void addParameter (const Parameterised &p)
 Adds all given parameter. More...
 
void addStep (SUMOTime duration, const std::string &state, int index=-1)
 Adds a phase to the logic. More...
 
void addTo (const StoringVisitor &cont) const
 Adds this object to the given container. More...
 
void clearParameter ()
 Clears the parameter map. More...
 
void closeBuilding ()
 closes the building process More...
 
void deletePhase (unsigned int index)
 
SUMOTime getDuration () const
 Returns the duration of the complete cycle. More...
 
const std::string & getID () const
 Returns the id. More...
 
const std::map< std::string, std::string > & getMap () const
 Returns the inner key/value map. More...
 
unsigned int getNumLinks ()
 Returns the number of participating links. More...
 
SUMOTime getOffset () const
 Returns the offset of first switch. More...
 
const std::string & getParameter (const std::string &key, const std::string &defaultValue) const
 Returns the value for a given key. More...
 
const std::vector< PhaseDefinition > & getPhases () const
 Returns the phases. More...
 
const std::string & getProgramID () const
 Returns the ProgramID. More...
 
TrafficLightType getType () const
 get the algorithm type (static etc..) More...
 
bool knowsParameter (const std::string &key) const
 Returns whether the parameter is known. More...
 
 NBTrafficLightLogic (const std::string &id, const std::string &subid, unsigned int noLinks, SUMOTime offset=0, TrafficLightType type=TLTYPE_STATIC)
 Constructor. More...
 
 NBTrafficLightLogic (const NBTrafficLightLogic *logic)
 Copy Constructor. More...
 
void resetPhases ()
 
void setID (const std::string &newID)
 resets the id More...
 
void setOffset (SUMOTime offset)
 Sets the offset of this tls. More...
 
void setPhaseDuration (unsigned int phaseIndex, SUMOTime duration)
 Modifies the duration for an existing phase (used by NETEDIT) More...
 
void setPhaseState (unsigned int phaseIndex, unsigned int tlIndex, LinkState linkState)
 Modifies the state for an existing phase (used by NETEDIT) More...
 
void setType (TrafficLightType type)
 set the algorithm type (static etc..) More...
 
 ~NBTrafficLightLogic ()
 Destructor. More...
 

Protected Attributes

std::string myID
 The name of the object. More...
 

Private Types

typedef std::vector< PhaseDefinitionPhaseDefinitionVector
 Definition of a vector of traffic light phases. More...
 

Private Member Functions

NBTrafficLightLogicoperator= (const NBTrafficLightLogic &s)
 Invalidated assignment operator. More...
 

Private Attributes

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

Static Private Attributes

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

Detailed Description

A SUMO-compliant built logic for a traffic light.

Definition at line 59 of file NBTrafficLightLogic.h.

Member Typedef Documentation

Definition of a vector of traffic light phases.

Definition at line 220 of file NBTrafficLightLogic.h.

Constructor & Destructor Documentation

NBTrafficLightLogic::NBTrafficLightLogic ( const std::string &  id,
const std::string &  subid,
unsigned int  noLinks,
SUMOTime  offset = 0,
TrafficLightType  type = TLTYPE_STATIC 
)

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
[in]offsetThe offset of the program (delay)
[in]typeThe algorithm type for the computed traffic light

Definition at line 70 of file NBTrafficLightLogic.cpp.

NBTrafficLightLogic::NBTrafficLightLogic ( const NBTrafficLightLogic logic)

Copy Constructor.

Parameters
[in]logicThe logic to copy

Definition at line 77 of file NBTrafficLightLogic.cpp.

NBTrafficLightLogic::~NBTrafficLightLogic ( )

Destructor.

Definition at line 86 of file NBTrafficLightLogic.cpp.

Member Function Documentation

void Parameterised::addParameter ( const std::string &  key,
const std::string &  value 
)
inherited
void Parameterised::addParameter ( const std::map< std::string, std::string > &  mapArg)
inherited

Adds all given parameter.

Parameters
[in]mapArgThe keys/values to insert

Definition at line 59 of file Parameterised.cpp.

References Parameterised::myMap.

void Parameterised::addParameter ( const Parameterised p)
inherited

Adds all given parameter.

Parameters
[in]pThe keys/values to insert

Definition at line 67 of file Parameterised.cpp.

References Parameterised::myMap.

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 90 of file NBTrafficLightLogic.cpp.

References ALLOWED_STATES, Named::getID(), myNumLinks, myPhases, and toString().

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

void Named::addTo ( const StoringVisitor cont) const
inlineinherited

Adds this object to the given container.

Parameters

Definition at line 121 of file Named.h.

References Named::StoringVisitor::add().

void Parameterised::clearParameter ( )
inherited

Clears the parameter map.

Definition at line 91 of file Parameterised.cpp.

References Parameterised::myMap.

void NBTrafficLightLogic::closeBuilding ( )

closes the building process

Joins equal steps.

Definition at line 141 of file NBTrafficLightLogic.cpp.

References myPhases.

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

void NBTrafficLightLogic::deletePhase ( unsigned int  index)

Definition at line 114 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 131 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

Definition at line 60 of file Named.h.

References Named::myID.

Referenced by NIImporter_SUMO::_loadNetwork(), MSVehicleTransfer::add(), TraCIServerAPI_Lane::StoringVisitor::add(), Named::StoringVisitor::add(), MSDetectorControl::add(), RORouteDef::addAlternative(), MSNet::addBusStop(), NBLoadedSUMOTLDef::addConnection(), NLHandler::addConnection(), NIXMLConnectionsHandler::addCrossing(), RODFDetectorCon::addDetector(), RONet::addEdge(), ROJTREdge::addFollowerProbability(), MSTLLogicControl::TLSLogicVariants::addLogic(), RONet::addNode(), NIImporter_SUMO::addPhase(), RONet::addRouteDef(), NBDistrict::addSink(), NBDistrict::addSource(), addStep(), MSRouteHandler::addStop(), NIXMLTrafficLightsHandler::addTlConnection(), NIVissimDisturbance::addToNode(), MSVehicle::addTraciStop(), GUITrafficLightLogicWrapper::begin2TrackPhases(), MSPerson::MSPersonStage_Driving::beginEventOutput(), MSPerson::MSPersonStage_Waiting::beginEventOutput(), NIVisumTL::build(), RODFNet::buildApproachList(), MS_E2_ZS_CollectorOverLanes::buildCollector(), NBNode::buildCrossings(), NIImporter_VISUM::buildDistrictNode(), NIVissimConnection::buildEdgeConnections(), RODFNet::buildEdgeFlowMap(), NBNode::buildInnerEdges(), NBEdge::buildInnerEdges(), NGEdge::buildNBEdge(), NIVissimEdge::buildNBEdge(), NBRampsComputer::buildOffRamp(), NBRampsComputer::buildOnRamp(), NBNode::buildWalkingAreas(), MSSimpleTrafficLightLogic::changeStepAndDuration(), NBEdge::checkGeometry(), MSVehicleTransfer::checkInsertions(), ODDistrictHandler::closeDistrict(), NLHandler::closeEdge(), RORouteHandler::closeRouteDistribution(), RORouteHandler::closeVehicle(), NBTrafficLightDefinition::collectAllLinks(), NBTrafficLightDefinition::collectEdges(), ROJTRRouter::compute(), NBTrafficLightDefinition::compute(), NBNode::computeInternalLaneShape(), NBEdge::computeLaneShapes(), NBNode::computeLogic(), NBNode::computeNodeShape(), RODFNet::computeRoutesFor(), NBTrafficLightLogicCont::computeSingleLogic(), NBTurningDirectionsComputer::computeTurnDirectionsForNode(), NGNet::connect(), MSAbstractLaneChangeModel::continueLaneChangeManeuver(), NLDetectorBuilder::convUncontE2PosLength(), GUINet::createTLWrapper(), MSLane::detectCollisions(), NIVissimDistrictConnection::dict_BuildDistricts(), MSPerson::MSPersonStage_Driving::endEventOutput(), MSPerson::MSPersonStage_Waiting::endEventOutput(), MSE3Collector::enter(), MSCalibrator::execute(), Command_SaveTLSState::execute(), Command_SaveTLSSwitchStates::execute(), Command_SaveTLSSwitches::execute(), MSVTypeProbe::execute(), MSPModel_Striping::MovePedestrians::execute(), MSVehicle::executeMove(), MSLane::executeMovements(), NBNodeCont::extract(), NBTrafficLightLogicCont::extract(), NBEdgeCont::extract(), RODFDetectorCon::getAggFlowFor(), RODFDetectorCon::getAnyDetectorForEdge(), MSNet::getBusStopID(), NBEdge::getCrossingAngle(), RODFNet::getDetectorEdge(), MSMeanData::getEdgeID(), PedestrianEdge< E, L, N >::getEffort(), NBEdge::getFirstNonPedestrianLane(), MS_E2_ZS_CollectorOverLanes::getLanePredeccessorLanes(), AGStreet::getName(), NIImporter_VISUM::getNamedEdgeContinuating(), MSPModel_Striping::getNextLane(), GUIVehicle::getParameterWindow(), GUITrafficLightLogicWrapper::getPopUpMenu(), NLTriggerBuilder::getPosition(), NLDetectorBuilder::getPositionChecking(), NBNode::getPossiblySplittedIncoming(), NBNode::getPossiblySplittedOutgoing(), NIImporter_VISUM::getReversedContinuating(), NBNode::guessCrossings(), RODFDetectorCon::guessEmptyFlows(), NBNodeCont::guessTLs(), GUITLLogicPhasesTrackerWindow::GUITLLogicPhasesTrackerWindow(), NBEdgeCont::ignoreFilterMatch(), MSActuatedTrafficLightLogic::init(), MSAgentbasedTrafficLightLogic::init(), MSTrafficLightLogic::init(), PedestrianEdge< E, L, N >::initPedestrianNetwork(), NIImporter_SUMO::initTrafficLightLogic(), NIXMLTrafficLightsHandler::initTrafficLightLogic(), NBDistrictCont::insert(), NBTrafficLightLogicCont::insert(), NBNodeCont::insert(), NBEdgeCont::insert(), NBNode::invalidateTLS(), MSTLLogicControl::isActive(), RODFNet::isDestination(), RODFNet::isFalseSource(), RODFNet::isSource(), NBEdgeCont::joinSameNodeConnectingEdges(), MSE3Collector::leave(), NIImporter_OpenDrive::loadNetwork(), NBRampsComputer::moveRampRight(), MSPModel_Striping::PState::moveToNextLane(), MSCalibrator::MSCalibrator(), MSPerson::MSPersonStage_Waiting::MSPersonStage_Waiting(), NBOwnTLDef::myCompute(), NBLoadedTLDef::myCompute(), NIXMLTrafficLightsHandler::myEndElement(), NIXMLEdgesHandler::myEndElement(), NIImporter_SUMO::myEndElement(), NIXMLConnectionsHandler::myStartElement(), MSLaneSpeedTrigger::myStartElement(), MSTriggeredRerouter::myStartElement(), NBConnection::NBConnection(), NBRequest::NBRequest(), MSDevice_BTreceiver::notifyEnter(), MSDevice_Tripinfo::notifyEnter(), MSDevice_BTsender::notifyEnter(), MSDevice_Example::notifyEnter(), MSCalibrator::VehicleRemover::notifyEnter(), MSDevice_Tripinfo::notifyLeave(), MSDevice_Person::notifyLeave(), MSDevice_Example::notifyLeave(), MSDevice_BTreceiver::notifyLeave(), MSDevice_BTsender::notifyLeave(), MSDevice_Example::notifyMove(), MSDevice_BTreceiver::notifyMove(), MSDevice_BTsender::notifyMove(), GUIViewTraffic::onGamingClick(), RORouteHandler::openRoute(), Named::ComparatorIdLess::operator()(), NBTurningDirectionsComputer::combination_by_angle_sorter::operator()(), RODFNet::idComp::operator()(), NBOwnTLDef::edge_by_incoming_priority_sorter::operator()(), NBNetBuilder::by_id_sorter::operator()(), NBContHelper::same_connection_edge_sorter::operator()(), MSEdge::by_id_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(), NBLoadedSUMOTLDef::patchIfCrossingsAdded(), MSLCM_JE2013::patchSpeed(), NBLoadedTLDef::SignalGroup::patchTYellow(), MSRightOfWayJunction::postloadInit(), AGStreet::print(), TraCIServerAPI_InductionLoop::processGet(), TraCIServerAPI_TLS::processGet(), TraCIServerAPI_Vehicle::processGet(), TraCIServerAPI_Lane::processGet(), TraCIServerAPI_Vehicle::processSet(), NWWriter_SUMO::prohibitionConnection(), MSPModel_Striping::PState::PState(), NBEdgeCont::recheckPostProcessConnections(), NBLoadedTLDef::SignalGroup::remapIncoming(), NBLoadedTLDef::SignalGroup::remapOutgoing(), NBLoadedSUMOTLDef::removeConnection(), MSCalibrator::removePending(), NBNode::removeSelfLoops(), NBEdgeCont::removeUnwishedEdges(), NBNodeCont::removeUnwishedNodes(), NBNodeCont::rename(), NBEdgeCont::rename(), NBConnection::replaceFrom(), MSBaseVehicle::replaceRouteEdges(), NBConnection::replaceTo(), NIImporter_DlrNavteq::TrafficlightsHandler::report(), NIXMLTrafficLightsHandler::retrieveLaneIndex(), RODFNet::revalidateFlows(), PCPolyContainer::save(), RONet::saveAndRemoveRoutesUntil(), MSBaseVehicle::saveState(), NBNodeCont::setAsTLControlled(), NBEdge::setControllingTLInformation(), NIXMLEdgesHandler::setNodes(), MSLink::setRequestInformation(), NBOwnTLDef::setTLControllingInformation(), NBLoadedSUMOTLDef::setTLControllingInformation(), NBLoadedTLDef::setTLControllingInformation(), NBEdgeCont::splitAt(), MSLane::succLinkSec(), GUITrafficLightLogicWrapper::switchTLSLogic(), MSDevice_BTreceiver::BTreceiverUpdate::updateVisibility(), TraCIServerAPI_Vehicle::vtdMap_matchingEdgeLane(), TraCIServerAPI_Vehicle::vtdMap_matchingRoutePosition(), MSLCM_JE2013::wantsChange(), MSFCDExport::write(), MSEmissionExport::write(), MSInstantInductLoop::write(), NBSign::writeAsPOI(), NWWriter_SUMO::writeConnection(), NWWriter_SUMO::writeDistrict(), MSFullExport::writeEdge(), MSXMLRawOut::writeEdge(), NWWriter_SUMO::writeEdge(), MSMeanData::writeEdge(), NWWriter_XML::writeEdgesAndConnections(), RODFDetector::writeEmitterDefinition(), RODFDetectorCon::writeEmitterPOIs(), RODFDetectorCon::writeEmitters(), RODFDetectorCon::writeEndRerouterDetectors(), NWWriter_SUMO::writeInternalConnections(), NWWriter_SUMO::writeJunction(), MSQueueExport::writeLane(), MSFullExport::writeLane(), NWWriter_DlrNavteq::writeLinksUnsplitted(), NWWriter_OpenDrive::writeNetwork(), NWWriter_XML::writeNodes(), NWWriter_DlrNavteq::writeNodesUnsplitted(), NWWriter_SUMO::writeRoundabout(), RODFDetectorCon::writeSpeedTrigger(), NWWriter_DlrNavteq::writeTrafficSignals(), MSInductLoop::writeTypedXMLOutput(), RODFDetectorCon::writeValidationDetectors(), MSFullExport::writeVehicles(), MSRouteProbe::writeXMLOutput(), and MSE2Collector::writeXMLOutput().

const std::map<std::string, std::string>& Parameterised::getMap ( ) const
inlineinherited

Returns the inner key/value map.

Returns
the inner map

Definition at line 107 of file Parameterised.h.

References Parameterised::myMap.

Referenced by NBTrafficLightDefinition::compute(), GUIVehicle::getParameterWindow(), and PCPolyContainer::save().

unsigned int NBTrafficLightLogic::getNumLinks ( )
inline

Returns the number of participating links.

Definition at line 195 of file NBTrafficLightLogic.h.

References myNumLinks.

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

SUMOTime NBTrafficLightLogic::getOffset ( ) const
inline

Returns the offset of first switch.

Returns
The switch offset

Definition at line 188 of file NBTrafficLightLogic.h.

References myOffset.

Referenced by NBLoadedSUMOTLDef::NBLoadedSUMOTLDef().

const std::string & Parameterised::getParameter ( const std::string &  key,
const std::string &  defaultValue 
) const
inherited
const std::vector<PhaseDefinition>& NBTrafficLightLogic::getPhases ( ) const
inline

Returns the phases.

Returns
The phase list

Definition at line 180 of file NBTrafficLightLogic.h.

References myPhases.

Referenced by NBLoadedSUMOTLDef::patchIfCrossingsAdded(), and NBLoadedSUMOTLDef::removeConnection().

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

Returns the ProgramID.

Returns
The ID of the program (subID)

Definition at line 172 of file NBTrafficLightLogic.h.

References mySubID.

TrafficLightType NBTrafficLightLogic::getType ( ) const
inline

get the algorithm type (static etc..)

Definition at line 200 of file NBTrafficLightLogic.h.

References myType.

Referenced by NBLoadedSUMOTLDef::NBLoadedSUMOTLDef().

bool Parameterised::knowsParameter ( const std::string &  key) const
inherited

Returns whether the parameter is known.

Parameters
[in]keyThe key to ask for
Returns
Whether the key is known

Definition at line 75 of file Parameterised.cpp.

References Parameterised::myMap.

Referenced by MSDevice_Example::buildVehicleDevices(), MSDevice::equippedByDefaultAssignmentOptions(), and TraCIServerAPI_Vehicle::vtdMap_matchingNearest().

NBTrafficLightLogic& NBTrafficLightLogic::operator= ( const NBTrafficLightLogic s)
private

Invalidated assignment operator.

void NBTrafficLightLogic::resetPhases ( )

Definition at line 124 of file NBTrafficLightLogic.cpp.

References myNumLinks, and myPhases.

Referenced by NIXMLTrafficLightsHandler::myStartElement().

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

resets the id

Parameters
[in]newIDThe new id of this object

Definition at line 68 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 164 of file NBTrafficLightLogic.h.

References myOffset.

Referenced by NBTrafficLightLogicCont::computeSingleLogic(), and NBLoadedSUMOTLDef::setOffset().

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 163 of file NBTrafficLightLogic.cpp.

References myPhases.

void NBTrafficLightLogic::setPhaseState ( unsigned int  phaseIndex,
unsigned 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 154 of file NBTrafficLightLogic.cpp.

References myPhases.

void NBTrafficLightLogic::setType ( TrafficLightType  type)
inline

set the algorithm type (static etc..)

Definition at line 205 of file NBTrafficLightLogic.h.

References myType.

Field Documentation

const std::string NBTrafficLightLogic::ALLOWED_STATES
staticprivate

Definition at line 230 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 211 of file NBTrafficLightLogic.h.

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

SUMOTime NBTrafficLightLogic::myOffset
private

The tls program's offset.

Definition at line 217 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 223 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 214 of file NBTrafficLightLogic.h.

Referenced by getProgramID().

TrafficLightType NBTrafficLightLogic::myType
private

The algorithm type for the traffic light.

Definition at line 226 of file NBTrafficLightLogic.h.

Referenced by getType(), and setType().


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