Class FWSimOutputCache

All Implemented Interfaces:
Serializable, Cloneable, Map<FWSimVariable<?>, Object>

public class FWSimOutputCache extends HashMap<FWSimVariable<?>, Object>
Aggregation cache of one output for one simulation. For each header variable it stores the values of the steps since the last output line (or only the current value for DAILY and CAL outputs) and, when a line is due, reduces them according to the mode of the variable (SUM, AVG, MIN, MAX, COUNT, FIRST, LAST).
Author:
Andreas Enders
See Also:
  • Constructor Details

    • FWSimOutputCache

      public FWSimOutputCache(FWSimVarMap aVarMap, LinkedHashMap<String, FWSimVariable<?>> aHeaderVariables)
      Creates the cache: for each header variable with a simple rule (a variable name) the referenced model variable is looked up once; complex rules are evaluated in each step.
      Parameters:
      aVarMap - variable map of the simulation
      aHeaderVariables - header variables of the output
  • Method Details

    • fill

      public void fill(FWSimVarMap aVarMap, FWSimIOAdapter.FREQUENCE aFrequence)
      Stores the current value of each header variable: the value of the referenced variable or the evaluated rule, converted to the data type of the header variable. Arrays are copied; for a single index (count) only that element is taken (99998 or 99999 mean the last element, from count 99999 resp. last). DAILY and CAL outputs keep only the current value, other outputs collect the values.
      Parameters:
      aVarMap - variable map of the simulation
      aFrequence - frequency of the output
      Throws:
      org.apache.commons.jexl3.JexlException - if a rule cannot be evaluated (logged and rethrown)
    • reset

      public void reset()
      Discards the collected values of all header variables.
    • generate

      public FWSimQueueObjectMap generate(FWSimVarMap aVarMap, LinkedHashMap<String, FWSimVariable<?>> aHeaderVariables, boolean aArrayMode, FWSimIOAdapter.FREQUENCE aFrequence)
      Creates the output line of the current step. For DAILY and CAL outputs the current values are taken; in array mode array variables are reduced to the elements given by their count (all elements if empty). For other frequencies the collected values are aggregated by the mode of each variable and then discarded.
      Parameters:
      aVarMap - variable map of the simulation (simulation id and current date of the line)
      aHeaderVariables - header variables of the output, in column order
      aArrayMode - true if the adapter writes array elements as separate values
      aFrequence - frequency of the output
      Returns:
      the output line