Class TimeStampWriter

java.lang.Object
tools.descartes.dlim.exporter.utils.TimeStampWriter
Direct Known Subclasses:
EqualDistanceTimestampWriter, UniformDistributionTimestampWriter

public abstract class TimeStampWriter extends Object
Creates a time-stamp file from an arrival rate list. Abstract class. Subclasses must implement the (PrintWriter writer, double step, double arrRate, double tmpStep, double tmpTime) writeTimestampsForArrivalRate method to define the exact sampling of timestamps
  • Constructor Details

    • TimeStampWriter

      protected TimeStampWriter(String endOfLineCharacter)
      Instantiates a new time stamp writer.
      Parameters:
      endOfLineCharacter - The character before the end of a line in the output file. Note: the "\n" is always printed after this character. It does not have to be included here.
    • TimeStampWriter

      protected TimeStampWriter()
      The constructor.
  • Method Details

    • getEndOfLineCharacter

      protected String getEndOfLineCharacter()
      Gets the end of line character for the .csv.
      Returns:
      the end of line character
    • getDecimalplaces

      protected int getDecimalplaces()
      Gets the decimal places.
      Returns:
      the decimal places
    • formatDoubleForDecimalPlaces

      protected String formatDoubleForDecimalPlaces(double d)
      Formats the double to only contain decimalplaces decimals after the period.
      Parameters:
      d - The double to format.
      Returns:
      The formatted double as a String.
    • getStretch

      protected double getStretch()
      Gets the time stretch factor.
      Returns:
      the stretch
    • generateTimeStampsFromArrivalRates

      public void generateTimeStampsFromArrivalRates(File file, List<ArrivalRateTuple> arrRates, int decimalPlaces, double stretch, double arDevisor)
      Generate time stamps from arrival rates.
      Parameters:
      file - The filename of the produced output file
      arrRates - The list of arrival rates as provided by the ArrivalRateGenerator.
      decimalPlaces - The amount of decimal places a time-stamp is allowed to have.
      stretch - The factor by which to stretch the times of the arrival rate tuples. Using a value < 1 compresses the time.
      arDevisor - Divide the arrival rates from the arrival rate tuples by this to produce less time-stamps. Using a value < 1 produces more time stamps
    • writeTimestampsForArrivalRate

      protected abstract void writeTimestampsForArrivalRate(PrintWriter writer, double step, double arrRate, double tmpStep, double tmpTime)
      Write the arrival rate using the provided writer in the specific chosen format.
      Parameters:
      writer - PrintWriter, is already initialized and writing.
      step - step between two time stamps
      arrRate - current arrival rate
      tmpStep - the temporary step
      tmpTime - the temporary time