_TrafficLight

Module Contents

Classes

TrafficLight

class _TrafficLight.TrafficLight(id: str)

Bases: trasmapy._IdentifiedObject.IdentifiedObject

property state: list[trasmapy.control.SignalColor.SignalColor]

Returns the named traffic lights state.

property phaseIndex: int

Returns the index of the current phase in the currrent program.

property phaseDuration: float

Returns a default total duration of the active phase (s).

property phaseName: str

Returns the name of the current phase in the current program.

property nextSwitchTime: float

Returns the absolute simulation time at which the traffic light is schedule to switch to the next phase (s).

property timeTillNextSwitch: float

Returns the time left for the next switch (s).

property controlledLinkIds: dict[int, list[trasmapy.control._Link.Link]]

Returns a dictionary of links controlled by the traffic light, where the key is the tls link index of the connection.

property controlledLaneIds: list[str]

Returns the list of lanes which are controlled by the named traffic light. Returns at least one entry for every element of the phase state (signal index).

property programSet: list[trasmapy.control._TLProgram.TLProgram]

Returns the list of programs of the traffic light. Each progam is encoded as a TrafficLogic object.

property programId: str

“Returns the id of the current program.

property program: trasmapy.control._TLProgram.TLProgram

“Returns the current program.

getProgram(programId: str) trasmapy.control._TLProgram.TLProgram

Returns the program with the given id.

getBlockingVehiclesIds(linkIndex: int) list[str]

Returns the ids of vehicles that occupy the subsequent rail signal block.

getRivalVehiclesIds(linkIndex: int) list[str]

Returns the ids of vehicles that are approaching the same rail signal block.

getPriorityVehiclesIds(linkIndex: int) list[str]

Returns the ids of vehicles that are approaching the same rail signal block with higher priority.

setRedYellowGreenState(colors: list[trasmapy.control.SignalColor.SignalColor])

Sets the phase definition. Accepts a list of SignalColors that represent light definitions. After this call, the program of the traffic light will be set to online, and the state will be maintained until the next call of setRedYellowGreenState() or until setting another program with setProgram()

turnOff()

Turns off the traffic light.

isPhaseInProgram(programId: str, phaseIndex: int) bool

Returns true if the program with the given Id contains a phase with at the given index.