Logic Machine Forum
Equal script to FBeditor input selection switch - 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: Equal script to FBeditor input selection switch (/showthread.php?tid=3809)



Equal script to FBeditor input selection switch - ONJ - 14.01.2022

Hello

Is someone having a more simple event based script that is equal to FBeditor Input selection switch?

Code:
require('custom.fbeditor20.Select_switch')

functions_Select_switch_json_fbe_input_selection_switch_input_1 = grp.getvalue('2/4/0')
functions_Select_switch_json_fbe_input_selection_switch_input_2 = grp.getvalue('32/1/7')
functions_Select_switch_json_fbe_input_selection_switch_input_3 = grp.getvalue('32/1/6')
out = fbe_input_selection_switch(functions_Select_switch_json_fbe_input_selection_switch_input_1, functions_Select_switch_json_fbe_input_selection_switch_input_2, functions_Select_switch_json_fbe_input_selection_switch_input_3, 'fb__Setpunktvalg_A101__fbe_input_selection_switch__id')
if out ~= nil then
    grp.write('2/0/51', out)
end



RE: Equal script to FBeditor input selection switch - Daniel - 14.01.2022

Something like this should do.

TAG all input objects and select and create event script from this TAG
Code:
select = grp.getvalue('1/1/1')
input1 = grp.getvalue('1/1/2')
input2 = grp.getvalue('1/1/3')
input3 = grp.getvalue('1/1/4')
outgrp = '1/1/5'



if select == 1 then
grp.checkwrite(outgrp, input1)
elseif select == 2 then
  grp.checkwrite(outgrp, input2)
elseif select == 3 then
  grp.checkwrite(outgrp, input3) 
end



RE: Equal script to FBeditor input selection switch - ONJ - 15.01.2022

Thank you, it works very well.

Is it possible to add an delay in the script, so it waits few seconds before it runs when the select switch change state?


RE: Equal script to FBeditor input selection switch - Daniel - 17.01.2022

Adding delay in event script which is triggered by few objects is not recommended as it will run each time when change happen and each time delay will start. You may end up in situation when not correct input is selected in time.

Delay is simply added like this
-- wait for 1.5 seconds
os.sleep(1.5)