package Thermostat
import Timer.SimulatedTimer
-//JPF's Verify API
-import gov.nasa.jpf.vm.Verify
-
public class Thermostats{
int deviceNumbers
List thermostats
private int latestHeatingSetPoint = 50
- Thermostats(Closure sendEvent, int deviceNumbers) {
+ Thermostats(Closure sendEvent, int deviceNumbers, boolean init) {
this.sendEvent = sendEvent
this.timers = new SimulatedTimer()
this.deviceNumbers = deviceNumbers
this.thermostats = []
- def initTemperature = Verify.getIntFromList(60, 66, 70)
- this.temperature = initTemperature
- this.currentTemperature = initTemperature
-
- def initCoolingSetpoint = Verify.getIntFromList(70, 80, 90)
- this.currentCoolingSetpoint = initCoolingSetpoint
- this.coolingSetpoint = initCoolingSetpoint
-
- def initHeatingSetpoint = Verify.getIntFromList(20, 35, 50)
- this.currentHeatingSetpoint = initHeatingSetpoint
- this.heatingSetpoint = initHeatingSetpoint
-
- def initThermostatSetpoint = Verify.getIntFromList(50, 60, 70)
- this.thermostatSetpoint = initThermostatSetpoint
-
- def initFanMode = Verify.getInt(0,4)
- if (initFanMode == 0) {
+ if (init) {
+ this.temperature = 60
+ this.currentTemperature = 60
+ this.currentCoolingSetpoint = 70
+ this.coolingSetpoint = 70
+ this.currentHeatingSetpoint = 35
+ this.heatingSetpoint = 35
+ this.thermostatSetpoint = 50
this.thermostatFanMode = "auto"
this.thermostatLatestFanMode = "auto"
- } else if (initFanMode == 1) {
- this.thermostatFanMode = "fanCirculate"
- this.thermostatLatestFanMode = "fanCirculate"
- } else if (initFanMode == 2) {
- this.thermostatFanMode = "circulate"
- this.thermostatLatestFanMode = "circulate"
- } else if (initFanMode == 3) {
- this.thermostatFanMode = "fanOn"
- this.thermostatLatestFanMode = "fanOn"
- } else {
- this.thermostatFanMode = "on"
- this.thermostatLatestFanMode = "on"
- }
-
- def initMode = Verify.getInt(0,4)
- if (initMode == 0) {
this.thermostatMode = "auto"
this.currentThermostatMode = "auto"
this.thermostatLatestMode = "auto"
- } else if (initMode == 1) {
- this.thermostatMode = "cool"
- this.currentThermostatMode = "cool"
- this.thermostatLatestMode = "cool"
- } else if (initMode == 2) {
- this.thermostatMode = "emergencyHeat"
- this.currentThermostatMode = "emergencyHeat"
- this.thermostatLatestMode = "emergencyHeat"
- } else if (initMode == 3) {
- this.thermostatMode = "heat"
- this.currentThermostatMode = "heat"
- this.thermostatLatestMode = "heat"
} else {
+ this.temperature = 66
+ this.currentTemperature = 66
+ this.currentCoolingSetpoint = 80
+ this.coolingSetpoint = 80
+ this.currentHeatingSetpoint = 50
+ this.heatingSetpoint = 50
+ this.thermostatSetpoint = 60
+ this.thermostatFanMode = "circulate"
+ this.thermostatLatestFanMode = "circulate"
this.thermostatMode = "off"
this.currentThermostatMode = "off"
- this.thermostatLatestMode = "off"
+ this.thermostatLatestMode = "off"
}
-
thermostats.add(new Thermostat(sendEvent, id, label, displayName, this.temperature, this.currentCoolingSetpoint,
this.currentHeatingSetpoint, this.coolingSetpoint, this.thermostatSetpoint, this.heatingSetpoint, this.coolingSetpointRange,
this.thermostatSetpointRange, this.heatingSetpointRange, this.supportedThermostatFanModes, this.supportedThermostatModes,
thermostats[0].heat()
}
}
-
+
def auto() {
if (thermostatMode != "auto") {
this.thermostatLatestMode = "auto"
}
}
+ def emergencyHeat() {
+ if (thermostatMode != "emergencyHeat") {
+ this.thermostatLatestMode = "emergencyHeat"
+ this.thermostatMode = "emergencyHeat"
+ this.currentThermostatMode = "emergencyHeat"
+ thermostats[0].emergencyHeat()
+ }
+ }
+
def off() {
if (thermostatMode != "off") {
this.thermostatLatestMode = "off"
this.coolingSetpoint = coolingSetpoint
this.currentHeatingSetpoint = heatingSetpoint
this.heatingSetpoint = heatingSetpoint
+ this.latestCoolingSetPoint = coolingSetpoint
+ this.latestHeatingSetPoint = heatingSetpoint
thermostats[0].setHold(info1, coolingSetpoint, heatingSetpoint, info2, info3)
}
}
}
} else if (eventDataMap["name"] == "heatingSetpoint") {
if (eventDataMap["value"].toInteger() != thermostats[0].heatingSetpoint) {
- this.latestHeatingSetpoint = eventDataMap["value"].toInteger()
+ this.latestHeatingSetPoint = eventDataMap["value"].toInteger()
this.heatingSetpoint = eventDataMap["value"].toInteger()
thermostats[0].setValue(eventDataMap["value"], "heatingSetpoint")
sendEvent(eventDataMap)
}
} else if (eventDataMap["name"] == "thermostatSetpoint") {
if (eventDataMap["value"].toInteger() != thermostats[0].thermostatSetpoint) {
- this.latestThermostatSetpoint = eventDataMap["value"].toInteger()
+ this.latestThermostatSetPoint = eventDataMap["value"].toInteger()
this.thermostatSetpoint = eventDataMap["value"].toInteger()
thermostats[0].setValue(eventDataMap["value"], "thermostatSetpoint")
sendEvent(eventDataMap)