Getting Started with Calculations
When configuring Tags in the OAS server, you can choose Calculation as the Data Source. This allows you to create dynamic data transformations on existing values already being monitored from local or remote sources. You can even use input data directly from OPC Servers with the DirectOPC interface and these items can come from the local service or a remote service. The following video demonstrates the configuration and use of Calculation Tags.
NOTE: If you have security enabled on a remote service to disable reading all Tags or specific Tags used in a calculation, you will need to define the OAS Service username and password under Configure > Options. It is also recommended to enable security to limit access to reading Tags from remote services to prevent unwanted changes on the source server.
Quick Start Guide
The following is a quick walkthrough of setting up a Calculation Tag:
Step 1
Using Configure > Tags in the OAS Configuration Application, create a new Tag with the name Total
Step 2
Select the newly created Total Tag and set the Data Source to Calculation
Step 3
Use the Edit button to the right of the Calculation field to open the Calculation Editor
The options presented are OK, Insert Tag, Insert Function, and Cancel Insert Tag allows you to browse for a Tag on your local or remote OAS servers to insert a reference Insert Function inserts the syntax for a function to use in your calculation OK validates and saves the calculation Cancel exists without saving
Select Insert Tag, then browse your local system for the Ramp.Value. This Tag is included in the demo Tags when the OAS Platform is installed. If you have removed the demo Tags, you can select any other numeric Tag that you have on your server.
Next, add a + symbol after the [Ramp.Value] and insert another numeric Tag such as [Sine.Value]. Repeat this step with a third tag such as [Random.Value] to complete the equation which should look like this:
[Ramp.Value] + [Sine.Value] + [Random.Value]
Tag Syntax
When referencing Tags in any calculation, it is assumed that you are accessing them on the current OAS server. However, you can also access remote Tags on any OAS server that can be reached by the current server and via Live Data Cloud. Read more about the proper syntax for accessing Tags and Tag Variables.
Click OK to validate and save the calculation, then click Apply Changes to apply the calculation to the Tag.
Step 4
You should now see the value of your Test Tag reflecting the calculated sum of Ramp, Sine, and Random and will be updated as the source values change over time.
NOTE: Should any of the source Tag values become unavailable, or if any of the source Tags have a status of Bad Quality, the Calculation Tag will also show Bad Quality. Alternatively, you can configure the Source When Bad property of the tag to change the data source under these conditions.
Calculation Function Reference
The OAS Calculation Engine supports a wide variety of built-in functions. Below is a list of function categories:
- Math
Various common mathematical functions - Trig
Trigonometric functions such as SIN, COS, and TAN - Compare
Value comparison functions - Limit
Limit functions such as min and max - Logical
Boolean logical comparison functions - Text
String manipulation and searching functions - Statistics
Dynamic statistical functions for value compilation over time - Date
Date conversion functions - Tag Alias
Utility functions for referencing tags within Tag Groups - JSON
Functions for searching and manipulating JSON data