I spent thirty minutes today playing with a few of the newest PI Analytics Service features surrounding Event Frames. What sounded the most interesting was the the ability to write outputs at an Event Frame end time. Prior to this feature, common posts on PI Square were people attempting to perform an hourly month to date calculation to retrieve the total amount of product lost during time excursion events. Using analysis, this wasn't a very pleasant experience. This new feature will reduce most of the duplicate logic that OSIsoft's customers and partners have been writing in order to trend Event Frame attributes, perform simple roll-ups, aggregate event data and more.
In my first attempt to understand the feature, I just wrote the value of an attribute back to the PI Data Historian and to the created Event Frame. Note, writing back to PI (data historian) is optional and the UI makes it easy to create attributes on both the event frame template and element. Next, I changed my EF triggering condition and performed a recalculation. The values were deleted from the PI Server and different values at different new times were written. Very easy to do this, and maybe too easy!
For round two, I decided to perform an actual calculation instead of just echoing my second favorite tag: CDT158. I used the new PE like function "EventFrame" to obtain the Event Frame start and end times. I had to test "Duration" to see what was returned. It turned out to be the number of seconds within the duration. From here, I constructed an equation that calculates the average of an element attribute from two minutes after the event frame start until the event frame end time.
If you can't read it, here is the expression: if EventFrame("Duration") > 120 Then TagAvg('attribute1',EventFrame("StartTime") +120, Eventframe("EndTime")) else TagAvg('attribute1', EventFrame("StartTime"), EventFrame("EndTime"))
In the above equation, I check that the Event Frame duration is more than two minutes before adding two minutes (120 seconds) to the start time. If it is less than 2 minutes, I just calculate the average using the event start time and end time. I think it is important to note that the analysis runs on the element and not the Event Frame. This means if you modify the Event Frame start/end times via any tool/SDK, the output attribute will not automatically update.
Next, I played around with the ability to name the Event Frame based on an attribute value. It appears that the name is evaluated at the start of the event frame. I can see this being very useful in adding more descriptive names to Event Frames. Sample syntax to enter for the Naming Pattern is as follow: %@Attribute_Name%.
Overall, I'm very happy and impressed with the ability of analysis service to perform perform calculations on Event Frames! It took me a few minutes to figure out what was returned by the functions and the behavior of the services; but once I figured it out, I had no issues.
Tomorrow, if I have time I want to understand the automatic recalculation feature. In general, recalculations are quite complex and the PI System Explorer documentation didn't answer my questions on automatic recalculation. I feel that this is a topic worth understanding in full as recalculations can have many interesting consequences and unexpected behaviors.