11 Replies Latest reply on Aug 8, 2017 1:50 PM by Afthab

    Count the number of EF of same type

    Afthab

      Hi,

      Is there any way to count the number of event frames generated of same type. I am working on a dashboard to report the number of EF active on that day grouped by same type. I need to get the count of similar events in separate attributes(AF attributes).

       

      Thanks

      Afthab

        • Re: Count the number of EF of same type
          Rick Davin

          Hello Afthab,

           

          What do you mean by "same type"?  Same event frame template?  Same element category?  Same primary referenced element?  Or is it based on the value of some attribute on each event frame (note this gives slowest performance).  All of the above or some combination?

           

          About saving the calculated count in a separate attribute ...  Where is this separate attribute?  On one of the event frames, and if so, how do you know which one?  Couldn't you dynamically generate the count and write that to your dashboard?

           

          Please share more about what you are trying to do.  The clearer the picture you paint for us, the more tailor made the answer will be.

            • Re: Count the number of EF of same type
              Afthab

              Hello Rick

               

              Same type - Same template

              separate attribute means an AF attribute which holds the count so I can use it in PIVision dashboard.

               

              This is sample AF structure

               

               

              Where I have an Analyses running for EF creation which will trigger when the engine is 'Down'. I need to get the number of times the engine gone down(day wise), in the engine # down count attribute. So I am trying to count the number of times the analyses triggered or simply to count the number of EF generated.

                • Re: Count the number of EF of same type
                  Rick Davin

                  Hi Afthab,

                   

                  Generating the event frames via Analytics is very convenient.  And while you may configure it as shown, and you know the relationships among the element, the analyses on that element, and the event frames generated from those analyses, a search call does not.  Your analysis will have only one referenced element to the event frames, and that one will be the primary referenced element.  However, an event frame doesn't have to be created under that restriction.  It could have many referenced elements.  When searching you shouldn't take for granted what you know, but rather put in explicit distinguishing information.

                   

                  Allow me to correct your earlier statements:

                   

                  Same type - Same template

                  By "same type", you want event frames that (1) have the same primary referenced element, and (2) that were created from the same event frame template.  Later along with a time context, this important clarification will help narrow your search.

                   

                  separate attribute means an AF attribute

                    No kidding.  Again it's important to know that the attribute resides on the primary referenced element.

                   

                  Even with that said, I need more information.  Do the analyses "Engine 1 down" and "Engine 2 down" use the same or different event frame templates?  If they use the same event frame template, then simply counting based on primary referenced element and event frame template will not produce the correct count.  If you are trying to count for "Engine 1", you would also be counting "Engine 2".  So I really need to know if your 2 analyses use different event frame templates, and if not, then I need to know what other information is on the event frame that distinguishes one from another?

                   

                  Also what version of AF SDK are you using? 

                  1 of 1 people found this helpful
                  • Re: Count the number of EF of same type
                    Dan Fishman

                    There are a lot of ways to do this and other ways to reshape your hierarchy.   If you want to avoid custom coding or dependencies on other OSIsoft products you could write an EF Analysis that writes a "1" out at the start of each event.  You could then use another attribute attribute to display the sum since the start of the day.  The cost here of course is more PI Points and Analysis Rules to maintain.  The advantage is you do not have to depend on AF SDK code or a SQL Statement.

                    3 of 3 people found this helpful
                • Re: Count the number of EF of same type
                  Dan Fishman

                  A few ways to do this depending on how you define type.

                   

                  You can use a custom data reference and define any logic you need to return a count of event frames. Another popular option is to use PI OLEDBE Enterprise.  Similarly, you could use the BA Integrator and then bring that data back into the the PI System.

                   

                  Depending on how complex you define "type" you could increment PI Point counters whenever each event of a specific type starts and have logic to restart the counter at the end of each day/month.  Of course, an alternative would be to do all of the sorting client side within your dashboard.

                  • Re: Count the number of EF of same type
                    mhalhead

                    We achieved exactly what you are looking for using a custom data reference. It isn't a particularly difficult piece of code; basically it just exposes the AF Event Frame search method. To avoid the situation of trying to query an unbound time range we have an AF Analysis that then writes these values to PI Points. The screenshot shows the DR config.