How to Create a Calculation Tag
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.
In this guide you will learn how to create a simple calculation tag to convert a temperature from degrees Celsius to degrees Fahrenheit.
1 - Add Tag for Temperature in Degrees Celsius
In this section you will create a Tag to represent a temperature value in degrees Celsius.
Select Configure > Tags from the top menu.
If you want to add a Tag to the root Tags group make sure the Tags node is selected in the tag list and click on the ADD TAG button.
If you want to add a Tag to a Tag Group, select the Tag Group first and then click on the ADD TAG button.
You can also add Tag Groups by using the ADD GROUP button.
Provide the Tag Name Temperature C and click the OK button.
2 - Add Tag for Temperature in Degrees Fahrenheit
In this section you will create a Tag to represent a temperature value in degrees Fahrenheit.
Select Configure > Tags from the top menu.
If you want to add a Tag to the root Tags group make sure the Tags node is selected in the tag list and click on the ADD TAG button.
If you want to add a Tag to a Tag Group, select the Tag Group first and then click on the ADD TAG button.
You can also add Tag Groups by using the ADD GROUP button.
Provide the Tag Name Temperature F and click the OK button.
3 - Set Tag Data Source
You will now set the Data Source of the Temperature F tag to Calculation so that you can write the function that will convert the temperature from Celsius to Fahrenheit.
Select the Temperature F tag.
Set the Data Source to Calculation.
Click on the EDIT button next to the Calculation field to open the Calculation Editor window.
4 - Apply Temperature Conversion Function
You will now write the function that will convert the temperature from Celsius to Fahrenheit. This function will reference the Temperature C tag and scale the value accordingly.
In the Calculations Editor window type the following function:
([Temperature C.Value] * 9/5) + 32
This should appear as follows.
Tips
To insert a tag you can either type the tag path manually and surround it using square brackets
[]
or you can use the Tag Browser by selecting the INSERT TAG button.Tips
To reference a Tag's value remember to add .Value at the end of the tag path.
Click on the OK button and then the Apply Changes button to apply the changes.
Check that the quality status is Good Quality and the data in the Value field is as expected.
5 - Verify Calculation
Let's check that the conversion function is working as expected.
Select the Temperature C tag.
In the Enter Value field type in a temperature value in Degrees Celsius and press the Enter key on the keyboard.
Click on Apply Changes.
Select the Temperature F tag and check that the value matches the expected value.