Commit #3
authoramiraj <amiraj.95@uci.edu>
Sat, 29 Jun 2019 00:23:58 +0000 (17:23 -0700)
committeramiraj <amiraj.95@uci.edu>
Sat, 29 Jun 2019 00:23:58 +0000 (17:23 -0700)
Extractor/ExtractedObjects.groovy
Switch/switches.groovy
Switch/switching.groovy
main.groovy

index 7fb41f5..67d3b0f 100644 (file)
@@ -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!
index 359248d..34ebe8e 100644 (file)
@@ -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) {
index da2f30c..bc74af6 100644 (file)
@@ -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()
+                       }
                }
        }
 
index e406b84..fb7fadd 100644 (file)
@@ -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!