Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Info
iconfalse

Download the

Solution Example here:

solution TagEstimatedValues.dbsln

  • Solution Name: Tag Estimated Values
  • Software Version: v10
  • Keywords: Tags. Tag Estimated Value. Tag Historian Value. Trend PlayBack. Display PlayBack.

.

Built with v10.

This solution example shows how to use Estimated Values.



Summary

Estimated Values can be used for multiple purposes, such as reducing noise in calculations. This solution example shows how to use this property in multiple ways

Summary

Example showing the difference between DisplayValue and EstimatedValue in a solution.


Technical Information

DisplayValue Tag Property

The Tags are used on display, you use the syntax Tag.TagName. 

Each TagName has many properties like Quality, TimeStamp, Value, Min, Max and others. So in fact when you add Tag.TagName to a display, the system is selecting the Default Properties to the value, which is the property Value.

It is possible to customize that behavior, so the display instead of showing the Value of the tag, will show its estimated value, or historical data.

The DisplayValue field of that can  will show The DisplayValue property will show one of three options:

The

the Value tag property (the tag's current value),

The

the EstimatedValue tag property (which is a user-defined calculation)

.The

, or a Historian Value of the tag

at an specified DateTime

.

With

Using this infrastructure, you can calculate the EstimatedValue for any simulating, or process analysis reason,  and the Value property and dynamically choose whether your display or another system will show the units dynamically.
The method to To switch between multiple display values is through , use the " Client.Context.DisplayValueMode " property, where each given specific number changes its the DisplayValue (ie.eg., if set to 0, it will show display the original value; if set to 1, it will show display the estimated value).In the given example

, the current estimation is done by obtaining the first three significant digits of your original numberAlternatively, you can use the following code snippet in the CodeBehind for dynamic switching.

Code Block
Client@Client.Context.SetDisplayValueToEstimated(); // the DisplayValue will show the Tag EstimatedValue property

Client@Client.Context.SetDisplayValueToCurrent(); // the DisplayValue will show the Tag Value property

Showing Tag Historian Value to PlayBack

You can also change the Client.Context.DisplayValueMode, to Historian information using the method:

Code Block
Client.Context.

@Client.Context.SetDisplayValueToHistorian(DateTime selectedDateTime)

This command will set the DisplayValue property to the tags show the HistorianValue at the selected DateDate. 

This features can be used to PlayBack the contents of an HMI display. By calling the method to the desired date time. It can controlled by an operator input, scripts. it can be one specific time or playback at a give interval, your solution logic when control when new values shall be loaded.

In order to accomplish the task, the system will look for the Historian storage for that tag, therefore only tags that are enabled to Historian can play back. 

The system will run more efficiently if all tags of the display used for playback are in the Historian Table.

To make the HMI display to show again the current value for tag, use the command

; // the DisplayValue will show the HistorianValue at the selected DateTime

The method for calculating EstimatedValue may vary depending on your application. However, in this solution example, we’ve set up a code snippet in Classes / Tasks that triggers every time a tag changes, ensuring the EstimatedValue is accurately recalculated with the new data. You can find the path to these Tasks in the image below.

Image Added

Finally, the code used to obtain the first three significant figures is shown in the code snippet below.

Code Block
double scale = Math.Pow(10, Math.Floor(Math.Log10(Math.Abs(@Tag.tag2))) + 1);
if(@Tag.tag2 == 0)
	@Tag.tag2.EstimatedValue = 0;
else
	@Tag.tag2.EstimatedValue = scale * Math.Round(@Tag.tag2 / scale, 3);
Code Block
Client.Context.SetDisplayValueToCurrent()



Reference Information

→ See Tags for more information.


In this section:

Page Tree
root@parent
spacesV10