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.

Multi OR port
#1
Hallo,
I need create a OR port with about 90-100 input. I tagged each input in objects window. It's possible create the OR gate useing the tag of the group address?

I wrote the follow example that don't function:


if (true == grp.tag('LuciScalaA')) then
  grp.write('12/1/21', true)
else
  os.sleep(100)
  grp.write('12/1/21', false)
end

See attached

Best regards

Attached Files Thumbnail(s)
   
Reply
#2
Hi,

grp.tag will always return a table with objects so this is never true or false..

Here are the needed scripts for logical and/or by TAG:
Code:
-- Logical OR port by tagged objects
tagname = 'OR_LOGIC'
output = '1/1/1'
for i, object in ipairs(grp.tag(tagname)) do
  if object.data then
    grp.checkwrite(output, true, 1)
    return
 end
end
grp.checkwrite(output, false, 1)

Code:
-- Logical AND port by tagged objects
tagname = 'AND_LOGIC'
output = '1/1/1'  
for i, object in ipairs(grp.tag(tagname)) do
 if not object.data then
   grp.checkwrite(output, false, 1)
   return
 end
end
grp.checkwrite(output, true, 1)
BR,

Erwin
Reply
#3
Hi
Here is universal script
https://forum.logicmachine.net/showthrea...18#pid1518
BR
------------------------------
Ctrl+F5
Reply
#4
What script is more effective and takes less time and less resources to execute? Something like this:

Quote:value = grp.getvalue('1address')
value2 = grp.getvalue('2address)
value3 = grp.getvalue('3address')

output = 'outputaddress'

if(value or value2 or value3 == true) then
  grp.write(output, true)
else 
  grp.write(output, false)
end
 Or this one:

Quote:tagname = 'OR_LOGIC'
output = 'output_address'
for i, object in ipairs(grp.tag(tagname)) do
if object.data then
grp.checkwrite(output, true, 1)
return
end
end
grp.checkwrite(output, false, 1)

I have many lights and many rooms and if I turn on ALL lights at the same time there are a lot of scripts executing at once, so I need the most perfomance-effective solution.
Reply
#5
The best for performance is this
https://forum.logicmachine.net/showthrea...18#pid1518
------------------------------
Ctrl+F5
Reply
#6
Well you see I have a problem with this one. As I have A LOT lights, it feels that if many lights are turning on/off the script starts to "hang" and doesn't update any addresses any more and then it needs to be disabled/enabled to work again. I've tried upgrading LM to newest version but it didn't help so I'm kind of stuck with those 2 scripts.
Reply
#7
If you have a lot of lights then this script is much better as it is just one PID, The other creates a lots of them with each telegram sent. Can you send me your project to PM to check why it is happening, It could be some bug or other reason.
------------------------------
Ctrl+F5
Reply
#8
Hi,

Are you using a os.sleep in your script?

If you do that in a event script you might have several scripts running in paralel..

BR,

Erwin
Reply


Forum Jump: