CapacityLink.java

  1. package org.opentrafficsim.core.network;

  2. import org.djunits.value.vdouble.scalar.Frequency;
  3. import org.opentrafficsim.core.geometry.FractionalLengthData;
  4. import org.opentrafficsim.core.geometry.OtsLine2d;

  5. /**
  6.  * A link with a maximum capacity, expressed as the maximum number of GTUs per time unit that the link can handle.
  7.  * <p>
  8.  * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  9.  * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
  10.  * </p>
  11.  * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
  12.  * @author <a href="https://tudelft.nl/staff/p.knoppers-1">Peter Knoppers</a>
  13.  */
  14. public class CapacityLink extends Link implements Capacity
  15. {
  16.     /** */
  17.     private static final long serialVersionUID = 20151108L;

  18.     /** Link capacity in vehicles per time unit. This is a mutable property (e.g., blockage). */
  19.     private Frequency capacity;

  20.     /**
  21.      * Construct a new link.
  22.      * @param network Network; the network.
  23.      * @param id String; the link id
  24.      * @param startNode Node; start node (directional)
  25.      * @param endNode Node; end node (directional)
  26.      * @param linkType LinkType; Link type to indicate compatibility with GTU types
  27.      * @param designLine OtsLine2d; the OtsLine2d design line of the Link
  28.      * @param elevation FractionalLengthData; elevation given over fractional length, may be {@code null}.
  29.      * @param capacity Frequency; link capacity in GTUs per hour // XXX per direction? which GtuType?
  30.      * @throws NetworkException if link already exists in the network, if name of the link is not unique, or if the start node
  31.      *             or the end node of the link are not registered in the network.
  32.      */
  33.     @SuppressWarnings("checkstyle:parameternumber")
  34.     public CapacityLink(final Network network, final String id, final Node startNode, final Node endNode,
  35.             final LinkType linkType, final OtsLine2d designLine, final FractionalLengthData elevation, final Frequency capacity)
  36.             throws NetworkException
  37.     {
  38.         super(network, id, startNode, endNode, linkType, designLine, elevation);
  39.         this.capacity = capacity;
  40.     }

  41.     /** {@inheritDoc} */
  42.     @Override
  43.     public final Frequency getCapacity()
  44.     {
  45.         return this.capacity;
  46.     }

  47.     /** {@inheritDoc} */
  48.     @Override
  49.     public final void setCapacity(final Frequency capacity)
  50.     {
  51.         this.capacity = capacity;
  52.     }

  53.     /** {@inheritDoc} */
  54.     @Override
  55.     public String toString()
  56.     {
  57.         return "CapacityOTSLink [capacity=" + this.capacity + "]";
  58.     }

  59. }