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