Commit #9: More classes + Extractor with Rahmadi's editions + Fixing some bugs
[smartthings-infrastructure.git] / Methods / runIn.groovy
index 178e16da4433a9eb92a06a826596a4e395033458..6e4bea3284d568e48e775be20a1880cf3e490cc0 100644 (file)
@@ -3,10 +3,26 @@
 def runIn(int seconds, Closure functionToCall) {
        if (timersFuncList.contains(functionToCall)) {
                timersList[timersFuncList.indexOf(functionToCall)].cancel()
-               def task = timersList[timersFuncList.indexOf(functionToCall)].runAfter(1000*seconds, functionToCall)
+               def task = timersList[timersFuncList.indexOf(functionToCall)].runAfter(1000*seconds*0, functionToCall)
        } else {
                timersFuncList.add(functionToCall)
                timersList.add(new SimulatedTimer())
-               def task = timersList[timersFuncList.indexOf(functionToCall)].runAfter(1000*seconds, functionToCall)
+               def task = timersList[timersFuncList.indexOf(functionToCall)].runAfter(1000*seconds*0, functionToCall)
+       }
+}
+
+def runIn(int seconds, Closure functionToCall, LinkedHashMap metaData) {
+       runIn(seconds, functionToCall)
+}
+
+def runIn(int seconds, String nameOfFunction, LinkedHashMap metaData) {
+       runIn(seconds, nameOfFunction)
+}
+
+def runIn(int seconds, String nameOfFunction) {
+       timersFuncList.add(nameOfFunction)
+       timersList.add(new SimulatedTimer())
+       def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(seconds*1000*0) {
+               "$nameOfFunction"()
        }
 }