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.

TP Load
#1
Hi,

Is there any way to register TP bus load from Logic Machine?

I want to represent TP bus load in trend log.

   

Thanks
Reply
#2
This will give you a table with current statistics. Keep in mind that these values are cleared after reboot so trends might have a wrong value there.
Code:
stats = buslib.getstats()
Reply
#3
(20.01.2020, 09:28)admin Wrote: This will give you a table with current statistics. Keep in mind that these values are cleared after reboot so trends might have a wrong value there.
Code:
stats = buslib.getstats()

Thanks!

But this table doesn´t give me " TP load". How can I get/calculate it?

Thanks
Reply
#4
Try this (untested, so might not work) scheduled script, set to run every minute. Change 1/2/3 to object that will store current bus load (datatype is scale %).
Code:
key = 'bus-telegrams'
prev = storage.get(key)

stats = buslib.getstats()

if stats then
  curr = stats.tprx + stats.tprx

  if prev and prev < curr then
    delta = curr - prev

    -- convert to percent
    load = math.ceil(delta / 9 + 0.5)
    load = math.min(100, load)

    grp.update('1/2/3', load)
  end

  storage.set(key, curr)
end
Reply
#5
Hi,

i don’t think this works as prev is not existing on first run, so storage will never be created..

i think you need to change it into this “prev = storage.get(key) or 0”

BR,

Erwin
Reply
#6
Thanks, I've edited my post with corrected code
Reply
#7
Hello Admin,

I would like to ask if there is a way to have a trend log of the TP load. I have tested this script but in my case didn't update the value of the virtual object (scale datatype).
I am using firmware 20180828.

Thank you in advance
Reply
#8
Anyone got this working?
Tried it but no new values are written to the virtual object.
Reply
#9
I have done this before. Have a look at this thread for code and info:

https://forum.logicmachine.net/showthread.php?tid=2552

Please note an error in my posted script that has been corrected by admin a little down in the thread.
There are 10 kinds of people in the world; those who can read binary and those who don't  Cool
Reply


Forum Jump: