AnsweredAssumed Answered

Need PI AF Analysis to count number of daily alarms

Question asked by gfmalek on Oct 15, 2020
Latest reply on Oct 22, 2020 by ChrisPIGuy

I was recently asked to create a PI AF Analysis that counts the number of alarm events for a given day.  This corresponds to events in which a tag's value goes from below 0.3 to above 0.3.   I needed to apply this analysis to 40 different tags.  For each tag, I implemented the following one-line of code:


ArrayLength(FilterData(MapData(MapData(RecordedValues('\\server\tagname','t-1d', 't'),if $val > 0.3 then 1 else 0),DeltaValue($val,True)),$val = 1))


The RecordedValues function pulls in the tag's compressed values, then the first MapData call translates each array value to zero or 1, based on whether the value is below or above 0.3.  The second MapData call uses the DeltaValue function to calculate the difference between each 0-1 value.  DeltaValues of "1" correspond to events where the tag value goes from below 0.3 to above 0.3.  The FilterData function filters this array to retrieve only 1's, and the ArrayLength function counts the 1's only, which is the daily event count.


This equation works just fine for all 40 tags, but I have been asked to amend the analysis to count consecutive events with brief intermittence as one event.  For example, if a tag goes above 0.3, then falls back below 0.3 for two minutes, before exceeding 0.3 once more, this should only count as one event instead of two.  It is the exclusion of this brief intermittence that I am struggling with.


I know this result can generally be retrieved by adding functions like TimeGT or LastValue into the FilterData conditions, but calling these functions on every value within the array seems very computationally expensive and time-consuming, without even considering duplication of this method for all 40 tags.


Thanks for any help you can provide.