Decreasing the number of required events for each device by mapping them to one singl...
[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         functionToCall()
13 }
14
15 def runIn(int seconds, Closure functionToCall, LinkedHashMap metaData) {
16         runIn(seconds, functionToCall)
17 }
18
19 def runIn(int seconds, String nameOfFunction, LinkedHashMap metaData) {
20         runIn(seconds, nameOfFunction)
21 }
22
23 def runIn(int seconds, String nameOfFunction) {
24         /*timersFuncList.add(nameOfFunction)
25         timersList.add(new SimulatedTimer())
26         def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(seconds*1000*0) {
27                 "$nameOfFunction"()
28         }*/
29         "$nameOfFunction"()
30 }