4 Replies Latest reply on Jul 9, 2015 9:14 PM by bshang

    AF SDK PiPoinList Summaries

    mdspath

      Hello:

      I'm using the AF SDK to gather specific data from our server and starting to try to use the power of the the SDK to get me aggregated values in some continuous data. I looked into the AF SDK help to get an example and modify to suit but I'm running into issues. Attached is the snapshot of the screen in the IDE and below is the snippet from the help. I'm confused on the pointList.Summaries() method. I thought that pointList could be replaced by my PiPointList object I created above but it doesn't find any summary methods.

      Can someone aide on what I'm missing here?

      Thanks

       

                // **** copied code from the Help

                  // Holds the results keyed on the associated point

                  var resultsMap = new Dictionary<PIPoint, AFValues>();

       

       

                  // Results should be sent back for 100 tags in each page.

                  PIPagingConfiguration config = new PIPagingConfiguration(PIPageType.TagCount, 100);

       

       

                  try

                  {

                      var listResults = pointList.Summaries(myTimeRange, span,

                         AFSummaryTypes.Average, AFCalculationBasis.TimeWeighted,

                         AFTimestampCalculation.Auto, config);

       

       

                      foreach (IDictionary<AFSummaryTypes, AFValues> pointResults in listResults)

                      {

                          // Get average values from the result dictionary

                          AFValues pointValues = pointResults[AFSummaryTypes.Average];

                          PIPoint point = pointValues.PIPoint;

       

       

                          // Map the results back to the point

                          resultsMap[point] = pointValues;

                      }

                  }

        • Re: AF SDK PiPoinList Summaries
          bshang

          Hi Mike,

           

          that example in the AF SDK guide is a bit confusing in that the PIPointList object is already assumed to have been instantiated (as pointList).

           

          I think what you need is a reference to a PIPointList object so it can be reused.

           

          I see

           

          new PIPointList(points).InterpolatedValues()

           

          You can do instead

           

          PIPointList myPointList = new PIPointList(points);

           

          Then call

           

          myPointList.InterpolatedValues()

          myPointList.Summaries()

          etc.

           

          Let us know if this is what you were after or something else.

            • Re: AF SDK PiPoinList Summaries
              mdspath

              Thanks Barry:
              I had a suspicion I had the semantics wrong. Have a great day!

              Mike

              • Re: AF SDK PiPoinList Summaries
                mdspath

                Hi again Barry:

                I hate to pile on here but I'm trying to find an elegant way using the AF SDK to have the user subdivide the result into a defined interval. For example if the interpolatedValues call results with 7,000 timestamps, I want to have them be able to enter a value in which to divide the result by (10 for example) then give an average for each of those intervals. So if I were to export to an excel sheet the number of rows would be 700.

                I have been looking into the

                AFCalculation.CalculateSummaries Method 

                This method evaluates the specified expression over the passed time range. The passed time range is first divided into a number of summary intervals. The method then computes the specified summaries over each interval.

                Namespace: OSIsoft.AF.Data
                Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 2.7.0.6298
                Syntax
                C#
                public static IDictionary<AFSummaryTypes, AFValues> CalculateSummaries(
                Object target,
                string expression,
                AFTimeRange timeRange,
                AFTimeSpan summaryDuration,
                AFSummaryTypes summaryType,
                AFCalculationBasis calcBasis,
                AFSampleType sampleType,
                AFTimeSpan sampleInterval,
                AFTimestampCalculation timeType
                )

                 

                I have a PiPointList that I'm dealing with so I'm not sure how to use the AFCalculation class.

                 

                I have been trying to use the PiPointList.Summaries as well but it seems as if I would have to write code to divide the interval then repeatedly call into the piserver to get the result.

                Mike

                  • Re: AF SDK PiPoinList Summaries
                    bshang

                    Yeah, there doesn't appear to be a server-side way to perform a Summaries call using interpolated values as input. PIPointList.Summaries() can subdivide the intervals (each interval has range of AFTimeSpan), but the inputs to each average will be taken from the archived (non-interpolated) values.

                     

                    An alternative is to first call PIPointList.InterpolatedValues to get the IEnumerable<AFValues>. Then, for each AFValues, call the AFValues.Summaries() method, which will perform the averaging on the client-side. The drawback is the extra processing the client must perform and the fact that all the interpolated values are first returned over the wire to the client, when it really only needs the summary averages.

                     

                    The drawback with AFCalculation is the lack of bulk call support. If you have many tags in the PIPointList, then AFCalculation looping through the tags may be slow.

                     

                    Is there a requirement to use interpolated values as inputs into the averaged intervals? PIPointList.Summaries() seems most efficient, but I'm wondering if the inputs to the calculations can just be the archived events. Otherwise, it may be possible to use AFValues.Summaries() to subdivide and perform the averaging.