From: amiraj Date: Sat, 29 Jun 2019 00:23:58 +0000 (-0700) Subject: Commit #3 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=9c64ca1c3ecff2587ffd66a336249cbdfbf926d3;p=smartthings-infrastructure.git Commit #3 --- diff --git a/Extractor/ExtractedObjects.groovy b/Extractor/ExtractedObjects.groovy index 7fb41f5..67d3b0f 100644 --- a/Extractor/ExtractedObjects.groovy +++ b/Extractor/ExtractedObjects.groovy @@ -1,13 +1,13 @@ //Global Object for class switch! -@Field def switchesoff = new switching(1) +@Field def switchesoff = new switching(3) //Global Object for class switch! -@Field def switcheson = new switching(1) +@Field def switcheson = new switching(3) //Global Object for class lock! -@Field def lock1 = new locking(1) +@Field def lock1 = new locking(2) //Global variable for mode! -@Field def newMode = "away" +@Field def newMode = "home" //Global variable for number! -@Field def waitfor = 5 +@Field def waitfor = 10 //Global Object for functions in subscribe method! @Field def installed = this.&installed //Global Object for functions in subscribe method! diff --git a/Switch/switches.groovy b/Switch/switches.groovy index 359248d..34ebe8e 100644 --- a/Switch/switches.groovy +++ b/Switch/switches.groovy @@ -6,8 +6,10 @@ public class switches { private String displayName private String currentSwitch private String switchLatestValue + def Timers switches(int id, String displayName, String currentSwitch, String switchLatestValue) { + this.Timers = new Timer() this.id = id this.displayName = displayName this.currentSwitch = currentSwitch @@ -21,10 +23,11 @@ public class switches { } def on(LinkedHashMap LHM) { - sleep(LHM["delay"]) - println("the switch with id:$id is on!") - this.switchLatestValue = this.currentSwitch - this.currentSwitch = "on" + def task = Timers.runAfter(LHM["delay"]) { + println("the switch with id:$id is on!") + this.switchLatestValue = this.currentSwitch + this.currentSwitch = "on" + } } def off() { @@ -34,10 +37,11 @@ public class switches { } def off(LinkedHashMap LHM) { - sleep(LHM["delay"]) - println("the switch with id:$id is off!") - this.switchLatestValue = this.currentSwitch - this.currentSwitch = "off" + def task = Timers.runAfter(LHM["delay"]) { + println("the switch with id:$id is off!") + this.switchLatestValue = this.currentSwitch + this.currentSwitch = "off" + } } def currentValue(String S) { diff --git a/Switch/switching.groovy b/Switch/switching.groovy index da2f30c..bc74af6 100644 --- a/Switch/switching.groovy +++ b/Switch/switching.groovy @@ -4,8 +4,10 @@ package Switch public class switching{ List switches int count + def Timers switching(int count) { + this.Timers = new Timer() this.count = count if (count == 1) { switches = [new switches(0, "switch0", "off", "off")] @@ -26,11 +28,13 @@ public class switching{ def on(LinkedHashMap LHM) { if (count == 1) { - sleep(LHM["delay"]) - switches[0].on() + def task = Timers.runAfter(LHM["delay"]) { + switches[0].on() + } } else { - sleep(LHM["delay"]) - switches*.on() + def task = Timers.runAfter(LHM["delay"]) { + switches*.on() + } } } @@ -44,11 +48,13 @@ public class switching{ def off(LinkedHashMap LHM) { if (count == 1) { - sleep(LHM["delay"]) - switches[0].off() + def task = Timers.runAfter(LHM["delay"]) { + switches[0].off() + } } else { - sleep(LHM["delay"]) - switches*.off() + def task = Timers.runAfter(LHM["delay"]) { + switches*.off() + } } } diff --git a/main.groovy b/main.groovy index e406b84..fb7fadd 100644 --- a/main.groovy +++ b/main.groovy @@ -41,15 +41,15 @@ import appTouch.Touch //ExtractedObjects //Global Object for class switch! -@Field def switchesoff = new switching(1) +@Field def switchesoff = new switching(3) //Global Object for class switch! -@Field def switcheson = new switching(1) +@Field def switcheson = new switching(3) //Global Object for class lock! -@Field def lock1 = new locking(1) +@Field def lock1 = new locking(2) //Global variable for mode! -@Field def newMode = "away" +@Field def newMode = "home" //Global variable for number! -@Field def waitfor = 5 +@Field def waitfor = 10 //Global Object for functions in subscribe method! @Field def installed = this.&installed //Global Object for functions in subscribe method!