Seite 1 von 1

#1 timers / delay from logic

Verfasst: Mo 13. Jun 2011, 19:51
von twinkelm
Hi Filip, hi all,

one more question, if allowed ;-)

Is it possible to use DELAY or TIMER commands from the logic module? I want to create a timer based callback, and DELAY or TIMER commands would be really helpful instead of programming a timer by myself.

Something like
use abc = "TIMER.room.5s.C.LOGIC"
abc.value = "mycallback(parameter)"

If yes, do you have some sample code? I tried some variations of above, but no success ;-)

Any other options?

Have a nice evening,
Best regards,

Thomas

#2 RE: timers / delay from logic

Verfasst: Mo 13. Jun 2011, 21:31
von DOMIQ
You could use timers like below:

Code: Alles auswählen

function handler(test)
  print("This is delayed " .. test)
end

command("TIMER.test.5.C.LOGIC=handler('Hello')")

#3 RE: timers / delay from logic

Verfasst: Di 14. Jun 2011, 19:38
von twinkelm
That is an elegant solution, just what I was expecting, thanks a lot. And especially thanks for the super fast reply!

Best regards,
Thomas

#4 RE: timers / delay from logic

Verfasst: Di 14. Jun 2011, 22:38
von DOMIQ
Sorry, I just found one reason why that will not work. :blush:
Next version of the system will have it fixed. As for now command call is adding C. in front.
As a workaround until it's fixed you can add following line to the Events tab:

Code: Alles auswählen

Channel: C%.TIMER%.(.+)
Command:
Channel name: TIMER.$C1
Channel value: $D0

This will forward any data sent to C.TIMER.xxx=yyy as TIMER.xxx=yyy. You can try the same approach with delays.