Logic Machine Forum
While Do loop with delay - 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: While Do loop with delay (/showthread.php?tid=3277)



While Do loop with delay - Kai-Roger - 02.04.2021

Hello.

Since the code below floods my KNX bus, i want to have a delay between each loop. The os.sleep in the code below does not work. Can anyone explaine how i can delay this loop?


while Variable1 == true
do
  Variable2 :write(true)
  os.sleep (10)
end


While Do loop with delay - Tim - 02.04.2021

Use sleep(1) with no space between sleep and ().




Sent from my IN2023 using Tapatalk


RE: While Do loop with delay - Kai-Roger - 02.04.2021

(02.04.2021, 11:49)Tim Wrote: Use  sleep(1) with no space between sleep and ().




Sent from my IN2023 using Tapatalk

Hi.

No that did not work. But i see there is a difference between having no os.sleep and having a os.sleep with any number in the parentheses.
Even if i write os.sleep(10000000), the scrips still writes several telegrams to the bus each second.


While Do loop with delay - Tim - 02.04.2021

What's triggering the script?
All event scripts can run in parallel as many times as they are triggered.
Also it's not os.sleep() just sleep()


Sent from my IN2023 using Tapatalk


RE: While Do loop with delay - admin - 02.04.2021

You probably have several instances of the same event script running. Please post the whole script code.


RE: While Do loop with delay - Kai-Roger - 02.04.2021

(02.04.2021, 12:19)Tim Wrote: What's triggering the script?
All event scripts can run in parallel as many times as they are triggered.
Also it's not os.sleep() just sleep()


Sent from my IN2023 using Tapatalk

Hi.

I just made a new small test script, and now i see it is working as it should. I think i had made an event loop that retriggered the script constantly. Thanks for replies. I will see how i can change the way of triggering the script.


While Do loop with delay - Tim - 02.04.2021

No problem

Sent from my IN2023 using Tapatalk


RE: While Do loop with delay - Kai-Roger - 02.04.2021

Is there a difference between os.sleep and sleep? I see os.sleep is used by Erwin in the forum.


While Do loop with delay - Tim - 02.04.2021

I doubt it, probably just aliases.
Tested them now, they seem to work the same way.

Sent from my IN2023 using Tapatalk


RE: While Do loop with delay - Kai-Roger - 02.04.2021

(02.04.2021, 12:37)Tim Wrote: I doubt it, probably just aliases.
Tested them now, they seem to work the same way.

Sent from my IN2023 using Tapatalk

Ok. Thanks.