TSTool / Command / EvaluateExpression
Overview
This command is under development.
The EvaluateExpression command evaluates an expression
using the EvalEx library (see the EvalEx documentation).
This command can be used to evaluate an expression such as the following:
a*b + 1.0
The resulting value can be set as the following:
- a property (set in this command)
- time series value
- table value
For example use a For command to iterate over data in a time series,
evaluate an expression, and set in another time series or table.
Input for the expression are taken from command processor properties that are of types known to the EvalEx library, as listed in the following table. Additional input handling will be enabled in the future. Properties can be set for use as input using the following (and other) commands:
- Processor property:
- Property from time series:
- Property from table:
TSTool Properties Passed as Input
| Type | Comment |
|---|---|
| Boolean | Yes |
| DateTime | No |
| Double | Yes |
| Integer | Yes |
| String | Yes |
| Others (e.g., general objects) | No |
EvalEx DataType output is handled as described in the following table.
EvalEx Result DataType and TSTool Properties
| DataType | Comment |
|---|---|
ARRAY |
Set as java.util.list, not currently converted to TSTool Object type. |
BINARY |
Set as java.lang.Object, not currently converted to TSTool Object type. |
BOOLEAN |
Set as java.lang.Boolean, which matches TSTool Boolean property type. |
DATE_TIME |
Set as java.lang.Instant, not currently converted to TSTool DateTime property type. |
DURATION |
Set as java.time.Duration, not currently comverted to TSTool TimeInterval property type. |
EXPRESSION_NODE |
Set as com.ezylang.evalex.parser.ASTNode, not currently converted to TSTool Object type. |
NULL |
Set as null. |
NUMBER |
Converted from java.math.BigDecimal to TSTool Double property type. |
STRING |
Set as java.lang.String, which matches TSTool String property type. |
STRUCTURE |
Set as java.util.Map, not currently converted to TSTool Object type. |
The expression output is set as a property similar to the SetProperty command.
The PropertyType is currently ignored but may be enabled in the future to help with casting output to different data types.
Other commands can be used to set the property in other data objects, including:
- Time series:
ReplaceValuecommandSetDataValuecommandSetTimeSeriesPropertycommand
- Table:
SetTableValuescommand
After commands are run, the value of properties can be viewed in the TSTool Results / Properties tab,
Command Editor
The command is available in the following TSTool menu:
- Commands / General - Running and Properties
The following dialog is used to edit the command and illustrates the command syntax for expression parameters.
EvaluateExpression Command Editor for Expression Parameters (see full-size image)
The following dialog is used to edit the command and illustrates the command syntax for input parameters.
EvaluateExpression Command Editor for Input Parameters (see full-size image)
The following dialog is used to edit the command and illustrates the command syntax for output parameters.
EvaluateExpression Command Editor for Output Parameters (see full-size image)
Command Syntax
The command syntax is as follows:
EvaluateExpression(Parameter="Value",...)
Command Parameters
| Tab | Parameter | Description | Default |
|---|---|---|---|
| Expression | Expressionrequired |
The expression to evaluate, can use ${Property} syntax. |
None - must be specified. |
| Input | Expression input is currently automatically determined from processor properties. | ||
| Output | PropertyNamerequired |
The output property name, can use${Property} syntax and nested property names are allowed. |
None - must be specified. |
PropertyType |
Currently ignored. Optional output property type, when casting the expression output to a different type, one of:
SetInputPeriod command for more information. |
Type from the expression evaluation. . |
Examples
See the automated tests.
Troubleshooting
See the main TSTool Troubleshooting documentation.
See Also
ForcommandIfcommandReplaceValuecommandSetDataValuecommandSetPropertycommandSetPropertyFromTablecommandSetPropertyFromTimeSeriescommandSetTableValuescommandSetTimeSeriesPropertycommand