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