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
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected HashMap<String,FWSimVariable<?>> initial field map as given by the createVariables()-Method in the SimComponent implementationprotected FWSimIOAdapter.FREQUENCEfrequence to check if component is executed or notregistered links of the SimComponent implementationprotected JexlRuleScriptrule to check if component is executed or notprotected FWSimComponentGroupIf component is part of a SimComponent Group Main Component mentioned hereprotected StringName of componentprotected intorder number for the serial order of the componentsprotected final booleanInfo about ComponentGroupprotected org.jdom2.Elementoriginal SimComponent configuration element (jdom)protected FWSimModelSimModel reference - can be seen as the thread the component is accessed inprotected FWSimVarMapCentrally used VarMap reference -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMain constructor for use with Class.forName()protectedFWSimComponent(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 TypeMethodDescriptionvoidaddVariable(FWSimVariable<?> aVariable) Add Variable to the Filed map.protected voidbind()The model initialization function.voidcheckCondition(Boolean aCheckResult, String aMessage) Called from inside the FWSimFieldContainer to log the initialization Errors.protected abstract FWSimComponentclone(FWSimVarMap aVarMap) static FWSimComponentcreateSimComponent(String aClassname) static FWSimComponentcreateSimComponent(String tName, FWSimVarMap aVarMap, FWSimModel aSimModel, int aOrderNumber) static FWSimComponentcreateSimComponent(org.jdom2.Element aSimComponentElement, FWSimComponentGroup aComponentGroup, FWSimVarMap aVarMap, FWSimModel aSimModel, int aOrderNumber) factory method creating a SimComponentstatic FWSimComponentcreateSimComponent(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 voidThe 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.Elementorg.jdom2.ElementgetEditFormXML(boolean aEnabled) returns the input variables from FieldMapgetName()intgetVariable(String aKey) protected FWSimVariable<?>getVariableField(String aKey) protected abstract voidinit()The model initialization function.voidThe model initialization function.booleanprotected booleanisVariableAvailable(String aString) voidlinks like given in the input part of the SimComponent configuration are performed.protected voidperformLinks(HashMap<String, String> aLinkMap) protected abstract voidprocess()The main model calculation function.readInputs(org.jdom2.Element aSimComponentElement) voidremoveVariable(String aID) Remove variable from FieldMap - handle with care!protected voidreset(FWSimVarMap aVarMap) static BooleanrunComponentTest(String aComponentClassName, int aTestIndex) called for single component test to check the components algorithm.protected voidThe models writable variables like outputs, states and rates are set to default .org.jdom2.Elementorg.jdom2.ElementtoDocXML()org.jdom2.ElementtoGroupXML(HashSet<String> aComponentsInGroup, String aGroupName) org.jdom2.Elementorg.jdom2.Elementorg.jdom2.ElementtoString()Name of the Componentorg.jdom2.ElementtoXML()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:
addVariablein interfaceFWSimFieldContainer- Parameters:
aVariable-
-
getVariable
- Specified by:
getVariablein 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:
removeVariablein interfaceFWSimFieldContainer- See Also:
-
getName
- Specified by:
getNamein interfaceFWSimFieldContainer- Returns:
- the name
-
getFieldMap
- Specified by:
getFieldMapin interfaceFWSimFieldContainer- Returns:
- the name
-
getVarMap
- Specified by:
getVarMapin 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:
createVariablesin 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:
getInputVariablesin interfaceFWSimFieldContainer- Returns:
- FWSimVarables filtered - only input Variables
- See Also:
-
getConstantVariables
- Returns:
- constant variables from the FieldMAp
-
getOutputVariables
- Specified by:
getOutputVariablesin 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:
toXMLin 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:
getCreateFormXMLin interfaceFWSimFieldContainer- Returns:
- a xml element with all the settings of this component()
- See Also:
-
getEditFormXML
public org.jdom2.Element getEditFormXML(boolean aEnabled) - Specified by:
getEditFormXMLin interfaceFWSimFieldContainer- Returns:
- a xml element with all the settings of this component()
- See Also:
-
getOrderNumber
public int getOrderNumber()- Specified by:
getOrderNumberin interfaceFWSimFieldContainer- Returns:
- number in the order of Components
- See Also:
-
getContentType
- Specified by:
getContentTypein interfaceFWSimFieldContainer- Returns:
- number in the order of Components
- See Also:
-
getFrequence
- Specified by:
getFrequencein 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:FWSimFieldContainerCalled from inside the FWSimFieldContainer to log the initialization Errors.- Specified by:
checkConditionin interfaceFWSimFieldContainer
-
isConditionCheck
public boolean isConditionCheck()- Specified by:
isConditionCheckin interfaceFWSimFieldContainer
-