Time Since False
I've got a use case where I want to keep a running timer of how long a piece of equipment has been off. There is a tag for status: 1 = running, 0 = off. How long the unit has been off will affect how long it takes to start the unit up, so operations wants to know at a glance how long it's been since status went from 1 to 0. Any thoughts on how to do this?
My current plan: Have a calculation that writes the current timestamp to a tag whenever the status goes from 1 to 0 (using PreviousValue to check). Then a new calculation(or maybe just a new expression) that does durationsincetimestamp of the previously defined tag and outputs that to a 2nd tag. Thoughts?
8 replies
-
Hi ,
If you just used DurationSinceLastTVQ, that would output the number of milliseconds since the last value. You would want to make this a periodic calculation. If you use this function in conjunction with the Value Change frequency, it would always output 0. So maybe you run it every minute??? It would depend on how granular you want the time elapsed to be.
This would also return the amount of time it was running so you may want to build in something to ignore that time or output nothing if it is in the running state.
if([StatusTag]=0, DurationSinceLastTVQ('[StatusTag]'), NoOutput())
-
I just did a test on a different tag, it seems DurationSinceLastTVQ doesn't look at the extended value.
Shows last TVQ 6.3 hours ago:
Right now it's 1:07 PM and last real value was 6:43 AM. The extended value is 3 minutes ago and seems to be ignored. I tried both true and false in the 2nd parameter of the DurationSinceLastTVQ function and it didn't seem to matter.
-
said:
the last value would just continueI guess I misunderstood what you meant by . I thought you were talking about how Canary extends the value if it hasn't gotten one in a while. But I guess you were talking about how Canary won't store the same value two times in a row.
Either way, I'm on board now. I tried using NoOutput() to prove it to myself. It worked at first, but then it never wrote again.
Now if I can just figure out why turning on this calculation breaks SaF. (Nicklaus is looking into it)
if(PreviousValue('[Mountain Creek.%Asset%.Energy Production Status]') = 1 && [Mountain Creek.%Asset%.Energy Production Status] = 0, 'Shutdown', SetOutputQuality(NoData))