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
13 private List events = []
14 private List timeOfEvents = []
17 ContactSensor(String id, String label, String displayName, String contactState, String currentContact, String alarmState, String latestValue) {
20 this.displayName = displayName
21 this.contactState = contactState
22 this.currentContact = currentContact
23 this.latestValue = latestValue
24 this.alarmState = alarmState
27 def setValue(String value) {
28 println("the contact sensor with id:$id is triggered to $value!")
29 this.contactState = value
30 this.currentContact = value
31 this.latestValue = value
36 println("the contact sensor with id:$id is armed!")
37 this.alarmState = "armed"
41 println("the contact sensor with id:$id is not armed!")
42 this.alarmState = "not armed"
45 def currentValue(String deviceFeature) {
46 if (deviceFeature == "contact") {
51 def currentState(String deviceFeature) {
52 if (deviceFeature == "contact") {
57 def latestValue(String deviceFeature) {
58 if (deviceFeature == "contact") {