Expressions are combinations of data sources, numbers, operators, grouping symbols (such as brackets and parentheses) arranged in a meaningful way which can be evaluated. During runtime mode, OPC servers resolve the data source for the expression and the expression is evaluated. There are two types of Expressions available in the GENESIS64 , and both are described in this topic: local and global.
Some applications like GraphWorX64 support built-in local expressions, which can be defined locally using the Data Browser's Expressions tab. An example of a local expression in the Unified Data Browser is shown below. A detailed description of this tab is provided in Expression Editor, along with ways to write effective expressions.
A Local Expression in the Data Browser
In addition, GENESIS64 provides Global Expressions. They are defined centrally in the Workbench in the Unified Data Manager and available as normal OPC tags in OPC UA client applications. A global expression allows combining of miscellaneous data tags in a simple expression. Each global expression is implemented as a single expression data tag. Its re-calculation will be based on input values or on trigger data tags. Client applications can access these expression data tags as read/write data tags with a configured data type.
Once a global expression is defined in the Unified Data Manager , it can be used in OPC UA client applications. To use an expression, you open the Data Browser and browse the OPC UA tab, then OPC Servers, then My Server, then Global Expressions, and then choose the desired folder or global expression. As you navigate to the expression, the path to the expression is shown in the navigation toolbar as a bread crumb, as shown in the figure below. When you click on the navigation toolbar, the path switches to the standard UNC format.
Global Expressions in the Data Browser
Global expressions are organized in a tree structure of folders and expression items. Features of global expressions include:
Create and edit expressions.
Create folders for expressions.
Expressions are available as data tags.
Parameters are supported.
Specify READ expressions or WRITE expressions.
Expressions within expressions are calculated together.
To Create a Global Expression:
Start the Workbench and open the Unified Data Manager .
In the Unified Data Manager, right-click the Expressions node in the navigation tree and select Expression, as shown in the figure below.
The New Expression Command in the Data Manager
Enter a name in the Name text box for the Global Expression form.
On the Expression Properties tab, specify the data type, default scan rate, and parameters if any. This tab is described in detail below, in Expression Properties Tab.
Click the Read Expression tab and enter the expression definition. Then, if you intend to write values, click on the Write Expression tab and enter the expression for the WRITE operation. The essential actions of an expression are contained in the these two tabs. They are described in detail below in Read Expression Tab and Write Expression Tab.
When you are done, click the Apply button.
Note. Some expressions have READ definitions, and others may have both READ and WRITE. |
A Sample READ Expression
Global expressions can be logically organized inside Unified Data Manager in folders. Each folder appears as a node in the navigation tree. Some folders may already be defined, such as the SubExpressions and Units folders. You can add a folder to the Expressions node or to any existing folder.
To Create a New Folder:
In the Unified Data Manager, right-click the node in the navigation tree and select Folder. A new folder (with the name New Folder) appears in the tree control and the Folder form appears.
In the Name field, type a name for the new folder.
The Expression Properties tab allows you to configure the following settings:
Name. Enter a name for the expression.
Description. Enter a description for the expression (optional).
Data Type. Each expression must have a data type that will be used as an output data type. In the case the output value cannot be converted into this configured data type, you will get an error and the return value will be bad and of no use. Select from the following data types: Native/Empty, Float, Double, Boolean, Byte, Word, DWord, Character, Short, Long, String.
Default Scan Rate: Specify the default scan rate (in milliseconds) for all input and trigger data tags. This value can be overridden for particular data tags by using point extension syntax.
Parameters. List the parameters to be included in the expression. Parameters are client-driven, and they do not change the number of requested data tags in runtime. Parameters can replace parts of data tag names by values passed in the expression data tag name. Each parameter can be an integer or a string data type with optional formatting. Type the name of the parameter to add it to the list. Once the parameter tag is added to the list, you can click the Remove button to delete the parameter from the list, or you can click the Move Up and Move Down buttons to change the order of the parameter in the list. For more information about parameters, see Parameters below.
Apply. Saves all changes to the configuration database.
Reset. Clears all recently added information.
Each data tag may support parameters that could modify names of the data tags. Each parameter can be integer or string data type with optional formatting. The table below shows possible formatting for each supported data type.
Data Types
Data Type |
Formatting |
Integer (number) |
Minimum number of digits used for character representation of an integer number and padded character. |
String |
Minimum number of characters and padding characters plus padding direction (add padding characters from left or right side). |
The client application passes configured parameter values as a part of the full data tag name. Parameters are client driven, and they do not change the number of requested data tags in runtime. Parameters can be integer or string values. These values are then formatted using pre configured format data, and then they replace specific parts of a data tag name by values passed in the data tag name. Parameters are delimited by double carets (i.e., << and >>) and specified by their names in the tag name, as shown below:
ICONICS .Simulator.1\SimulatePLC\Ramp<<Parameter1>>) in the data tag name.
A READ expression must be compliant with the ICONICS expression syntax. In runtime, it is processed by the standard ICONICS expression engine. The expression can be recalculated and triggered in two basic ways:
When at least one trigger data tag is changed
When any data expression input changes
In the Read Expression tab, configure the following settings:
Read Expression. Click the Expression Editor button to create an expression, or type the expression text directly into the edit box.
Expression Editor. Launches the Expression Editor, which is available to assist you in creating your expression. In the Expression editor, you can choose tags from connected OPC servers by clicking the Variables button to open the Data Browser.
Use Trigger Tags. Checking this check box enables you to specify a set of data tags that may trigger an expression calculation. The expression can be calculated when one of the trigger tags becomes true, becomes false, or changes value.
Send Initial Update. When you subscribe to the expression data tag, you get the value of the tag immediately.
Send All Updates. Every time the expression is recalculated, the expression engine for the Unified Data Manager will send the new value to the client.
Trigger Tags. Specify a set of data tags that may trigger an expression calculation. The expression can be calculated when one of the trigger tags becomes true, becomes false, or changes value, which you specify in the Method box. Click the ellipsis button to select a list of data trigger tags from the Unified Data Browser. Once the selected tag is added to the list, you can click the Remove button to delete the tag from the list, or you can click the Edit button to change the tag.
The data trigger executes an event on any data tag change, or when the specified data tag changes to TRUE or FALSE. Under the Method column (next to the tag name), specify execution on Change, True, or False for each tag in the list.
An expression can be defined to WRITE new values, but expression must be compliant with GENESIS64 's expression syntax. The three rules you need to follow are:
WRITE expressions allow one output data tag.
They can use as inputs the written value and any number of other input data tags.
The Write Expression tab has the following settings:
Enable Write Expression. You must check this check box to create and edit write expressions and have values calculated.
Write Expression. The write expression. mark a place in your expression, where you expect an operator’s input. The input value, which a runtime operator writes into the expression tag, is represented by the string {{input}}. For example, x= (<<input>>*1.8)+32 is the write expression of a thermometer. You can click the Expression Editor button to create an expression, or type the expression text directly into the edit box.
Expression Editor. Launches the Expression Editor, which is available to assist you in creating your expression. In the Expression editor, you can choose tags from connected OPC servers by clicking the Variables button to open the Data Browser.
Output Tag. Specify a data point where the result of write expression will be stored. If you are doing a conversion, it might make sense to use the same tag as the one used in the Read expression. Write expressions allow one output data tag only. Click the ellipsis button to select a tag from the Unified Data Browser.
See also: