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