Using Variables in an Animation
To use a variable in an animation you enter its name optionally preceded by the @ character. If you already know the name, you can enter it directly but it is normally easier to use the Variable Browser to select the name. The following are all examples of valid variable names.
Process.Engine1.Compressor1.B1
@Process.Engine1.Compressor1.B1
Process.Engine1.Compressor1.A1
CARD1.VARIABLESTREE.B1
Node1.DataTable3_256
Simulation.Square Waves.Int4
B1
For further information, see the topic Using the Variable Selector.
Using relative referencing
If the animation is in a window that has been opened with a branch (for example Process.Engine1) you can use relative referencing. With relative referencing, each variable reference uses only part of the variable name. For example, you might use the name Compressor1.B1. The other part of the variable name is supplied by the branch of the window. The variable names are automatically calculated at run-time by joining the branch with the relative name in the animation.
When using the Variable Browser to select a variable in a window with a branch it automatically selects the correct part of the variable name for you. For example, if the window was opened with the branch Process.Engine2 and you selected the variable Process.Engine2.Compressor1.B1 it would insert Compressor1.B1.
Using the ?.VarName syntax
Unless prefixed with the @ character, variable names that you include in an expression are relative to any branch being used. However, it is possible to reference variables starting back from the root of the branch hierarchy by using the ?.VarName syntax. For example, the expression is used with the branch ProcessB.Machine2.Engine1 but you need to use the variable ProcessB.NumRunning. In that case you can use ?.NumRunning in the expression. The question mark tells to start from the root level in the branch hierarchy when resolving the variable name, and in this example, it would result in the variable name ProcessB.NumRunning being used in the expression at run-time.
You can use more question marks to address all intermediate levels in the branch hierarchy. For example, ?.?.?.VarName would go down three levels from the root.
This technique can also be used when designing symbols using relative referencing. See the topic Creating a relative referencing symbol.
Forcing direct referencing
Sometimes in a window that has been opened with a branch, you need to refer to a variable with a different branch or no branch at all. To achieve this you use direct referencing where the variable name is preceded by the @ character. For example, @CARD1.VARIABLESTREE.B1. When using direct referencing the same variable is always referred to whichever branch the window is opened with. If you use the Variable Browser to select the variable the @ character is inserted automatically when you select a variable with a different branch to that of the window.
The name of a variable with the prefix @ is known as the full name of this variable. When a variable is referenced in such a way in an animation, the reference is direct and any branch is ignored.
Errors when selecting variables
The following error icons may appear alongside the support drawing element when you select a variable for an animation.
|
The variable does not exist. |
|
The variable exists but it has a bad status (for example - out of limits). Depending on the HMI option Variable warning display, the icon with an exclamation mark may be used instead. |
|
The object could not be initialized. This icon appears only for objects such as:
|