AnsweredAssumed Answered

Time a digital value has been in effect

Question asked by Steve Boyko Champion on Apr 28, 2016
Latest reply on May 3, 2016 by akenyon

I have a digital tag that I want to compute how long it has been in the current state.


Imagine data like this:

2016/4/28 14:34ON
2016/4/28 15:00OFF
2016/4/28 15:08ON
2016/4/28 16:00OFF
2016/4/28 16:08ON


I have this equation to try to measure how long 'tag' has been either ON or OFF.

if 'tag' = "ON" then '*'-FindNE('tag', '*', '*-2d', "ON") else '*'-FindNE('tag', '*', '*-2d', "OFF")


The problem is that the FindNE is returning the time when the tag first was not equal to the state, not the last moment.


For example, FindNE('tag', '*', '*-2d', "ON") executed at 16:17 returns 2016-04-28 16:00 when I really want it to return 2016-04-28 16:07:59.


What can I do to get the last time a value was true?


(and FindNE('tag', '*', '*-2d', "OFF") executed at 16:17 returns 2016-04-28 16:17 (current time) so it is not helpful; FindEQ(... "ON") returns the same, of course)