Class FWSimpleSimComponent

java.lang.Object
net.simplace.sim.model.FWSimComponent
net.simplace.sim.components.FWSimpleSimComponent
All Implemented Interfaces:
IntegratableComponent, FWSimFieldContainer

public final class FWSimpleSimComponent extends FWSimComponent implements IntegratableComponent
SimComponent defined completely in the solution, without own Java class: the children of process (and optionally integrate) are output variables whose values are calculated by their rules (JEXL) in each step (resp. after the integration). The variables used in the rules become the inputs of the component.
Author:
Andreas Enders
  • Constructor Details

    • FWSimpleSimComponent

      public FWSimpleSimComponent(String aName, HashMap<String, FWSimVariable<?>> aFieldMap, HashMap<String,String> aInputMap, org.jdom2.Element aSimComponentElement, FWSimVarMap aVarMap, int aOrderNumber)
      Parameters:
      aName - name of the component
      aFieldMap - variables of the component
      aInputMap - input links of the component
      aSimComponentElement - the simcomponent element
      aVarMap - variable map of the simulation
      aOrderNumber - order number of the component
    • FWSimpleSimComponent

      public FWSimpleSimComponent()
      Constructor for instantiation via reflection.
    • FWSimpleSimComponent

      public FWSimpleSimComponent(String aName, HashMap<String, FWSimVariable<?>> aFieldMap, LinkedList<FWSimVariable<?>> aProcessAlgorithmsMap, LinkedList<FWSimVariable<?>> aIntegrateAlgorithmsMap, HashMap<String,String> aInputMap, org.jdom2.Element aSimComponentElement, FWSimVarMap aVarMap, int aOrderNumber)
      Constructor used by clone(FWSimVarMap); the algorithm lists are shared until init().
      Parameters:
      aName - name of the component
      aFieldMap - variables of the component
      aProcessAlgorithmsMap - variables calculated in the process step
      aIntegrateAlgorithmsMap - variables calculated after the integration
      aInputMap - input links of the component
      aSimComponentElement - the simcomponent element
      aVarMap - variable map of the simulation
      aOrderNumber - order number of the component
  • Method Details

    • createVariables

      public HashMap<String, FWSimVariable<?>> createVariables()
      Creates the variables of the process and integrate children and registers the variables used in their rules as inputs (component.var as var, a leading v becomes c). Each of the two elements may be missing; if both are missing, an error is logged.
      Specified by:
      createVariables in interface FWSimFieldContainer
      Specified by:
      createVariables in class FWSimComponent
      Returns:
      the field map, or null without component element
      See Also:
    • bind

      protected void bind()
      Nothing to bind; the variables are evaluated by their rules.
      Overrides:
      bind in class FWSimComponent
    • init

      protected void init()
      Replaces the algorithm variables by the instances of the variable map of the simulation.
      Specified by:
      init in class FWSimComponent
      See Also:
    • process

      protected void process()
      Evaluates the rules of the process variables in order and sets their values. Errors are logged.
      Specified by:
      process in class FWSimComponent
      See Also:
    • postIntegrate

      public void postIntegrate()
      Evaluates the rules of the integrate variables in order and sets their values. Errors are logged, like in process().
      Specified by:
      postIntegrate in interface IntegratableComponent
      See Also:
    • getLinkedVariableNames

      public Set<String> getLinkedVariableNames()
      Returns:
      the names of the variables used in the rules
    • getProcessAlgorithms

      public LinkedList<FWSimVariable<?>> getProcessAlgorithms()
      Returns:
      the variables calculated in the process step
    • getIntegrateAlgorithms

      public LinkedList<FWSimVariable<?>> getIntegrateAlgorithms()
      Returns:
      the variables calculated after the integration
    • getFieldsInfo

      public String getFieldsInfo()
      Returns:
      the configuration of the component (algorithms and variables) as HTML, e.g. for an info dialog of the GUI
    • getEditFormXML

      public final org.jdom2.Element getEditFormXML(boolean aEnabled)
      Creates the edit form: name, class and the process and integrate definitions as text (one name=rule per line).
      Specified by:
      getEditFormXML in interface FWSimFieldContainer
      Overrides:
      getEditFormXML in class FWSimComponent
      Parameters:
      aEnabled - if the definitions are editable
      Returns:
      the XML form definition used by the GUI to edit the settings of this container
      See Also:
    • toXML

      public org.jdom2.Element toXML()
      Creates the simcomponent element: a copy of the configuration element as read or as set by setVariables(List, List) (keeping description, comments and all attributes); without element it is created from the process and integrate variables.
      Specified by:
      toXML in interface FWSimFieldContainer
      Overrides:
      toXML in class FWSimComponent
      Returns:
      an XML element with all settings of this container
      See Also:
    • setVariables

      public void setVariables(List<org.jdom2.Element> aProcess, List<org.jdom2.Element> aIntegrate)
      Replaces the variables of the component (e.g. from the editor of the GUI, Redmine #62): the var elements of process and integrate are replaced in the configuration element (other content like comments stays, an empty section is removed), the old variables are removed from the var map and the field map of the model, the new ones are created and registered, and the inputs are derived from the rules again.
      Parameters:
      aProcess - the var elements calculated in the process step, in order
      aIntegrate - the var elements calculated after the integration, in order
    • fillTestVariables

      public HashMap<String, FWSimVariable<?>> fillTestVariables(int aParamIndex, FWSimComponent.TEST_STATE aDefineOrCheck)
      No component tests for simple components.
      Specified by:
      fillTestVariables in class FWSimComponent
      Parameters:
      aParamIndex - index of the test case (not used)
      aDefineOrCheck - define or check phase (not used)
      Returns:
      always null
      See Also:
    • clone

      protected FWSimComponent clone(FWSimVarMap aVarMap)
      Clones the component for a simulation; the algorithm lists are replaced by the simulation's instances in init().
      Specified by:
      clone in class FWSimComponent
      Parameters:
      aVarMap - var map of the new simulation
      Returns:
      the new instance
      See Also: