java.lang.Object
org.djutils.event.LocalEventProducer
org.opentrafficsim.trafficcontrol.ccol.Ccol
All Implemented Interfaces:
Serializable, Remote, EventListener, org.djutils.base.Identifiable, org.djutils.event.EventListener, org.djutils.event.EventProducer, org.opentrafficsim.core.animation.Drawable, org.opentrafficsim.core.object.NonLocatedObject, ActuatedTrafficController, TrafficController

public class Ccol extends org.djutils.event.LocalEventProducer implements ActuatedTrafficController
Communication link with a CCOL traffic control program.

Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.

Author:
Alexander Verbraeck, Peter Knoppers, Wouter Schakel
See Also:
  • Field Details

    • EVALUATION_INTERVAL

      static final org.djunits.value.vdouble.scalar.Duration EVALUATION_INTERVAL
      The evaluation interval of a CCOL controller.
  • Constructor Details

    • Ccol

      public Ccol(String id, String controlProgram, Set<TrafficLight> trafficLights, Set<TrafficLightDetector> sensors, org.opentrafficsim.core.dsol.OtsSimulator simulator) throws TrafficControlException, nl.tudelft.simulation.dsol.SimRuntimeException
      Construct a new CCOL communication link.
      Parameters:
      id - String; id of the traffic controller
      controlProgram - String; name of the CCOL program that this CCOL link must communicate with
      trafficLights - 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 program
      sensors - 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 program
      simulator - DevsSimulator<Time, Duration, SimTimeDoubleUnit>; the simulation engine
      Throws:
      TrafficControlException - on failure to initialize the connection to the external CCOL program
      nl.tudelft.simulation.dsol.SimRuntimeException - on failure to schedule the first evaluation event
  • Method Details

    • 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(org.djutils.event.Event event) throws RemoteException
      Specified by:
      notify in interface org.djutils.event.EventListener
      Throws:
      RemoteException
    • getId

      public String getId()
      Retrieve the Id of the traffic light controller.
      Specified by:
      getId in interface org.djutils.base.Identifiable
      Specified by:
      getId in interface TrafficController
      Returns:
      String; the id of the traffic light controller
    • getFullId

      public String getFullId()
      Specified by:
      getFullId in interface org.opentrafficsim.core.object.NonLocatedObject
    • updateDetector

      public void updateDetector(String detectorId, boolean detectingGTU)
      Tell the traffic controller that the state of a detector has changed.
      Specified by:
      updateDetector in interface ActuatedTrafficController
      Parameters:
      detectorId - String; id of the detector
      detectingGTU - boolean;
    • getDisplayContainer

      public Container getDisplayContainer()
      Retrieve the Swing (for now) container in which the controller displays its current state.
      Specified by:
      getDisplayContainer in interface ActuatedTrafficController
      Returns:
      Container; the display of the current state; may return null!