Defining Calculated Variables
(Original Document)
At a Glance
You can create calculated boolean, integer, and floating variables. There are also wizards to help you to create variables with pre-formatted equations (Extract a bit as an integer, create an integer with a boolean variable and convert a BCD to an integer).
The Equation Tree
The equations of the variables calculated in Trending Tool are represented as a structured tree. The coding principle used is similar to that of the Polish code (the way that HP calculators work). The example below illustrates the technique used to reproduce parenthesis levels in Trending Tool.
Available Operators
Operators
Operands
Results
Description
Boolean operators
AND
from 1 to N boolean terms
Boolean
Performs the logical AND between all the terms.
OR
Performs the logical OR between all the terms.
NOT
1 boolean term
Returns the negation of the term.
XOR
2 boolean terms
Returns TRUE if the two terms are different.
DELAY
1 boolean term
Delays the activation or deactivation of the term.
Comparison operators
EQUAL TO
2 integer or floating terms
Returns TRUE if both terms are equal, or else FALSE.
GREATER THAN
Returns TRUE if the first term is strictly superior to the second one, or else FALSE.
GREATER THAN OR EQUAL TO
Returns TRUE if the first term is superior or equal to the second one, or else FALSE.
LESS THAN
Returns TRUE if the first term is strictly inferior to the second one, or else FALSE.
LESS THAN OR EQUAL TO
Returns TRUE if the first term is inferior or equal to the second one, or else FALSE.
DIFFERENT FROM
Returns TRUE if both terms are different, or else FALSE.
Arithmetical operators
PLUS
2 integer or floating terms
Integer
Returns the sum of the values of both terms.
MINUS
Returns the subtraction of the values of both terms.
MULTIPLY
Returns the multiplication of the values of both terms.
DIVIDE
Returns the result of the division of the first term by the second one. If the second term is equal to zero, the result arbitrarily returned by Trending Tool will be zero.
QUOTIENT
Returns the quotient of the division of the first term by the second one.
REMAINDER
Returns the remainder of the division of the first term by the second one.
CONSTANT
-
Returns the value of the constant.
CONSTANT TIME
-
Returns the number of second from midnight to selected time as a constant.
CURRENT TIME
-
Returns the number of second from midnight to chronogram current time as a constant.
SQUARE
1 integer or floating term
Integer or floating
Returns the value of the term to the square.
SQUARE ROOT
Returns the square root of the value of the term.
EXPONENTIAL
Returns exp(value of the term).
LOGARITHM
Returns log(value of the term).
NAPIERIAN LOGARITHM
Returns ln(value of the term).
SINE
Returns sin(value of the term).
COSINE
Returns cos(value of the term).
TANGENT
Returns tan(value of the term).
Logical operators
LOGICAL AND
2 integer terms
Integer
Returns the result of the AND between the two integer terms.
LOGICAL OR
Returns the result of the OR between the two integer terms.
LOGICAL XOR
Returns the result of the XOR between the two integer terms.
LOGICAL NOT
1 integer term
Returns the complement of the integer term.
Conversion operators
INTEGER->BOOLEAN
Boolean
Returns FALSE if the value of the term is 0, TRUE otherwise.
BOOLEAN-> INTEGER
1 boolean term
Integer
Returns 1 if the value of the term is TRUE, 0 if the value of the term is FALSE.
Specific operators
TIMER
1 boolean term
Integer
Shows the activity length of a boolean variable in milliseconds. The value changes on the falling edge of the boolean variable.
Viewing the Calculated Variable Dialog Box Options
The new calculated variable dialog box enables you to create an equation to determine how the calculated variable will operate.
Dialog Box Tabs
Description
Equation
Trending Tool boolean equations are represented as a tree. This area of the dialog box shows the equation of the calculated variable.
Operators
This tab enables you to add operators to the equations of calculated variables. Available operators are represented by the leaves of the tree shown in the tab. To add an operator, select it on the tree and click on the Add button on the left-hand side.
  • Add: This button enables you to add the selected operator to the equation currently being created.
  • Remove: This button enables you to remove the selected operator from the equation.
  • Show all operators: This option is used to hide the least common operators.
Variables
The following two headings appear in this tab: Modules and Trending Tool variables.
  • Modules: This drop-down list contains all the modules present in the configuration.
  • Trending Tool variables: This list contains the variables of the selected module.
  • Add: This button enables you to add the selected operator to the equation currently being created.
  • Remove: This button enables you to remove the selected operator from the equation.
OK
This buttons confirms the changes made to the equation and closes the dialog box.
Cancel
This button closes the dialog box without applying the changes made to the variable's equation.
Creating a Calculated Variable
Calculated variables can be created in Trending Tool at any time, just like any other variable, even during or after a recording.
To create a calculated variable in a module, proceed as follows:
Step
Action
1
On the module tree, select the module to which you wish to add a calculated variable.
2
In the Insert/Calculated variable menu, choose the type of variable to create. This command opens the New calculated variable dialog box.
3
In the dialog box, select the root operator of the equation in the list of the Operators, click then on the button to Add. In Trending Tool equations, the root operator is always an operator that returns a result of the chosen type.
4
Select a first term for the root operator, either from the list of Variables to add a variable directly to the equation, or from the list of the Operators to add a sub-equation, then click the button again to Add.
5
Repeat steps 3 and 4 until a comprehensive equation is obtained and click on the OK button to add the variable to the module and close the dialog box. The OK button is only active if the syntax of the equation is correct.
Changing a Calculated Variable
Calculated variables are boolean variables. They have the same display and analysis properties. In addition, the calculated variable properties dialog box features an Equation tab.
To change the equation of a calculated variable:
Step
Action
1
Select the variable you want to change in the statistical table of the variables.
2
Use the Properties... command from the Edit menu. This command opens the dialog box containing the properties of the calculated variable.
3
Click on the Equation tab in the dialog box. The Equation tab shows the variable's current equation.
4
Click on the Change... button to open the equation editor.
5
Change the variable's equation as required and click on the OK button to save your changes and close the editor. The Cancel button enables you to cancel the changes and close the editor at the same time.
6
Click on the OK button to close the calculated variable properties dialog box. The developments of the variable are immediately recalculated for the whole of the recording.
Viewing the Equation Tab for a Variable
The Equation tab displays the equation of a calculated variable.
Dialog Box Options
Description
Equation
This area enables you to view the equation associated with the variable in the form of a tree.
Change
Click on this button to open the dialog box to change the variable's equation.
OK
Close the dialog box and apply the changes made.
Cancel
Close the dialog box without applying the changes made.
Apply
Apply the changes made without closing the dialog box.
Help
Open a window featuring an online help related to the dialog box properties.
Deleting a Variable Linked To a Calculated Variable
Calculated variables are linked to the variables used in their equations. If you try to delete these variables, Trending Tool will display an alert message preventing you from deleting them.