Info |
---|
Download the |
solution TagEstimatedValues.dbsln |
. Built with v10. This solution example shows how to use |
Estimated Values. |
Summary
Example showing the difference between DisplayValue and EstimatedValue in a solution.
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.
Technical Information
The DisplayValue property will show one of the three options: the Value tag property (the tag's current value (Value property).The ), the EstimatedValue tag property (which is a user-defined calculation), or a Historian Value of the tag.
Using With this infrastructure, you can calculate the EstimatedValue to be the unit conversion for the Value property and select if dynamically choose whether your display or another system will show the units dynamically.. 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); |
In this section:
Page Tree | ||||
---|---|---|---|---|
|