Logic Machine Forum
TP Load - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: TP Load (/showthread.php?tid=2431)



TP Load - DGrandes - 20.01.2020

Hi,

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

I want to represent TP bus load in trend log.

   

Thanks


RE: TP Load - admin - 20.01.2020

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()



RE: TP Load - DGrandes - 23.01.2020

(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


RE: TP Load - admin - 24.01.2020

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



RE: TP Load - Erwin van der Zwart - 24.01.2020

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


RE: TP Load - admin - 24.01.2020

Thanks, I've edited my post with corrected code


RE: TP Load - manos@dynamitec - 31.08.2020

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


RE: TP Load - Tokatubs - 08.02.2021

Anyone got this working?
Tried it but no new values are written to the virtual object.


RE: TP Load - Trond Hoyem - 08.02.2021

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.