Several years ago I posted an Idea on PI Square to use the Formula data reference (DR) as a standard way to configure a Duration attribute on event frames. Long story short, the Idea on PI Square was lost during some backend changes* and since I still get questions on this topic, I'm resurrecting it as a blog with a few edits. Please see below.
- Pro: using Outputs on close is a nice, all-in-one method if you also want to output the duration to a PI Pt attribute on the reference element where it can be used elsewhere (e.g., real-time dashboards or calculations in AF).
Note that you can choose to have the output written only to a static EF attribute so you just get Duration on the EFs (nothing on the reference elements), but using this has the following cons:
- Con: Because the output expressions are not evaluated until the EF closes, there are no intermediate Duration attribute values available for open EFs.
- Con: This method is more complex to configure and maintain when Duration attributes for EFs are used widely. For every event frame generation analysis where we want the EFs to have a duration attribute, we need to add the Duration output expression. Using the Formula approach above, the Duration attribute can be configured on a base EF template from which other EF templates can be derived.
Note 4: As mentioned in a followup post from Rick, you can use %Duration% in a String Builder DR attribute with Value Type set to <Anything> in order to produce a time span (i.e., formatted like dd:hh:mm:ss). This is the same as what is produced by the Duration property of the EF.
For further details/discussion, please see the comments under Rick's blog.
Please comment here to let me know what you think of this.
Thanks for your time!
*Surprisingly, the old linked feedback item still exists even though the PI Square Idea was lost. ¯\_(ツ)_/¯