Commit #5
authoramiraj <amiraj.95@uci.edu>
Tue, 2 Jul 2019 22:02:20 +0000 (15:02 -0700)
committeramiraj <amiraj.95@uci.edu>
Tue, 2 Jul 2019 22:02:20 +0000 (15:02 -0700)
ContactSensor/Contacting.groovy
Extractor/extractedObjects.groovy
Lock/Locking.groovy
Lock/Locks.groovy
Switch/Switches.groovy
Switch/Switching.groovy
main.groovy

index 1fa6c47..022b44a 100644 (file)
@@ -5,17 +5,18 @@ public class Contacting{
        private int deviceNumbers
        private List contacts
        def sendEvent
-       
-       
-       
+               
        Contacting(Closure sendEvent, int deviceNumbers) {
                this.sendEvent = sendEvent              
                this.deviceNumbers = deviceNumbers
                this.contacts = []
-               int id = 0
-               for (int i = 0;i < deviceNumbers;i++) {
-                       contacts.add(new Contacts(id, "contact"+id.toString(), "closed", "closed"))//By default closed
-                       id = id+1
+               if (deviceNumbers == 1) {
+                       contacts = [new Contacts(sendEvent, 0, "contact0", "closed", "closed")]
+               } else if (deviceNumbers == 2) {
+                       contacts = [new Contacts(sendEvent, 0, "contact0", "closed", "closed"), new Contacts(sendEvent, 1, "contact1", "closed", "closed")]
+               } else if (deviceNumbers == 3) {
+                       contacts = [new Contacts(sendEvent, 0, "contact0", "closed", "closed"), new Contacts(sendEvent, 1, "contact1", "closed", "closed")
+                                  ,new Contacts(sendEvent, 2, "contact2", "closed", "closed")]
                }
        }
 
index ccd3d3a..c978614 100644 (file)
@@ -3,7 +3,7 @@
 //Global Object for class switch!
 @Field def switcheson = new Switching(sendEvent, 1)
 //Global Object for class lock!
-@Field def lock1 = new Locking(sendEvent, 2)
+@Field def lock1 = new Locking(sendEvent, 1)
 //Global variable for mode!
 @Field def newMode = "away"
 //Global variable for number!
index 20b0a11..9d43ae0 100644 (file)
@@ -10,12 +10,16 @@ public class Locking{
        Locking(Closure sendEvent, int deviceNumbers) {
                this.sendEvent = sendEvent
                this.timers = new Timer()
+               timers.cancel() //Timer is ready to use
                this.deviceNumbers = deviceNumbers
                this.locks = []
-               int id = 0
-               for (int i = 0;i < deviceNumbers;i++) {
-                       locks.add(new Locks(sendEvent, id, "lock"+id, "locked", "locked"))//By default locked
-                       id = id+1
+               if (deviceNumbers == 1) {
+                       locks = [new Locks(sendEvent, 0, "lock0", "locked", "locked")]
+               } else if (deviceNumbers == 2) {
+                       locks = [new Locks(sendEvent, 0, "lock0", "locked", "locked"), new Locks(sendEvent, 1, "lock1", "locked", "locked")]
+               } else if (deviceNumbers == 3) {
+                       locks = [new Locks(sendEvent, 0, "lock0", "locked", "locked"), new Locks(sendEvent, 1, "lock1", "locked", "locked")
+                               ,new Locks(sendEvent, 2, "lock2", "locked", "locked")]
                }
        }
 
index 752f509..42e0fc4 100644 (file)
@@ -17,6 +17,7 @@ public class Locks {
                this.lockCurrentValue = lockCurrentValue
                this.lockLatestValue = lockLatestValue
                this.timers = new Timer()
+               timers.cancel() //Timer is ready to use
        }
 
        //By Apps
index dcf981f..65cac12 100644 (file)
@@ -13,6 +13,7 @@ public class Switches {
        Switches(Closure sendEvent, int id, String displayName, String switchCurrentValue, String switchLatestValue) {
                this.sendEvent = sendEvent
                this.timers = new Timer()
+               timers.cancel() //Timer is ready to use
                this.id = id
                this.displayName = displayName
                this.switchCurrentValue = switchCurrentValue
index 1364d41..c9a0efb 100644 (file)
@@ -10,13 +10,18 @@ public class Switching{
        Switching(Closure sendEvent, int deviceNumbers) {
                this.sendEvent = sendEvent
                this.timers = new Timer()
+               timers.cancel() //Timer is ready to use
                this.deviceNumbers = deviceNumbers
                this.switches = []
-               int id = 0
-               for (int i = 0;i < deviceNumbers;i++) {
-                       switches.add(new Switches(sendEvent, id, "switch"+id.toString(), "off", "off"))
-                       id = id+1
+               if (deviceNumbers == 1) {
+                       switches = [new Switches(sendEvent, 0, "switch0", "off", "off")]
+               } else if (deviceNumbers == 2) {
+                       switches = [new Switches(sendEvent, 0, "switch0", "off", "off"), new Switches(sendEvent, 1, "switch1", "off", "off")]
+               } else if (deviceNumbers == 3) {
+                       switches = [new Switches(sendEvent, 0, "switch0", "off", "off"), new Switches(sendEvent, 1, "switch1", "off", "off")
+                                  ,new Switches(sendEvent, 2, "switch2", "off", "off")]
                }
+               println("salam")
        }
 
        //By Apps
index ac7aa3b..2e249bd 100644 (file)
@@ -48,7 +48,7 @@ import Event.Event
 //Global Object for class switch!
 @Field def switcheson = new Switching(sendEvent, 1)
 //Global Object for class lock!
-@Field def lock1 = new Locking(sendEvent, 2)
+@Field def lock1 = new Locking(sendEvent, 1)
 //Global variable for mode!
 @Field def newMode = "away"
 //Global variable for number!