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