5 Replies Latest reply on May 8, 2018 9:48 PM by andrewwilliamson

    Store Event Frame Duration as an Attribute

    andrewwilliamson

      Hey PI Square,

       

      I am a new PI AF user working on an event frame.  The event frame works and I'm able to capture the duration however I do not have a way to see it as an attribute that I can use in PI Vision.  I can see the duration in excel and in the event frames tab on PI Vision but I'd like to see this duration as an attribute that I could use in real time.   For example a real time rolling averages of last three event durations that could be on a display.

       

      Any help is appreciated.

       

      Andrew

        • Re: Store Event Frame Duration as an Attribute
          Rick Davin

          Hi Andrew,

           

          The old answer to this would be found at Duration attribute on an Event Frame - Part 1 .

           

          However, since that blog was created we have introduced a %Duration% variable, so there is no longer any need to work from a Start and End attribute.  You can just use StringBuilder to echo %Duration%.  Be sure to change the attribute's type from Basic Types String to Objects <Anything> as it produces a TimeSpan object in the form of  [dd:]hh:mm:ss.fff.

           

          The config string should be:    "%Duration%";

           

          This could produce such output as:

           

          2018-05-03 14_38_11-Window.png

           

          Note the Value is 14:41:28 in this example.  You may use this in an Analysis but you will need to put a Float() around it to convert to seconds.  In fact, I would strongly suggest the recommended: Convert(Float(duration), "s").

           

          Keep in mind that the event frame now has a property named "Duration" as well an attribute named "Duration".  To avoid confusion, usually the attribute is specified as "|Duration".  That or you could name the attribute "Elapsed Time".  Then again, having the same name "Duration" probably wouldn't matter whether its the property or the attribute since they both contain the same value.  All you care about is that when you ask for "Duration" that you get the right value back.

          2 of 2 people found this helpful
            • Re: Store Event Frame Duration as an Attribute
              andrewwilliamson

              Rick,

               

              Thanks for the response.  I saw your blog while searching for the answer and it was very informative.  However the question that I am looking for an answer to is taking this point you have created just a little further.

               

              I am trying to find a way to make this attribute we have created on the event frame into an attribute on the main element that continues to update based on the event frames as they come in.  If I use the attribute on the event frame in PI Vision it is locked to that specific event frame.  We are using PI Vision on a display board in the control room that looks at real time data.  For this event frame to be useful, I would need to see the last event "duration" continue to update as the events come in.  I realize this may not be possible but I thought I would reach out and see if there was a way.

               

              Andrew