I'm looking for a solution which enables me to build, for every element, an attribute with a value that at any given time corresponds to the number of open Event Frames associated with that element.
Thanks in advance!
Thanks, we've solved the problem via a table lookup.
Only open event frames, eh? First thought I have is that the actual number is quite dynamic at any given instance, so I'm thinking a custom data reference is needed. I'd make the DR have a config setting for Open, Closed, or Any, just to be flexible. That's at least how I get values fed into an attribute.
The other side of the coin is creating said attributes on each element. Could do this in AFBuilder or via code. Or if everything is templated, it might be easier just to add to the element templates.
Sounds simple enough. Except ... what to do with the time context of a DR. If you want to find currently open event frames, the DR would be invoked with a simple GetValues() call (no time context). What would you expect to be the correct value if you changed the time context to 3 months ago? I know what I would expect to see but that would be different from what you want.
Can you tell me why you need this information? Also, what client tools would you use to view this information?
My question is linked to an OSI-Esri integration effort. We would like to show a map of a wind park, colored red and green, depending on whether there are any open ("active") event frames associated with a given turbine. The red/green status in the map would come from our PI Geo setup, but as far as I understand this approach requires an attribute that counts the number of active event frames.
Do you want to do this via writing your own code? If so, you can search for open event frames and then just count them up.
Attached is a screen shot of the Event Frame search dialog box in PI System Explorer. As you can see, there's a check box for "In Progress".
Hope this helps.
AF Product Manager
I'm also looking for a solution which enables me to configure an Element attribute that correspond to the TOTAL number of Event Frames associated with the element.
Can you explain the solution you implement via a table lookup a little bit ?
Thanks in Advance,
We are making a table link to the AF Server using PIOLEDBENT as provider. The query would look like this:
SELECT Count(*) as NoOfEvents
SELECT ef.Name, ef.StartTime, ef.EndTime, ef.PrimaryReferencedElementID, eft.Name as eventframename
FROM AFDatabase.EventFrame.EventFrame ef
INNER JOIN AFDatabase.EventFrame.EventFrameTemplate eft ON ef.EventFrameTemplateID = eft.ID
WHERE EndTime is Null --< BETWEEN '' AND '*'
ORDER BY StartTime
-- TOP clause is propagated to the AF backend only for single table queries;
-- thus, to optimize the execution, we separate the event frame search
-- from the subsequent attribute query
INNER JOIN AFDatabase.Asset.ElementHierarchy eh ON eh.ElementID = t.PrimaryReferencedElementID and eh.Level=0 and eh.Name = @TurbineID
OPTION (FORCE ORDER)
In order to get the total number of EF you should change the WHERE clause.
To get the attribute we make an attribute template where we substitute the parameter @TurbineID with the element name.
Thank you very much, it works perfectly !
Thanks for sharing. I would like to point out some specifics of this query.
1. The element in question has to be the primary referenced element
2. The element has to be at the root level.
3. To get total number of EFs, you can remove the WHERE clause
4. The EF has to be templated (untemplated open EFs will not be counted)
Retrieving data ...