AnsweredAssumed Answered

PrevVal with Time Gaps

Question asked by dcunningham on Jan 25, 2016
Latest reply on Jan 26, 2016 by dcunningham

Hi Everyone,

 

I'm using the PrevVal function in PI DataLink to filter out repeated values for a tag that I'm working with (I want to know when the state changes). The function I'm using works very well for what I'm looking for. Here's what it looks like:

 

PrevVal('SWITCH.STATE','*')<>'SWITCH.STATE'

 

The only issue I have with this is that sometimes the installation is turned off, causing a stop in the flow of data. So what can happen is if the state is the same after the installation is turned on, the second instance is filtered out. For example:

 

The raw data is like this:

 

15-Jan-2016 15:43:29     1

15-Jan-2016 16:50:15     1

15-Jan-2016 16:50:30     1

15-Jan-2016 16:50:45     1

15-Jan-2016 16:51:00     1

15-Jan-2016 16:51:15     0

 

With the filter I get this:

 

15-Jan-2016 15:43:29     1

15-Jan-2016 16:51:15     0

 

Which can be deceptive because it could suggest that the state was 1 from 15:43:29 up until 16:50:30, which is not true.

 

Is there a way to have the function above recognize gaps in data (say for five minutes or greater)? So that the raw data above with the filter applied would return:

 

15-Jan-2016 15:43:29     1

15-Jan-2016 16:50:15     1

15-Jan-2016 16:51:15     0

 

Thanks in advance for any help you can provide.

 

Dan

Outcomes