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