Commit #9: More classes + Extractor with Rahmadi's editions + Fixing some bugs
[smartthings-infrastructure.git] / Location / LocationVar.groovy
index 43c88cd078867f09eed4ae22cb884f4d0034871b..b2016e839d3469b898e89b256be3d66ba7873bb5 100644 (file)
@@ -7,15 +7,25 @@ class LocationVar {
        private String mode
        private List contacts
        private List phoneNumbers
+       def sendEvent
     
        private Phrase helloHome
 
-       LocationVar() {
+       LocationVar(Closure sendEvent) {
                this.modes = [[name: "home"],[name: "away"],[name: "night"]]
                this.mode = "home"
                this.helloHome = new Phrase()
                this.contactBookEnabled = 1
                this.contacts = ['AJ']
                this.phoneNumbers = [9495379373]
+               this.sendEvent = sendEvent
        }
+
+       //By Model Checker
+       def setValue(LinkedHashMap eventDataMap) {
+               def sentMode = eventDataMap['value']
+               println("The location is changed to $sentMode!")
+               this.mode = sentMode
+               sendEvent(eventDataMap)
+       }
 }