1 Reply Latest reply on Jun 8, 2016 1:56 PM by pthivierge

    Syntax for stringCompare of FilteredSummaries

    Shane318

      Hi,

       

      When completing a PI AF SDK request in MATLAB I'm having some trouble in defining the stringCompare for FilteredSummaries. I have been able to retrieve data for a simple request such as all values greater than x (i.e. '.'>x), however the string compare I want to make is a little more complicated than this.

       

      I'm looking to count the total number of rising edges for when a PI Point has exceeded the threshold value x.

       

      So far I have defined the following:

       

      NET.addAssembly('OSIsoft.AFSDK');
      import OSIsoft.AF.*
      import OSIsoft.AF.Asset.*;
      import OSIsoft.AF.Time.*;
      import OSIsoft.AF.Data.*;
      import OSIsoft.AF.PI.*;
      
      
      piSystems = OSIsoft.AF.PISystems;
      af_server = piSystems.Item(server);
      af_database = af_server.Databases.Item(database);
      element = af_database.Elements.Item(RootPath);
      
      
      attribute1 = element.Attributes.Item(attribute);
      myPIPoint = char(attribute1.PIPoint.Name);
      timeRange = AFTimeRange(starttime,endtime);
      
      StringCompare = = ['''.''','>x',' AND ','PrevVal(','''.''',',','''*''',')<=x']; %StringCompare = '.'>x AND PrevVal('.','*')<=x
      
      AllData =  attribute1.Data.FilteredSummaries(timeRange,AFTimeSpan(timeRange.Span),StringCompare,AFSummaryTypes.All, AFCalculationBasis.EventWeighted,AFSampleType.ExpressionRecordedValues, AFTimeSpan.Zero, AFTimestampCalculation.Auto);
      
      TotalExceedences = AllData.Item(AFSummaryTypes.Count).Item(0).Value;
      

      Based on the results the request is returning, the syntax I have used for PrevVal() is incorrect. Was just wondering if someone can point me to a document that details the correct syntax for this string compare or if they know the correct syntax to use for FilteredSummaries() stringCompare.

       

      Thanks,

      Regards,

      Shane