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://github.com/peter-knoppers">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 /** Id of this controller. */
20 private final String id;
21
22 /**
23 * Constructor for traffic controller.
24 * @param id id
25 * @param simulator simulator
26 */
27 public AbstractTrafficController(final String id, final OtsSimulatorInterface simulator)
28 {
29 Throw.whenNull(id, "Id may not be null.");
30 this.id = id;
31 fireTimedEvent(TrafficController.TRAFFICCONTROL_CONTROLLER_CREATED,
32 new Object[] {this.id, TrafficController.STARTING_UP}, simulator.getSimulatorTime());
33 }
34
35 /**
36 * @return id.
37 */
38 @Override
39 public String getId()
40 {
41 return this.id;
42 }
43
44 }