ReactionTime.java

  1. package org.opentrafficsim.road.network.sampling.data;

  2. import org.djunits.unit.DurationUnit;
  3. import org.djunits.value.vfloat.scalar.FloatDuration;
  4. import org.opentrafficsim.base.parameters.ParameterException;
  5. import org.opentrafficsim.base.parameters.ParameterTypes;
  6. import org.opentrafficsim.kpi.sampling.data.ExtendedDataTypeDuration;
  7. import org.opentrafficsim.road.network.sampling.GtuData;

  8. /**
  9.  * Leader id in trajectory information.
  10.  * <p>
  11.  * Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  12.  * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
  13.  * <p>
  14.  * @version $Revision$, $LastChangedDate$, by $Author$, initial version 19 mrt. 2019 <br>
  15.  * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
  16.  * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
  17.  * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
  18.  */
  19. public class ReactionTime extends ExtendedDataTypeDuration<GtuData>
  20. {

  21.     /**
  22.      * Constructor.
  23.      */
  24.     public ReactionTime()
  25.     {
  26.         super("Tr");
  27.     }

  28.     /** {@inheritDoc} */
  29.     @Override
  30.     public FloatDuration getValue(final GtuData gtu)
  31.     {
  32.         try
  33.         {
  34.             return new FloatDuration(gtu.getGtu().getParameters().getParameter(ParameterTypes.TR).getSI(), DurationUnit.SI);
  35.         }
  36.         catch (ParameterException exception)
  37.         {
  38.             return FloatDuration.NaN;
  39.         }
  40.     }

  41. }