1 package org.opentrafficsim.road.network.lane;
2
3 import java.awt.Color;
4 import java.rmi.RemoteException;
5
6 import javax.naming.NamingException;
7
8 import org.djunits.value.vdouble.scalar.Length;
9 import org.opentrafficsim.core.dsol.OTSDEVSSimulatorInterface;
10 import org.opentrafficsim.core.gtu.RelativePosition;
11 import org.opentrafficsim.road.gtu.lane.LaneBasedGTU;
12
13
14
15
16
17
18
19
20
21
22
23
24
25 public class SimpleReportingSensor extends AbstractSensor
26 {
27
28 private static final long serialVersionUID = 20150130L;
29
30
31
32
33
34
35
36
37
38 public SimpleReportingSensor(final Lane lane, final Length.Rel position,
39 final RelativePosition.TYPE triggerPosition, final String name, final OTSDEVSSimulatorInterface simulator)
40 {
41 super(lane, position, triggerPosition, name, simulator);
42 try
43 {
44 new SensorAnimation(this, simulator, Color.YELLOW);
45 }
46 catch (RemoteException | NamingException exception)
47 {
48 exception.printStackTrace();
49 }
50 }
51
52
53 @Override
54 public void trigger(final LaneBasedGTU gtu)
55 {
56 System.out.println(this + " triggered by FRONT of " + gtu);
57 }
58
59
60 @Override
61 public String toString()
62 {
63 return "Sensor [Lane=" + this.getLane() + "]";
64 }
65 }