View Javadoc
1   package org.opentrafficsim.road.gtu.lane.plan.operational;
2   
3   import java.io.Serializable;
4   
5   import org.djunits.value.vdouble.scalar.Acceleration;
6   import org.opentrafficsim.core.network.LateralDirectionality;
7   
8   import nl.tudelft.simulation.language.Throw;
9   
10  /**
11   * Simplified plan containing only an acceleration value and possible lane change direction.
12   * <p>
13   * Copyright (c) 2013-2016 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
14   * BSD-style license. See <a href="http://opentrafficsim.org/docs/current/license.html">OpenTrafficSim License</a>.
15   * <p>
16   * @version $Revision$, $LastChangedDate$, by $Author$, initial version Jul 26, 2016 <br>
17   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
18   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
19   * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
20   */
21  
22  public class SimpleOperationalPlan implements Serializable
23  {
24  
25      /** */
26      private static final long serialVersionUID = 20160811L;
27  
28      /** Acceleration. */
29      private Acceleration acceleration;
30  
31      /** Lane change direction. */
32      private final LateralDirectionality laneChangeDirection;
33  
34      /**
35       * @param acceleration acceleration
36       */
37      public SimpleOperationalPlan(final Acceleration acceleration)
38      {
39          this(acceleration, LateralDirectionality.NONE);
40      }
41  
42      /**
43       * @param acceleration acceleration
44       * @param laneChangeDirection lane change direction, may be {@code null}.
45       */
46      public SimpleOperationalPlan(final Acceleration acceleration, final LateralDirectionality laneChangeDirection)
47      {
48          Throw.whenNull(acceleration, "Acceleration may not be null.");
49          Throw.whenNull(laneChangeDirection, "Lane change direction may not be null.");
50          this.acceleration = acceleration;
51          this.laneChangeDirection = laneChangeDirection;
52      }
53  
54      /**
55       * @return acceleration.
56       */
57      public final Acceleration getAcceleration()
58      {
59          return this.acceleration;
60      }
61      
62      /**
63       * @return if lane change.
64       */
65      public final boolean isLaneChange()
66      {
67          return this.laneChangeDirection != LateralDirectionality.NONE;
68      }
69  
70      /**
71       * @return laneChangeDirection, may be NONE if no lane change.
72       */
73      public final LateralDirectionality getLaneChangeDirection()
74      {
75          return this.laneChangeDirection;
76      }
77      
78      /**
79       * Set minimum of current and given acceleration.
80       * @param a acceleration to set if lower than current acceleration
81       */
82      public final void minimumAcceleration(final Acceleration a)
83      {
84          this.acceleration = Acceleration.min(this.acceleration, a);
85      }
86      
87      /** {@inheritDoc} */
88      @Override
89      @SuppressWarnings("checkstyle:designforextension")
90      public String toString()
91      {
92          return "SimpleOperationalPlan [Acceleration=" + this.acceleration + ", change=" + this.laneChangeDirection + "]";
93      }
94  
95  }