package CarbonMonoxideDetector
import Timer.SimulatedTimer
-//JPF's Verify API
-import gov.nasa.jpf.vm.Verify
-
public class CarbonMonoxideDetectors {
private int deviceNumbers
private List carbonMonoxideDetectors
private String carbonMonoxideLatestValue = "clear"
- CarbonMonoxideDetectors(Closure sendEvent, int deviceNumbers) {
+ CarbonMonoxideDetectors(Closure sendEvent, int deviceNumbers, boolean init) {
this.sendEvent = sendEvent
this.deviceNumbers = deviceNumbers
this.carbonMonoxideDetectors = []
- /*def init = Verify.getInt(0,2)
- if (init == 0) {
+ if (init) {
this.carbonMonoxide = "clear"
+ this.currentCarbonMonoxideValue = "clear"
this.carbonMonoxideLatestValue = "clear"
} else if (init == 1) {
this.carbonMonoxide = "detected"
+ this.currentCarbonMonoxideValue = "detected"
this.carbonMonoxideLatestValue = "detected"
- } else {
- this.carbonMonoxide = "tested"
- this.carbonMonoxideLatestValue = "tested"
- }*/
+ }
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"])
- this.carbonMonoxideLatestValue = carbonMonoxideDetectors[0].carbonMonoxideLatestValue
- this.carbonMonoxide = carbonMonoxideDetectors[0].currentCarbonMonoxideValue
- this.currentCarbonMonoxideValue = carbonMonoxideDetectors[0].currentCarbonMonoxideValue
sendEvent(eventDataMap)
}
}
def find(Closure Input) {
carbonMonoxideDetectors.find(Input)
}
+ def sort(Closure Input) {
+ carbonMonoxideDetectors.sort(Input)
+ }
def collect(Closure Input) {
carbonMonoxideDetectors.collect(Input)
}