Class CacheOutputAdapter

All Implemented Interfaces:
FWSimFieldContainer

public class CacheOutputAdapter extends FWSimOutputAdapter
Output adapter for the memory interface: stores the output lines of each simulation in a FWSimResultCache for later use in the application (charts, calibration, wrapper). The caches are created when the simulations are registered (registerSimulation(FWSimSimulation)).
Author:
Andreas Enders
  • Constructor Details

    • CacheOutputAdapter

      public CacheOutputAdapter(org.jdom2.Element aResourceElement, int aOrderNumber, FWSimVarMap aVarMap)
      Creates the adapter from an output element.
      Parameters:
      aResourceElement - the output element
      aOrderNumber - order number of the adapter
      aVarMap - template variable map of the solution
    • CacheOutputAdapter

      public CacheOutputAdapter(String aName, int aOrderNumber, FWSimIOAdapter.FREQUENCE aFrequence, String aCacheSize, ProcessTime aProcessTime, FWSimSession aSession)
      Creates the adapter from the graph panel with its own memory interface.
      Parameters:
      aName - name of the adapter and the interface
      aOrderNumber - order number of the adapter
      aFrequence - frequency of the output
      aCacheSize - capacity of the queue and the interface (must be a number)
      aProcessTime - runtime statistics of the adapter
      aSession - the session
    • CacheOutputAdapter

      public CacheOutputAdapter(String aName, FWSimIOAdapter.FREQUENCE aFrequence, LinkedHashMap<String, FWSimVariable<?>> aVarList, FWSimVarMap aVarMap)
      Constructor for calibration outputs: creates a result cache CALIBRATION for the given variables. Note: the header variables are still empty when their rules are set, and writeData(FWSimQueueObjectMap) looks up caches by simulation id, so this cache is not filled.
      Parameters:
      aName - name of the adapter
      aFrequence - frequency of the output
      aVarList - variables of the result cache
      aVarMap - variable map (session and simulation id)
    • CacheOutputAdapter

      public CacheOutputAdapter(FWSimOutputAdapter aOldAdapter, MEMORYInterface aInterface)
      Copy constructor used when the interface is replaced.
      Parameters:
      aOldAdapter - the adapter to copy
      aInterface - the new interface
  • Method Details

    • init

      protected void init(FWSimVarMap aVarMap)
      Nothing to initialize; the caches are created per simulation.
      Specified by:
      init in class FWSimOutputAdapter
      Parameters:
      aVarMap - variable map used for replacing tokens
    • isArrayMode

      public boolean isArrayMode()
      Returns false; arrays are stored as a whole.
      Overrides:
      isArrayMode in class FWSimIOAdapter
      Returns:
      true if the adapter has array variables (array elements are handled as separate values)
      See Also:
    • writeData

      protected void writeData(FWSimQueueObjectMap aObjectToWrite)
      Stores an output line in the result cache of its simulation (in the writer thread). A missing cache is logged.
      Specified by:
      writeData in class FWSimOutputAdapter
      Parameters:
      aObjectToWrite - the output line
      See Also:
    • registerSimulation

      public void registerSimulation(FWSimSimulation aFwSimSimulation)
      Creates the result cache of a simulation and registers it at the simulation.
      Parameters:
      aFwSimSimulation - the simulation
    • getResultCache

      public FWSimResultCache getResultCache(String aID)
      Parameters:
      aID - id of the simulation
      Returns:
      the result cache of the simulation, or null if not registered
    • getDataContainer

      public DataContainer getDataContainer(String aSimulationID)
      Parameters:
      aSimulationID - id of a simulation, or null for all simulations
      Returns:
      the data of one or all result caches as DataContainer (e.g. for the wrapper), or null if there is no result cache for the simulation id or no result cache at all (logged as warning)
    • finalize

      public void finalize() throws Exception
      Nothing to finalize; the caches stay available.
      Overrides:
      finalize in class FWSimIOAdapter
      Throws:
      Exception - if finalizing the interface fails
      See Also:
    • clearSimulation

      public void clearSimulation()
      Removes all result caches.