Package eu.bandm.tools.message
Class TrafficMessageReceiver
java.lang.Object
eu.bandm.tools.message.TrafficMessageReceiver
- All Implemented Interfaces:
MessageReceiver<Message>
Graphic indication of received messages.
One or more
As long as no message arrives, the intial state is left unchanged.
One or more
TrafficLight
objects can be linked to this kind of
message receiver.
The state of all these is changed to "red" as soon as a critical
message arrives, and to "yellow" as soon as any other message arrives
(provided the state is not red!).
As long as no message arrives, the intial state is left unchanged.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addLight
(TrafficLight light) Addslight
as a listener to state changes.void
clear()
Convenience: set state of all currently added traffic lights to "green".Convenience: constructs a newTrafficLight
andadds
it.getState()
Return the current state.void
Sets state toTrafficLight.State.red
if the received message is critcal, otherwise to yellow, if it is not already red.void
removeLight
(TrafficLight light) Removeslight
as a listener to state changes.protected void
setState
(TrafficLight.State state) Convenience: set state of all currently added traffic lights tostate
.
-
Constructor Details
-
TrafficMessageReceiver
public TrafficMessageReceiver()
-
-
Method Details
-
addLight
Addslight
as a listener to state changes. -
removeLight
Removeslight
as a listener to state changes. -
createLight
Convenience: constructs a newTrafficLight
andadds
it. -
clear
public void clear()Convenience: set state of all currently added traffic lights to "green". -
receive
Sets state toTrafficLight.State.red
if the received message is critcal, otherwise to yellow, if it is not already red.- Specified by:
receive
in interfaceMessageReceiver<Message>
- See Also:
-
getState
Return the current state. -
setState
Convenience: set state of all currently added traffic lights tostate
.
-