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.

Take object and record on new object
#1
Is my first scrip, help is very welcome:

powerin = grp.getvalue('1/1/2')
powerout = grp.getvalue('3/1/5')
COP = powerout / powerin
grp.write ('4/1/1', COP)


There should be an "IF" in. The COP should only be calculated if the powerout is bigger than 0 becouse powerout can be up to -7000W heat power and COP should be 0 in that case (is already written to a defreezing obiject by the counter itself so "-" values are to ignoere).
Reply
#2
Hi,
I'd probably do it something like this:
Tag both Powerin and powerout objects with something like COP and have the script execute if the group is triggered.

Powerin = grp.getvalue('1/1/2')
Powerout = grp.getvalue('3/1/5')
COP = Powerout / Powerin
if COP > 0 then grp.checkwrite('2/0/157', COP, 1)
end
Reply
#3
If you want to write zero when COP value is negative you can simply apply math.max:
Code:
COP = math.max(0, Powerout / Powerin)
Reply
#4
Thanks to both of you.
Reply


Forum Jump: