Versions Compared

Key

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


Info
iconfalse

Download the Solution Example here: TagEstimatedValues.dbsln


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

Summary

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


Technical Information

The DisplayValue property will show one of three options: the Value tag property (the tag's current value), the EstimatedValue tag property (which is a user-defined calculation), or a Historian Value of the tag.

With this infrastructure, you can calculate the EstimatedValue for the Value property and dynamically choose whether your display or another system will show the units. To switch between multiple display values, use the Client.Context.DisplayValueMode property, where each specific number changes the DisplayValue (e.g., if set to 0, it will display the original value; if set to 1, it will display the estimated value).

Alternatively, you can use the following code snippet in the CodeBehind for dynamic switching.

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

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

@Client.Context.SetDisplayValueToHistorian(DateTime selectedDateTime); // 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.

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);



Reference Information

→ See Tags for more information.


In this section:

Page Tree
root@parent
spacesV10