Changes in classes: new concept for latest value + all types of events generated...
[smartthings-infrastructure.git] / Methods / runIn.groovy
1 /////////////////////////////////////////////////////////////////////
2 ////runIn(time, func)
3 def runIn(int seconds, Closure functionToCall) {
4         if (timersFuncList.contains(functionToCall)) {
5                 timersList[timersFuncList.indexOf(functionToCall)].cancel()
6                 def task = timersList[timersFuncList.indexOf(functionToCall)].runAfter(1000*seconds*0, functionToCall)
7         } else {
8                 timersFuncList.add(functionToCall)
9                 timersList.add(new SimulatedTimer())
10                 def task = timersList[timersFuncList.indexOf(functionToCall)].runAfter(1000*seconds*0, functionToCall)
11         }
12 }
13
14 def runIn(int seconds, Closure functionToCall, LinkedHashMap metaData) {
15         runIn(seconds, functionToCall)
16 }
17
18 def runIn(int seconds, String nameOfFunction, LinkedHashMap metaData) {
19         runIn(seconds, nameOfFunction)
20 }
21
22 def runIn(int seconds, String nameOfFunction) {
23         timersFuncList.add(nameOfFunction)
24         timersList.add(new SimulatedTimer())
25         def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(seconds*1000*0) {
26                 "$nameOfFunction"()
27         }
28 }