This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Object On Time
#1
Hi, looking for any possible examples or suggestion on how to implement a monitor script which will record how long an object is switched ON.
At present we have 40 objects (using a tag name of event_log) so we can define which objects to monitor.
We need to calculate usage by daily, weekly, monthly and year for each individual object. Was thinking of creating a .LP file to use to email data table to client.

Any help would be much appreciated.
Reply
#2
You can use updatetime for this..

grp.find('1/1/1').updatetime wil give you the unix timestamp that you can compare with os.time() to calculate the seconds the object has this value.

You can use storage to store this value when using event based scripts so you can fetch the value from storage from last event and then store new timestamp again.

You mentioned period usage, why not using a trend on a value and use trend.fetchone to get the usage over a set period?

https://kb.logicmachine.net/libraries/trends/
Reply
#3
You can use trends logs for this if the object does not change very often since the current value is sampled once per minute.

Assign a trend to a binary object, use Absolute value / Average mode / 1 hour resolution / 3 decimal places. The resulting trend values will show how much of time selected time period the object was in ON state (for example 0.5 = 30 minutes per hour).
Reply


Forum Jump: