View Javadoc
1   package org.opentrafficsim.road.network.lane.object.sensor;
2   
3   import org.djunits.unit.LengthUnit;
4   import org.djunits.value.vdouble.scalar.Length;
5   import org.opentrafficsim.core.compatibility.Compatible;
6   import org.opentrafficsim.core.gtu.RelativePosition;
7   import org.opentrafficsim.road.gtu.lane.LaneBasedGTU;
8   import org.opentrafficsim.road.network.lane.object.LaneBasedObject;
9   
10  import nl.tudelft.simulation.dsol.simulators.DEVSSimulatorInterface;
11  import nl.tudelft.simulation.event.EventType;
12  
13  /**
14   * A sensor is a lane-based object that can be triggered by a relative position of the GTU (e.g., front, back) when that
15   * relative position passes over the sensor location on the lane.
16   * <p>
17   * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
18   * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
19   * <p>
20   * $LastChangedDate: 2015-09-14 01:33:02 +0200 (Mon, 14 Sep 2015) $, @version $Revision: 1401 $, by $Author: averbraeck $,
21   * initial version Dec 31, 2014 <br>
22   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
23   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
24   */
25  public interface SingleSensor extends Sensor, Comparable<SingleSensor>, LaneBasedObject, Compatible
26  {
27      /** @return the relative position type of the vehicle (e.g., FRONT, BACK) that triggers the sensor. */
28      RelativePosition.TYPE getPositionType();
29  
30      /**
31       * Trigger an action on the GTU. Normally this is the GTU that triggered the sensor. The typical call therefore is
32       * <code>sensor.trigger(this);</code>.
33       * @param gtu LaneBasedGTU; the GTU for which to carry out the trigger action.
34       */
35      void trigger(LaneBasedGTU gtu);
36  
37      /** @return The simulator. */
38      DEVSSimulatorInterface.TimeDoubleUnit getSimulator();
39  
40      /**
41       * The <b>timed</b> event type for pub/sub indicating the triggering of a Sensor on a lane. <br>
42       * Payload: Object[] {String sensorId, Sensor sensor, LaneBasedGTU gtu, RelativePosition.TYPE relativePosition}
43       */
44      EventType SENSOR_TRIGGER_EVENT = new EventType("SENSOR.TRIGGER");
45  
46      /** Default elevation of a sensor; if the lane is not at elevation 0; this value is probably far off. */
47      Length DEFAULT_SENSOR_ELEVATION = new Length(0.1, LengthUnit.METER);
48  
49  }