Logic Machine Forum
1 script 200 Rooms - 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: 1 script 200 Rooms (/showthread.php?tid=3990)



1 script 200 Rooms - Stuart2000 - 12.04.2022

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)


RE: 1 script 200 Rooms - admin - 12.04.2022

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.


RE: 1 script 200 Rooms - Stuart2000 - 12.04.2022

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


RE: 1 script 200 Rooms - admin - 12.04.2022

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.


RE: 1 script 200 Rooms - Stuart2000 - 12.04.2022

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


RE: 1 script 200 Rooms - admin - 13.04.2022

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



RE: 1 script 200 Rooms - Stuart2000 - 19.04.2022

(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