Logic Machine Forum
Stop execution of KNX secuence - 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: Stop execution of KNX secuence (/showthread.php?tid=972)



Stop execution of KNX secuence - ivanposada - 31.08.2017

Hello from Spain,

i have a script with a secuence in KNX, using "os.sleep(t)" to do a delay between telegrams. It works well, but in any case, the secuence duration is 4-5 minutes.
¿How can i do to stop the secuence in the middle of execution? Any "break" or "exit" or "kill" exception to stop the script.


Code:
os.sleep(23)
  grp.write('0/0/39', 0)
  grp.write('0/0/53', 0)
  grp.write('0/0/56', 0)
  grp.write('0/0/58', 0)
  grp.write('0/0/40', 0)
  grp.write('0/0/62', 0)
  grp.write('0/0/47', 0)
  grp.write('0/0/41', 1)
  grp.write('0/0/7', 1)
  grp.write('0/5/8', 100)
  grp.write('0/0/29', 1)
  grp.write('0/0/33', 1)
  os.sleep(14)
  grp.write('0/0/41', 0)
  grp.write('0/0/7', 0)
  grp.write('0/0/29', 0)
  grp.write('0/0/33', 0)
  grp.write('0/0/38', 1)
  grp.write('0/0/59', 1)
  grp.write('0/0/60', 1)
  grp.write('0/0/61', 1)
  os.sleep(39)
  grp.write('0/5/8', 0)
  grp.write('0/0/38', 0)
  grp.write('0/0/59', 0)
  grp.write('0/0/60', 0)
  grp.write('0/0/61', 0)
  grp.write('0/0/29', 1)


Thanks!

Iván.


RE: Stop execution of KNX secuence - admin - 31.08.2017

You can use an object or a storage variable as a status, then check this status after each sleep:
Code:
os.sleep(23)
if not grp.getvalue('1/1/1') then
  return
end



RE: Stop execution of KNX secuence - ivanposada - 05.09.2017

(31.08.2017, 11:29)admin Wrote: You can use an object or a storage variable as a status, then check this status after each sleep:
Code:
os.sleep(23)
if not grp.getvalue('1/1/1') then
 return
end

Thanks admin!!

It works! The inconvenience is that i have to copy that a lot of times in the code, but it works.

Ivan.


RE: Stop execution of KNX secuence - buuuudzik - 05.09.2017

You can prepare some table with values and then iterate over it with some loop.This is only a little inspirationWink

Code:
pause = 14 -- seconds
statusGA = '1/1/1'

sequence = {
{grp = '1/2/3', val = 1 },
{grp = '1/2/6', val = 100 }
}

for _, scene in ipairs(sequence) do
grp.write(scene.grp, scene.val)
if grp.getvalue(statusGA) == false then break end
os.sleep(pause)
end



RE: Stop execution of KNX secuence - Erwin van der Zwart - 05.09.2017

Hi Buuuudzik,

Check your sample (:

statusGA is a address (string) and not a value so will never be false (bool)

BR,

Erwin


RE: Stop execution of KNX secuence - buuuudzik - 06.09.2017

Thanks, yes I've updated the above scriptWink