Event Frame duration - easy way in AF2.6 or higher

Idea created by Roger Palmen on Nov 18, 2015

    In the past it was not that easy to get the Event Frame duration in an EF attribute. One approach involved a workaround on a PI Point: https://pisquare.osisoft.com/thread/2896?q=Event%20Frame%20duration


    Since the introduction of the String Builder DataReference, this is easy. Create the following attributes on your Event Frame (template):

    • StartTime:
      • Value Type: DateTime
      • Data Refernce: String Builder
      • Configstring: "%UtcStartTime%";
    • EndTime:
      • Value Type: DateTime
      • Data Refernce: String Builder
      • Configstring: "%UtcEndTime%";
    • Duration:
      • Value Type: Int32
      • Data Refernce: Formula
      • Default UOM: second
      • Configstring: A=StartTime;B=EndTime;[B-A]


    Be aware about:

    • DST: i used UTC to ensure we have real seconds, and not clock seconds. Not sure how this is handled by the Formula DR, and too lazy to experiment.
    • This relies on the implicit data type conversion from DateTime to integer in the StartTime / EndTime attributes. PSE will reset the value type anytime it can to String.


    String builder was introduced in PI AF 2014R2 / 2.6.1.

    Release notes: https://techsupport.osisoft.com/Viewer/File/5B5DA121-7D36-4CEE-9EC2-BB71C9AD7FE7


    Still i would prefer to have the duration as a substitution parameter to avoid the need to build things like this.