4 Replies Latest reply on Apr 1, 2013 1:24 PM by rdube02

    Counts Over Periods of Time

    rdube02

      Hi everyone,

       

      I'm attempting to do something similar to some script I've done before, but I can't quite figure this one out. I suspect there's a solution using IPICalculation that I just don't know about. I'm working in ProcessBook using VBA code.

       

      What I'm trying to do is to examine a string PI tag over a period of time, say 4 days - and I want to generate an array of values that represent the number of times that the tag equaled a certain value.  For example, it's a reason code that could contain 7 or 8 different reasons for dumping a part - in this case I want to know how many times the tag was "Bad Spring" each hour over the course of those 4 days.

       

      I think I need to pull in PIvalues over the 4 days, and then parse through those values and calculate the total for each hour over the 4 days, right? Or is there an IPICalculation call that I can use to do this without writing a bunch of loops to go through all the data?

       

      Thanks for any insight you can offer!

       

      -Ryan

        • Re: Counts Over Periods of Time
          hanyong

          Hi Ryan,

           

          Since you mentioned IPICalculation, I assume you are thinking of using PI SDK in ProcessBook VBA to get the result that you want. The PI SDK object and method that you are looking out for should be PIData.Summaries, this allows you to retrieve aggregated data for a time interval (count or total) of a tag over a time range, which should suit your requirements directly.

           

          IPICalculation.ExpressionSummaries can do something similar, but for getting aggregated data over time for a Performance Equation Expression like 'TagA' + 'TagB' instead of just a single tag.

           

          If you have more questions on this, it would be a better idea to post it in the PI SDK Development Forum.

           


            • Re: Counts Over Periods of Time
              rdube02

              Do you know where one can find the PDF version of a manual for PI SDK?  All I can find are the .chm files, which don't seem to work in my version of processbook. It would be nice to have a PDF manual like all of the other manuals - or really anything you know about that details how to use IPICalculation and the object/methods. I'm having a very hard time finding the documentation.

                • Re: Counts Over Periods of Time
                  hanyong

                  Unfortunately, there isn't PDF versions of the PI SDK Programming Reference that I know of. I think the best alternative is to search the forums for the keyword IPICalculation, you should be able to find other threads on it. Though most of them have code samples in .NET (VB.NET or C#).

                   

                  Ryan Dube

                  All I can find are the .chm files, which don't seem to work in my version of processbook.

                   

                  I'm not sure what you mean here. Are you having a hard time opening the help file? or you are having a problem using the PI SDK library in ProcessBook? FYI, to access the PI SDK objects in ProcessBook VBA, you will need to add reference to the PI SDK Type Library, and probably PISDKCommon and PITimeServer library as well.

                    • Re: Counts Over Periods of Time
                      rdube02

                      Yeah - the CHM content was showing like a blocked web page. Oddly enough this morning when I checked again, the content was loading fine. Maybe I just needed a reboot...

                       

                      Now that I can view the SDK help files with all of the syntax help, I should be able to figure this out. Thanks so much for your response and support Han.