You are on page 1of 14

Services

Module 17
Expressions
Contents

1 Introduction 3
1.1 PcVue version 3
1.2 In this module you will learn 3
1.3 Files used in this module 3
1.4 Third party software used in this module 3

2 This feature in PcVue architecture 4


3 Expression concepts 5
3.1 Expression in an animation 5
3.2 Expression on a Variable 7
3.3 Expression template 10
3.4 Expressions in the Application Architect 11

4 Summing-up 14

V12 Module 17 - Expressions Page 2/14


1 Introduction
1.1 PcVue version
This module is for PcVue version 12.

1.2 In this module you will learn


About the different uses of expressions,
How to create an expression.

1.3 Files used in this module


The PcVue project at the end of Module 16 Basic.

1.4 Third party software used in this module


None.

V12 Module 17 - Expressions Page 3/14


2 This feature in PcVue architecture

Figure 1

V12 Module 17 - Expressions Page 4/14


3 Expression concepts
An expression is used to calculate a value using the real-time value of one or more
variables and operators. For example: “(TEMP1 + TEMP2) / 2”

The complete list of operator functions for expressions is available


in the online Help in: The Application Explorer / Variables /
Expressions / Expression syntax.
An expression is automatically evaluated each time any of the variable values within
it changes.

The result of an expression is NS if any variable within the


expression is NS.

Expressions can be defined and used in three ways:


By entering it directly in an animation.
By attaching an expression to a variable.
By entering an expression template.

3.1 Expression in an animation


You can directly enter an expression in any animation in the field normally used for
the variable. The expression must be preceded by the character “=”.
The following screen-shot represents an expression increasing the temperature value
by 1.

Figure 2

The animation must match the expression result. In this example you cannot enter
this expression in a Color / Bit… animation because the result is a register.

V12 Module 17 - Expressions Page 5/14


Exercise 1.
a. Open the Animations mimic.
b. Insert a text and add the animation Text / Display register.
c. Configure the expression:
=@BUILDING.FLOOR_01.ROOM_001.AC.TEMP + 1
d. Switch to Run mode and check it.

V12 Module 17 - Expressions Page 6/14


3.2 Expression on a Variable
We often want the result of an expression in a variable, for example if we want to
record it in an Archive Unit.
To configure an Expression to a Variable:
Step 1. Open the Application Explorer and expand the configuration tree to
select the Expressions node.
Step 2. Right click the node and, from the context menu, select Add an
expression on a variable..

Figure 3

Step 3. The Expression on Variables dialog opens. Configure the expression.


a. Enter a name for the expression or accept the default.
b. It’s useful to also enter a Description for future reference.
c. Select the Result variable.

Figure 4

V12 Module 17 - Expressions Page 7/14


d. Select the Expression tab and enter the expression.

Figure 5

e. Click the OK button to confirm the expression and close the dialog.

The tool (small icon) at the top left of the Expression tab can be
used to open the Variable Selector and insert a variable.

Exercise 2.
a. Create the variable BUILDING.FLOOR_01.TEMP_AVG as an
internal register.
b. Create an expression to make this variable the average
Temperature of Floor 1.
c. Open the mimic “BUILDING_FLOOR_01_Mim” and display the
average value of Temperature.

V12 Module 17 - Expressions Page 8/14


The Expression on Variable dialog allows you to optionally select a variable branch. If
you do so, the name of the result variable and the variables in the expression, are
relative to that branch. This can be useful to reduce the amount of typing!

Figure 6

Exercise 3.
Edit the previous expression you created so that all references to
variables are relative to the branch BUILDING.FLOOR_01.

V12 Module 17 - Expressions Page 9/14


3.3 Expression template
When you need to create the same expression several times it’s better to make an
Expression template. The principle is the same as that of the symbol. Several
expressions are using a template; if you modify the template the expressions are
updated. You can use this template in an animation or as a variable in another
expression.
To create an expression template:
Step 1. Open the Application Explorer and expand the configuration tree to
select the Expressions node.
Step 2. Right click the node and, from the context menu, select Add an
expression template.
Step 3. Configure the expression template.
a. Enter a name for the expression template or accept the default.
b. It’s useful to also enter a Description for future reference.

Figure 7

c. Enter the Expression.


d. Click the OK button to enter the expression and close the dialog.

When you use an Expression Template in an animation you enter:


=<Template Name>
When you use an Expression Template as a variable in another
expression you enter:
<Template Name>

V12 Module 17 - Expressions Page 10/14


3.4 Expressions in the Application Architect
You can create an expression on a variable, as a variable behaviour, in the Application
Architect. However, due to the way in which the Architect works, it is not always the
best place to generate an expression. For example:
Taking our previous example of an expression to calculate the average temperature
of the rooms on each floor. If we enter the expression directly into an expression on a
template or variable it is quite easy, you just add up the temperatures for the rooms
and then divide by the number of rooms. But, from a template in the Architect you
don’t know how many instances (rooms) there are, or what the branches (names)
are. So the calculation is not possible.
However, sometimes an expression generated in the Architect is quite feasible. For
example:
We want to display the temperature in Fahrenheit, as well as in Centigrade. The
expression is quite simple: F = (C X 1.8) + 32. If we entered this in an expression on
a variable, making use of the branch property, we could have something like:
Branch: BUILDING.FLOOR_01.ROOM_101.AC.
Result: TEMP_C
Expression: (TEMP * 1.8) + 32
We can use the same approach in the Architect by using differentiation with the
branch property. Consider the following.
Step 1. Open the Architect and navigate to the AC template previously
created. Add a new register variable TEMP_F.

Figure 8

V12 Module 17 - Expressions Page 11/14


Step 2. Add an expression behaviour to the TEMP_F. The Branch property
must be configured as Define by expression.

Figure 9

Step 3. Review the result of the expression we entered in the Instantiation


tab. It confirms that it is good.

Figure 10

Step 4. Save and generate!

V12 Module 17 - Expressions Page 12/14


After generation we can use the Application Explorer to check the expression has
been correctly generated and that the calculation is working. You can see that there is
one expression for each instance of the AC template.

Figure 11

Figure 12

Why doesn’t the expression branch affect the result variable


name?
The result variable name is preceded by an @ which means
absolute. The branch is ignored.

V12 Module 17 - Expressions Page 13/14


4 Summing-up
The result of an Expression can be used directly in an animation or it can
provide a variable’s value.
PcVue lets you use Expression Templates to manage repetitive expressions.
Expressions can be configured using the Application Explorer or the Application
Architect.

V12 Module 17 - Expressions Page 14/14

You might also like