1 package org.opentrafficsim.road.gtu.perception.object;
2
3 import java.util.function.Supplier;
4
5 import org.djunits.value.vdouble.scalar.Duration;
6 import org.djunits.value.vdouble.scalar.Length;
7 import org.opentrafficsim.core.dsol.OtsSimulatorInterface;
8 import org.opentrafficsim.road.network.object.trafficlight.TrafficLight;
9 import org.opentrafficsim.road.network.object.trafficlight.TrafficLightColor;
10
11
12
13
14
15
16
17
18
19 public class PerceivedTrafficLightChannel extends PerceivedTrafficLight
20 {
21
22
23 private final Supplier<Duration> perceptionDelay;
24
25
26 private final OtsSimulatorInterface simulator;
27
28
29
30
31
32
33
34
35
36 public PerceivedTrafficLightChannel(final TrafficLight trafficLight, final Length distance, final boolean turnOnRed,
37 final Supplier<Duration> perceptionDelay)
38 {
39 super(trafficLight, distance, turnOnRed);
40 this.perceptionDelay = perceptionDelay;
41 this.simulator = trafficLight.getSimulator();
42 }
43
44
45
46
47
48 @Override
49 public TrafficLightColor getTrafficLightColor()
50 {
51 Duration when = this.simulator.getSimulatorTime().minus(this.perceptionDelay.get());
52 return getTrafficLight().getTrafficLightColor(when);
53 }
54
55 }