Condition, Logic, and Calculation Nodes
About Condition, Logic, and Calculation Nodes in Family Policies
Condition Nodes
You can use the following nodes to apply a variety of conditions, calculations, and logic to the values represented by Input nodes in the policy model.
Logic Nodes
Calculation Nodes
The following Calculation nodes perform calculations on single values:
- Add
- Convert Type
- Divide
- Exponent
- Field Value Changing
- Is Null
- JSON Parser
- Math
- Multiply
- R Script
- Remainder
- Round
- Subtract
- Text
The following Calculation nodes perform calculations on a collection of data:
The Baseline Rule node performs calculations based on the corresponding rule.
Add, Subtract, Multiply, Divide, Exponent and Remainder Nodes in Family Policies
The following Calculation nodes represent basic mathematical calculations:
Node | Description |
---|---|
Add | Adds one value to another value. |
Subtract | Subtracts one value from another value. |
Multiply | Multiplies one value by another value. |
Divide | Divides one value by another value. |
Exponent | Determines the number of times a value is multiplied by itself. |
Remainder | Determines the remainder after a division operation. |
Each math node has two inputs. Input requirements differ depending on the type of math node.
- Input for Add, Subtract, Multiply, Divide, and Remainder nodes may be numeric values or certain time-based values.
- Inputs for Exponent nodes must be numeric values.
A math node has only one output. The output of a math node is the result of the mathematical calculation.
Node Properties
The Properties window for each math node contains the items that are described in the following table.
Item | Description | Notes |
---|---|---|
First value | The first input value that will be used in the calculation. | None. |
Calculation symbol | The symbol that corresponds with the mathematical calculation that is performed by the node. | None. |
Second value | The second input value that will be used in the calculation. | None. |
Display list | Determines the label that appears on the node in the policy model. | This list does not appear if you enter a constant in the corresponding section. |
Add Node
The following example illustrates how you can use an Add node to add a constant value to a value that is defined by a predecessor node. Consider the following nodes and connection.
In this example, the Add node adds 1 to the value in the Alert Level field of a Health Indicator record. The following image shows the Properties window for the Add node.
Remainder and Subtract Nodes
Suppose that you want to add reading values to a Health Indicator, but you know that the accuracy of the reading values is +/-10%. Before adding the reading values to a Health Indicator, use a policy to round down the reading values.
Consider the following nodes and connections. In the policy shown in the following image, the Remainder node is used in conjunction with a Subtract node to round down to the nearest ten the last reading value associated with a Measurement Location.
The following image shows the Properties window of a Remainder node. You can use the Remainder node to calculate the amount remaining after the Last Reading value is divided by 10. For example, if the last reading value is 87, the result of the remainder node is 7 (87/10=8 with a remainder of 7).
The following image shows the Properties window of a Subtract node. You can then subtract the remainder from the reading value. The result of this calculation is the reading value rounded down to the nearest ten. Continuing with the previous example, the result of this node is 80 (87-7=80).
Finally, the result of the Subtract node (80) is added to a Health Indicator Value record that is linked to a Health Indicator.
How Input Values Correspond to Calculations
The following table illustrates how the input values that you define for each node correspond to the mathematical calculations performed by the node. This table includes the mathematical calculation and output for each type of node when the first input value is 3 and the second input value is 2, as shown in the following image:
Node Type | Mathematical Calculation | Output Value |
---|---|---|
Add | 3+2 | 5 |
Subtract | 3-2 | 1 |
Multiply | 3x2 | 6 |
Divide | 3/2 | 1.5 |
Exponent | 3^2 | 9 |
Remainder | 3%2 | 1 |
Using Time-Based Values
The following tables summarize the possible combinations of time-based input values that you can use with Add, Subtract, Multiply, Divide, and Remainder nodes.
First Value | Second Value | Output | Example |
---|---|---|---|
Time stamp | Time span | Time stamp | 1/11/2000 + 10 Days = 1/21/2000 |
Time stamp | Number | Time stamp | 1/11/2000 + 10 = 1/21/2000 00:00:10 |
Time span | Time stamp | Time stamp | 10 Days + 1/11/2000 = 1/21/2000 |
Time span | Time span | Time span | 12 Days + 10 Days = 22 Days |
Time span | Number | Time span | 12 Days + 10 = 12.00:00:10 |
Number | Time stamp | Time stamp | 10 + 1/11/2000 = 1/21/2000 00:00:10 |
Number | Time span | Time span | 10 + 12 Days = 12.00:00:10 |
Time stamp | Time stamp | Invalid | N/A |
First Value | Second Value | Output | Example |
---|---|---|---|
Time stamp | Time span | Time stamp | 1/11/2000 - 10 Days = 1/1/2000 |
Time stamp | Number | Time stamp | 1/11/2000 - 10 = 1/10/2000 23:59:50 |
Time span | Time stamp | Invalid | N/A |
Time span | Time span | Time span | 12 Days - 10 Days = 2 Days |
Time span | Number | Time span | 12 Days - 10 = 11.23:59:50 |
Number | Time span | Time span | 10 - 12 Days = 11.23:59:50 |
Time stamp | Time stamp | Time span | 1/11/2000 - 1/1/2000 = 10 Days |
First Value | Second Value | Output | Example |
---|---|---|---|
Time span | Time span | Invalid | N/A |
Time span | Number | Time span | 10 Days x 5 = 50 Days |
Number | Time span | Time span | 5 x 10 Days = 50 Days |
First Value | Second Value | Output | Example |
---|---|---|---|
Time span | Time span | Number | 1 day / 8 hours = 3 |
Time span | Number | Time span | 1 day / 2 = 12 hours |
Number | Time span | Invalid | N/A |
First Value | Second Value | Output | Example |
---|---|---|---|
Time span | Time span | Time span | 15 Days % 10 Days = 5 Days |
Time span | Number | Invalid | N/A |
Number | Time span | Invalid | N/A |
And and Or Nodes in Family Policies
And and Or nodes are Logic nodes that you can use in a policy model to specify whether or not policy execution should continue based on the results of the incoming logic paths.
Specifically:
- The And node evaluates whether or not all incoming logic paths result in a value of true passed to the And node.
-
The Or node evaluates whether or not at least one incoming logic path results in a value of true passed to the Or node.
Note: Unlike other nodes which require all immediate predecessor nodes to be executed in order for the node to be, the Or node requires only one immediate predecessor node to be executed in order for the Or node to be executed.
In a policy model, Logic nodes must be preceded immediately by comparison or other Logic nodes. A value of true is passed to the Logic node when the logical result of the preceding node matches the logic path configured for the corresponding connection. For example, if the logical result of an immediately preceding condition node is no and the logic path configured for the corresponding connection is no, a value of true is passed to the Logic node.
The output of a Logic node is the logical result of the node. Specifically, when a Logic node is executed:
- If the Logic node's criteria is met, the output (that is, logical result) of the node will be yes.
- If the Logic node's criteria is not met, the output (that is, logical result) of the node will be no.
The logical results of Logic nodes are used by connections to successor nodes in order to determine if the successor node will be executed. You can use the Properties window for a connection starting at a Logic node to configure a logic path for the connection. If you do not configure a logic path for a connection, a Yes path is assumed but does not appear on the model. The APM system will execute only the branches of a policy model where the logical result of the Logic node matches the logic path defined for the corresponding connection.
More Information: Logical Results
The following table summarizes what the result of each Logic node will be for various input combinations.
Input A |
Input B |
And Node Result |
Or Node Result |
---|---|---|---|
True |
True |
Yes |
Yes |
False |
False |
No |
No |
True |
False |
No |
Yes |
And Node
The following example illustrates how you can use the And node to monitor policy execution. To simplify this example, only constant values are used in the policy model. Consider the following nodes and connections, which are shown after validation has been run.
In this example, you can see that each node executed successfully. The logical result of the And node is yes because all incoming logic paths result in a value of true passed to the And node (that is, the logical result of each preceding condition node matches the logic path of the corresponding connection). Therefore, policy execution continues past the And node.
Or Node
The following example illustrates how you can use the Or node to monitor policy execution. To simplify this example, only constant values are used in the policy model. Consider the following nodes and connections, which are shown after validation has been run.
In this example, you can see that each node executed successfully. The logical result of the Or node is yes because the logical result of at least one incoming logic path results in a value of true passed to the Or node (that is, the result of the 5 > 3 Condition node is yes, which matches the logic path of the corresponding connection). Therefore, policy execution continues past the Or node.
Average Nodes in Family Policies
An Average node is a Calculation node that you can use in a policy model to calculate the average value of data in a specified column of a collection.
The input for an Average node must be a collection with a column containing numeric or time-based values. The output of an Average node, Value, contains the average value of data in the specified column.
Node Properties
The Properties window for an Average node contains the items that are described in the following table.
Item |
Description |
Notes |
---|---|---|
Collection section |
Specifies the collection that contains the values that you want to average. |
You can select to specify the output of a predecessor node in this section. |
Collection Column section |
Specifies the column that contains that values that you want to average. |
This list contains the columns that are available in the selected collection. The column that you select must contain numeric or time-based values. |
Baseline Rule Nodes in Family Policies
Node Properties
Other than optionally specifying a name for the node, there are no properties to configure for a Baseline Rule node.
Guidelines for using the Baseline Rule node
When working with the Baseline Rule node, consider the following behaviors and guidelines:
- You must ensure that the policy logic is designed so that only one Baseline Rule node will execute. A notification of this requirement will appear if more than one Baseline Rule node is added to the policy.
- When you validate a family policy that includes a Baseline Rule node, the validation will actually execute the corresponding rule. It is therefore recommended that the policy is fully tested in a development or quality assurance environment prior to implementing the policy in a production system, where testing the policy could have undesirable consequences.
- Where a family policy executes a Baseline Rule node, you may observe a noticeable delay when updating records that trigger the policy.
Baseline Rule Node
The APM baseline rules for the Reading family includes a Before Insert rule that sets the Status field on a Reading record according to when the reading was taken. If the Reading Taken Date is before the Next Date on the related Checkpoint Task, the Status is set to 'I' (i.e. Ignored), and the Next Date on the Checkpoint Task is not updated, leaving the previously set schedule for the checkpoint intact. This might indicate either that there is a maintenance issue with the related asset which needs additional attention, or that the reading was taken ahead of schedule. In the first scenario, you might want to ensure that any required maintenance action has been planned or completed. In the second scenario, you might want to reset the checkpoint schedule to avoid repeating an inspection unnecessarily.
The following example illustrates how you can configure a set of family policies for the Reading family to notify users that an Ignored reading has been inserted.
First, in a Before Insert policy, you can use the Baseline Rule node to run the existing APM baseline rule that sets the Status of the new reading. The following image shows this basic policy. No settings are required on either of the nodes in this policy.
Then, you can configure a second family policy on the After Insert trigger to send an email to the Rounds administrator if an Ignored reading was inserted. The following image shows this policy.
As you can see in the following image of the Properties window for the Equal node, the value in the Status field is checked to determine whether it is equal to 'I', which is the stored system code (not the display value) for the field.
And, finally, as you can see in the following image of the Properties window for the Email Contact node, you can configure the email address to which to send the email notification and a message.
Case Nodes in Family Policies
A Case node is a Condition node that you can use in the policy model to set up scenarios in which the output values of the node should be changed automatically based on specific input values. Throughout this documentation, we refer to each defined scenario as a Case. Each Case within the Case node has an input value and one or more output values that the APM system will use if the value in a defined input field matches the input value of the Case.
There are two types of Cases in the Case node, which we refer to as the If Case and Else Case throughout this documentation:
- If Case
- The type of Case that is executed if the value in a defined input field matches a specific input value that you specify. You can define one or more If Cases for a given Case node.
- Else Case
- The Case that is executed by default if the value in a defined input field does not match a specific input value that you specified in an If Case. There is only one Else Case for a given Case node.
The input of a Case node must be a single value or the logical result of a comparison node. The output of a Case node is the value that you define in the Value column corresponding to the output option that you select in a successor node. Outputs may be single values or collections.
Node Properties
The Properties window for a Case node contains the items that are described in the following table.
Item |
Description |
Notes |
---|---|---|
Input section |
Specifies the field whose value you want to compare to each If Input = value in order to determine the output(s) of the Case node. |
If you select a comparison Condition node as a predecessor node, the logical result of the condition will be used automatically as the input value. |
If Case section | ||
If Input = text box |
Specifies the value that must match the value that is defined in the Input section in order for the corresponding If Case to be executed. |
You can use the and buttons in the If Input = row to add or delete If Cases in the Case node. |
Output section |
Specifies the output(s) for the corresponding If Case. The output section contains two columns:
|
You can use the and buttons in the output section to add or delete output rows. When you add or delete an output row in one Case, corresponding output rows in all cases are added or deleted automatically. |
Else Case section | ||
Else output section |
Specifies the output(s) of the Else Case. The Else Case will be executed if the value in the If Input = section does not match any value defined in an If Input = text box. |
This output section contains the same functionality as described above. You cannot delete the Else Case from the Case node. |
Collection Filter Nodes in Family Policies
A Collection Filter node is a Calculation node that you can use to apply one or more filters to collections that are represented by nodes in the policy model. Filters may, for example, specify a range of values or dates within which readings must fall in order to be evaluated by successor nodes.
The input of a Collection Filter node must be a collection of data. The output of a Collection Filter node, Filtered Collection, includes only the rows in a collection that pass all filter criteria that are defined in the Collection Filter node's Properties window.
Node Properties
The Properties window for a Collection Filter node contains the items that are described in the following table.
Item |
Description |
Notes |
---|---|---|
Collection section |
Specifies the collection that you want to filter. |
You can select to specify the output of a predecessor node in this section. |
button |
Adds a new filter row to the Collection Filter node. |
Each filter row consists of a column, operator, condition, and the button. |
Column list |
Specifies the column whose values you want to use in the filter. | This list contains the columns that are available in the selected collection. |
Operator list |
Specifies the comparison operator that you want to apply to the values in the selected column. |
This list contains the following operators:
|
Condition value |
The value that will be compared against the values in the corresponding column to determine the output of the node. |
You can select to specify the output of a predecessor node in this section. |
button |
Deletes the corresponding filter row from the Collection Filter node. |
None |
Comparison Nodes in Family Policies
Comparison nodes are Condition nodes that you can use to compare two input values using the comparison operator that corresponds to the name of the node. The following comparison nodes are available:
- Equal
- Not Equal
- Greater Than
- Greater Than or Equal
- Less Than
- Less Than or Equal
Each comparison node requires two inputs, which must be single values. For Equal and Not Equal nodes, inputs can be any type of data. For the remaining comparison nodes, inputs must be numeric or time-based values.
The output of a comparison node is the logical result of the comparison (i.e., yes or no). The output of a comparison node can be used only as an input to Case or Logic nodes. For all other successor nodes, the output is used by the connection to the successor node in order to determine if the successor node will be executed.
You can use the Properties window for a connection starting at a comparison node to configure a logic path for the connection. If you do not configure a logic path for a connection, a Yes path is assumed but does not appear on the model. The APM system will execute only the branches of a policy model where the logical result of the comparison matches the logic path defined for the corresponding connection.
Node Properties
The Properties window for each comparison node contains the items that are described in the following table.
Item |
Description |
Notes |
---|---|---|
First value |
The input value that will be compared to the second input value. |
You can select to specify the output of a predecessor node in this section. |
Operator symbol |
The symbol that corresponds with the comparison operation that is performed by the node. |
None |
Second value |
The input value that will be compared to the first input value. |
You can select to specify the output of a predecessor node in this section. |
Display list |
Determines the label that appears on the node in the policy model. |
This list does not appear if you enter a constant in the corresponding section. |
Convert Type Nodes in Family Policies
You can use a Convert Type node to convert a single value, or one column in a collection of values, to another data type. The node converts the value or column of values to the corresponding values of the specified data type, and provides the converted value as its output. When the Convert Type node is configured to operate on a collection column, the output collection includes all the columns of the collection, not only the column of converted values.
- Boolean
- Time & Date
- Decimal
- Integer
- String
- Time Span
Node Properties
The Properties window for a Convert Type node contains the items described in the following table.
Field | Description | Note |
---|---|---|
Output Type | Specifies the data type to which you want to convert the value. | None. |
Input Value | Specifies the value that you want to convert. | If the data type of the input value is such that it cannot be converted to the data type specified in the Output Type field, the node will not be executed during the execution of the policy. |
How Values Are Converted
The following table describes how the input values of different data types are converted by the Convert Type node.
Data Type of Input Value | Data Type Specified for Output Value | |||||
---|---|---|---|---|---|---|
Boolean | Decimal | Integer | String | Time & Date | Time Span | |
Boolean | Retained without conversion. |
|
| Converted to the string representation of the value | Cannot be converted, and results in execution failure of the node | Cannot be converted, and results in execution failure of the node |
Dataframe | Cannot be converted, and results in execution failure of the node | Cannot be converted, and results in execution failure of the node | Cannot be converted, and results in execution failure of the node | Converted to the string representation of the value | Cannot be converted, and results in execution failure of the node | Cannot be converted, and results in execution failure of the node |
Time & Date | Cannot be converted, and results in execution failure of the node | Converted to the number of seconds elapsed between January 1, 1970 and the value | Converted to the number of seconds elapsed between January 1, 1970 and the value | Converted to the string representation of the value | Retained without conversion | Cannot be converted, and results in execution failure of the node |
Decimal |
| Retained without conversion | Rounded to the nearest whole number | Converted to the string representation of the value | Converted to date after considering the value as the number of seconds since January 1, 1970 | Converted to represent number of seconds |
GUID | Cannot be converted, and results in execution failure of the node | Cannot be converted, and results in execution failure of the node | Cannot be converted, and results in execution failure of the node | Converted to the string representation of the value | Cannot be converted, and results in execution failure of the node | Cannot be converted, and results in execution failure of the node |
Integer |
| Retained without conversion | Retained without conversion | Converted to the string representation of the value | Converted to the corresponding date after considering the value as the number of seconds elapsed since January 1, 1970 | Converted to represent number of seconds |
String |
| Converted to the corresponding numeric value and then rounded to the nearest whole number | Converted to the corresponding numeric value | Retained without conversion |
|
|
Time Span | Cannot be converted, and results in execution failure of the node | Converted to the number of seconds represented by the value | Converted to the number of seconds represented by the value | Converted to the string representation of the value | Cannot be converted, and results in execution failure of the node | Retained without conversion |
Convert Type node
The following example illustrates how the Convert Type node can be used to convert the text string output of a Text node to a time span value.
In this example, the Text node is configured to create a text string that indicates a time span, using the values represented by the Point Value nodes. Because the Subtract node cannot perform any calculation on a text string, the Convert Type node converts the string to a value of the Time Span data type. The converted time span value is then used in the Subtract node to calculate the required date.
The following image illustrates the Properties window of the Convert Type node described in this example.
Count Nodes in Family Policies
A Count node is a Calculation node that you can use in a policy model to calculate the total number of rows in a collection.
The input for a Count node must be a collection. The output for a Count node, Value, contains the result of the calculation.
Node Properties
The Properties window for a Count node contains the items that are described in the following table.
Item |
Description |
Notes |
---|---|---|
Collection section |
Specifies the collection for which you want to calculate the total number of rows. |
You can select to specify the output of a predecessor node in this section. |
Field Value Changing Nodes in Family Policies
- The logical result of the node (i.e., yes if the value in the specified field is changing in the corresponding transaction or no if it is not changing).Note: Logical results are used by the connections to successor nodes in order to determine if the successor node will be executed. You can use the Properties window for a connection starting at a Field Value Changing node to configure a logic path for the connection.
- Original Value, which is the value in the specified field before the change.
Node Properties
The Properties window for a Field Value Changing node contains the items that are described in the following table.
Item |
Description |
Notes |
---|---|---|
Field section |
Specifies the field whose value will be evaluated to determine whether it is changing in the transaction that triggered the family policy. |
You must specify a field from a Current Entity or Current Relationship node. |
Field Value Changing node
The following example illustrates how you can use a Field Value Changing node to send an email message if the Criticality Indicator value in an Equipment record changes from A to some other value. Consider the following nodes and connections.
In this example, the Field Value Changing node first determines whether or not the value in the Criticality Indicator field is changing. The following image shows the Properties window for the Field Value Changing node.
If the value in the Criticality Indicator field is changing (i.e., the logical result of the Field Value Changing node is yes), the Equal node then evaluates whether the initial value in the field was A, as shown in the following image.
Finally, if the original Criticality Indicator value was A, an email message is sent to the specified recipient(s).
Is Null Nodes in Family Policies
An Is Null node is a Calculation node that you can use to specify a default value that should be used in subsequent calculations in the event that the input value is null. You can also use this node in combination with a logic node to specify an action to be taken in the event that an input value is null.
- If the input value is not null, Answer, represents the same input value.
- If the input value is null, Answer represents the value that you specify in the Properties window.
Node Properties
The Properties window for an Is Null node contains the items that are described in the following table.
Item |
Description |
Notes |
---|---|---|
Input Valuesection |
Specifies the value that you want to determine whether it is null. |
You can select to specify the output of a predecessor node in this section. |
Value if Input is Null section |
Specifies the output value of the node if the value specified in the Input Value section is null. |
You can select to specify the output of a predecessor node in this section. |
JSON Parser Nodes
A JSON Parser node is a Calculation node that you can use in a policy to transform a JSON object, such as the output from an API node, so that the results can be further evaluated by the policy. You can use the node to transform a JSON object to a collection with column names that you specify, which can then be evaluated by policy nodes designed to operate on collections.
The inputs for a JSON Parser node are a single JSON object and one or more JSON Path query expressions.
- In the default mode, the outputs from the node include a Collection containing columns with names that you define, and a set of single value outputs. In this mode, all the JSON Path expressions you specify must return lists of values of equal length.
- In the alternate mode, only the single value outputs are provided. In this mode, the JSON Path query expressions are not required to return equal-length lists. To activate the alternate mode, in the Remove output collection? box, select Yes.
Item | Description | Notes |
---|---|---|
JSON section | Specifies the JSON object that you want to parse. | You can select to specify the output of a predecessor node in this section. |
Remove output collection? | Specifies the output mode that you want to use for the node. | By default, this option is set to No. |
button | Adds a new row to the JSON Parser node. | Each row consists of a Name, JSON Path and the button. |
Name section | Specifies the Name of an output value and/or column. | |
JSON Path section | Specifies a JSON Path expression you want to use to query the JSON input. | You can select to specify the output of a predecessor node in this section. Refer to About Querying using JSON Path Expressions for more information. |
button | Deletes the corresponding row from the JSON Parser node |
About querying using JSON Path expressions
JSON Path Operator | Description |
---|---|
$ | Root object/element |
@ | Current object/element |
. or [] | Child operator |
.. | Recursive descent |
* | Wildcard |
[] | Subscript operator |
[,] | Union operator |
[start:end:step] | Array slice operator |
?() | Filter using (script) expression. |
{ "store": {
"book": [
{ "category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{ "category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
},
{ "category": "fiction",
"author": "Herman Melville",
"title": "Moby Dick",
"isbn": "0-553-21311-3",
"price": 8.99
},
{ "category": "fiction",
"author": "J. R. R. Tolkien",
"title": "The Lord of the Rings",
"isbn": "0-395-19395-8",
"price": 22.99
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
}
}
Required Output | JSON Path Example | Result |
---|---|---|
The authors of all books in the store | $.store.book[*].author | ["Nigel Rees","Evelyn Waugh","Herman Melville","J. R. R. Tolkien"] |
All authors | $..author | ["Nigel Rees","Evelyn Waugh","Herman Melville","J. R. R. Tolkien"] |
All things in the store, which are some books and a red bicycle | $.store.* | [[{"category":"reference","author":"Nigel Rees","title":"Sayings of the Century","price":8.95},{"category":"fiction","author":"Evelyn Waugh","title":"Sword of Honour","price":12.99},{"category":"fiction","author":"Herman Melville","title":"Moby Dick","isbn":"0-553-21311-3","price":8.99},{"category":"fiction","author":"J. R. R. Tolkien","title":"The Lord of the Rings","isbn":"0-395-19395-8","price":22.99}],{"color":"red","price":19.95}] |
The price of everything in the store | $.store..price | [8.95,12.99,8.99,22.99,19.95] |
The third book Note: The first item in an array has index 0, so the third item has index 2. | $..book[2] | { "category": "fiction", "author": "Herman Melville", "title": "Moby Dick", "isbn": "0-553-21311-3", "price": 8.99 } |
The last book Note: The last item in the array is accessed by specifying -1 as the start index. | $..book[-1:] | { "category": "fiction", "author": "J. R. R. Tolkien", "title": "The Lord of the Rings", "isbn": "0-395-19395-8", "price": 22.99 } |
The first two books | $..book[0,1] -or- $..book[:2] | [{"category":"reference","author":"Nigel Rees","title":"Sayings of the Century","price":8.95},{"category":"fiction","author":"Evelyn Waugh","title":"Sword of Honour","price":12.99}] |
All books with an ISBN number | $..book[?(@.isbn)] | [{"category":"fiction","author":"Herman Melville","title":"Moby Dick","isbn":"0-553-21311-3","price":8.99},{"category":"fiction","author":"J. R. R. Tolkien","title":"The Lord of the Rings","isbn":"0-395-19395-8","price":22.99}] |
All books cheaper than 10 | $..book[?(@.price<10)] | [{"category":"reference","author":"Nigel Rees","title":"Sayings of the Century","price":8.95},{"category":"fiction","author":"Herman Melville","title":"Moby Dick","isbn":"0-553-21311-3","price":8.99}] |
All members of JSON structure | $..* | The entire input JSON object shown above is returned. |
Last Nodes in Family Policies
A Last node is a Calculation node that you can use in a policy model to retrieve the last row in a collection, whose fields you can then use in successor nodes to perform various calculations or actions.
The input for a Last node must be a collection. The output for the Last node is any field in the row that the Last node retrieves.
Node Properties
The Properties window for a Last node contains the items that are described in the following table.
Item |
Description |
Notes |
---|---|---|
Collection section |
Specifies the collection from which you want to retrieve the last row. |
You can select to specify the output of a predecessor node in this section. |
Math Node
A Math node is a Calculation node that you can use in the policy model to perform mathematical operations on numeric input values. The node performs operations on the values represented by variables that you define for the node. It evaluates the expression that you provide (for example, a^2+b*c) based on the input values, mathematical functions, and operators used. The resulting value of the expression is returned as the output of the Math node, which can be used in another node in the policy model. The variables used in the mathematical expression defined for a Math node can be configured to represent a single value or a collection of numeric values.
Comparison with R Script Node
For moderately complex calculations on numeric values, a Math node offers a simpler alternative to the R Script node in that it does not require the knowledge of the R programming language, and it runs faster than the R Script node.
Node Properties
The Properties window for a Math node contains items that are described in the following table.
Item |
Description |
Note |
---|---|---|
Math expression | The mathematical expression to be evaluated. |
|
Name | The variable name that you may have used in the Math expression. |
|
Value | The value of the named variable. | This must be a numeric value or collection of numeric values. |
Adds a row for Name and Value. | None | |
Deletes the corresponding row. | None. |
How Input Values Correspond to Calculations
The following table describes how the input values that you define for a Math node correspond to the mathematical operations performed by the node. Here, 'a' and 'b' are variables whose values are 5 and 8, respectively.
Math expression |
Output |
Note |
---|---|---|
2+pi | 5.1415926536 | pi is a mathematical constant. |
a!+b | 128 | This is a factorial operator. |
a=b^2 | 0, if false; 1, if true. | ^ is an exponentiation operator. |
if(a>b,100,0) | 0, if false; 100, if true. | > is a relational operator. |
sqrt(a+b) | 3.6055512755 | sqrt is a square root operator. |
How Input Values Correspond to Calculations using Logical Operators
The following table describes how the input values that you define for a Math node correspond to the mathematical operations performed by the node when the mathematical expression contains logical operators. Here, A, B, and C are variables whose values are 1, 0, and 0 respectively.
Math expression |
Output |
Note |
---|---|---|
A | B & C | 1 (that is, True) | The And (&) operator takes precedence over the Or (|) operator |
(A|B) & C | 0 (that is, False) | None |
A | (B&C) | 1 (that is, True) | None |
How A Collection of Input Values Represented by a Single Variable Correspond to Calculations
The following table describes how a collection of input values that are represented by a single variable defined for a Math node corresponds to the mathematical operations performed by the node. Here, 'a' is a variable that represents a collection of values 10, 20, 30, and 40, and 'b' is a variable that represents a collection of values 100, 110, 120, and 130.
Math expression |
Output |
Note |
---|---|---|
add(a) | 100 | add is a summation operator. |
mean(a,b) | 70 | mean is an average value operator. |
a1+b1 | 110 | You can reference individual values in the collection by adding a number to the end of the variable name. |
Math node
The following example illustrates how you can use the Math node to evaluate a Math expression.
Consider the following policy model that is designed to provide an email alert when an equipment has exhausted the threshold percentage of its life expectancy.
The threshold percentage of life used for the equipment is stored as a Technical Characteristic. The life data of the equipment (for example, hours for turbine, starts for crane, take-offs for aircraft, tonnes moved for mining equipment), is stored as Measurement Location readings.
The percentage of expected life of the equipment is calculated in the Math node using the Cumulative Distribution Function (CDF) of the Weibull Distribution, which is a mathematical function for analyzing life data.
The Math expression used for this calculation is as follows:
100*(1-e^(-((Time/Eta)^Beta)))
where:
- e is a mathematical constant.
- Time is the life used.
- Eta and Beta are Weibull distribution parameters.
The following image shows the Properties window of the Math node:
To easily identify the Measurement Location, Technical Characteristic, and Weibull Distribution parameters associated with the equipment, the Equipment Entity input node is specified as the primary node, indicating that the record specified for this node is the primary record to which all the other input records (represented by other Input nodes) will be linked.
The Weibull Distribution Entity input node provides the distribution parameters (that is, Eta and Beta), which were determined in the Reliability Analytics module by analyzing the failure data of a similar equipment.
The Life Used Measurement Location input node provides the readings to the Recent Reading Last calculation node, which retrieves the latest measurement reading (that is, Time).
The resulting value of the Math expression is passed to the Cumulative Probability Return Value action node, which will include the value in the policy execution history.
The Life Used Alert Level Entity input node provides the Technical Characteristic value to a comparison condition node, which compares it with the output of the Weibull CDF Math calculation node.
When the Weibull CDF value exceeds the Technical Characteristic value (that is, the threshold percentage) of the equipment, the message specified in the Email Text calculation node is sent via email to the user specified in the Email Contact action node.
The following image shows the Execution Details window of the Math node.
Min and Max Nodes in Family Policies
Min and Max nodes are Calculation nodes that you can use in a policy model to determine the row of a collection which contains the smallest or largest value, respectively, in a specified column.
The input for a Min or Max node must be a collection with a column containing numeric or time-based values. The output of a Min or Max node is any field in the row that the Min or Max node retrieves. If multiple rows contain the minimum or maximum value, then only the first row encountered is returned.
Node Properties
The Properties windows for Min and Max nodes contain the items that are described in the following table.
Item |
Description |
Notes |
---|---|---|
Collection section |
Specifies the collection for which you want to determine the smallest or largest value in a certain column. |
You can select to specify the output of a predecessor node in this section. |
Collection Column section |
Specifies the column that contains the values of which you want to determine the smallest or largest value. | This list contains the columns that are available in the selected collection.
The column that you select must contain numeric or time-based values. |
Round Nodes in Family Policies
A Round node is a Calculation node that you can use in a policy model to:
-
Round a value to a specific number of decimal places. This is called decimal rounding.
-or-
- Round a value to a specific number of significant figures. This is called precision rounding.
The input of a Round node must be a single, numeric value. The output of a Round node, Answer, contains the rounded value.
About Decimal and Precision Rounding
When you use decimal rounding, you can specify the number of decimal places to which you want to round the input value. For example, if the input value is 3.51 and you indicate that you want to round to the nearest tenth (by specifying the value 1 in the Digits text box on the Properties window), the input value will be rounded to 3.5.
When you use precision rounding, you can specify the number of digits that you want keep from the input value. For example, if the input value is 7,658,321 and you indicate that you want to keep the first three values (by specifying the value 3 in the Digits text box on the Properties window), the input value will be rounded to 7,660,000 (where the third digit, 5, is rounded to 6, and the remaining digits are changed to 0).
Node Properties
The Properties window for a Round node contains the items that are described in the following table.
Item |
Description |
Notes |
---|---|---|
Value section |
Specifies the value that will be rounded. |
You can select to specify the output of a predecessor node in this section. |
Digits section |
The value in this section serves a different purpose depending on the option that you select in the Mode section. You can select:
|
You can select to specify the output of a predecessor node in this section. If the list in the Mode section contains the value:
Regardless of the values that you specify for the Round node, when you validate the policy logic, only two decimal places are displayed. You can see the actual values by accessing the Properties window for the appropriate node. |
Mode list |
Specifies the type of rounding that the node will perform. |
This list contains the following options:
By default, the Mode list contains the value Decimal rounding and the Digits text box is empty (this is the same as typing 0 [zero]). This means that decimal values will be rounded to the nearest whole number. |
R Script Nodes in Family Policies
An R Script node is a Calculation node that you can use in a policy model to return a result that is calculated by an R script created outside the policy using the R script editor.
The inputs for an R Script node must correspond to the type of inputs expected by the R Script. The outputs of an R Script node contain the values calculated by the R script.
Node Properties
The Properties window for an R Script node contains the items that are described in the following table.
Item |
Description |
Notes |
---|---|---|
Path | Specifies the path to the R script that will run when the policy is executed. |
You can enter the path manually, or you can browse to the query by selecting . |
Additional sections corresponding to the inputs expected by the R script. | Specifies the values that will be used in the R script to calculate a result. | The number of sections displayed in the Properties window is determined by the number of inputs configured in the specified R script. In each section, you can select to display the output of a predecessor node. The value that you specify should correspond to the type of input expected by the R Script (i.e., a Vector of Values, a Matrix of Values, Data Frame, or a single value that is Numeric, Character, Boolean, or Time & Date). |
Working with R Scripts
You should account for the following behaviors when working with R scripts in policies:
- The policy execution engine sends date inputs to the R script in UTC. If your R script performs any calculations based on dates, the date output must also be in UTC and use the standard date format yyyy-MM-dd hh:mm:ss.fff.
- For Data Frame inputs:
- The entire collection you specify is passed to the R script.
- The supported data types for each column are Time & Date, Numeric, Character, and Boolean.
- Reading values in readings collections specified directly from an input node such as the OPC Tag, Measurement Location, or Health Indicator node are untyped and therefore sent to the R script as string values.
R Script Using Multiple Inputs from Policy
As shown in the following image, you can use the Properties window for the R Script node to select a particular R script that was created using the R script editor. The R script in this example requires three input values: LinerBaseDF, LiningConditionAdjustment, and OnlineMonitoringAdjustment. These input values correspond to variables in the specified R script.
Calculating Average and Standard Deviation of a Reading Collection
The following example illustrates how you can use a policy to execute an R script that calculates statistical information regarding readings related to a Measurement Location, and then send that information via email message to a designated recipient.
This R script calculates the average reading value, count of readings, standard deviation, and most recent reading date of input values provided as a Data Frame.
This policy first filters Measurement Location readings to only those readings recorded within the last 30 days. Then, the filtered readings are sent as a Data Frame input to the R script.
Next, the calculated results returned by the R script are used in a Text node to construct a message that will ultimately be sent via email to a responsible user.
Sum Nodes in Family Policies
A Sum node is a Calculation node that you can use in a policy model to calculate the total value of data in a specified column of a collection.
The input for a Sum node must be a collection containing numeric or time span values. The output of a Sum node, Value, contains the result of the calculation for the specified column.
Node Properties
The Properties window for a Sum node contains the items that are described in the following table.
Item | Description | Notes |
---|---|---|
Collection section | Specifies the collection that contains the values for which you want to calculate the total value. |
You can select to specify the output of a predecessor node in this section. Note: If the input specified for a Sum node is an empty collection, the resulting answer from the Sum node is automatically zero (0).
|
Collection Column section | Specifies the column that contains that values for which you want to calculate the total value. | This list contains the columns that are available in the selected collection.
The column that you select must contain numeric or time span values. |
Text Nodes in Family Policies
A Text node is a Calculation node that you can use in a policy model to create a custom text string based on constants and the values returned by other nodes in a policy execution.
The inputs for a Text node must be single values. The output of a Text node, Answer, contains the custom text string.
Node Properties
The Properties window for a Text node contains the items that are described in the following table.
Item |
Description |
Notes |
---|---|---|
Text Pattern box |
Defines the pattern for the custom text string that will be the output of the Text node. |
You must enter a valid .NET String.Format expression in this box. When you create the text pattern, the index numbers you use must be sequential starting at zero. However, the numbers do not have to be listed sequentially within the string and each number can be used multiple times. |
Index / Value section |
Specifies the value that each index specified in the Text Pattern box represents. |
When the node is executed, the indexes in the text string will be replaced with the corresponding values you specify in this section. Important: You must define values for all indexes defined in the Text Pattern box.
You can select to specify the output of a predecessor node in this section. You can use the and buttons in this section to add or delete values. Note: Constant values to represent dates (e.g., now, today, Sunday, October, etc.) or specific values (e.g., Pi or e) are not supported in this section. To use these one of these constants, you must define it using a Constant or Point Value node with an appropriate type.
|
.NET String.Format Expressions
The Text node supports .NET String.Format expressions, including the formatting capabilities supported by String.Format. The following table shows various example expressions and the resulting strings.Text Pattern | Defined Index Values | Resulting String |
---|---|---|
The temperature of the motor is {0} degrees Celsius. | {0}=12 | The temperature of the motor is 12 degrees Celsius. |
The temperature of the {1} is {0:F2} degrees Celsius. |
{0}=23.456 {1}=pump | The temperature of the pump is 23.46 degrees Celsius. |
The temperature was recorded at {0:t} on {0:d}. |
{0}= 1/1/2016 05:30:00 | The temperature was recorded at 5:30 AM on 1/1/2016. |
The cost to repair the damaged part is {0:C2}. | {0}=1600 | The cost to repair the damaged part is $1,600.00. |
Threshold Statistics Nodes in Family Policies
A Threshold Statistics node is a Calculation node that you can use in a policy model to determine the frequency and duration over which input values cross a defined threshold (i.e., meet a defined condition).
The input for a Threshold Statistics node must be a collection with columns containing timestamps and numeric values. A Threshold Statistics node generates the following outputs:
- Count, which represents the number of times that input values crossed the defined threshold.
- Accumulated Time, which represents the amount of time over which input values crossed the defined threshold.
Node Properties
The Properties window for a Threshold Statistics node contains the items that are described in the following table.
Item | Description | Notes |
---|---|---|
Collection section | Specifies the collection for which you want to calculate a threshold statistic. |
You can select to specify the output of a predecessor node in this section. |
Timestamp Column list | Specifies the column that contains the timestamps that you want to use to calculate the accumulated time during which the input values cross the defined threshold. | This list contains the columns that are available in the selected collection. |
Value Column list |
Specifies the column that contains the input values that will be compared to the threshold value. |
This list contains the columns that are available in the selected collection. |
Threshold section | Specifies the threshold value that will be compared to the values that are defined in the Value Column list. |
You can select to specify the output of a predecessor node in this section. |
Operator list | Specifies the comparison operator that will be used to compare inputs values to the threshold value. | This list contains the following operators:
|