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-2023 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
13 * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
14 * </p>
15 * @author <a href="https://tudelft.nl/staff/p.knoppers-1">Peter Knoppers</a>
16 */
17 public class DualAccelerationStep implements Serializable
18 {
19 /** */
20 private static final long serialVersionUID = 20150311L;
21
22 /** AccelerationStep for the leader. */
23 private final AccelerationStep leaderAccelerationStep;
24
25 /** AccelerationStep for the (new) follower. */
26 private final AccelerationStep followerAccelerationStep;
27
28 /**
29 * Create a new DualAccelerationStep.
30 * @param leaderAccelerationStep AccelerationStep; the acceleration and time step size for the leader
31 * @param followerAccelerationStep AccelerationStep; the acceleration and time step size for the (new) follower
32 */
33 public DualAccelerationStep(final AccelerationStep leaderAccelerationStep, final AccelerationStep followerAccelerationStep)
34 {
35 this.leaderAccelerationStep = leaderAccelerationStep;
36 this.followerAccelerationStep = followerAccelerationStep;
37 }
38
39 /**
40 * Retrieve the AccelerationStep for the leader GTU.
41 * @return AccelerationStep; the acceleration and time step size for the leader
42 */
43 public final AccelerationStep getLeaderAccelerationStep()
44 {
45 return this.leaderAccelerationStep;
46 }
47
48 /**
49 * Retrieve the AccelerationStep for the (new) follower GTU.
50 * @return AccelerationStep; the acceleration and time step size for the (new) follower
51 */
52 public final AccelerationStep getFollowerAccelerationStep()
53 {
54 return this.followerAccelerationStep;
55 }
56
57 /**
58 * Return the acceleration of the leader.
59 * @return DoubleScalar<AccelerationUnit>; the acceleration of the leader
60 */
61 public final Acceleration getLeaderAcceleration()
62 {
63 return getLeaderAccelerationStep().getAcceleration();
64 }
65
66 /**
67 * Return the acceleration of the follower.
68 * @return DoubleScalar<AccelerationUnit>; the acceleration of the follower
69 */
70 public final Acceleration getFollowerAcceleration()
71 {
72 return getFollowerAccelerationStep().getAcceleration();
73 }
74
75 /**
76 * Return the time up to which the result of the leader is valid.
77 * @return DoubleScalar<TimeUnit>; the time up to which the result of the leader is valid
78 */
79 public final Time getLeaderValidUntil()
80 {
81 return getLeaderAccelerationStep().getValidUntil();
82 }
83
84 /**
85 * Return the time up to which the result of the follower is valid.
86 * @return DoubleScalar<TimeUnit>; the time up to which the result of the follower is valid
87 */
88 public final Time getFollowerValidUntil()
89 {
90 return getFollowerAccelerationStep().getValidUntil();
91 }
92
93 /** {@inheritDoc} */
94 @Override
95 public final String toString()
96 {
97 return "Follower: " + getFollowerAccelerationStep() + ", Leader: " + getLeaderAccelerationStep();
98 }
99
100 }