View Javadoc
1   package org.opentrafficsim.road.network.lane;
2   
3   import java.rmi.RemoteException;
4   
5   import javax.naming.NamingException;
6   
7   import org.opentrafficsim.core.dsol.OTSDEVSSimulatorInterface;
8   import org.opentrafficsim.core.gtu.RelativePosition;
9   import org.opentrafficsim.road.gtu.lane.LaneBasedGTU;
10  
11  /**
12   * sensor that deletes the GTU.
13   * <p>
14   * Copyright (c) 2013-2015 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands.<br>
15   * All rights reserved. <br>
16   * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
17   * <p>
18   * $LastChangedDate: 2015-08-12 16:37:45 +0200 (Wed, 12 Aug 2015) $, @version $Revision: 1240 $, by $Author: averbraeck $,
19   * initial version an 30, 2015 <br>
20   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
21   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
22   */
23  public class SinkSensor extends AbstractSensor
24  {
25      /** */
26      private static final long serialVersionUID = 20150130L;
27  
28      /**
29       * @param lane the lane that triggers the deletion of the GTU.
30       * @param position the position of the sensor
31       * @param simulator the simulator to enable animation.
32       */
33      public SinkSensor(final Lane lane, final Length.Rel position, final OTSDEVSSimulatorInterface simulator)
34      {
35          super(lane, position, RelativePosition.FRONT, "SINK@" + lane.toString(), simulator);
36          try
37          {
38              new SinkAnimation(this, simulator);
39          }
40          catch (RemoteException | NamingException exception)
41          {
42              exception.printStackTrace();
43          }
44      }
45  
46      /** {@inheritDoc} */
47      @Override
48      public void trigger(final LaneBasedGTU gtu) 
49      {
50          gtu.destroy();
51      }
52  
53      /** {@inheritDoc} */
54      @Override
55      public String toString()
56      {
57          return "SinkSensor [Lane=" + this.getLane() + "]";
58      }
59  }