View Javadoc
1   package org.opentrafficsim.core.network;
2   
3   import org.djunits.value.vdouble.scalar.Frequency;
4   import org.opentrafficsim.core.geometry.OTSLine3D;
5   
6   import nl.tudelft.simulation.dsol.simulators.SimulatorInterface;
7   
8   /**
9    * A link with a maximum capacity, expressed as the maximum number of GTUs per time unit that the link can handle.
10   * <p>
11   * Copyright (c) 2013-2018 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/docs/license.html">OpenTrafficSim License</a>.
13   * </p>
14   * $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $,
15   * initial version Nov 8, 2015 <br>
16   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
17   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
18   */
19  public class CapacityOTSLink extends OTSLink implements Capacity
20  {
21      /** */
22      private static final long serialVersionUID = 20151108L;
23  
24      /** Link capacity in vehicles per time unit. This is a mutable property (e.g., blockage). */
25      private Frequency capacity;
26  
27      /**
28       * Construct a new link.
29       * @param network the network.
30       * @param id the link id
31       * @param startNode start node (directional)
32       * @param endNode end node (directional)
33       * @param linkType Link type to indicate compatibility with GTU types
34       * @param designLine the OTSLine3D design line of the Link
35       * @param simulator the simulator on which events can be scheduled
36       * @param capacity link capacity in GTUs per hour // XXX per direction? which GTUType?
37       * @throws NetworkException if link already exists in the network, if name of the link is not unique, or if the start node
38       *             or the end node of the link are not registered in the network.
39       */
40      @SuppressWarnings("checkstyle:parameternumber")
41      public CapacityOTSLink(final Network network, final String id, final Node startNode, final Node endNode,
42              final LinkType linkType, final OTSLine3D designLine, final SimulatorInterface.TimeDoubleUnit simulator,
43              final Frequency capacity) throws NetworkException
44      {
45          super(network, id, startNode, endNode, linkType, designLine, simulator);
46          this.capacity = capacity;
47      }
48  
49      /**
50       * Clone a link for a new network.
51       * @param newNetwork the new network to which the clone belongs
52       * @param newSimulator the new simulator for this network
53       * @param animation whether to (re)create animation or not
54       * @param link the link to clone from
55       * @throws NetworkException if link already exists in the network, if name of the link is not unique, or if the start node
56       *             or the end node of the link are not registered in the network.
57       */
58      protected CapacityOTSLink(final Network newNetwork, final SimulatorInterface.TimeDoubleUnit newSimulator,
59              final boolean animation, final CapacityOTSLink link) throws NetworkException
60      {
61          super(newNetwork, newSimulator, animation, link);
62          this.capacity = link.capacity;
63      }
64  
65      /** {@inheritDoc} */
66      @Override
67      public final Frequency getCapacity()
68      {
69          return this.capacity;
70      }
71  
72      /** {@inheritDoc} */
73      @Override
74      public final void setCapacity(final Frequency capacity)
75      {
76          this.capacity = capacity;
77      }
78  
79      /** {@inheritDoc} */
80      @Override
81      public final String toString()
82      {
83          return "CapacityOTSLink [capacity=" + this.capacity + "]";
84      }
85  
86      /** {@inheritDoc} */
87      @Override
88      @SuppressWarnings("checkstyle:designforextension")
89      public CapacityOTSLink clone(final Network newNetwork, final SimulatorInterface.TimeDoubleUnit newSimulator,
90              final boolean animation) throws NetworkException
91      {
92          return new CapacityOTSLink(newNetwork, newSimulator, animation, this);
93      }
94  
95  }