//Create a class for thermostat device package Thermostat import Timer.SimulatedTimer public class Thermostats{ int deviceNumbers List thermostats def sendEvent def timers //When we have only one device private int id = 50 private String label = "thermostat" private String displayName = "thermostat" private int temperature = 66 private int currentCoolingSetpoint = 70 private int currentHeatingSetpoint = 50 private int coolingSetpoint = 70 private int thermostatSetpoint = 60 private int heatingSetpoint = 50 private coolingSetpointRange = [70, 90] private thermostatSetpointRange = [50, 70] private heatingSetpointRange = [20, 50] private supportedThermostatFanModes = ["auto", "fanCirculate", "circulate", "fanOn", "on"] private supportedThermostatModes = ["auto", "cool", "emergencyHeat", "heat", "off"] private String thermostatOperatingState = "cooling" private String thermostatFanMode = "auto" private String thermostatMode = "auto" Thermostats(Closure sendEvent, int deviceNumbers) { this.sendEvent = sendEvent this.timers = new SimulatedTimer() this.deviceNumbers = deviceNumbers this.thermostats = [] for (int i = 0;i < deviceNumbers;i++) { thermostats.add(new Thermostat(sendEvent, i+50, label+i.toString(), displayName+i.toString(), this.temperature, this.currentCoolingSetpoint, this.currentHeatingSetpoint, this.coolingSetpoint, this.thermostatSetpoint, this.heatingSetpoint, this.coolingSetpointRange, this.thermostatSetpointRange, this.heatingSetpointRange, this.supportedThermostatFanModes, this.supportedThermostatModes, this.thermostatOperatingState, this.thermostatFanMode, this.thermostatMode)) } } //Methods for closures def count(Closure Input) { thermostats.count(Input) } def size() { thermostats.size() } def each(Closure Input) { thermostats.each(Input) } //By Apps def setCoolingSetpoint(int coolingSetpoint) { thermostats*.setCoolingSetpoint(coolingSetpoint) } def setHeatingSetpoint(int heatingSetpoint) { thermostats*.setHeatingSetpoint(heatingSetpoint) } def setSchedule() { //Not implemented yet } def setThermostatFanMode(String thermostatFanMode) { thermostats*.setThermostatFanMode(thermostatFanMode) } def setThermostatMode(String thermostatMode) { thermostats*.setThermostatMode(thermostatMode) } //By Model Checker(There is no event based on thermostat?) /*def setValue(LinkedHashMap eventDataMap) { thermostats[eventDataMap["deviceId"]].setValue(eventDataMap["value"]) if (deviceNumbers == 1) this.lockState = locks[eventDataMap["deviceId"]].lockState this.currentLock = locks[eventDataMap["deviceId"]].lockState this.lockLatestValue = locks[eventDataMap["deviceId"]].lockLatestValue sendEvent(eventDataMap) }*/ def getAt(int ix) { locks[ix] } }