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-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
11 * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
12 * <p>
13 * @version $Revision$, $LastChangedDate$, by $Author$, initial version 28 jun. 2018 <br>
14 * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
15 * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
16 * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
17 */
18 @FunctionalInterface
19 public interface TaskSupplier
20 {
21
22 /**
23 * Returns a task for the given GTU.
24 * @param gtu LaneBasedGTU; gtu
25 * @return Task; task for given GTU
26 */
27 Task getTask(LaneBasedGTU gtu);
28
29 /**
30 * Class that supplies a constant task.
31 */
32 class Constant implements TaskSupplier
33 {
34 /** Id. */
35 private final String id;
36
37 /** Task demand. */
38 private final double taskDemand;
39
40 /**
41 * Constructor.
42 * @param id String; id
43 * @param taskDemand double; task demand
44 */
45 public Constant(final String id, final double taskDemand)
46 {
47 this.id = id;
48 this.taskDemand = taskDemand;
49 }
50
51 /** {@inheritDoc} */
52 @Override
53 public Task getTask(final LaneBasedGTU gtu)
54 {
55 return new ConstantTask(this.id, this.taskDemand);
56 }
57 }
58
59 }