1 package org.opentrafficsim.trafficcontrol;
2
3 import org.opentrafficsim.base.Identifiable;
4 import org.opentrafficsim.core.object.InvisibleObjectInterface;
5
6 import nl.tudelft.simulation.event.EventListenerInterface;
7 import nl.tudelft.simulation.event.EventProducerInterface;
8 import nl.tudelft.simulation.event.EventType;
9
10 /**
11 * Interface for traffic light controllers.
12 * <p>
13 * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
14 * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
15 * <p>
16 * @version $Revision$, $LastChangedDate$, by $Author$, initial version Oct 14, 2016 <br>
17 * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
18 * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
19 * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
20 */
21 public interface TrafficController
22 extends EventProducerInterface, EventListenerInterface, InvisibleObjectInterface, Identifiable
23 {
24 /**
25 * Retrieve the Id of the traffic light controller.
26 * @return String; the id of the traffic light controller
27 */
28 @Override
29 public String getId();
30
31 /** Traffic controller is starting up. Particular traffic control programs may use additional states not listed here. */
32 final String STARTING_UP = "starting up";
33
34 /** Traffic controller is being cloned. Particular traffic control programs may use additional states not listed here. */
35 final String BEING_CLONED = "being cloned";
36
37 /** Traffic controller is running. */
38 final String RUNNING = "running";
39
40 /** Traffic controller is shutting down. */
41 final String SHUTTING_DOWN = "shutting down";
42
43 /** Traffic controller is off. */
44 final String OFF = "off";
45
46 /** Constant to select variables that have no associated traffic stream. */
47 public final static int NO_STREAM = -1;
48
49 /**
50 * The <b>timed</b> event type for pub/sub that a newly created traffic controller emits. <br>
51 * Payload: Object[] { String trafficControllerId, String initialState }
52 */
53 EventType TRAFFICCONTROL_CONTROLLER_CREATED = new EventType("TRAFFICCONTROL.CONTROLLER_CREATED");
54
55 /**
56 * The <b>timed</b> event type for pub/sub that a traffic controller emits when it begins the computations to determine its
57 * response to the current input (detector states).<br>
58 * Payload: Object[] { String trafficControllerId }
59 */
60 EventType TRAFFICCONTROL_CONTROLLER_EVALUATING = new EventType("TRAFFICCONTROL.CONTROLLER_EVALUATING");
61
62 /**
63 * The <b>timed</b> event type for pub/sub that a traffic controller uses to convey warnings.<br>
64 * Payload: Object[] { String trafficControllerId, String message }
65 */
66 EventType TRAFFICCONTROL_CONTROLLER_WARNING = new EventType("TRAFFICCONTROL.CONTROLLER_WARNING");
67
68 /**
69 * The <b>timed</b> event for pub/sub emitted by a traffic control machine when it changes state (STARTING_UP, RUNNING,
70 * SHUTTING_DOWN, OFF, etc. The exact set of states may vary depending on the type of traffic control machine. <br>
71 * Payload: Object[] { String trafficControllerId, String oldState, String newState }
72 */
73 EventType TRAFFICCONTROL_STATE_CHANGED = new EventType("TRAFFIC_CONTROL.STATE_CHANGED");
74
75 /**
76 * The <b>timed</b>event that is fired by a traffic control program when a traffic light must change state. <br>
77 * Payload: Object[] { String trafficControllerId, Integer stream, TrafficLightColor newColor }
78 */
79 public static final EventType TRAFFIC_LIGHT_CHANGED = new EventType("TrafficLightChanged");
80
81 /**
82 * The <b>timed</b> event type for pub/sub indicating the creation of a traffic control program variable. <br>
83 * Listeners to this event can send <code>TRAFFICCONTROL_SET_TRACE</code> messages to set the tracing level of a
84 * variable.<br>
85 * Payload: Object[] {String trafficControllerId, String variableId, Integer trafficStream, Double initialValue}
86 */
87 EventType TRAFFICCONTROL_VARIABLE_CREATED = new EventType("TRAFFICCONTROL.VARIABLE_CREATED");
88
89 /**
90 * The <b>timed</b> event type that instruct a traffic controller to change the tracing level of a variable. <br>
91 * Payload: Object[] { String trafficControllerId, String variableId, Integer trafficStream, Boolean trace } <br>
92 * Remark 1: an empty string for the variableId sets or clears tracing for all variables associated with the traffic stream.
93 * <br>
94 * Remark 2: The stream number <code>NO_STREAM</code> selects variable(s) that are not associated with a particular traffic
95 * stream. <br>
96 * Remark 3: setting the tracing level of a variable changes the amount of
97 * <code>TRAFFICCONTROL_TRACED_VARIABLE_UPDATED</code> events sent to <b>all</b> listeners; i.e. it is not possible to
98 * affect tracing on a per listener basis.
99 */
100 EventType TRAFFICCONTROL_SET_TRACING = new EventType("TRAFFICCONTROL.SET_TRACING");
101
102 /**
103 * The <b>timed</b> event type for pub/sub indicating the update of a traced control program variable. <br>
104 * Payload: Object[] {String trafficControllerId, String variableId, Integer trafficStream, Double oldValue, Double
105 * newValue, String expressionOrDescription} <br>
106 * Remark 1: for variable that are not associated with a particular traffic stream, the trafficStream value shall be
107 * <code>NO_STREAM</code> <br>
108 * Remark 2: if the variable is a timer that has just been initialized; newValue will reflect the duration in seconds
109 */
110 EventType TRAFFICCONTROL_TRACED_VARIABLE_UPDATED = new EventType("TRAFFICCONTROL.VARIABLE_UPDATED");
111
112 /**
113 * The <b>timed</b> event for pub/sub emitted by a traffic control machine when it changes to another conflict group. <br>
114 * Payload: Object[] { String trafficControllerId, String oldConflictGroupStreams, String newConflictGroupStreams } <br>
115 * Remark 1: a conflict group is described as a space-separated list of traffic stream numbers. The traffic streams within a
116 * conflict group should be compatible; i.e. not conflicting. <br>
117 * Remark 2: The value <code>00</code> can be used as a place holder for a stream in a conflict groups that have fewer than
118 * the maximum number of traffic streams that occur in any conflict group.<br>
119 * Remark 3: The very first event of this type may use an empty string for <code>oldConflictGroupStreams</code>.<br>
120 * Remark 4: Some traffic control systems may not operate in a conflict group by conflict group fashion and therefore not
121 * emit these events.
122 */
123 EventType TRAFFICCONTROL_CONFLICT_GROUP_CHANGED = new EventType("TRAFFIC_CONTROL.CONFLICT_GROUP_CHANGED");
124
125 }