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 7fb41f51fabb4ba96874cabec1c50a6767846ae5..67d3b0f6dd009a97cd7c3dd15d6d9c442c1836a2 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 359248d9734b584feddbc65002d28e5acbc6dc43..34ebe8ea09f478c3071deb98fde2602a47fd91bd 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 da2f30ce038ff082eb858bf01e57c9765981718c..bc74af6768f576f301a517099b0330c7ca3002bc 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 e406b84248a0ca0013e123ccc59bf4f78b510c4e..fb7fadd284c4f1b58466c9bdec864aa22e5e1a36 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!