Class FWSimComponentGroup
java.lang.Object
net.simplace.sim.model.FWSimComponent
net.simplace.sim.model.FWSimComponentGroup
- All Implemented Interfaces:
IntegratableComponent, FWSimFieldContainer
A SimComponent composed of several SimComponents. The members are defined in a group configuration file
<package/name>.grp.xml on the class path (element simgroup with
simcomponent elements). The group behaves like a single component: its members are initialized,
processed and integrated in order, their ids are prefixed with the group name (Group_Member), and the
inputs and outputs of the members are mapped to inputs and outputs of the group.
Repeated execution (sub-time-steps): if the simcomponent element of the group in the solution
has the attribute repeatrule, its rule is evaluated once per time step and the members are processed that
many times in a row (0 = not at all). After each pass the integratable members are integrated
(IntegratableComponent.postIntegrate()), so the next pass works on the updated states; the integration at the
end of the time step is then skipped for the group. A rule giving a decimal number is truncated; a rule that does
not give a number or gives a negative number stops the simulation. Example:
<simcomponent id="Transport" class="net.simplace.sim.model.FWSimComponentGroup" repeatrule="${SubSteps.Count}">
<group>soil.Transport.grp.xml</group>
...
</simcomponent>
A repeated group provides two outputs: <group id>.Repetition, the number of the current pass
(1 to n, 0 before the first pass of a step), and <group id>.Repetitions, the number of passes of
the current step. Members read them like any group input, e.g.
<input id="iPass" source="Transport.Repetition"/> in the group configuration (with the simple
name of the configuration file as prefix).- Author:
- Andreas Enders
-
Nested Class Summary
Nested classes/interfaces inherited from class FWSimComponent
FWSimComponent.TEST_STATE -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final LinkedList<FWSimComponent> The member components, in order of executionMapping from the ids in the group configuration (and the simple group name) to the ids used in the simulationprotected StringName (class path location) of the group configurationInput links of the members: map from input variable name to source variable nameOutput links: map from output variable of the group to the member variable it is taken fromprotected booleantrueif at least one member is anIntegratableComponentprotected JexlRuleScriptRule for the number of passes per time step, ornullif the group is processed onceprotected FWSimVariable<Integer> Number of the current pass (only for repeated groups)protected FWSimVariable<Integer> Number of passes of the current time step (only for repeated groups)protected org.jdom2.ElementRoot element of the group configuration fileprotected StringName of the group configuration without package, as used in the configuration filestatic final StringAttribute of thesimcomponentelement holding the rule for the number of passes per time stepstatic final StringName (without group prefix) of the output holding the number of the current passstatic final StringName (without group prefix) of the output holding the number of passes of the current time stepFields inherited from class FWSimComponent
iFieldMap, iFrequence, iInputMap, iJexlRule, iMasterComponentGroup, iName, iOrderNumber, iResetWhenInactive, isComponentGroup, iSimComponentElement, iSimModel, iVarMap -
Constructor Summary
ConstructorsModifierConstructorDescriptionDefault constructor, used to create the group by class name.FWSimComponentGroup(String aGroupName) Creates a group for a given configuration.protectedFWSimComponentGroup(String aName, HashMap<String, FWSimVariable<?>> aFieldMap, HashMap<String, String> aInputMap, org.jdom2.Element aSimComponentElement, FWSimVarMap aVarMap, int aOrderNumber, LinkedList<FWSimComponent> aComponentList, HashMap<String, String> aInternalInputLinkMap, HashMap<String, String> aInternalOutputLinkMap) Creates the group for a new simulation; the members are cloned with the new var map. -
Method Summary
Modifier and TypeMethodDescriptionprotected FWSimComponentclone(FWSimVarMap aVarMap) Creates the instance of this component for a new simulation (usually via the protected clone constructor).final voidcreate()Reads the group configuration and creates the member components, collecting their variables and links.final HashMap<String, FWSimVariable<?>> Registers the variables of the members under the names of the group: group inputs are mapped to the member inputs (and vice versa for internal links), group outputs to the member outputs.HashMap<String, FWSimVariable<?>> fillTestVariables(int aParamIndex, FWSimComponent.TEST_STATE aDefineOrCheck) Collects the test values of all members.protected final voidinit()Initializes all members.booleanvoidPerforms the input links of the members (from group inputs or other members).protected voidperformLinks(HashMap<String, String> aLinkMap) Registers linked variables in the var map under the destination names.voidPerforms the output links from the members to the group outputs.final voidCallsIntegratableComponent.postIntegrate()of all integratable members.protected final voidprocess()Processes all members in order (each with its own frequency check).protected voidReads the group configuration; its name is taken from thegroupchild of the configuration element (or from the constructor).protected voidreadConfiguration(String aConfigurationXMLPath) Reads the group configuration file from the class path and renames the member ids to<group name>_<member id>.org.jdom2.ElementtoDocXML()Creates the documentation XML of the group: the definitions of its input and output variables, sorted by content type and name.Methods inherited from class FWSimComponent
addVariable, bind, checkCondition, createSimComponent, createSimComponent, createSimComponent, createSimComponent, doProcess, getConstantVariables, getContentType, getCreateFormXML, getDescription, getEditFormXML, getFieldMap, getFrequence, getFrequenceRuleScript, getInputs, getInputValueText, getInputVariables, getMasterComponentGroup, getName, getOrderNumber, getOutputVariables, getSimComponentElement, getVariable, getVariableField, getVarMap, initialize, isConditionCheck, isVariableAvailable, performLinks, readInputs, removeVariable, reset, runComponentTest, setInputValue, setVariablesDefault, syncInputLinks, toComponentLinkingXML, toGroupXML, toOutputDefinitionXML, toResourcesDataXML, toResourcesDefinitionXML, toString, toXML, writeVarInfos
-
Field Details
-
REPEAT_ATTRIBUTE
Attribute of thesimcomponentelement holding the rule for the number of passes per time step- See Also:
-
REPETITION
Name (without group prefix) of the output holding the number of the current pass- See Also:
-
REPETITIONS
Name (without group prefix) of the output holding the number of passes of the current time step- See Also:
-
iRepeatRule
Rule for the number of passes per time step, ornullif the group is processed once -
iRepetition
Number of the current pass (only for repeated groups) -
iRepetitions
Number of passes of the current time step (only for repeated groups) -
iComponentMapping
-
iComponentList
The member components, in order of execution -
iSimGroupElement
protected org.jdom2.Element iSimGroupElementRoot element of the group configuration file -
iInternalInputLinkMap
-
iInternalOutputLinkMap
-
iConfigurationXMLPath
Name (class path location) of the group configuration -
iSimpleName
Name of the group configuration without package, as used in the configuration file -
iIsIntagratable
protected boolean iIsIntagratabletrueif at least one member is anIntegratableComponent
-
-
Constructor Details
-
FWSimComponentGroup
public FWSimComponentGroup()Default constructor, used to create the group by class name. The configuration name is read from thegroupchild of thesimcomponentelement. -
FWSimComponentGroup
Creates a group for a given configuration.- Parameters:
aGroupName- name of the group configuration, e.g.net.simplace.sim.groups.MyGroup(fornet/simplace/sim/groups/MyGroup.grp.xml)
-
FWSimComponentGroup
protected FWSimComponentGroup(String aName, HashMap<String, FWSimVariable<?>> aFieldMap, HashMap<String, String> aInputMap, org.jdom2.Element aSimComponentElement, FWSimVarMap aVarMap, int aOrderNumber, LinkedList<FWSimComponent> aComponentList, HashMap<String, String> aInternalInputLinkMap, HashMap<String, String> aInternalOutputLinkMap) Creates the group for a new simulation; the members are cloned with the new var map.- Parameters:
aName- name of the groupaFieldMap- the shared field mapaInputMap- the links of the group inputsaSimComponentElement- the configuration elementaVarMap- var map of the new simulationaOrderNumber- position in the order of executionaComponentList- the members of the template groupaInternalInputLinkMap- input links of the membersaInternalOutputLinkMap- output links of the group
-
-
Method Details
-
readConfiguration
protected void readConfiguration()Reads the group configuration; its name is taken from thegroupchild of the configuration element (or from the constructor).- See Also:
-
readConfiguration
Reads the group configuration file from the class path and renames the member ids to<group name>_<member id>. Errors are logged.- Parameters:
aConfigurationXMLPath- name of the configuration (dots as package separators, optionally with.grp.xml)
-
createVariables
Registers the variables of the members under the names of the group: group inputs are mapped to the member inputs (and vice versa for internal links), group outputs to the member outputs. The member variables are already in the field map (seecreate()).- Specified by:
createVariablesin interfaceFWSimFieldContainer- Specified by:
createVariablesin classFWSimComponent- Returns:
- the field map
- See Also:
-
getComponentList
- Returns:
- the member components, in order of execution
-
getComponentMapping
-
getInternalInputLinkMap
-
getInternalOutputLinkMap
-
performOutputLinks
Performs the output links from the members to the group outputs. Must be called before the external links are performed.- Throws:
SimLinkInvalidException- if a link is invalid
-
performLinks
Registers linked variables in the var map under the destination names. Missing variables are reported as warnings.- Overrides:
performLinksin classFWSimComponent- Parameters:
aLinkMap- map with key = destination and value = source variable name- Throws:
SimLinkInvalidException- if a link is invalid
-
performInputLinks
Performs the input links of the members (from group inputs or other members). Must be called AFTER all external links are performed.- Throws:
SimLinkInvalidException- if a link is invalid
-
init
protected final void init()Initializes all members. A repeated group also fetches its own outputs from the var map and sets them to 0.- Specified by:
initin classFWSimComponent
-
process
protected final void process()Processes all members in order (each with its own frequency check). A repeated group evaluates its repeat rule and runs that many passes; after each pass the integratable members are integrated.- Specified by:
processin classFWSimComponent
-
postIntegrate
public final void postIntegrate()CallsIntegratableComponent.postIntegrate()of all integratable members. Does nothing for a repeated group, whose members are integrated after each pass inprocess().- Specified by:
postIntegratein interfaceIntegratableComponent
-
isRepeated
public boolean isRepeated()- Returns:
trueif the members are processed several times per time step (attribute "repeatrule")
-
create
Reads the group configuration and creates the member components, collecting their variables and links.- Throws:
SimLinkInvalidException- if a member cannot be created
-
getSimpleName
- Returns:
- the name of the group configuration without package, as used inside the configuration file
-
toDocXML
public org.jdom2.Element toDocXML()Creates the documentation XML of the group: the definitions of its input and output variables, sorted by content type and name.- Overrides:
toDocXMLin classFWSimComponent- Returns:
- the documentation element
-
fillTestVariables
public HashMap<String, FWSimVariable<?>> fillTestVariables(int aParamIndex, FWSimComponent.TEST_STATE aDefineOrCheck) Collects the test values of all members.- Specified by:
fillTestVariablesin classFWSimComponent- Parameters:
aParamIndex- number of the test case, starting with 0aDefineOrCheck- phase of the test- Returns:
- the combined test variables of the members (empty if no member defines this test case)
- See Also:
-
clone
Description copied from class:FWSimComponentCreates the instance of this component for a new simulation (usually via the protected clone constructor).- Specified by:
clonein classFWSimComponent- Parameters:
aVarMap- var map of the new simulation- Returns:
- the new instance
-