View Javadoc
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.Fuller.Task;
5   
6   /**
7    * Supplies a Task for within Fullers model.
8    * <p>
9    * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
10   * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
11   * <p>
12   * @version $Revision$, $LastChangedDate$, by $Author$, initial version 28 jun. 2018 <br>
13   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
14   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
15   * @author <a href="http://www.transport.citg.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 Task.Constant(this.id, this.taskDemand);
55          }
56      }
57  
58  }