My employer, CSE ICON, gave me the opportunity to take OSIsoft’s AF SDK training this year. While taking the training, I realized that a Custom Data Reference to count Event Frames would be a great project to test my new skills.
Why an Event Frame Counter? I encountered many OSIsoft customers, including myself, who wanted to count the number of events for an asset (Element). For example, I wanted to count the number of times a pump shut down unexpectedly which was being recorded as Event Frames. By putting this value into an Attribute, I can insert it in my Element Relative PI Vision display and monitor the number of times my pump was down for the time frame of the display.
Although the same count can be obtained using a combination of PI OLEDB Enterprise and AF Tables with a Table Lookup AF Data Reference, this Custom Data Reference cuts to the chase and directly queries the Event Frames via the AF SDK providing faster results.
One important “lesson learned” from this project was to automatically version my assembly. Otherwise, the AF Client would not use the newer DLL even after registering it using the regplugin command. I had to modify the AssemblyInfo.cs file as follows:
Then, I had to close the project and modify the *.csproj file to disable the Deterministic setting otherwise Visual Studio wouldn’t automatically version the assembly.
Here’s a screenshot of the end result inside PI System Explorer:
As you may notice, I provided the option to use Event Frame Templates or AF Categories for the search. The AF Category allows me to count Event Frames that are not using the same Template as long as the Category is applied to all of the Event Frames I want to find. I didn’t use Event Frame names as a search option because those names could be arbitrary and have very different naming patterns over time.
I also included the ability to override the client’s start and end times to enable me to count matching Event Frames within any time context I choose. For example, I can show the number of Downtime events from the past day on a PI Vision display, regardless of the start time set on the display.
After completing this project, it occurred to me that a similar approach could be used to make an Event Frame Rollup which I may tackle next.
Does anybody have any ideas to improve this?
Improvement ideas aside, if you or your company may have a use for this type of Custom Data Reference, don’t hesitate to reply to this blog requesting that we connect.