- CarbonMonoxideDetectors(Closure sendEvent, int deviceNumbers, boolean init) {
- this.sendEvent = sendEvent
- this.deviceNumbers = deviceNumbers
- this.carbonMonoxideDetectors = []
-
- if (init) {
- this.carbonMonoxide = "clear"
- this.currentCarbonMonoxideValue = "clear"
- this.carbonMonoxideLatestValue = "clear"
- } else if (init == 1) {
- this.carbonMonoxide = "detected"
- this.currentCarbonMonoxideValue = "detected"
- this.carbonMonoxideLatestValue = "detected"
- }
- carbonMonoxideDetectors.add(new CarbonMonoxideDetector(id, label, displayName, this.currentCarbonMonoxideValue, this.carbonMonoxideLatestValue))
- }
-
- //By Model Checker
- def setValue(LinkedHashMap eventDataMap) {
- if (eventDataMap["value"] != carbonMonoxideDetectors[0].currentCarbonMonoxideValue) {
- this.carbonMonoxideLatestValue = eventDataMap["value"]
- this.carbonMonoxide = eventDataMap["value"]
- this.currentCarbonMonoxideValue = eventDataMap["value"]
- carbonMonoxideDetectors[0].setValue(eventDataMap["value"])
- sendEvent(eventDataMap)
- }
- }
-
- //Methods for closures
- def count(Closure Input) {
- carbonMonoxideDetectors.count(Input)
- }
- def size() {
- carbonMonoxideDetectors.size()
- }
- def each(Closure Input) {
- carbonMonoxideDetectors.each(Input)
- }
- def find(Closure Input) {
- carbonMonoxideDetectors.find(Input)
- }
- def sort(Closure Input) {
- carbonMonoxideDetectors.sort(Input)
- }
- def collect(Closure Input) {
- carbonMonoxideDetectors.collect(Input)
- }