3 Replies Latest reply on Jul 21, 2017 7:28 AM by StefanH

    Check if a sequence was successfully processed (PI Datalink / filter expression)


      Hi all,


      using PI Datalink I am trying to check if a sequence of steps was successfully processed. Basically it the sequence looks like this: 0, 5, 10, 20, ... , 300. Right now I am using Datalink -> compressed data -> filter expressions.


      The filter expression I am using looks like this:

      '('Tag1') =0 and NextVal('Tag1','*')=5 and NextVal('Tag1',NextEvent('Tag1','*'))=10 AND NextVal('Tag1',NextEvent('Tag1',NextEvent('Tag1','*')))=20 AND NextVal('Tag1',NextEvent('Tag1',NextEvent('Tag1',NextEvent('Tag1','*'))))=30 AND NextVal('Tag1',NextEvent('Tag1',NextEvent('Tag1',NextEvent('Tag1',NextEvent('Tag1','*')))))=40 AND NextVal('Tag1',NextEvent('Tag1',NextEvent('Tag1',NextEvent('Tag1',NextEvent('Tag1',NextEvent('Tag1','*'))))))=50 AND NextVal('Tag1',NextEvent('Tag1',NextEvent('Tag1',NextEvent('Tag1',NextEvent('Tag1',NextEvent('Tag1',NextEvent('Tag1','*')))))))=60 AND NextVal('Tag1',NextEvent('Tag1',NextEvent('Tag1',NextEvent('Tag1',NextEvent('Tag1',NextEvent('Tag1',NextEvent('Tag1',NextEvent('Tag1','*'))))))))=70 AND NextVal('Tag1',NextEvent('Tag1',NextEvent('Tag1',NextEvent('Tag1',NextEvent('Tag1',NextEvent('Tag1',NextEvent('Tag1',NextEvent('Tag1',NextEvent('Tag1','*')))))))))=80 AND NextVal('Tag1',NextEvent('Tag1',NextEvent('Tag1',NextEvent('Tag1',NextEvent('Tag1',NextEvent('Tag1',NextEvent('Tag1',NextEvent('Tag1',NextEvent('Tag1',NextEvent('Tag1','*'))))))))))=90

      It works, but if I am going to implement the whole sequence up to 300 it will become a little unhandy.


      Is there a better solution than using those nested 'NextEvent (...NextEvent(...NextEvent(........)))' functions?


      Thank you.



        • Re: Check if a sequence was successfully processed (PI Datalink / filter expression)
          Rhys Kirk

          You might be able to do it slightly different.

          Find the Start and End Times...

          - Start = FindEq('Tag1','*-7d','*',0)

          - End = FindEq('Tag1',FindEq('Tag1','*-7d','*',0),'*',300)


          Assuming you have valid times then you have found the start and end of a sequence. You could check if the Event Count and/or Total over that period matches your expectations; 61 events across the sequence, or a total of 9150. If either of those are not true then likely the sequence wasn't executed as expected. You can filter out Bad Values such as comms issues from any Interfaces.


          For example:

          =PIAdvCalcFilVal("Tag1",Sheet1!$E$1,Sheet1!$D$4,"NOT Badval('Tag1')","count","event-weighted","compressed","10m",0,1,0,"")



          =PIAdvCalcFilVal("Tag1",Sheet1!$E$1,Sheet1!$D$4,"NOT Badval('Tag1')","count","event-weighted","total","10m",0,1,0,"")


          Of course you could further validate by pulling out values where there was no increase of 5 by using Compressed Data with a filter expression using the Times you found earlier...

          ('Tag1' - PrevEvent('Tag1','*') <> 5)


          If you have values that match that then the sequence wasn't present as expected. You'll need to check for the 0 value though, something like:

          if 'Tag1' = 0 then 0 else ('Tag1' - PrevEvent('Tag1','*') <> 5)

          1 of 1 people found this helpful
          • Re: Check if a sequence was successfully processed (PI Datalink / filter expression)

            What about using a little math to help you? From your post sounds that your sequence is 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90...280, 290, 300. If we drop the 5, you have a simple AP going from 10 to 300, incrementing on a factor of 10.


            2017-07-12 10_21_28-Document1 - Word.png

            So, if indeed 4655 means that your process went all right, we just need to check if the sum is 4655 and the event count equals 32. You could have a cell like this:




            Note that I'm using y and t as time references, you should adjust it to your time window.


            Does this sound reasonable?

            1 of 1 people found this helpful