CapacityLink.java

  1. package org.opentrafficsim.core.network;

  2. import org.djunits.value.vdouble.scalar.Frequency;
  3. import org.opentrafficsim.core.geometry.OtsLine3d;

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

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

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

  38.     /** {@inheritDoc} */
  39.     @Override
  40.     public final Frequency getCapacity()
  41.     {
  42.         return this.capacity;
  43.     }

  44.     /** {@inheritDoc} */
  45.     @Override
  46.     public final void setCapacity(final Frequency capacity)
  47.     {
  48.         this.capacity = capacity;
  49.     }

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

  56. }