private String smoke = "clear"
private String currentSmokeValue = "clear"
private String smokeLatestValue = "clear"
+ private String carbonMonoxide = "clear"
+ private String currentCarbonMonoxideValue = "clear"
+ private String carbonMonoxideLatestValue = "clear"
+ private int battery = 50
+ private int batteryLatestValue = 50
SmokeDetectors(Closure sendEvent, int deviceNumbers) {
this.deviceNumbers = deviceNumbers
this.smokeDetectors = []
+<<<<<<< HEAD
+ def initBattery = Verify.getIntFromList(30, 50, 70)
+ this.battery = initBattery
+ this.batteryLatestValue = initBattery
+
+ def initSmoke = Verify.getInt(0,2)
+ if (initSmoke == 0) {
+=======
/*def init = Verify.getInt(0,2)
if (init == 0) {
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
this.currentSmokeValue = "clear"
this.smokeLatestValue = "clear"
- } else if (init == 1) {
+ } else if (initSmoke == 1) {
this.currentSmokeValue = "detected"
this.smokeLatestValue = "detected"
} else {
this.currentSmokeValue = "tested"
this.smokeLatestValue = "tested"
+<<<<<<< HEAD
+ }
+
+ def initCarbonMonoxide = Verify.getInt(0,2)
+ if (initCarbonMonoxide == 0) {
+ this.currentCarbonMonoxideValue = "clear"
+ this.carbonMonoxideLatestValue = "clear"
+ } else if (initCarbonMonoxide == 1) {
+ this.currentCarbonMonoxideValue = "detected"
+ this.carbonMonoxideLatestValue = "detected"
+ } else {
+ this.currentCarbonMonoxideValue = "tested"
+ this.carbonMonoxideLatestValue = "tested"
+ }
+ smokeDetectors.add(new SmokeDetector(id, label, displayName, this.currentSmokeValue, this.smokeLatestValue, this.currentCarbonMonoxideValue,
+ this.carbonMonoxideLatestValue, this.battery))
+=======
}*/
smokeDetectors.add(new SmokeDetector(id, label, displayName, this.currentSmokeValue, this.smokeLatestValue))
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
}
//By Model Checker
def setValue(LinkedHashMap eventDataMap) {
- if (eventDataMap["value"] != smokeDetectors[0].currentSmokeValue) {
- smokeDetectors[0].setValue(eventDataMap["value"])
- this.smokeLatestValue = smokeDetectors[0].smokeLatestValue
- this.smoke = smokeDetectors[0].currentSmokeValue
- this.currentSmokeValue = smokeDetectors[0].currentSmokeValue
- sendEvent(eventDataMap)
+ if (eventDataMap["name"].contains("smoke")) {
+ if (eventDataMap["value"] != smokeDetectors[0].currentSmokeValue) {
+ this.smokeLatestValue = eventDataMap["value"]
+ this.smoke = eventDataMap["value"]
+ this.currentSmokeValue = eventDataMap["value"]
+ smokeDetectors[0].setValue(eventDataMap["value"], eventDataMap["name"])
+ sendEvent(eventDataMap)
+ }
+ } else if (eventDataMap["name"].contains("carbonMonoxide")) {
+ if (eventDataMap["value"] != smokeDetectors[0].currentCarbonMonoxideValue) {
+ this.carbonMonoxideLatestValue = eventDataMap["value"]
+ this.carbonMonoxide = eventDataMap["value"]
+ this.currentCarbonMonoxideValue = eventDataMap["value"]
+ smokeDetectors[0].setValue(eventDataMap["value"], eventDataMap["name"])
+ sendEvent(eventDataMap)
+ }
+ } else if (eventDataMap["name"].contains("battery")) {
+ if (eventDataMap["value"].toInteger() != smokeDetectors[0].battery) {
+ this.battery = eventDataMap["value"].toInteger()
+ this.batteryLatestValue = eventDataMap["value"].toInteger()
+ smokeDetectors[0].setValue(eventDataMap["value"], eventDataMap["name"])
+ sendEvent(eventDataMap)
+ }
}
}
def find(Closure Input) {
smokeDetectors.find(Input)
}
+ def sort(Closure Input) {
+ smokeDetectors.sort(Input)
+ }
def collect(Closure Input) {
smokeDetectors.collect(Input)
}