//Create a class for thermostat device package Thermostat import Timer.SimulatedTimer public class Thermostat { private String id private String label private String displayName private int temperature private int currentCoolingSetpoint private int currentHeatingSetpoint private int coolingSetpoint private int thermostatSetpoint private int heatingSetpoint private List coolingSetpointRange private List thermostatSetpointRange private List heatingSetpointRange private List supportedThermostatFanModes private List supportedThermostatModes private String thermostatOperatingState private String thermostatFanMode private String thermostatMode private String currentThermostatMode private String climateName def sendEvent def timers Thermostat(Closure sendEvent, String id, String label, String displayName, int temperature, int currentCoolingSetpoint, int currentHeatingSetpoint, int coolingSetpoint, int thermostatSetpoint, int heatingSetpoint, List coolingSetpointRange, List thermostatSetpointRange, List heatingSetpointRange, List supportedThermostatFanModes, List supportedThermostatModes, String thermostatOperatingState, String thermostatFanMode, String thermostatMode, String climateName) { this.id = id this.label = label this.sendEvent = sendEvent this.temperature = temperature this.currentCoolingSetpoint = currentCoolingSetpoint this.currentHeatingSetpoint = currentHeatingSetpoint this.coolingSetpoint = coolingSetpoint this.thermostatSetpoint = thermostatSetpoint this.heatingSetpoint = heatingSetpoint this.coolingSetpointRange = coolingSetpointRange this.thermostatSetpointRange = thermostatSetpointRange this.heatingSetpointRange = heatingSetpointRange this.supportedThermostatFanModes = supportedThermostatFanModes this.supportedThermostatModes = supportedThermostatModes this.thermostatOperatingState = thermostatOperatingState this.thermostatFanMode = thermostatFanMode this.thermostatMode = thermostatMode this.currentThermostatMode = thermostatMode this.climateName = climateName } //By Apps def setCoolingSetpoint(int coolingSetpoint) { this.coolingSetpoint = coolingSetpoint this.currentCoolingSetpoint = currentCoolingSetpoint println("Cooling set point for the thermostat with id:$id is changed to $coolingSetpoint!") } def setHeatingSetpoint(int heatingSetpoint) { this.heatingSetpoint = heatingSetpoint this.currentHeatingSetpoint = currentHeatingSetpoint println("Heating set point for the thermostat with id:$id is changed to $heatingSetpoint!") } def setSchedule() { //Not implemented yet } def setThermostatFanMode(String thermostatFanMode) { this.thermostatFanMode = thermostatFanMode println("Fan mode of the thermostat with id:$id is changed to $thermostatFanMode!") } def setThermostatMode(String thermostatMode) { this.thermostatMode = thermostatMode this.currentThermostatMode = currentThermostatMode println("Mode of the thermostat with id:$id is changed to $thermostatMode!") } def cool() { this.thermostatMode = "cool" this.currentThermostatMode = "cool" println("Mode of the thermostat with id:$id is changed to cool!") } def heat() { this.thermostatMode = "heat" this.currentThermostatMode = "heat" println("Mode of the thermostat with id:$id is changed to heat!") } def auto() { this.thermostatMode = "auto" this.currentThermostatMode = "auto" println("Mode of the thermostat with id:$id is changed to auto!") } def off() { this.thermostatMode = "off" this.currentThermostatMode = "off" println("Mode of the thermostat with id:$id is changed to off!") } def setClimate(String info, String givenClimateName) { this.climateName = givenClimateName println("Climate name of the thermostat with id:$id is changed to $givenClimateName!") } def setHold(String info1, int coolingSetpoint, int heatingSetpoint, String info2, String info3) { this.coolingSetpoint = coolingSetpoint this.currentCoolingSetpoint = currentCoolingSetpoint println("Cooling set point for the thermostat with id:$id is changed to $coolingSetpoint!") this.heatingSetpoint = heatingSetpoint this.currentHeatingSetpoint = currentHeatingSetpoint println("Heating set point for the thermostat with id:$id is changed to $heatingSetpoint!") } //By Model Checker def setValue(String value) { println("the thermostat with id:$id is $value!") this.thermostatMode = value this.currentThermostatMode = value } }