1 //Create a class for contact sensor
3 import Timer.SimulatedTimer
5 public class ContactSensor {
8 private String displayName
9 private String contactState
10 private String currentContact
11 private String latestValue
12 private String alarmState
15 ContactSensor(String id, String label, String displayName, String contactState, String currentContact, String alarmState, String latestValue) {
18 this.displayName = displayName
19 this.contactState = contactState
20 this.currentContact = currentContact
21 this.latestValue = latestValue
22 this.alarmState = alarmState
25 def setValue(String value) {
26 this.latestValue = contactState
27 println("the contact sensor with id:$id is triggered to $value!")
28 this.contactState = value
29 this.currentContact = value
33 println("the contact sensor with id:$id is armed!")
34 this.alarmState = "armed"
38 println("the contact sensor with id:$id is not armed!")
39 this.alarmState = "not armed"
42 def currentValue(String deviceFeature) {
43 if (deviceFeature == "contact") {
48 def latestValue(String deviceFeature) {
49 if (deviceFeature == "contact") {