4 Replies Latest reply on Oct 12, 2017 2:46 PM by nmosher

    PISDK Data.Summaries Method


      I'm using VBA in Excel trying to write a function that accepts a PI point name (string), start time, end time, and interval then returns a 2D array of interval averages along with the timestamps.


      How do I convert the PISDKCommon.NamedValues object returned by the Data.Summaries method into a PISDK.PIValues object?

        • Re: PISDK Data.Summaries Method

          Hi Nicholas.


          From our documentation for the PI SDK and the summaries method, it says that the Value property of the NamedValues object contains the PIValues object. Here is my example:

          Set namedVals = pt.Data.Summaries(startTime, endTime, btAuto, asAverage)      'namedVals is a NamedValues object

          Set piVals = namedVals("Average").Value      'piVals is a PIValues object


          Let me know if this helps!




          Here is the documentation that I referenced: https://techsupport.osisoft.com/Documentation/PI-SDK/PI_SDK_Interfaces/PI-SDK_Objects/PIData/IDH_DAT_SUMMARIES.htm

          You'll want to scroll down to the end of the page. The PI SDK documentation is also available in %PIHOME64%\help\en\pisdk.chm.

          1 of 1 people found this helpful
            • Re: PISDK Data.Summaries Method



              This worked well!  I didn't realize on the SDK documentation that if you scrolled all the way to the bottom there were additional frames that contained more content.


              While it works, I'm still a bit confused why the NamedValues object that is returned requires a parameter ("Average") which was specified in the Data.Summaries call as a parameter (asAverage),  Does the NamedValues object contain a set of PIValues objects for each calculation (e.g. Min, Max, Average, etc.)?




              - Nick

                • Re: PISDK Data.Summaries Method

                  Hi Nick,


                  I think these lines from the PI SDK documentation would help address your confusion:


                  "The Summaries2 method retrieves several summary types in a single call over the specified range, and for each interval within the range. The method returns a NamedValues collection which contains named summaries as PIValues... The summaries methods can compute multiple summary results over multiple calculation periods. The summaries methods return the result as a NamedValues collection. Each requested summary type produce a corresponding NamedValue item in the NamedValues collection. The name property of the NamedValue item contains the string representing the summary type. The following table shows the string corresponding to each summary type. SummariesType like asAll or asTotalAndAvg will result in NamedValues collection with more than one item."


                  So yes, the NamedValues collection could contain more than 1 summary type which is why you would be required to specify it again when accessing the Value property.



                  2 of 2 people found this helpful