Commit #9: More classes + Extractor with Rahmadi's editions + Fixing some bugs
[smartthings-infrastructure.git] / Location / LocationVar.groovy
1 //Create a class for location variable
2 package Location
3
4 class LocationVar {
5         private int contactBookEnabled
6         private def modes
7         private String mode
8         private List contacts
9         private List phoneNumbers
10         def sendEvent
11     
12         private Phrase helloHome
13
14         LocationVar(Closure sendEvent) {
15                 this.modes = [[name: "home"],[name: "away"],[name: "night"]]
16                 this.mode = "home"
17                 this.helloHome = new Phrase()
18                 this.contactBookEnabled = 1
19                 this.contacts = ['AJ']
20                 this.phoneNumbers = [9495379373]
21                 this.sendEvent = sendEvent
22         }
23
24         //By Model Checker
25         def setValue(LinkedHashMap eventDataMap) {
26                 def sentMode = eventDataMap['value']
27                 println("The location is changed to $sentMode!")
28                 this.mode = sentMode
29                 sendEvent(eventDataMap)
30         }
31 }