1 package org.opentrafficsim.road.gtu.lane.perception.mental.sdm;
2
3 import org.opentrafficsim.road.gtu.lane.LaneBasedGtu;
4 import org.opentrafficsim.road.gtu.lane.perception.mental.ConstantTask;
5 import org.opentrafficsim.road.gtu.lane.perception.mental.Task;
6
7 /**
8 * Supplies a Task for within Fullers model.
9 * <p>
10 * Copyright (c) 2013-2023 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
11 * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
12 * </p>
13 * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
14 * @author <a href="https://tudelft.nl/staff/p.knoppers-1">Peter Knoppers</a>
15 * @author <a href="https://dittlab.tudelft.nl">Wouter Schakel</a>
16 */
17 @FunctionalInterface
18 public interface TaskSupplier
19 {
20
21 /**
22 * Returns a task for the given GTU.
23 * @param gtu LaneBasedGtu; gtu
24 * @return Task; task for given GTU
25 */
26 Task getTask(LaneBasedGtu gtu);
27
28 /**
29 * Class that supplies a constant task.
30 */
31 class Constant implements TaskSupplier
32 {
33 /** Id. */
34 private final String id;
35
36 /** Task demand. */
37 private final double taskDemand;
38
39 /**
40 * Constructor.
41 * @param id String; id
42 * @param taskDemand double; task demand
43 */
44 public Constant(final String id, final double taskDemand)
45 {
46 this.id = id;
47 this.taskDemand = taskDemand;
48 }
49
50 /** {@inheritDoc} */
51 @Override
52 public Task getTask(final LaneBasedGtu gtu)
53 {
54 return new ConstantTask(this.id, this.taskDemand);
55 }
56 }
57
58 }