Adding jpf.jar to enable the compilation of apps with the gov.nasa.jpf.vm.Verify...
[smartthings-infrastructure.git] / ContactSensor / ContactSensor.groovy
1 //Create a class for contact sensor
2 package ContactSensor
3 import Timer.SimulatedTimer
4
5 public class ContactSensor {
6         private int id
7         private String label
8         private String displayName
9         private String contactState
10         private String contactLatestValue
11
12         ContactSensor(int id, String label, String displayName, String contactState, String contactLatestValue) {
13                 this.id = id
14                 this.label = label
15                 this.displayName = displayName
16                 this.contactState = contactState
17                 this.contactLatestValue = contactLatestValue
18         }
19
20         def setValue(String value) {
21                 this.contactLatestValue = contactState
22                 println("the contact sensor with id:$id is triggered to $value!")
23                 this.contactState = value
24         }
25         
26         def currentValue(String deviceFeature) {
27                 if (deviceFeature == "contact") {
28                         return contactState
29                 }
30         }
31
32         def latestValue(String deviceFeature) {
33                 if (deviceFeature == "contact") {
34                         return contactLatestValue
35                 }
36         }
37 }