Class TrafficLightGroupUnit

java.lang.Object
org.eclipse.mosaic.fed.application.ambassador.simulation.AbstractSimulationUnit
org.eclipse.mosaic.fed.application.ambassador.simulation.TrafficLightGroupUnit
All Implemented Interfaces:
CommunicationModuleOwner, AdHocCommunicative, CellCommunicative, Locatable, OperatingSystem, TrafficLightOperatingSystem, EventProcessor

public class TrafficLightGroupUnit extends AbstractSimulationUnit implements TrafficLightOperatingSystem
Simulation unit that represents a traffic light group.
  • Constructor Details

    • TrafficLightGroupUnit

      public TrafficLightGroupUnit(String simulationUnitId, GeoPoint trafficLightPosition, TrafficLightGroup trafficLightGroup)
      Creates a new traffic light group simulation unit.
      Parameters:
      simulationUnitId - internal traffic light group identifier
      trafficLightPosition - traffic light position
      trafficLightGroup - traffic light group identifier
  • Method Details

    • getPosition

      public GeoPoint getPosition()
      Description copied from interface: Locatable
      This data element provides an absolute geographical longitude and latitude in a WGS84 coordinate system.
      Specified by:
      getPosition in interface Locatable
      Returns:
      the position.
    • getInitialPosition

      public GeoPoint getInitialPosition()
      Description copied from interface: Locatable
      This data element provides an absolute geographical longitude and latitude in a WGS84 coordinate system.
      Specified by:
      getInitialPosition in interface Locatable
      Overrides:
      getInitialPosition in class AbstractSimulationUnit
      Returns:
      the position.
    • processEvent

      public void processEvent(@Nonnull Event event) throws Exception
      Description copied from interface: EventProcessor
      Processes the given event.
      Specified by:
      processEvent in interface EventProcessor
      Parameters:
      event - the event to process
      Throws:
      Exception
    • setRemainingDurationOfCurrentPhase

      public void setRemainingDurationOfCurrentPhase(long remainingDuration)
      Description copied from interface: TrafficLightOperatingSystem
      Set the remaining duration of the current traffic light program phase of this traffic light group. Please consider only using numbers that fulfill the condition >= 0 to avoid unwanted changes. Negative numbers usage will affect the next phase so that the absolute value of the given negative number will be subtracted from the remaining duration of the next phase.
      Specified by:
      setRemainingDurationOfCurrentPhase in interface TrafficLightOperatingSystem
      Parameters:
      remainingDuration - the new phase remaining duration in millisecond
    • switchToPhaseIndex

      public void switchToPhaseIndex(int newPhaseId)
      Description copied from interface: TrafficLightOperatingSystem
      Switches the phase in the current traffic light program to the phase with the given id. Remaining phase duration will be reset.
      Specified by:
      switchToPhaseIndex in interface TrafficLightOperatingSystem
      Parameters:
      newPhaseId - id of the phase it will be switched to
    • switchToCustomState

      public void switchToCustomState(List<TrafficLightState> stateList)
      Description copied from interface: TrafficLightOperatingSystem
      Switches all traffic lights which belong to this group to the given state. The states will be held until switched to another list of states, or to another program or phase index.
      Specified by:
      switchToCustomState in interface TrafficLightOperatingSystem
      Parameters:
      stateList - the list of states to set (one state for each traffic light in the correct order)
    • switchToProgram

      public void switchToProgram(String newProgramId)
      Description copied from interface: TrafficLightOperatingSystem
      Sets a new traffic light program, identified by the given newProgramId, to this traffic light group. Important: when interacting with SUMO one should consider that after changing a program the new program will NOT begin from its first phase, but from the time at which the previous program was interrupted (and from the according phase). Consider using the TrafficLightOperatingSystem.switchToProgramAndPhase(String newProgramId, int phaseId) method to avoid this effect. Therefore changing the program to the same program doesn't change anything.
      Specified by:
      switchToProgram in interface TrafficLightOperatingSystem
      Parameters:
      newProgramId - Id of the new traffic light program.
    • switchToProgramAndPhase

      public void switchToProgramAndPhase(String newProgramId, int phaseId)
      Description copied from interface: TrafficLightOperatingSystem
      Sets a new traffic light program with the given id to this traffic light group and also sets the wanted phase for the new program. Important: Internal this is made with *two* TraCI commands because it's not possible to do it in one step while interacting with SUMO.
      Specified by:
      switchToProgramAndPhase in interface TrafficLightOperatingSystem
      Parameters:
      newProgramId - Id of the new traffic light program
      phaseId - the index of the phase to switch to
    • getSignalSequence

      public Collection<TrafficLightState> getSignalSequence(String trafficLightProgramId, int trafficLightId)
      Description copied from interface: TrafficLightOperatingSystem
      Returns a sequence of states for a certain traffic light, where each state represents a state of the traffic light during a phase within a traffic light program. If there is no program with given id, a sequence of states for the current program is returned.
      Specified by:
      getSignalSequence in interface TrafficLightOperatingSystem
      Parameters:
      trafficLightProgramId - id of the traffic light program to look into
      trafficLightId - id of a traffic light
      Returns:
      a sequence of states for a certain traffic light within a traffic light program with given id or a sequence of states for the current program.
    • getControlledLanes

      public Collection<String> getControlledLanes()
      Description copied from interface: TrafficLightOperatingSystem
      Returns a collection of incoming lanes controlled by this traffic light group.
      Specified by:
      getControlledLanes in interface TrafficLightOperatingSystem
      Returns:
      controlled lanes
    • getTrafficLightGroup

      public TrafficLightGroup getTrafficLightGroup()
      Description copied from interface: TrafficLightOperatingSystem
      Getter for the traffic light group.
      Specified by:
      getTrafficLightGroup in interface TrafficLightOperatingSystem
      Returns:
      Traffic light group
    • getAllPrograms

      public Collection<TrafficLightProgram> getAllPrograms()
      Description copied from interface: TrafficLightOperatingSystem
      Returns all traffic light programs that are registered for a traffic light group using this operating system.
      Specified by:
      getAllPrograms in interface TrafficLightOperatingSystem
      Returns:
      all traffic light programs that are registered for a traffic light group
    • getCurrentProgram

      public TrafficLightProgram getCurrentProgram()
      Description copied from interface: TrafficLightOperatingSystem
      Returns the traffic light program that is currently running on a traffic light group using this operating system.
      Specified by:
      getCurrentProgram in interface TrafficLightOperatingSystem
      Returns:
      the current traffic light program
    • getCurrentPhase

      public TrafficLightProgramPhase getCurrentPhase()
      Description copied from interface: TrafficLightOperatingSystem
      Returns the traffic light program phase that is currently running on a traffic light group using this operating system.
      Specified by:
      getCurrentPhase in interface TrafficLightOperatingSystem
      Returns:
      the current traffic light program phase
    • getAllTrafficLights

      public List<TrafficLight> getAllTrafficLights()
      Description copied from interface: TrafficLightOperatingSystem
      Returns all traffic lights a traffic light group using this operating system.
      Specified by:
      getAllTrafficLights in interface TrafficLightOperatingSystem
      Returns:
      all traffic lights within a traffic light group
    • assembleCamMessage

      public CamBuilder assembleCamMessage(CamBuilder camBuilder)
      Description copied from interface: CommunicationModuleOwner
      Assembles a CamBuilder (Cooperative Awareness Message) using the given MessageRouting and the units' status information.
      Specified by:
      assembleCamMessage in interface CommunicationModuleOwner
      Parameters:
      camBuilder - the routing for the Cam
      Returns:
      the assembled Cam, which can be sent