Time a bool is true!!
V23 User
I have a machine status, if true, the machine is productive, false if not productive. I want to periodically calculate the percentage of the current day the bool is true or machine is "productive." I started with the following to find how many hours the machine has been productive
DurationInStateNonZero('[machine_productive_bool]', '1D', 'Day')/1000/60/60
but it errors with
"Error evaluating expression: Exception occurred while getting queue value."
Any help on this would be much appreciated!! Thank you in advance
4 replies
-
Hi ,
I think it is looking into the future using the third optional start time parameter 'Day'. If you don't include that, it will look at the last day up until now.
Are you just calculating this once a day or do you want to do it throughout the day? If it's just once a day, just use
DurationInStateNonZero('[machine_productive_bool]', '1D')/1000/60/60
If you want to calculate it throughout the day, you can use
ResettingAnchoredInterval('DurationInStateNonZero', '[machine_productive_bool]', '1d')
The second option can be calculated periodically throughout the day and then will reset after 1d and start a new interval. The first option would only calculate once a day.
-
Hey Steve! This is exactly what I needed, the second option. The idea is to have a continuous idea of todays machine availability at a glance. In order to get a percentage of today's already past time the bool has been true, is there a function to get the time that has already passed today? "Amount of time bool is true"/"Amount of time today has passed"
-
Hey All, I answered my own question: I took the above function and added durationsincedatetime and it worked great! see below example....
ResettingAnchoredInterval('DurationInStateNonZero', '[machine_productive_bool]', '1d')/(DurationSinceDateTime('day'))*100
This provides me with a percentage machine is productive today (since midnight) Hope this helps someone else!
Thanks again Steve!