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-2018 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, final AccelerationStep followerAccelerationStep) 36 { 37 this.leaderAccelerationStep = leaderAccelerationStep; 38 this.followerAccelerationStep = followerAccelerationStep; 39 } 40 41 /** 42 * Retrieve the AccelerationStep for the leader GTU. 43 * @return AccelerationStep; the acceleration and time step size for the leader 44 */ 45 public final AccelerationStep getLeaderAccelerationStep() 46 { 47 return this.leaderAccelerationStep; 48 } 49 50 /** 51 * Retrieve the AccelerationStep for the (new) follower GTU. 52 * @return AccelerationStep; the acceleration and time step size for the (new) follower 53 */ 54 public final AccelerationStep getFollowerAccelerationStep() 55 { 56 return this.followerAccelerationStep; 57 } 58 59 /** 60 * Return the acceleration of the leader. 61 * @return DoubleScalar<AccelerationUnit>; the acceleration of the leader 62 */ 63 public final Acceleration getLeaderAcceleration() 64 { 65 return getLeaderAccelerationStep().getAcceleration(); 66 } 67 68 /** 69 * Return the acceleration of the follower. 70 * @return DoubleScalar<AccelerationUnit>; the acceleration of the follower 71 */ 72 public final Acceleration getFollowerAcceleration() 73 { 74 return getFollowerAccelerationStep().getAcceleration(); 75 } 76 77 /** 78 * Return the time up to which the result of the leader is valid. 79 * @return DoubleScalar<TimeUnit>; the time up to which the result of the leader is valid 80 */ 81 public final Time getLeaderValidUntil() 82 { 83 return getLeaderAccelerationStep().getValidUntil(); 84 } 85 86 /** 87 * Return the time up to which the result of the follower is valid. 88 * @return DoubleScalar<TimeUnit>; the time up to which the result of the follower is valid 89 */ 90 public final Time getFollowerValidUntil() 91 { 92 return getFollowerAccelerationStep().getValidUntil(); 93 } 94 95 /** {@inheritDoc} */ 96 @Override 97 public final String toString() 98 { 99 return "Follower: " + getFollowerAccelerationStep() + ", Leader: " + getLeaderAccelerationStep(); 100 } 101 102 }