Link.java

  1. package org.opentrafficsim.core.network;

  2. import java.io.Serializable;
  3. import java.util.Set;

  4. import org.djunits.value.vdouble.scalar.Length;
  5. import org.opentrafficsim.base.Identifiable;
  6. import org.opentrafficsim.core.geometry.OTSLine3D;
  7. import org.opentrafficsim.core.gtu.GTU;
  8. import org.opentrafficsim.core.gtu.GTUType;

  9. import nl.tudelft.simulation.dsol.animation.Locatable;
  10. import nl.tudelft.simulation.dsol.simulators.SimulatorInterface;
  11. import nl.tudelft.simulation.event.EventType;

  12. /**
  13.  * Link as a connection between two Nodes.
  14.  * <p>
  15.  * Copyright (c) 2013-2018 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  16.  * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
  17.  * <p>
  18.  * $LastChangedDate: 2018-09-19 13:55:45 +0200 (Wed, 19 Sep 2018) $, @version $Revision: 4006 $, by $Author: averbraeck $,
  19.  * initial version Aug 19, 2014 <br>
  20.  * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
  21.  * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
  22.  */
  23. public interface Link extends Locatable, Serializable, Identifiable
  24. {
  25.     /**
  26.      * Return the network in which this link is registered. Cannot be null.
  27.      * @return Network; the network in which this link is registered
  28.      */
  29.     Network getNetwork();

  30.     /** @return id. */
  31.     @Override
  32.     String getId();

  33.     /** @return start node. */
  34.     Node getStartNode();

  35.     /** @return end node. */
  36.     Node getEndNode();

  37.     /** @return the link type. */
  38.     LinkType getLinkType();

  39.     /** @return the design line. */
  40.     OTSLine3D getDesignLine();

  41.     /** @return the simulator. */
  42.     SimulatorInterface.TimeDoubleUnit getSimulator();

  43.     /** @return length of the link. */
  44.     Length getLength();

  45.     /**
  46.      * This method returns the directionality of the link for a GTU type. It might be that the link is FORWARD (from start node
  47.      * to end node) for the GTU type CAR, but BOTH for the GTU type BICYCLE (i.e., bicycles can also go from end node to start
  48.      * node). If there is no entry for the given GTU Type, the values of GTUType.ALL will be returned. If this entry is not
  49.      * present, LongitudinalDirectionality.NONE will be returned.
  50.      * @param gtuType the GTU type to request the directionality for
  51.      * @return the longitudinal directionality of the link (FORWARD, BACKWARD, BOTH or NONE) for the given GTU type. NONE will
  52.      *         be returned if no directionality is given.
  53.      */
  54.     LongitudinalDirectionality getDirectionality(final GTUType gtuType);

  55.     /**
  56.      * Add a GTU to this link (e.g., for statistical purposes, or for a model on macro level). It is safe to add a GTU again. No
  57.      * warning or error will be given. The GTU_ADD_EVENT will only be fired when the GTU was not already on the link.
  58.      * @param gtu GTU; the GTU to add.
  59.      */
  60.     void addGTU(GTU gtu);

  61.     /**
  62.      * Remove a GTU from this link. It is safe to try to remove a GTU again. No warning or error will be given. The
  63.      * GTU_REMOVE_EVENT will only be fired when the GTU was on the link.
  64.      * @param gtu GTU; the GTU to remove.
  65.      */
  66.     void removeGTU(GTU gtu);

  67.     /**
  68.      * Provide a safe copy of the set of GTUs.
  69.      * @return Set&lt;GTU&gt;; a safe copy of the set of GTUs
  70.      */
  71.     Set<GTU> getGTUs();

  72.     /**
  73.      * Provide the number of GTUs on this link.
  74.      * @return int; the number of GTUs on this link
  75.      */
  76.     int getGTUCount();

  77.     /**
  78.      * The <b>timed</b> event type for pub/sub indicating the addition of a GTU to the link. <br>
  79.      * Payload: Object[] {String gtuId, GTU gtu, int count_after_addition}
  80.      */
  81.     EventType GTU_ADD_EVENT = new EventType("LINK.GTU.ADD");

  82.     /**
  83.      * The <b>timed</b> event type for pub/sub indicating the removal of a GTU from the link. <br>
  84.      * Payload: Object[] {String gtuId, GTU gtu, int count_after_removal}
  85.      */
  86.     EventType GTU_REMOVE_EVENT = new EventType("LINK.GTU.REMOVE");

  87. }