Roger Palmen

Limitations of PE expressions in AFCalculation class

Discussion created by Roger Palmen on Aug 27, 2013
Latest reply on Aug 28, 2013 by skwan

Hi all,

 

When looking for a solution to perform a summary over a year of a daily calculation of an expression against AF attributes (some AF Formula DR, some custom DR"s), i ran into an unexpected limitation.

 

My simple setup: I have an AF attribute that has uses a running-window day average PI Point lookup:

 

\\%Server%\SINUSOID;TimeMethod=TimeRange;RelativeTime=-24h;TimeRangeMethod=Average;TimeRangeMinPercentGood=0

 

 

 

Using the code below, i get an error message: "Expressions do not support PI Points with complex configurations in Attribute '.\TestRoger|Flow'." I do understand from the AFSDK documentation that only PI Points are supported , but the additional limitations came as a surprise. Is there anyone who can point me to some documentation on the limitations?

 

PS: I know the example does not make sense, but i'm researching the capabilities of the AFSDK, which is very capable and functionally rich! Ths any potential available i'd like to use.

 

Quote from the AFcalculation class documentation:

 

Expression syntax follows PI Performance Equation syntax. Expression variables are references to Attributes or PI Points using relative syntax to the target, which is typically an AF Database, AF Element or a PI Server. Variables must be enclosed in single quotes. Calculations are limited to Attributes or PI Points which originate from a single PI Server. Attributes which resolve to a static value (no data reference configured), are also acceptable.

 

SourceCode:

 

 

 
        private void btnCalculateSummaries_Click(object sender, EventArgs e)
        {
            //Get parameters from GUI
            object targetElement = afBasePicker1.AFSelection;
            AFTimeRange timerange = new AFTimeRange(txtTimeRangeStart.Text, txtTimeRangeEnd.Text);
            string strExpression = "'" + txtExpression.Text + "'";
            //Set other parameter inputs
            AFTimeSpan summaryduration = new AFTimeSpan(1);
            AFSummaryTypes summarytype = AFSummaryTypes.Total;
            AFCalculationBasis calcBasis = AFCalculationBasis.TimeWeighted;
            AFSampleType sampleType = AFSampleType.Interval;
            AFTimeSpan sampleInterval = new AFTimeSpan(0,0,1);
            AFTimestampCalculation timeType = AFTimestampCalculation.Auto;

            IDictionary<AFSummaryTypes, AFValues> results = AFCalculation.CalculateSummaries(targetElement, strExpression, timerange, summaryduration, summarytype, calcBasis, sampleType, sampleInterval, timeType);
            AFValue result = results.First().Value.First();
            txtResult_CalculateSummaries.Text = result.ToString();
        }

 

Outcomes