Class CCOL
- java.lang.Object
-
- org.djutils.event.EventProducer
-
- org.opentrafficsim.trafficcontrol.ccol.CCOL
-
- All Implemented Interfaces:
Serializable
,EventListener
,EventListenerInterface
,EventProducerInterface
,org.opentrafficsim.base.Identifiable
,org.opentrafficsim.core.animation.Drawable
,org.opentrafficsim.core.object.InvisibleObjectInterface
,ActuatedTrafficController
,TrafficController
public class CCOL extends EventProducer implements ActuatedTrafficController
Communication link with a CCOL traffic control program.Copyright (c) 2013-2022 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.- Version:
- $Revision$, $LastChangedDate$, by $Author$, initial version Jan 23, 2017
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static Duration
EVALUATION_INTERVAL
The evaluation interval of a CCOL controller.-
Fields inherited from class org.djutils.event.EventProducer
eventProducerImpl
-
Fields inherited from interface org.djutils.event.EventProducerInterface
FIRST_POSITION, LAST_POSITION
-
Fields inherited from interface org.opentrafficsim.trafficcontrol.TrafficController
BEING_CLONED, NO_STREAM, OFF, RUNNING, SHUTTING_DOWN, STARTING_UP, TRAFFIC_LIGHT_CHANGED, TRAFFICCONTROL_CONFLICT_GROUP_CHANGED, TRAFFICCONTROL_CONTROLLER_CREATED, TRAFFICCONTROL_CONTROLLER_EVALUATING, TRAFFICCONTROL_CONTROLLER_WARNING, TRAFFICCONTROL_SET_TRACING, TRAFFICCONTROL_STATE_CHANGED, TRAFFICCONTROL_TRACED_VARIABLE_UPDATED, TRAFFICCONTROL_VARIABLE_CREATED
-
-
Constructor Summary
Constructors Constructor Description CCOL(String id, String controlProgram, Set<TrafficLight> trafficLights, Set<TrafficLightSensor> sensors, org.opentrafficsim.core.dsol.OTSSimulator simulator)
Construct a new CCOL communication link.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.opentrafficsim.core.object.InvisibleObjectInterface
clone(org.opentrafficsim.core.dsol.OTSSimulatorInterface newSimulator, org.opentrafficsim.core.network.Network newNetwork)
(package private) Socket
getClientSocket()
Retrieve the client socket for shutdown.Container
getDisplayContainer()
Retrieve the Swing (for now) container in which the controller displays its current state.String
getFullId()
String
getId()
Retrieve the Id of the traffic light controller.Serializable
getSourceId()
void
notify(EventInterface event)
(package private) void
setClientSocket(Socket socket)
Set the client socket (called from the accept thread).void
updateDetector(String detectorId, boolean detectingGTU)
Tell the traffic controller that the state of a detector has changed.-
Methods inherited from class org.djutils.event.EventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, getEventTypesWithListeners, getListenerReferences, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.djutils.event.EventProducerInterface
addListener, addListener, addListener, addListener, getEventTypesWithListeners, hasListeners, numberOfListeners, removeListener
-
-
-
-
Field Detail
-
EVALUATION_INTERVAL
static final Duration EVALUATION_INTERVAL
The evaluation interval of a CCOL controller.
-
-
Constructor Detail
-
CCOL
public CCOL(String id, String controlProgram, Set<TrafficLight> trafficLights, Set<TrafficLightSensor> sensors, org.opentrafficsim.core.dsol.OTSSimulator simulator) throws TrafficControlException, SimRuntimeException
Construct a new CCOL communication link.- Parameters:
id
- String; id of the traffic controllercontrolProgram
- String; name of the CCOL program that this CCOL link must communicate withtrafficLights
- Set<TrafficLight>; the traffic lights. The ids of the traffic lights must end with two digits that match the stream numbers as used in the traffic control programsensors
- Set<TrafficLightSensor>; the traffic sensors. The ids of the traffic sensors must end with three digits; the first two of those must match the stream and sensor numbers used in the traffic control programsimulator
- DEVSSimulator<Time, Duration, SimTimeDoubleUnit>; the simulation engine- Throws:
TrafficControlException
- on failure to initialize the connection to the external CCOL programSimRuntimeException
- on failure to schedule the first evaluation event
-
-
Method Detail
-
setClientSocket
void setClientSocket(Socket socket)
Set the client socket (called from the accept thread).- Parameters:
socket
- Socket; the socket returned by accept
-
getClientSocket
Socket getClientSocket()
Retrieve the client socket for shutdown.- Returns:
- Socket; the socket for communication with the CCOL client
-
notify
public void notify(EventInterface event) throws RemoteException
- Specified by:
notify
in interfaceEventListenerInterface
- Throws:
RemoteException
-
getId
public String getId()
Retrieve the Id of the traffic light controller.- Specified by:
getId
in interfaceorg.opentrafficsim.base.Identifiable
- Specified by:
getId
in interfaceTrafficController
- Returns:
- String; the id of the traffic light controller
-
getFullId
public String getFullId()
- Specified by:
getFullId
in interfaceorg.opentrafficsim.core.object.InvisibleObjectInterface
-
updateDetector
public void updateDetector(String detectorId, boolean detectingGTU)
Tell the traffic controller that the state of a detector has changed.- Specified by:
updateDetector
in interfaceActuatedTrafficController
- Parameters:
detectorId
- String; id of the detectordetectingGTU
- boolean;
-
clone
public org.opentrafficsim.core.object.InvisibleObjectInterface clone(org.opentrafficsim.core.dsol.OTSSimulatorInterface newSimulator, org.opentrafficsim.core.network.Network newNetwork) throws org.opentrafficsim.core.network.NetworkException
- Specified by:
clone
in interfaceorg.opentrafficsim.core.object.InvisibleObjectInterface
- Throws:
org.opentrafficsim.core.network.NetworkException
-
getSourceId
public Serializable getSourceId()
- Specified by:
getSourceId
in interfaceEventProducerInterface
- Specified by:
getSourceId
in classEventProducer
-
getDisplayContainer
public Container getDisplayContainer()
Retrieve the Swing (for now) container in which the controller displays its current state.- Specified by:
getDisplayContainer
in interfaceActuatedTrafficController
- Returns:
- Container; the display of the current state; may return null!
-
-