3 Replies Latest reply on Jun 28, 2013 1:51 PM by Marcos Vainer Loeff

    PI AF - Calculations - .NET 3.5

    Ashok_NK

      Hi

       

      Is it possible to do calculations using the AF SDK targeting .NET 3.5?

       

      I am trying to retrieve data similar to a Pi ProcessBook - it has a DataSet - PI Calculation as follows:

       

      Pi Tag or expression: 'Tag1 Total.Median'+'Tag2 Total.Median'+'Tag3 Total.Median'+'Tag4 Total.Median'+'Tag5 Total.Median'
      Calc Interval: 10m
      Interval Sync Time: 00:00:00
      Value Columns Name: Value
      Stepped Plot: Yes|No

       

      Thanks

        • Re: PI AF - Calculations - .NET 3.5
          Marcos Vainer Loeff

          Hello Ashok,

           

          AF SDK has this feature only if you are targeting at least .NET 4. In this case,  the method AFCalculation.CalculateSummaries under the OSIsoft.AF.Data namespace is able to perform some calculations as shown in the example below:

           

           

           
          string expr = @"'SERV-DC1|Memory_Available MBytes'+'SERV-PI2012|Memory_Available MBytes'";
              
                
          var summaries = OSIsoft.AF.Data.AFCalculation.CalculateSummaries(Computers, expr, new AFTimeRange("*-3h", "*"), AFTimeSpan.Parse("3h"), AFSummaryTypes.Maximum, AFCalculationBasis.TimeWeighted, AFSampleType.ExpressionRecordedValues, AFTimeSpan.Parse("3h"), AFTimestampCalculation.MostRecentTime);
                          
          

           

           

          Nevertheless, could you to please describe what are you actually trying to do with more details? Where is your data stored? Is it stored on a PI Server or different databases through AF Table Lookup Data Reference?  We might be able to find a different solution for your problem.

            • Re: PI AF - Calculations - .NET 3.5
              Ashok_NK

              Hi Marcos

               

              Basically I want to retrieve the data as it has been setup in the Pi ProcessBook configuration I described. For example, I will retrieve the value of the calculation as a time series, 7 day window...

               

              Ok - so if the calculation capability is not available in the AF SDK (targeting .NET 3.5), what are the alternative approaches?

               

              1. PI AF SDK - (.NET 4.0 version)

               

              2. PI SDK (a version that targets .NET 3.5) ?

               

              3. Define that calculation as an Attribute within PI AF - then I can simply retrieve the value of the attribute (without needing to do the calculation in code level/API?)

               

              Thanks