Class FWSimpleSimComponentCodeGen
java.lang.Object
net.simplace.sim.model.FWSimpleSimComponentCodeGen
Generates the Java source of a SimComponent from a
FWSimpleSimComponent of a solution (Redmine #61), so a
component that was prototyped with JEXL rules in the solution can be turned into a compiled class.
The simple component is chosen by its id. All its rules (process and integrate) are
taken over:
- each rule becomes an output variable and its own commented block in
process()(resp.postIntegrate()); a block can be deleted together with its field and its line increateVariables() - the variables used in the rules become inputs (
i...) or, for solution variablesv..., constants (c...), with data type, unit and description of the linked variable - the JEXL rules are translated to Java:
${x}tofield.getValue(), the word operatorseq ne lt le gt ge and or notto Java operators, the namespacesmath:,array:,transform:,check:,file:to their classes, single quoted strings to Java strings. Constructs without a direct translation get aTODOcomment with the original rule.
simcomponent element that replaces the simple component in the solution is
generated.
Usage (command line):
FWSimpleSimComponentCodeGen <solution file> <component id> [package] [class name] [source dir].
Defaults: package "net.simplace.usermodules", class name = component id, source dir = ../simplace_modules/src.
The class is written to the source dir, the simcomponent element is printed.
- Author:
- Andreas Enders, Claude (Anthropic), co-author
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classResult of the generation. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionGenerates the class from a simple component of a solution.static voidCommand line:<solution file> <component id> [package] [class name] [source dir].
-
Field Details
-
DEFAULT_PACKAGE
-
-
Method Details
-
generate
public static FWSimpleSimComponentCodeGen.GeneratedCode generate(File aSolutionFile, String aComponentId, String aPackage, String aClassName) throws IOException Generates the class from a simple component of a solution. The solution is loaded (without running it) to know the data types and units of the variables used in the rules.- Parameters:
aSolutionFile- the solution fileaComponentId- id of thesimcomponentwith class FWSimpleSimComponentaPackage- package of the class, ornullfor "net.simplace.usermodules"aClassName- name of the class, ornullfor the component id (first letter upper case)- Returns:
- the generated class and solution element
- Throws:
IOException- if the solution cannot be loadedIllegalArgumentException- if the solution has no simple component with this id (the message lists the available ids)
-
main
Command line:<solution file> <component id> [package] [class name] [source dir]. Writes the class to the source dir (default../simplace_modules/src) and prints thesimcomponentelement for the solution.- Parameters:
aArgs- the arguments- Throws:
IOException- if the solution cannot be loaded or the class cannot be written
-