xgon
(Alexandre Gonçalves)
January 3, 2022, 3:50pm
1
Hello,
I need to reschedule a timer, but since it’s used in a Procedure, it would be more confortable to declare it anonymously, like this:
createTimer(now, [ |
if (some_condition) {
reschedule(now.plusSeconds(1))
} else {
do_something()
}
])
Obviously the above code fails on the reschedule(now.plusSeconds(1))
statement. Is there any way to achieve this?
Thanks.
rossko57
(Rossko57)
January 3, 2022, 4:25pm
2
No. You have to tell it what to reschedule, somehow.
The usual trick where there may be a number of similar timers is to store the handles in a ‘global’ Map,indexed by related Item name or similar.
Example-
To start with, I’d try something like this:
put all your windows that you want a notification for in a group
items file:
Group:Contact:OR(OPEN,CLOSED) allWindows
Contact DGBadFenster (allWindows)
Contact DGFlurFenster (allWindows)
...
persist that group with, for example, mapdb
mapdb.persist:
allWindows* : strategy = everyChange,restoreOnStartup
add 2 map-files to your transform folder.
windowShortName.map:
DGBadFenster=DG Bad
DGFlurFenster=DG Flur
...
...
...
windowLongName.map:
D…
xgon
(Alexandre Gonçalves)
January 4, 2022, 3:35am
3
I ended up using a List to reference all the timers inside the Procedure.