View Javadoc
1   package org.opentrafficsim.road.gtu.lane.tactical.following;
2   
3   import java.io.Serializable;
4   
5   import org.djunits.value.vdouble.scalar.Acceleration;
6   import org.djunits.value.vdouble.scalar.Time;
7   
8   /**
9    * Container for two instances of an AccelerationStep. One for the GTU that is deciding its move (the leader); one for the GTU
10   * that will/would be the (new) follower of that GTU.
11   * <p>
12   * Copyright (c) 2013-2016 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
13   * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
14   * <p>
15   * @version $Revision: 1368 $, $LastChangedDate: 2015-09-02 00:20:20 +0200 (Wed, 02 Sep 2015) $, by $Author: averbraeck $,
16   *          initial version 11 mrt. 2015 <br>
17   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
18   */
19  public class DualAccelerationStep implements Serializable
20  {
21      /** */
22      private static final long serialVersionUID = 20150311L;
23  
24      /** AccelerationStep for the leader. */
25      private final AccelerationStep leaderAccelerationStep;
26  
27      /** AccelerationStep for the (new) follower. */
28      private final AccelerationStep followerAccelerationStep;
29  
30      /**
31       * Create a new DualAccelerationStep.
32       * @param leaderAccelerationStep AccelerationStep; the acceleration and time step size for the leader
33       * @param followerAccelerationStep AccelerationStep; the acceleration and time step size for the (new) follower
34       */
35      public DualAccelerationStep(final AccelerationStep leaderAccelerationStep,
36          final AccelerationStep followerAccelerationStep)
37      {
38          this.leaderAccelerationStep = leaderAccelerationStep;
39          this.followerAccelerationStep = followerAccelerationStep;
40      }
41  
42      /**
43       * Retrieve the AccelerationStep for the leader GTU.
44       * @return AccelerationStep; the acceleration and time step size for the leader
45       */
46      public final AccelerationStep getLeaderAccelerationStep()
47      {
48          return this.leaderAccelerationStep;
49      }
50  
51      /**
52       * Retrieve the AccelerationStep for the (new) follower GTU.
53       * @return AccelerationStep; the acceleration and time step size for the (new) follower
54       */
55      public final AccelerationStep getFollowerAccelerationStep()
56      {
57          return this.followerAccelerationStep;
58      }
59  
60      /**
61       * Return the acceleration of the leader.
62       * @return DoubleScalar&lt;AccelerationUnit&gt;; the acceleration of the leader
63       */
64      public final Acceleration getLeaderAcceleration()
65      {
66          return getLeaderAccelerationStep().getAcceleration();
67      }
68  
69      /**
70       * Return the acceleration of the follower.
71       * @return DoubleScalar&lt;AccelerationUnit&gt;; the acceleration of the follower
72       */
73      public final Acceleration getFollowerAcceleration()
74      {
75          return getFollowerAccelerationStep().getAcceleration();
76      }
77  
78      /**
79       * Return the time up to which the result of the leader is valid.
80       * @return DoubleScalar&lt;TimeUnit&gt;; the time up to which the result of the leader is valid
81       */
82      public final Time getLeaderValidUntil()
83      {
84          return getLeaderAccelerationStep().getValidUntil();
85      }
86  
87      /**
88       * Return the time up to which the result of the follower is valid.
89       * @return DoubleScalar&lt;TimeUnit&gt;; the time up to which the result of the follower is valid
90       */
91      public final Time getFollowerValidUntil()
92      {
93          return getFollowerAccelerationStep().getValidUntil();
94      }
95  
96      /** {@inheritDoc} */
97      public final String toString()
98      {
99          return "Follower: " + getFollowerAccelerationStep() + ", Leader: " + getLeaderAccelerationStep();
100     }
101 
102 }