Class FWSimInputAdapter

java.lang.Object
net.simplace.sim.io.FWSimIOAdapter
net.simplace.sim.io.resources.FWSimInputAdapter
All Implemented Interfaces:
FWSimFieldContainer
Direct Known Subclasses:
FWSimResourceAdapter, FWSimResourceAlias, FWSimResourceTransformer

public abstract class FWSimInputAdapter extends FWSimIOAdapter
Base class of the adapters that only read input data: resources (resource element, reading from an interface) and transformers (transform element, deriving data from another resource). The data is provided as FWSimResourceCache by getData(FWSimVarMap); the header variables are the outputs of the adapter.
Author:
Andreas Enders
  • Field Details

    • iShouldCacheToDB

      protected Boolean iShouldCacheToDB
      if the content of the resource cache should also be stored in the database (attribute dbcache)
    • iJexlScript

      protected JexlRuleScript iJexlScript
      compiled rule of the adapter, created on demand by getJexlScript()
  • Constructor Details

    • FWSimInputAdapter

      protected FWSimInputAdapter(org.jdom2.Element aResourceElement, FWSimSession aSession, int aOrderNumber)
      Creates the adapter from a solution element. The attribute dbcache defaults to true for resources and false for transformers.
      Parameters:
      aResourceElement - the resource or transform element
      aSession - the session
      aOrderNumber - order number of the adapter
    • FWSimInputAdapter

      protected FWSimInputAdapter(org.jdom2.Element aResourceElement, String aName, int aOrderNumber, FWSimInterface<?> aInterface, FWSimIOAdapter.FREQUENCE aFrequence, FWSimSession aFwSimSession)
      Creates the adapter from the graph panel. The attribute dbcache defaults to true for resources and false for transformers (as for adapters from the solution).
      Parameters:
      aResourceElement - the resource or transform element
      aName - name (id) of the adapter
      aOrderNumber - order number of the adapter
      aInterface - interface to read from
      aFrequence - frequency the data is read with
      aFwSimSession - the session
    • FWSimInputAdapter

      protected FWSimInputAdapter(FWSimInputAdapter aAdapter, FWSimInterface<?> aInterface)
      Copy constructor used when the interface of an adapter is replaced.
      Parameters:
      aAdapter - the adapter to copy; null only for instantiation via reflection (then the adapter counts as transformer and dbcache stays unset)
      aInterface - the new interface
  • Method Details

    • getData

      public abstract FWSimResourceCache getData(FWSimVarMap aVarMap) throws MissingSimResourceException
      Reads the data of the resource for a simulation.
      Parameters:
      aVarMap - variable map of the simulation (e.g. for the key values of the rule)
      Returns:
      the cache containing the data read
      Throws:
      MissingSimResourceException - if the data cannot be read
    • getOutputVariables

      public Collection<FWSimVariable<?>> getOutputVariables()
      Returns the header variables.
      Returns:
      the output variables of the field map
      See Also:
    • getInputVariables

      public Collection<FWSimVariable<?>> getInputVariables()
      Returns an empty list; input adapters have no input variables.
      Returns:
      the input variables of the field map
      See Also:
    • getContentType

      public FWSimVariable.CONTENT_TYPE getContentType()
      Returns res.
      Returns:
      the content type of the variables of this container (e.g. sys, mgm)
      See Also:
    • getJexlScript

      public JexlRuleScript getJexlScript()
      Returns:
      the compiled rule of the adapter; created on the first call
    • setFrequenceAndRule

      public void setFrequenceAndRule(FWSimIOAdapter.FREQUENCE aFrequence, String aRule)
      Changes frequency and rule; the compiled rule is created again on the next use.
      Overrides:
      setFrequenceAndRule in class FWSimIOAdapter
      Parameters:
      aFrequence - the frequency
      aRule - the rule, empty for none (required for COMPLEX and BOOLEAN)
      See Also:
    • getVarMap

      public FWSimVarMap getVarMap()
      Returns the variable map of the solution of the session, or null if there is none.
      Returns:
      the var map this container belongs to
      See Also:
    • toHTMLTablestring

      public String toHTMLTablestring()
      Creates the HTML documentation of the adapter for the solution overview: name, class, interface (or source resource for transformers), frequency and a table of the header variables (without sys variables).
      Returns:
      the HTML fragment
    • isTransformer

      public boolean isTransformer()
      Returns:
      true if the adapter was created from a transform element
    • shouldCacheToDB

      public boolean shouldCacheToDB()
      Returns:
      true if the resource cache should also be stored in the database (false if not set, e.g. for adapters created via reflection)