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.

Counter and Trend
#3
(06.06.2016, 13:19)admin Wrote: You can create an event script which increases object value on each run. Trend will automatically show how many events happened during selected period. You can also get trend data from Lua to display certain stats: http://openrb.com/docs/

Code:
value = grp.getvalue('1/1/1')
grp.update('1/1/1', value + 1)

Tip: Use a 12. 4 byte unsigned integer object to have maximum size to count without exponent and also use:

value_reed = event.getvalue()
if value_reed == true then
    value = grp.getvalue('1/1/1')
     if value >= (256*256*256*256) then -- max of 12. 4 byte unsigned integer object
        grp.update('1/1/1', 0) -- reset object value to zero to start counting from start again
     else
        grp.update('1/1/1', value + 1)
   end
end

This makes the counting only happening on opening of the reed otherwise the count will happen on opening and closing, and will make the object value jump to 0 when max of object is reached.

BR,

Erwin
Reply


Messages In This Thread
Counter and Trend - by managementboy - 06.06.2016, 12:29
RE: Counter and Trend - by admin - 06.06.2016, 13:19
RE: Counter and Trend - by Erwin van der Zwart - 06.06.2016, 19:26
RE: Counter and Trend - by admin - 07.06.2016, 06:17

Forum Jump: