1 package org.opentrafficsim.core.network; 2 3 import java.util.Map; 4 5 import org.djunits.value.vdouble.scalar.Frequency; 6 import org.opentrafficsim.core.dsol.OTSSimulatorInterface; 7 import org.opentrafficsim.core.geometry.OTSLine3D; 8 import org.opentrafficsim.core.gtu.GTUType; 9 10 /** 11 * A link with a maximum capacity, expressed as the maximum number of GTUs per time unit that the link can handle. 12 * <p> 13 * Copyright (c) 2013-2017 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br> 14 * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>. 15 * </p> 16 * $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $, 17 * initial version Nov 8, 2015 <br> 18 * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a> 19 * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a> 20 */ 21 public class CapacityOTSLink extends OTSLink implements Capacity 22 { 23 /** */ 24 private static final long serialVersionUID = 20151108L; 25 26 /** Link capacity in vehicles per time unit. This is a mutable property (e.g., blockage). */ 27 private Frequency capacity; 28 29 /** 30 * Construct a new link. 31 * @param network the network. 32 * @param id the link id 33 * @param startNode start node (directional) 34 * @param endNode end node (directional) 35 * @param linkType Link type to indicate compatibility with GTU types 36 * @param designLine the OTSLine3D design line of the Link 37 * @param simulator the simulator on which events can be scheduled 38 * @param capacity link capacity in GTUs per hour // XXX per direction? which GTUType? 39 * @param directionalityMap the directions (FORWARD, BACKWARD, BOTH, NONE) that GTUtypes can traverse this link 40 * @throws NetworkException if link already exists in the network, if name of the link is not unique, or if the start node 41 * or the end node of the link are not registered in the network. 42 */ 43 @SuppressWarnings("checkstyle:parameternumber") 44 public CapacityOTSLink(final Network network, final String id, final Node startNode, final Node endNode, 45 final LinkType linkType, final OTSLine3D designLine, final OTSSimulatorInterface simulator, 46 final Frequency capacity, final Map<GTUType, LongitudinalDirectionality> directionalityMap) throws NetworkException 47 { 48 super(network, id, startNode, endNode, linkType, designLine, simulator, directionalityMap); 49 this.capacity = capacity; 50 } 51 52 /** 53 * Construct a new link, with a directionality for all GTUs as provided. 54 * @param network the network. 55 * @param id the link id 56 * @param startNode start node (directional) 57 * @param endNode end node (directional) 58 * @param linkType Link type to indicate compatibility with GTU types 59 * @param designLine the OTSLine3D design line of the Link 60 * @param simulator the simulator on which events can be scheduled 61 * @param capacity link capacity in GTUs per hour 62 * @param directionality the directionality for all GTUs 63 * @throws NetworkException if link already exists in the network, if name of the link is not unique, or if the start node 64 * or the end node of the link are not registered in the network. 65 */ 66 @SuppressWarnings("checkstyle:parameternumber") 67 public CapacityOTSLink(final Network network, final String id, final Node startNode, final Node endNode, 68 final LinkType linkType, final OTSLine3D designLine, final OTSSimulatorInterface simulator, 69 final Frequency capacity, final LongitudinalDirectionality directionality) throws NetworkException 70 { 71 super(network, id, startNode, endNode, linkType, designLine, simulator, directionality); 72 this.capacity = capacity; 73 } 74 75 /** 76 * Clone a link for a new network. 77 * @param newNetwork the new network to which the clone belongs 78 * @param newSimulator the new simulator for this network 79 * @param animation whether to (re)create animation or not 80 * @param link the link to clone from 81 * @throws NetworkException if link already exists in the network, if name of the link is not unique, or if the start node 82 * or the end node of the link are not registered in the network. 83 */ 84 protected CapacityOTSLink(final Network newNetwork, final OTSSimulatorInterface newSimulator, final boolean animation, 85 final CapacityOTSLink link) throws NetworkException 86 { 87 super(newNetwork, newSimulator, animation, link); 88 this.capacity = link.capacity; 89 } 90 91 /** {@inheritDoc} */ 92 @Override 93 public final Frequency getCapacity() 94 { 95 return this.capacity; 96 } 97 98 /** {@inheritDoc} */ 99 @Override 100 public final void setCapacity(final Frequency capacity) 101 { 102 this.capacity = capacity; 103 } 104 105 /** {@inheritDoc} */ 106 @Override 107 public final String toString() 108 { 109 return "CapacityOTSLink [capacity=" + this.capacity + "]"; 110 } 111 112 /** {@inheritDoc} */ 113 @Override 114 @SuppressWarnings("checkstyle:designforextension") 115 public CapacityOTSLink clone(final Network newNetwork, final OTSSimulatorInterface newSimulator, final boolean animation) 116 throws NetworkException 117 { 118 return new CapacityOTSLink(newNetwork, newSimulator, animation, this); 119 } 120 121 }