Class Detector

All Implemented Interfaces:
Serializable, Comparable<SingleSensor>, Locatable, nl.tudelft.simulation.event.EventProducerInterface, Identifiable, Drawable, Compatible, ObjectInterface, LaneBasedObject, Sensor, SingleSensor

public class Detector
extends AbstractSensor
Detector, measuring a dynamic set of measurements.

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

Version:
$Revision$, $LastChangedDate$, by $Author$, initial version 5 mrt. 2018
Author:
Alexander Verbraeck, Peter Knoppers, Wouter Schakel
See Also:
Serialized Form
  • Field Details

  • Constructor Details

  • Method Details

    • getLength

      public Length getLength()
      Returns the detector length.
      Returns:
      Length; the detector length
    • triggerResponse

      protected void triggerResponse​(LaneBasedGTU gtu)
      Implementation of the response to a trigger of this sensor by a GTU.
      Specified by:
      triggerResponse in class AbstractSensor
      Parameters:
      gtu - LaneBasedGTU; the lane based GTU that triggered this sensor.
    • hasLastValue

      public boolean hasLastValue()
      Returns whether the detector has aggregated data available.
      Returns:
      boolean; whether the detector has aggregated data available
    • getLastFlow

      public Frequency getLastFlow()
      Returns the last flow.
      Returns:
      last flow
    • getLastValue

      public <A> A getLastValue​(Detector.DetectorMeasurement<?,​A> detectorMeasurement)
      Returns the last value of the detector measurement.
      Type Parameters:
      A - aggregate value type of the detector measurement
      Parameters:
      detectorMeasurement - DetectorMeasurement<?,A>; detector measurement
      Returns:
      last value of the detector measurement
    • clone

      Clone the LaneBasedObject for e.g., copying a network.
      Specified by:
      clone in class AbstractSensor
      Parameters:
      newCSE - CrossSectionElement; the new cross section element to which the clone belongs
      newSimulator - SimulatorInterface.TimeDoubleUnit; the new simulator for this network
      Returns:
      AbstractLaneBasedObject; a clone of this object
      Throws:
      NetworkException - in case the cloning fails
    • writeToFile

      public static final void writeToFile​(OTSRoadNetwork network, String file, boolean periodic)
      Write the contents of all detectors in to a file.
      Parameters:
      network - OTSRoadNetwork; network
      file - String; file
      periodic - boolean; periodic data
    • writeToFile

      public static final <C> void writeToFile​(OTSRoadNetwork network, String file, boolean periodic, String format, Detector.CompressionMethod compression)
      Write the contents of all detectors in to a file.
      Type Parameters:
      C - accumulated type
      Parameters:
      network - OTSRoadNetwork; network
      file - String; file
      periodic - boolean; periodic data
      format - String; number format, as used in String.format()
      compression - CompressionMethod; how to compress the data
    • removeTrailingZeros

      public static final String removeTrailingZeros​(String string)
      Remove any trailing zeros.
      Parameters:
      string - String; string of number
      Returns:
      String; string without trailing zeros
    • printListDouble

      public static final String printListDouble​(List<Double> list, String format)
      Prints a list of doubles in to a formatted string.
      Parameters:
      list - List<Double>; double values
      format - String; format string
      Returns:
      formatted string of doubles