Class TimeSeries

java.lang.Object
microsim.statistics.TimeSeries
All Implemented Interfaces:
EventListener, UpdatableSource

public class TimeSeries extends Object implements EventListener, UpdatableSource
A container for multiple synchronized time series.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected cern.mateba.list.tdouble.DoubleArrayList
     
    static final char
    The character used to separate data in the output file: ','
    protected ArrayList<String>
     
    protected ArrayList<Series>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new time series container.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addSeries(@NonNull Object target, @NonNull String variableName, boolean getFromMethod)
    Adds a new series to the existing one.
    void
    addSeries(@NonNull DoubleSource source, @NonNull Enum<?> valueID)
    Adds a new series to the existing one.
    void
    addSeries(@NonNull IntSource source, @NonNull Enum<?> valueID)
    Adds a new series to the existing one.
    void
    addSeries(@NonNull LongSource source, @NonNull Enum<?> valueID)
    Adds a new series to the existing one.
    void
    addSeries(@NonNull Series aSeries)
    Adds a new series to the existing one.
    getSeries(int seriesIndex)
    Returns a series at the given index.
    int
    Returns the number of series.
    void
    onEvent(@NonNull Enum<?> type)
    Performs one of the defined actions.
    void
    Stores the entire data content in the output file in the same directory.
    void
    saveToFile(@NonNull String path, @NonNull String fileName)
    Stores the entire data content in the given output file.
    void
    saveToFile(@NonNull String path, @NonNull String fileName, boolean withTimes)
    Stores the entire data content in the given output file.
    void
    saveToFile(@NonNull String path, @NonNull String fileName, boolean withTimes, char separator)
    Stores the entire data content in the given output file.
    void
    Updates all the contained time series and the current time.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_SEPARATOR

      public static final char DEFAULT_SEPARATOR
      The character used to separate data in the output file: ','
      See Also:
    • series

      protected ArrayList<Series> series
    • absTimes

      protected cern.mateba.list.tdouble.DoubleArrayList absTimes
    • descTimes

      protected ArrayList<String> descTimes
  • Constructor Details

    • TimeSeries

      public TimeSeries()
      Creates a new time series container.
  • Method Details

    • addSeries

      public void addSeries(@NonNull @NonNull Series aSeries)
      Adds a new series to the existing one.
      Parameters:
      aSeries - An instance of Series.
      Throws:
      NullPointerException - when aSeries is null.
    • addSeries

      public void addSeries(@NonNull @NonNull DoubleSource source, @NonNull @NonNull Enum<?> valueID)
      Adds a new series to the existing one.
      Parameters:
      source - A DoubleSource object.
      valueID - The value identifier defined by source object.
      Throws:
      NullPointerException - when any of the input parameters is null.
    • addSeries

      public void addSeries(@NonNull @NonNull IntSource source, @NonNull @NonNull Enum<?> valueID)
      Adds a new series to the existing one.
      Parameters:
      source - The IntSource object.
      valueID - The value identifier defined by source object.
      Throws:
      NullPointerException - when any of the input parameters is null.
    • addSeries

      public void addSeries(@NonNull @NonNull LongSource source, @NonNull @NonNull Enum<?> valueID)
      Adds a new series to the existing one.
      Parameters:
      source - The LongSource object.
      valueID - The value identifier defined by source object.
      Throws:
      NullPointerException - when any of the input parameters is null.
    • addSeries

      public void addSeries(@NonNull @NonNull Object target, @NonNull @NonNull String variableName, boolean getFromMethod)
      Adds a new series to the existing one.
      Parameters:
      target - A generic source object.
      variableName - The name of the field or the method returning the variable to be probed.
      getFromMethod - Specifies if valueName is a method or a property value.
      Throws:
      NullPointerException - when any of the input parameters is null.
    • updateSource

      public void updateSource()
      Updates all the contained time series and the current time.
      Specified by:
      updateSource in interface UpdatableSource
    • getSeries

      public Series getSeries(int seriesIndex)
      Returns a series at the given index.
      Parameters:
      seriesIndex - The name of the series.
      Returns:
      The asked series or null if series does not exist.
      Throws:
      IndexOutOfBoundsException - If seriesIndex is out of bounds.
    • getSeriesCount

      public int getSeriesCount()
      Returns the number of series.
      Returns:
      The number of series.
    • saveToFile

      public void saveToFile()
      Stores the entire data content in the output file in the same directory.
    • saveToFile

      public void saveToFile(@NonNull @NonNull String path, @NonNull @NonNull String fileName)
      Stores the entire data content in the given output file.
      Parameters:
      path - The optional path string.
      fileName - The name of the output file.
    • saveToFile

      public void saveToFile(@NonNull @NonNull String path, @NonNull @NonNull String fileName, boolean withTimes)
      Stores the entire data content in the given output file.
      Parameters:
      path - The optional path string. Passing an empty string it is ignored.
      fileName - The name of the output file.
      withTimes - If true time description is saved. Only absolute time is saved if false.
    • saveToFile

      public void saveToFile(@NonNull @NonNull String path, @NonNull @NonNull String fileName, boolean withTimes, char separator)
      Stores the entire data content in the given output file.
      Parameters:
      path - The optional path string. Passing an empty string it is ignored.
      fileName - The name of the output file.
      withTimes - If true time description is saved. Only absolute time is saved if false.
      separator - The character used to separate data.
    • onEvent

      public void onEvent(@NonNull @NonNull Enum<?> type)
      Performs one of the defined actions.
      Specified by:
      onEvent in interface EventListener
      Parameters:
      type - a CommonEventType object.
      Throws:
      NullPointerException - when type is null.