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 Summary
ConstructorsConstructorDescriptionTrafficLightGroupUnit
(String simulationUnitId, GeoPoint trafficLightPosition, TrafficLightGroup trafficLightGroup) Creates a new traffic light group simulation unit. -
Method Summary
Modifier and TypeMethodDescriptionassembleCamMessage
(CamBuilder camBuilder) Assembles aCamBuilder
(Cooperative Awareness Message) using the givenMessageRouting
and the units' status information.Returns all traffic light programs that are registered for a traffic light group using this operating system.Returns all traffic lights a traffic light group using this operating system.Returns a collection of incoming lanes controlled by this traffic light group.Returns the traffic light program phase that is currently running on a traffic light group using this operating system.Returns the traffic light program that is currently running on a traffic light group using this operating system.This data element provides an absolute geographical longitude and latitude in a WGS84 coordinate system.This data element provides an absolute geographical longitude and latitude in a WGS84 coordinate system.getSignalSequence
(String trafficLightProgramId, int trafficLightId) 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.Getter for the traffic light group.void
processEvent
(Event event) Processes the given event.void
setRemainingDurationOfCurrentPhase
(long remainingDuration) Set the remaining duration of the current traffic light program phase of this traffic light group.void
switchToCustomState
(List<TrafficLightState> stateList) Switches all traffic lights which belong to this group to the given state.void
switchToPhaseIndex
(int newPhaseId) Switches the phase in the current traffic light program to the phase with the given id.void
switchToProgram
(String newProgramId) Sets a new traffic light program, identified by the givennewProgramId
, to this traffic light group.void
switchToProgramAndPhase
(String newProgramId, int phaseId) 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.Methods inherited from class org.eclipse.mosaic.fed.application.ambassador.simulation.AbstractSimulationUnit
getAdHocModule, getApplications, getApplicationsIterator, getCellModule, getConfigurationPath, getEventManager, getGroup, getId, getOsLog, getSimulationTime, loadApplications, preProcessEvent, processSumoTraciMessage, sendInteractionToRti, sendItefLogTuple, sendSumoTraciRequest, setGroup, setUp, tearDown, triggerOnSendMessage
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.mosaic.fed.application.app.api.os.modules.AdHocCommunicative
getAdHocModule
Methods inherited from interface org.eclipse.mosaic.fed.application.app.api.os.modules.CellCommunicative
getCellModule
Methods inherited from interface org.eclipse.mosaic.lib.util.scheduling.EventProcessor
canProcessEvent
Methods inherited from interface org.eclipse.mosaic.fed.application.app.api.os.OperatingSystem
getApplications, getApplicationsIterator, getConfigurationPath, getEventManager, getGroup, getId, getSimulationTime, getSimulationTimeMs, sendInteractionToRti, sendItefLogTuple, sendSumoTraciRequest
-
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 identifiertrafficLightPosition
- traffic light positiontrafficLightGroup
- traffic light group identifier
-
-
Method Details
-
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 interfaceLocatable
- Returns:
- the position.
-
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 interfaceLocatable
- Overrides:
getInitialPosition
in classAbstractSimulationUnit
- Returns:
- the position.
-
processEvent
Description copied from interface:EventProcessor
Processes the given event.- Specified by:
processEvent
in interfaceEventProcessor
- 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 interfaceTrafficLightOperatingSystem
- 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 interfaceTrafficLightOperatingSystem
- Parameters:
newPhaseId
- id of the phase it will be switched to
-
switchToCustomState
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 interfaceTrafficLightOperatingSystem
- Parameters:
stateList
- the list of states to set (one state for each traffic light in the correct order)
-
switchToProgram
Description copied from interface:TrafficLightOperatingSystem
Sets a new traffic light program, identified by the givennewProgramId
, 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 theTrafficLightOperatingSystem.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 interfaceTrafficLightOperatingSystem
- Parameters:
newProgramId
- Id of the new traffic light program.
-
switchToProgramAndPhase
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 interfaceTrafficLightOperatingSystem
- Parameters:
newProgramId
- Id of the new traffic light programphaseId
- 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 interfaceTrafficLightOperatingSystem
- Parameters:
trafficLightProgramId
- id of the traffic light program to look intotrafficLightId
- 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
Description copied from interface:TrafficLightOperatingSystem
Returns a collection of incoming lanes controlled by this traffic light group.- Specified by:
getControlledLanes
in interfaceTrafficLightOperatingSystem
- Returns:
- controlled lanes
-
getTrafficLightGroup
Description copied from interface:TrafficLightOperatingSystem
Getter for the traffic light group.- Specified by:
getTrafficLightGroup
in interfaceTrafficLightOperatingSystem
- Returns:
- Traffic light group
-
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 interfaceTrafficLightOperatingSystem
- Returns:
- all traffic light programs that are registered for a traffic light group
-
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 interfaceTrafficLightOperatingSystem
- Returns:
- the current traffic light program
-
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 interfaceTrafficLightOperatingSystem
- Returns:
- the current traffic light program phase
-
getAllTrafficLights
Description copied from interface:TrafficLightOperatingSystem
Returns all traffic lights a traffic light group using this operating system.- Specified by:
getAllTrafficLights
in interfaceTrafficLightOperatingSystem
- Returns:
- all traffic lights within a traffic light group
-
assembleCamMessage
Description copied from interface:CommunicationModuleOwner
Assembles aCamBuilder
(Cooperative Awareness Message) using the givenMessageRouting
and the units' status information.- Specified by:
assembleCamMessage
in interfaceCommunicationModuleOwner
- Parameters:
camBuilder
- the routing for theCam
- Returns:
- the assembled
Cam
, which can be sent
-