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