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