Class DefaultManagement
java.lang.Object
net.simplace.sim.model.FWSimComponent
net.simplace.sim.components.DefaultManagement
- All Implemented Interfaces:
FWSimManagementComponent, FWSimFieldContainer
Management component: sets management variables (content type
mgm) when the rule of an action is true.
Configuration example:
<simcomponent id="DefaultManagement" class="net.simplace.sim.components.DefaultManagement">
<action rule="${CURRENT.DOY} eq 230">
<mgm id="DoSow" datatype="BOOLEAN" default="false">true</mgm>
<mgm id="Crop" datatype="CHAR">${vCropName}</mgm>
</action>
<action rule="${CURRENT.DOY} eq 180">
<mgm id="DoHarvest" datatype="BOOLEAN" default="false">true</mgm>
<mgm id="Crop" datatype="CHAR"/>
</action>
</simcomponent>
In each step all action rules are evaluated; for a true rule the values of its mgm variables are set
(constant or rule, combined with the current value by the mode SET, SUM, MAX, MIN; RESET sets the default). A
variable is set only once per step. Variables with mode ITE are reset to their default when their rule is false.- Author:
- Andreas Enders
-
Nested Class Summary
Nested classes/interfaces inherited from class FWSimComponent
FWSimComponent.TEST_STATE -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected MultiHashMap<JexlRuleScript, FWSimVariable<?>> the management variables by action ruleFields inherited from class FWSimComponent
iFieldMap, iFrequence, iInputMap, iJexlRule, iMasterComponentGroup, iName, iOrderNumber, iResetWhenInactive, isComponentGroup, iSimComponentElement, iSimModel, iVarMap -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for instantiation via reflection.DefaultManagement(String aName, HashMap<String, FWSimVariable<?>> aFieldMap, HashMap<String, String> aInputMap, org.jdom2.Element aSimComponentElement, MultiHashMap<JexlRuleScript, FWSimVariable<?>> aActionMap, List<String> aFieldModifiedList, List<String> aResetFieldList, FWSimVarMap aVarMap, int aOrderNumber) Constructor used by clone and tests; the action map is shared. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbind()Nothing to bind; the management variables are accessed via the variable map.booleanEvaluates all action rules: for a true rule the variables are set (performEvent(ArrayList)), for a false rule ITE variables are reset (resetVariables(ArrayList)).protected FWSimComponentclone(FWSimVarMap aVarMap) Clones the management without reading the actions again (the action map is shared).HashMap<String, FWSimVariable<?>> Creates the management variables of all actions as variables of the component.voidReads theactionelements: compiles each rule and creates itsmgmvariables.HashMap<String, FWSimVariable<?>> fillTestVariables(int aParamIndex, FWSimComponent.TEST_STATE aDefineOrCheck) No component tests for the management.Returnsmgm.org.jdom2.Elementprotected voidinit()Reads the actions if not yet done.booleanperformEvent(ArrayList<FWSimVariable<?>> aActionList) Sets the variables of an action.protected voidprocess()Evaluates all action rules and sets the variables, then clears the list of variables set in this step.booleanresetVariables(ArrayList<FWSimVariable<?>> aActionList) Resets the variables with mode ITE and a default value to their default.voidsetActions(List<org.jdom2.Element> aActionElements) Replaces the actions, e.g.voidstart()Runs the process step from outside (the process method is protected).org.jdom2.ElementtoXML()Creates thesimcomponentelement: a copy of the configuration element (as edited withsetActions(List)), so rules, modes, defaults and descriptions are written as given.Methods inherited from class FWSimComponent
addVariable, checkCondition, createSimComponent, createSimComponent, createSimComponent, createSimComponent, doProcess, getConstantVariables, getCreateFormXML, getDescription, getEditFormXML, getFieldMap, getFrequence, getFrequenceRuleScript, getInputs, getInputValueText, getInputVariables, getMasterComponentGroup, getName, getOrderNumber, getOutputVariables, getSimComponentElement, getVariable, getVariableField, getVarMap, initialize, isConditionCheck, isVariableAvailable, performLinks, performLinks, readInputs, removeVariable, reset, runComponentTest, setInputValue, setVariablesDefault, syncInputLinks, toComponentLinkingXML, toDocXML, toGroupXML, toOutputDefinitionXML, toResourcesDataXML, toResourcesDefinitionXML, toString, writeVarInfos
-
Field Details
-
iActionMap
the management variables by action rule
-
-
Constructor Details
-
DefaultManagement
public DefaultManagement(String aName, HashMap<String, FWSimVariable<?>> aFieldMap, HashMap<String, String> aInputMap, org.jdom2.Element aSimComponentElement, MultiHashMap<JexlRuleScript, FWSimVariable<?>> aActionMap, List<String> aFieldModifiedList, List<String> aResetFieldList, FWSimVarMap aVarMap, int aOrderNumber) Constructor used by clone and tests; the action map is shared.- Parameters:
aName- name of the componentaFieldMap- variables of the componentaInputMap- input links of the componentaSimComponentElement- thesimcomponentelementaActionMap- the management variables by action ruleaFieldModifiedList- names of the variables already set in the current stepaResetFieldList- names of the variables with mode RESETaVarMap- variable map of the simulationaOrderNumber- order number of the component
-
DefaultManagement
public DefaultManagement()Constructor for instantiation via reflection.
-
-
Method Details
-
getActionMap
- Returns:
- the management variables by action rule
-
bind
protected void bind()Nothing to bind; the management variables are accessed via the variable map.- Overrides:
bindin classFWSimComponent- See Also:
-
fillActionMap
public void fillActionMap()Reads theactionelements: compiles each rule and creates itsmgmvariables. Inside a component group the component names in the rules are replaced by the names within the group.- Specified by:
fillActionMapin interfaceFWSimManagementComponent- See Also:
-
createVariables
Creates the management variables of all actions as variables of the component.- Specified by:
createVariablesin interfaceFWSimFieldContainer- Specified by:
createVariablesin classFWSimComponent- Returns:
- the field map
- See Also:
-
init
protected void init()Reads the actions if not yet done.- Specified by:
initin classFWSimComponent- See Also:
-
start
public void start()Runs the process step from outside (the process method is protected). -
process
protected void process()Evaluates all action rules and sets the variables, then clears the list of variables set in this step.- Specified by:
processin classFWSimComponent- See Also:
-
clone
Clones the management without reading the actions again (the action map is shared).- Specified by:
clonein classFWSimComponent- Parameters:
aVarMap- var map of the new simulation- Returns:
- the new instance
- See Also:
-
getContentType
Returnsmgm.- Specified by:
getContentTypein interfaceFWSimFieldContainer- Overrides:
getContentTypein classFWSimComponent- Returns:
- the content type of the variables of this container (e.g.
sys,mgm) - See Also:
-
checkForAction
public boolean checkForAction()Evaluates all action rules: for a true rule the variables are set (performEvent(ArrayList)), for a false rule ITE variables are reset (resetVariables(ArrayList)). Errors in rules are logged.- Specified by:
checkForActionin interfaceFWSimManagementComponent- Returns:
- always
false - See Also:
-
performEvent
Sets the variables of an action. Each variable is set only once per step (except mode RESET). The value is the constant or the evaluated rule; for INT and DOUBLE it is combined with the current value by the mode (SUM, MAX, MIN), RESET sets the default. Unparsable numbers becomenull(warning). The rule of the action variable is used, so the same variable may have different rules in different actions.- Specified by:
performEventin interfaceFWSimManagementComponent- Parameters:
aActionList- management variables of the action- Returns:
- always
true - See Also:
-
getLinkedVariableNames
-
resetVariables
Resets the variables with mode ITE and a default value to their default.- Specified by:
resetVariablesin interfaceFWSimManagementComponent- Parameters:
aActionList- management variables of the action- Returns:
- always
false - See Also:
-
toXML
public org.jdom2.Element toXML()Creates thesimcomponentelement: a copy of the configuration element (as edited withsetActions(List)), so rules, modes, defaults and descriptions are written as given. Without element, oneactionelement per rule is created from the action map. Before (#62) the rules were written as compiled source text (Script: CURRENT__DOY == ...) and the mgm variables with their current value instead of their rule.- Specified by:
toXMLin interfaceFWSimFieldContainer- Specified by:
toXMLin interfaceFWSimManagementComponent- Overrides:
toXMLin classFWSimComponent- Returns:
- an XML element with all settings of this container
- See Also:
-
getManagementElement
public org.jdom2.Element getManagementElement()- Returns:
- the configuration element (
simcomponentwith itsactionchildren), ornullfor a component created without element
-
setActions
Replaces the actions, e.g. after editing them in the GUI (#62): theactionchildren of the configuration element are replaced by copies of the given elements, the action map is read again and the management variables of the component (field map and var map) are replaced by the new ones.- Parameters:
aActionElements- the newactionelements (withmgmchildren)
-
fillTestVariables
public HashMap<String, FWSimVariable<?>> fillTestVariables(int aParamIndex, FWSimComponent.TEST_STATE aDefineOrCheck) No component tests for the management.- Specified by:
fillTestVariablesin classFWSimComponent- Parameters:
aParamIndex- index of the test case (not used)aDefineOrCheck- define or check phase (not used)- Returns:
- always
null - See Also:
-