Class Trafficlight


  • public class Trafficlight
    extends java.lang.Object
    Author:
    Mario Krumnow, Evamarie Wiessner
    • Constructor Detail

      • Trafficlight

        public Trafficlight()
    • Method Detail

      • getCompleteRedYellowGreenDefinition

        public static SumoCommand getCompleteRedYellowGreenDefinition​(java.lang.String tlsID)
        Returns the complete traffic light program.
        Parameters:
        tlsID - a string identifying the traffic light
        Returns:
        program definition
      • getIDCount

        public static SumoCommand getIDCount()
        Returns the number of all traffic lights in the network.
        Returns:
        number of traffic lights
      • getPhaseDuration

        public static SumoCommand getPhaseDuration​(java.lang.String tlsID)
        getPhaseDuration
        Parameters:
        tlsID - a string identifying the traffic light
        Returns:
        phase duration
      • getControlledLanes

        public static SumoCommand getControlledLanes​(java.lang.String tlsID)
        Returns the list of lanes which are controlled by the named traffic light.
        Parameters:
        tlsID - a string identifying the traffic light
        Returns:
        list of controlled lanes
      • getControlledLinks

        public static SumoCommand getControlledLinks​(java.lang.String tlsID)
        Returns the links controlled by the traffic light, sorted by the signal index and described by giving the incoming, outgoing, and via lane.
        Parameters:
        tlsID - a string identifying the traffic light
        Returns:
        list of controlled links
      • getControlledJunctions

        public static SumoCommand getControlledJunctions​(java.lang.String tlsID)
        Returns the junctions controlled by the traffic light
        Parameters:
        tlsID - a string identifying the traffic light
        Returns:
        list of controlled junctions
      • getExternalState

        public static SumoCommand getExternalState​(java.lang.String tlsID)
        Returns the external state
        Parameters:
        tlsID - a string identifying the traffic light
        Returns:
        compound of the external state
      • getIDList

        public static SumoCommand getIDList()
        Returns a list of IDs of all traffic lights within the scenario.
        Returns:
        a list of IDs of all TLS
      • getNextSwitch

        public static SumoCommand getNextSwitch​(java.lang.String tlsID)
        Returns the assumed time (in ms) at which the TLS changes the phase.
        Parameters:
        tlsID - a string identifying the traffic light
        Returns:
        absolute time, counting from simulation start, at which TLS may change
      • getParameter

        public static SumoCommand getParameter​(java.lang.String tlsID,
                                               java.lang.String param)
        Returns the chosen parameter
        Parameters:
        tlsID - a string identifying the traffic light
        param - a string identifying the parameter
        Returns:
        the specific parameter
      • setParameter

        public static SumoCommand setParameter​(java.lang.String tlsID,
                                               java.lang.String param,
                                               java.lang.String value)
        Sets the chosen parameter
        Parameters:
        vehID - a string identifying the vehicle
        param - a string identifying the parameter
        value - a string identifying the new value
        Returns:
        SumoCommand
      • getPhase

        public static SumoCommand getPhase​(java.lang.String tlsID)
        Returns the index of the current phase in the current program.
        Parameters:
        tlsID - a string identifying the traffic light
        Returns:
        index of the current phase
      • getPhaseName

        public static SumoCommand getPhaseName​(java.lang.String tlsID)
        Returns the name of the current phase in the current program.
        Parameters:
        tlsID - a string identifying the traffic light
        Returns:
        name of the current phase
      • getProgram

        public static SumoCommand getProgram​(java.lang.String tlsID)
        Returns the id of the current program.
        Parameters:
        tlsID - a string identifying the traffic light
        Returns:
        index of the current program
      • getRedYellowGreenState

        public static SumoCommand getRedYellowGreenState​(java.lang.String tlsID)
        Returns the named tl's state as a tuple of light definitions from rRgGyYoO, for red, green, yellow, off, where lower case letters mean that the stream has to decelerate.
        Parameters:
        tlsID - a string identifying the traffic light
        Returns:
        SumoCommand
      • setCompleteRedYellowGreenDefinition

        public static SumoCommand setCompleteRedYellowGreenDefinition​(java.lang.String tlsID,
                                                                      SumoTLSProgram tls)
        Set the complete traffic light program.
        Parameters:
        tlsID - a string identifying the traffic light
        tls - complete program definition
        Returns:
        SumoCommand
      • setPhase

        public static SumoCommand setPhase​(java.lang.String tlsID,
                                           int index)
        Set the index of the current phase in the current program.
        Parameters:
        tlsID - a string identifying the traffic light
        index - an integer identifying the phase (it must be between 0 and the number of phases known to the current program of the tls - 1)
        Returns:
        SumoCommand
      • setPhaseName

        public static SumoCommand setPhaseName​(java.lang.String tlsID,
                                               java.lang.String name)
        Set the name of the current phase in the current program.
        Parameters:
        tlsID - a string identifying the traffic light
        name - a string with the phase name
        Returns:
        SumoCommand
      • setPhaseDuration

        public static SumoCommand setPhaseDuration​(java.lang.String tlsID,
                                                   double phaseDuration)
        Set the duration of the currently active phase (in s?).
        Parameters:
        tlsID - a string identifying the traffic light
        phaseDuration - remaining duration of the current phase
        Returns:
        SumoCommand
      • setProgram

        public static SumoCommand setProgram​(java.lang.String tlsID,
                                             java.lang.String programID)
        Set the id of the current program.
        Parameters:
        tlsID - a string identifying the traffic light
        programID - a string identifying the program
        Returns:
        SumoCommand
      • setRedYellowGreenState

        public static SumoCommand setRedYellowGreenState​(java.lang.String tlsID,
                                                         java.lang.String state)
        Set the named tl's state as a tuple of light definitions.
        Parameters:
        tlsID - a string identifying the traffic light
        state - as a tuple of light definitions from rRgGyYoO, for red, green, yellow, off, where lower case letters mean that the stream has to decelerate
        Returns:
        SumoCommand