All Implemented Interfaces:
Comparable<LaneDetector>, nl.tudelft.simulation.dsol.animation.Locatable, Identifiable, EventProducer, OtsShape, HierarchicallyTyped<DetectorType,Detector>, Detector, LocatedObject, LaneBasedObject

public class SinkDetector extends LaneDetector
A SinkDetector is a detector that deletes GTUs that hit it, if they comply to a predicate.

Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands.
All rights reserved.
BSD-style license. See OpenTrafficSim License.

Author:
Alexander Verbraeck, Peter Knoppers, Wouter Schakel
  • Field Details

    • DESTINATION

      public static final BiPredicate<SinkDetector,LaneBasedGtu> DESTINATION
      Predicate to use to destroy all GTUs with routes ending in the end node of this link, possibly via a connector.
  • Constructor Details

    • SinkDetector

      public SinkDetector(Lane lane, org.djunits.value.vdouble.scalar.Length position, DetectorType detectorType) throws NetworkException
      Constructor. All GTUs matching the DetectorType will be removed.
      Parameters:
      lane - the lane that triggers the deletion of the GTU.
      position - the position of the detector
      detectorType - detector type.
      Throws:
      NetworkException - when the position on the lane is out of bounds w.r.t. the center line of the lane
    • SinkDetector

      public SinkDetector(Lane lane, org.djunits.value.vdouble.scalar.Length position, DetectorType detectorType, BiPredicate<SinkDetector,LaneBasedGtu> predicate) throws NetworkException
      Constructor.
      Parameters:
      lane - the lane that triggers the deletion of the GTU.
      position - the position of the detector
      detectorType - detector type.
      predicate - predicate for what GTUs will be destroyed.
      Throws:
      NetworkException - when the position on the lane is out of bounds w.r.t. the center line of the lane
  • Method Details

    • triggerResponse

      public final void triggerResponse(LaneBasedGtu gtu)
      Description copied from class: LaneDetector
      Implementation of the response to a trigger of this detector by a GTU.
      Specified by:
      triggerResponse in class LaneDetector
      Parameters:
      gtu - the lane based GTU that triggered this detector.
    • willDestroy

      public boolean willDestroy(LaneBasedGtu gtu)
      Returns whether the GTU will be removed by this sink.
      Parameters:
      gtu - gtu.
      Returns:
      whether the GTU will be removed by this sink.
    • toString

      public final String toString()
      Overrides:
      toString in class LaneDetector