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-2018 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          /** Task demand. */
34          private double taskDemand;
35          
36          /**
37           * Constructor.
38           * @param taskDemand double; task demand
39           */
40          public Constant(final double taskDemand)
41          {
42              this.taskDemand = taskDemand;
43          }
44  
45          /** {@inheritDoc} */
46          @Override
47          public Task getTask(final LaneBasedGTU gtu)
48          {
49              return new Task.Constant(this.taskDemand);
50          }
51      }
52      
53  }