Logic Machine Forum
Writing to multiple objects - 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: Writing to multiple objects (/showthread.php?tid=2335)



Writing to multiple objects - christian.troen@haaland.no - 11.11.2019

Hello

Is there a way for me to write for example a "3" to several objects in one script? Se attatchment.
Let say I tag all the objects I want to adress with "Modus", and I want to write this if another object (Lets say 32/0/3) is "True".


RE: Writing to multiple objects - admin - 11.11.2019

Like this:
Code:
objs = grp.tag('my_tag')
objs:write(123)



RE: Writing to multiple objects - christian.troen@haaland.no - 20.11.2019

Why won't it write the value of the group-adress 32/1/10 to tag "Modus"?


RE: Writing to multiple objects - Daniel - 20.11.2019

This is wrong. You should add tag 'Modus' to object 32/1/10 and instead of the address in your script put a value you want to write. If you want to write to single object then use single command.


RE: Writing to multiple objects - christian.troen@haaland.no - 20.11.2019

But the value i want to write comes from group-adress 32/1/10

I am trying to write the value that 32/1/10 holds to all objects with the tag "Modus".

The value 32/1/10 is being written from a PLC via BACnet.


RE: Writing to multiple objects - Daniel - 20.11.2019

Do it like this
Code:
value = grp.getvalue('32/1/10')
objs = grp.tag('Modus')
objs:write(value)



RE: Writing to multiple objects - admin - 20.11.2019

Then you need an event script, not a resident script:
Code:
value = event.getvalue()
objs = grp.tag('Modus')
objs:write(value)



RE: Writing to multiple objects - Kai-Roger - 20.11.2019

christian.troen@haaland.no

Hi.
 
In the heading you write that you want all object with tag "Modus", to recive the value of "3" if (32/0/3) is True. If this is still what you want, then you can use this as Event-based script.
This sends the value "3" to all "Modus" taged objects, but only when 32/0/3 gets True.
 
Code:
value = event.getvalue()
objs = grp.tag('Modus')
if value == true then objs:write(3)
end

 
BR
Kai-Roger