asoudek

AF Analytics - On Demand calculations

Blog Post created by asoudek Employee on Aug 31, 2016

Create calculations that are not stored in a PI Tag and understand which functions are supported for this

Sometimes it is desirable to perform calculations but not to store them in a PI tag.  This is done by creating an Expression Analytic and mapping it to an Attribute that does not have a PI Data Reference.  This Analytic is only performed when a PI AF Client tool asks for the value of that Attribute.  When you do this, the Data Reference for the output Attribute is set to Analysis and the Settings describes which Analysis is involved.

q1.jpg

There are some considerations and limitations that you need to think about before creating On Demand calculations:

Considerations

  • The calculation of the Expression is performed on the PI AF Client.
  • What is the frequency of the calculation, e.g. less than one second frequency?
  • Are the calculations daisy-chained, i.e. one On Demand Calculation uses Attributes that are also On Demand calculations?
  • How many of these calculations will be performed during one data request?
  • What are the typical time ranges for the data requests?

All of these will have an impact on performance of retrieving values for these Attributes.  Therefore, performing On Demand calculations should be used sparingly.

Limitations

Because some functions are very calculation expensive they have been either “restricted” or “banned” from being used for On Demand calculations.

Restricted

This means that the functions listed below are allowed in an On Demand calculation, but they do not support summary data calls. This applies to the following function list:

  • EventCount()
  • PctGood()
  • Range()
  • StDev()
  • TagAvg()
  • TagMax()
  • TagMean()
  • TagMin()
  • TagTot()

 

In this example, we take the Flow Attribute and create a rolling 5-minute average, and map it to the Attribute Average Flow.  This Attribute is not mapped to a PI tag, but we can evaluate it over a time range.  See the Figures below.

q2.jpg

q3.jpg

q4.jpg

However, if you try to use the Average Flow Attribute in another Expression where you want to use it in a Time Series function you will get the following error because data summary calls are not supported for On Demand calculated Attributes:

q5.jpg

If we create a new Attribute, Average Flow Historized, and map it to a PI tag.  Then map the average calculation to this new Attribute.

q7.jpg

Now if we perform the TagTot() on this Average Flow Historized Attribute all is ok.

q8.jpg

 

Banned

This means that the functions listed below are not allowed in an On Demand calculation.  If you try to use them in that way you will get an error when the Analyses tries to start up for the Elements:

q9.jpg

This applies to the following function list:

  • DeltaValue()
  • FindEq()
  • FindGE()
  • FindGT()
  • FindLE()
  • FindLT()
  • FindNE()
  • HasValueChanged()
  • NumOfChanges()
  • TimeEq()
  • TimeGE()
  • TimeGT()
  • TimeLE()
  • TimeLT()
  • TimeNE()
  • NoOutput()

Outcomes