Info |
---|
Download the Solution Example here:solution TagEstimatedValues.dbsln |
- Solution Name: Tag Estimated Values
- Software Version: v10
- Keywords:
. 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
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.
Using With this infrastructure, you can calculate the EstimatedValue as the unit conversion for 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 number.
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 | ||||
---|---|---|---|---|
|