Package net.simplace.sim.model
Class FWSimComponent
java.lang.Object
net.simplace.sim.model.FWSimComponent
- All Implemented Interfaces:
FWSimFieldContainer
- Direct Known Subclasses:
DefaultManagement
,FWAnalyticsSimComponent
,FWSimComponentGroup
,FWSimpleSimComponent
- Author:
- Andreas Enders FWSimComponent is the smallest definable unit of a model It overrides the abstract FWSimFieldContainer with methods init, clone (with reset) and process It contains the algorithms of the scientific model Has to be documented in detail Simulation Modules are similar to the so called ?strategies? in ACE. They can be encapsulated with SimObjects and used in ACE as in SMILE Model Engine. Each FWSimComponent should have its own Unit Test, Input Forms and Result Forms
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected HashMap<String,
FWSimVariable<?>> initial field map as given by the createVariables()-Method in the SimComponent implementationprotected FWSimIOAdapter.FREQUENCE
frequence to check if component is executed or notregistered links of the SimComponent implementationprotected JexlRuleScript
rule to check if component is executed or notprotected FWSimComponentGroup
If component is part of a SimComponent Group Main Component mentioned hereprotected String
Name of componentprotected int
order number for the serial order of the componentsprotected final boolean
Info about ComponentGroupprotected org.jdom2.Element
original SimComponent configuration element (jdom)protected FWSimModel
SimModel reference - can be seen as the thread the component is accessed inprotected FWSimVarMap
Centrally used VarMap reference -
Constructor Summary
ModifierConstructorDescriptionprotected
Main constructor for use with Class.forName()protected
FWSimComponent
(String aName, HashMap<String, FWSimVariable<?>> aFieldMap, HashMap<String, String> aInputMap, org.jdom2.Element aSimComponentElement, FWSimVarMap aVarMap, int aOrderNumber) called via clone -
Method Summary
Modifier and TypeMethodDescriptionvoid
addVariable
(FWSimVariable<?> aVariable) Add Variable to the Filed map.protected void
bind()
The model initialization function.void
checkCondition
(Boolean aCheckResult, String aMessage) Called from inside the FWSimFieldContainer to log the initialization Errors.protected abstract FWSimComponent
clone
(FWSimVarMap aVarMap) static FWSimComponent
createSimComponent
(String aClassname) static FWSimComponent
createSimComponent
(String tName, FWSimVarMap aVarMap, FWSimModel aSimModel, int aOrderNumber) static FWSimComponent
createSimComponent
(org.jdom2.Element aSimComponentElement, FWSimComponentGroup aComponentGroup, FWSimVarMap aVarMap, FWSimModel aSimModel, int aOrderNumber) factory method creating a SimComponentstatic FWSimComponent
createSimComponent
(org.jdom2.Element aSimComponentElement, FWSimVarMap aVarMap, FWSimModel aSimModel, int aOrderNumber) factory method creating a SimComponentabstract HashMap<String,
FWSimVariable<?>> called only once when the SimComponent is created.protected void
The main model calculation function.abstract HashMap<String,
FWSimVariable<?>> fillTestVariables
(int aTestIndex, FWSimComponent.TEST_STATE aDefineOrCheck) called for single component test to check the components algorithm.final org.jdom2.Element
org.jdom2.Element
getEditFormXML
(boolean aEnabled) returns the input variables from FieldMapgetName()
int
getVariable
(String aKey) protected FWSimVariable<?>
getVariableField
(String aKey) protected abstract void
init()
The model initialization function.void
The model initialization function.boolean
protected boolean
isVariableAvailable
(String aString) void
links like given in the input part of the SimComponent configuration are performed.protected void
performLinks
(HashMap<String, String> aLinkMap) protected abstract void
process()
The main model calculation function.readInputs
(org.jdom2.Element aSimComponentElement) void
removeVariable
(String aID) Remove variable from FieldMap - handle with care!protected void
reset
(FWSimVarMap aVarMap) static Boolean
runComponentTest
(String aComponentClassName, int aTestIndex) called for single component test to check the components algorithm.protected void
The models writable variables like outputs, states and rates are set to default .org.jdom2.Element
org.jdom2.Element
toDocXML()
org.jdom2.Element
toGroupXML
(HashSet<String> aComponentsInGroup, String aGroupName) org.jdom2.Element
org.jdom2.Element
org.jdom2.Element
toString()
Name of the Componentorg.jdom2.Element
toXML()
writeVarInfos
(String aFilePath) Writes the varInfos to a given FilePath.
-
Field Details
-
iName
Name of component -
iVarMap
Centrally used VarMap reference -
iFieldMap
initial field map as given by the createVariables()-Method in the SimComponent implementation -
iInputMap
registered links of the SimComponent implementation -
iSimModel
SimModel reference - can be seen as the thread the component is accessed in -
iSimComponentElement
protected org.jdom2.Element iSimComponentElementoriginal SimComponent configuration element (jdom) -
iOrderNumber
protected int iOrderNumberorder number for the serial order of the components -
iFrequence
frequence to check if component is executed or not -
iJexlRule
rule to check if component is executed or not -
isComponentGroup
protected final boolean isComponentGroupInfo about ComponentGroup -
iMasterComponentGroup
If component is part of a SimComponent Group Main Component mentioned here
-
-
Constructor Details
-
FWSimComponent
protected FWSimComponent()Main constructor for use with Class.forName()- Throws:
RuntimeException
-
FWSimComponent
protected FWSimComponent(String aName, HashMap<String, FWSimVariable<?>> aFieldMap, HashMap<String, String> aInputMap, org.jdom2.Element aSimComponentElement, FWSimVarMap aVarMap, int aOrderNumber) called via clone- Parameters:
aName
-aFieldMap
-aInputMap
-aSimComponentElement
-aVarMap
-aOrderNumber
-
-
-
Method Details
-
createSimComponent
public static FWSimComponent createSimComponent(org.jdom2.Element aSimComponentElement, FWSimVarMap aVarMap, FWSimModel aSimModel, int aOrderNumber) throws SimLinkInvalidException factory method creating a SimComponent- Parameters:
aSimComponentElement
-aVarMap
-aSimModel
-aOrderNumber
-- Returns:
- newly created FWSimComponent
- Throws:
SimLinkInvalidException
-
createSimComponent
public static FWSimComponent createSimComponent(org.jdom2.Element aSimComponentElement, FWSimComponentGroup aComponentGroup, FWSimVarMap aVarMap, FWSimModel aSimModel, int aOrderNumber) throws SimLinkInvalidException factory method creating a SimComponent- Parameters:
aSimComponentElement
-aComponentGroup
-aVarMap
-aSimModel
-aOrderNumber
-- Returns:
- newly created FWSimComponent
- Throws:
SimLinkInvalidException
-
createSimComponent
public static FWSimComponent createSimComponent(String tName, FWSimVarMap aVarMap, FWSimModel aSimModel, int aOrderNumber) throws SimLinkInvalidException - Parameters:
tName
-aVarMap
-aSimModel
-aOrderNumber
-- Returns:
- the created FWSimComponent
- Throws:
SimLinkInvalidException
-
createSimComponent
- Parameters:
aClassname
-- Returns:
- the newly created sim component
-
getVariableField
- Parameters:
aKey
-- Returns:
- the FWSimVariable from FieldMap (not from the VarMap!)
-
isVariableAvailable
- Parameters:
aString
-- Returns:
- if Variable is available in VarMap
-
addVariable
Add Variable to the Filed map. This should be called in implementing classes within the method "createVariables".- Specified by:
addVariable
in interfaceFWSimFieldContainer
- Parameters:
aVariable
-
-
getVariable
- Specified by:
getVariable
in interfaceFWSimFieldContainer
- Parameters:
aKey
-- Returns:
- one SimVariable registered for given key
- Throws:
SimFieldMissingException
- if Variable is Null
-
removeVariable
Remove variable from FieldMap - handle with care!- Specified by:
removeVariable
in interfaceFWSimFieldContainer
- See Also:
-
getName
- Specified by:
getName
in interfaceFWSimFieldContainer
- Returns:
- the name
-
getFieldMap
- Specified by:
getFieldMap
in interfaceFWSimFieldContainer
- Returns:
- the name
-
getVarMap
- Specified by:
getVarMap
in interfaceFWSimFieldContainer
- Returns:
- number in the order of Components
-
getFrequenceRuleScript
- Returns:
-
readInputs
- Parameters:
aSimComponentElement
-- Returns:
- HashMap of inputs
-
writeVarInfos
Writes the varInfos to a given FilePath.- Parameters:
aFilePath
-- Returns:
- the string result
-
bind
protected void bind()The model initialization function. Will be called only once, before running the model using process(). -
initialize
public void initialize()The model initialization function. Will be called only once, before running the model using process(). -
init
protected abstract void init()The model initialization function. Will be called only once, before running the model using process(). -
setVariablesDefault
protected void setVariablesDefault()The models writable variables like outputs, states and rates are set to default . -
createVariables
called only once when the SimComponent is created. Hereby the FieldMap is filled with the interfacing fields.- Specified by:
createVariables
in interfaceFWSimFieldContainer
- Returns:
- variables from the field map
- See Also:
-
performLinks
links like given in the input part of the SimComponent configuration are performed. This is done only while model creation.- Throws:
SimLinkInvalidException
-
performLinks
- Parameters:
aLinkMap
- with key = destination and value = source!- Throws:
SimLinkInvalidException
-
getInputs
- Returns:
- the map of the input relations. key is given without the name of the component.
-
reset
- Parameters:
aVarMap
-
-
doProcess
protected void doProcess()The main model calculation function. Is guaranteed to be called once per module-specific time step. -
process
protected abstract void process()The main model calculation function. Is guaranteed to be called once per module-specific time step. -
clone
- Parameters:
aVarMap
-- Returns:
- the deep clone of the SimComponent
-
getInputVariables
returns the input variables from FieldMap- Specified by:
getInputVariables
in interfaceFWSimFieldContainer
- Returns:
- FWSimVarables filtered - only input Variables
- See Also:
-
getConstantVariables
- Returns:
- constant variables from the FieldMAp
-
getOutputVariables
- Specified by:
getOutputVariables
in interfaceFWSimFieldContainer
- Returns:
- the OutputVariables from the FieldMap
- See Also:
-
toString
Name of the Component -
toDocXML
public org.jdom2.Element toDocXML()- Returns:
- Element of this document
- See Also:
-
toXML
public org.jdom2.Element toXML()- Specified by:
toXML
in interfaceFWSimFieldContainer
- Returns:
- a xml element with all the settings of this component()
- See Also:
-
toGroupXML
- Parameters:
aComponentsInGroup
-aGroupName
-- Returns:
- xml element which contains group of SimComponents
-
toResourcesDataXML
public org.jdom2.Element toResourcesDataXML()- Returns:
- xml element with all the info about constants of this component
-
toResourcesDefinitionXML
public org.jdom2.Element toResourcesDefinitionXML()- Returns:
- xml element which contains
section for this component for inclusion into solutions
-
toOutputDefinitionXML
public org.jdom2.Element toOutputDefinitionXML()- Returns:
- xml element which contains
-
toComponentLinkingXML
public org.jdom2.Element toComponentLinkingXML()- Returns:
- xml element which contains
section for this component for inclusion into solutions
-
getCreateFormXML
public final org.jdom2.Element getCreateFormXML()- Specified by:
getCreateFormXML
in interfaceFWSimFieldContainer
- Returns:
- a xml element with all the settings of this component()
- See Also:
-
getEditFormXML
public org.jdom2.Element getEditFormXML(boolean aEnabled) - Specified by:
getEditFormXML
in interfaceFWSimFieldContainer
- Returns:
- a xml element with all the settings of this component()
- See Also:
-
getOrderNumber
public int getOrderNumber()- Specified by:
getOrderNumber
in interfaceFWSimFieldContainer
- Returns:
- number in the order of Components
- See Also:
-
getContentType
- Specified by:
getContentType
in interfaceFWSimFieldContainer
- Returns:
- number in the order of Components
- See Also:
-
getFrequence
- Specified by:
getFrequence
in interfaceFWSimFieldContainer
- Returns:
- the Frequence of the Container calling
- See Also:
-
getMasterComponentGroup
- Returns:
- the master component if this is part of
FWSimComponentGroup
-
getDescription
- Returns:
- the description including title
-
runComponentTest
called for single component test to check the components algorithm.- Parameters:
aParamIndex
- : Used to set up different test cases. Start with 0 - 1 aso- See Also:
-
net.simplace.sim.util.FWSimFieldContainer#fillTestVariables(int aParamIndex, TEST_STATE aDefineOrCheck)
-
fillTestVariables
public abstract HashMap<String,FWSimVariable<?>> fillTestVariables(int aTestIndex, FWSimComponent.TEST_STATE aDefineOrCheck) called for single component test to check the components algorithm.- Parameters:
aParamIndex
- : Used to set up different test cases. Start with 0 - 1 asoaDefineOrCheck
- : Use TEST_STATE.DEFINE for defining the test default values and TEST_STATE.CHECK for the accepted results- See Also:
-
net.simplace.sim.util.FWSimFieldContainer#fillTestVariables(int aParamIndex, TEST_STATE aDefineOrCheck)
-
checkCondition
Description copied from interface:FWSimFieldContainer
Called from inside the FWSimFieldContainer to log the initialization Errors.- Specified by:
checkCondition
in interfaceFWSimFieldContainer
-
isConditionCheck
public boolean isConditionCheck()- Specified by:
isConditionCheck
in interfaceFWSimFieldContainer
-