View Javadoc
1   package org.opentrafficsim.trafficcontrol;
2   
3   import org.djutils.event.LocalEventProducer;
4   import org.djutils.exceptions.Throw;
5   import org.opentrafficsim.core.dsol.OtsSimulatorInterface;
6   
7   /**
8    * <p>
9    * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
10   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
11   * </p>
12   * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
13   * @author <a href="https://tudelft.nl/staff/p.knoppers-1">Peter Knoppers</a>
14   * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
15   */
16  public abstract class AbstractTrafficController extends LocalEventProducer implements TrafficController
17  {
18  
19      /** */
20      private static final long serialVersionUID = 20190221L;
21  
22      /** Id of this controller. */
23      private final String id;
24  
25      /**
26       * Constructor for traffic controller.
27       * @param id String; id
28       * @param simulator OtsSimulatorInterface; simulator
29       */
30      public AbstractTrafficController(final String id, final OtsSimulatorInterface simulator)
31      {
32          Throw.whenNull(id, "Id may not be null.");
33          this.id = id;
34          fireTimedEvent(TrafficController.TRAFFICCONTROL_CONTROLLER_CREATED,
35                  new Object[] {this.id, TrafficController.STARTING_UP}, simulator.getSimulatorTime());
36      }
37  
38      /**
39       * @return id.
40       */
41      @Override
42      public String getId()
43      {
44          return this.id;
45      }
46  
47  }