From: amiraj Date: Tue, 2 Jul 2019 22:02:20 +0000 (-0700) Subject: Commit #5 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=smartthings-infrastructure.git;a=commitdiff_plain;h=06efdd47fde0474c8f1a909ff28558b127157ae1 Commit #5 --- diff --git a/ContactSensor/Contacting.groovy b/ContactSensor/Contacting.groovy index 1fa6c47..022b44a 100644 --- a/ContactSensor/Contacting.groovy +++ b/ContactSensor/Contacting.groovy @@ -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")] } } diff --git a/Extractor/extractedObjects.groovy b/Extractor/extractedObjects.groovy index ccd3d3a..c978614 100644 --- a/Extractor/extractedObjects.groovy +++ b/Extractor/extractedObjects.groovy @@ -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! diff --git a/Lock/Locking.groovy b/Lock/Locking.groovy index 20b0a11..9d43ae0 100644 --- a/Lock/Locking.groovy +++ b/Lock/Locking.groovy @@ -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")] } } diff --git a/Lock/Locks.groovy b/Lock/Locks.groovy index 752f509..42e0fc4 100644 --- a/Lock/Locks.groovy +++ b/Lock/Locks.groovy @@ -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 diff --git a/Switch/Switches.groovy b/Switch/Switches.groovy index dcf981f..65cac12 100644 --- a/Switch/Switches.groovy +++ b/Switch/Switches.groovy @@ -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 diff --git a/Switch/Switching.groovy b/Switch/Switching.groovy index 1364d41..c9a0efb 100644 --- a/Switch/Switching.groovy +++ b/Switch/Switching.groovy @@ -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 diff --git a/main.groovy b/main.groovy index ac7aa3b..2e249bd 100644 --- a/main.groovy +++ b/main.groovy @@ -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!