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.

1 script 200 Rooms
#1
Hi, I have this script, but 200 rooms. What will the script look like when it is based on finding room number. 1 script for all my rooms?

Instead of 200 scripts. The room number is 1.203 in this case.

XXXXX_XZXX - XXX.XXX-SQXXX-room_Setpoint_XXX this line can be different..

433011_XZ30 - 360.004-SQ401-1.203_Setpoint_mp4

Comp_max_input1 = grp.getvalue('1.203-SX601_Cooling_C')
Comp_max_input2 = grp.getvalue('1.203-RB601_SQ_C')
Comp_max_output = '433011_XZ30 - 360.004-SQ401-1.203_Setpoint_mp4'
maxout = math.max(Comp_max_input1,Comp_max_input2)
grp.checkwrite(Comp_max_output, maxout)
Reply
#2
Do you follow a specific addressing scheme where other addresses can be calculated from the source address?
Something like 1/1/203 - input1, 1/2/203 - input2, 3/2/203 - output.
Reply
#3
(12.04.2022, 08:55)admin Wrote: Do you follow a specific addressing scheme where other addresses can be calculated from the source address?
Something like 1/1/203 - input1, 1/2/203 - input2, 3/2/203 - output.

No.
Reply
#4
Is there some rule how other names can be found from the source name? Another option is to tag objects with multiple tags (something like "input", "room_1_203") and find other objects using these tag. Or you can create a lookup table with all addresses that the script will use to find input/output objects.
Reply
#5
(12.04.2022, 09:17)admin Wrote: Is there some rule how other names can be found from the source name? Another option is to tag objects with multiple tags (something like "input", "room_1_203") and find other objects using these tag. Or you can create a lookup table with all addresses that the script will use to find input/output objects.

No this is what I have. What is the simplies way to do this with what i got?
Reply
#6
Here's a solution with a lookup table. All input objects should have a common tag to which an event script is attached. Fill the addrlist table with group addresses as needed. Each entry is a single room (input 1/2 + output).

The script finds the second input based on the group address that triggered the script and writes the maximum between two inputs to the output object.
Code:
addrlist = {
  {
    input1 = '1/1/1',
    input2 = '1/1/2',
    output = '1/1/3',
  },
  {
    input1 = '1/1/4',
    input2 = '1/1/5',
    output = '1/1/6',
  },
  {
    input1 = '1/2/4',
    input2 = '1/2/5',
    output = '1/2/6',
  },
}

for _, addrs in ipairs(addrlist) do
  if event.dst == addrs.input1 then
    altinput = addrs.input2
    output = addrs.output
    break
  elseif event.dst == addrs.input2 then
    altinput = addrs.input1
    output = addrs.output
    break
  end
end

if altinput and output then
  value1 = event.getvalue()
  value2 = grp.getvalue(altinput)

  grp.checkwrite(output, math.max(value1, value2))
end
Reply
#7
(13.04.2022, 11:21)admin Wrote: Here's a solution with a lookup table. All input objects should have a common tag to which an event script is attached. Fill the addrlist table with group addresses as needed. Each entry is a single room (input 1/2 + output).

The script finds the second input based on the group address that triggered the script and writes the maximum between two inputs to the output object.
Code:
addrlist = {
  {
    input1 = '1/1/1',
    input2 = '1/1/2',
    output = '1/1/3',
  },
  {
    input1 = '1/1/4',
    input2 = '1/1/5',
    output = '1/1/6',
  },
  {
    input1 = '1/2/4',
    input2 = '1/2/5',
    output = '1/2/6',
  },
}

for _, addrs in ipairs(addrlist) do
  if event.dst == addrs.input1 then
    altinput = addrs.input2
    output = addrs.output
    break
  elseif event.dst == addrs.input2 then
    altinput = addrs.input1
    output = addrs.output
    break
  end
end

if altinput and output then
  value1 = event.getvalue()
  value2 = grp.getvalue(altinput)

  grp.checkwrite(output, math.max(value1, value2))
end
TNX
Reply


Forum Jump: