86 lines
2.4 KiB
Java
86 lines
2.4 KiB
Java
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
|
|
|
import com.google.gson.annotations.SerializedName;
|
|
import java.math.BigDecimal;
|
|
import javax.persistence.Column;
|
|
import javax.persistence.Entity;
|
|
import javax.persistence.Transient;
|
|
import javax.validation.constraints.NotNull;
|
|
|
|
/** A thermostat capable of controlling cooling and heating. */
|
|
@Entity
|
|
public class Thermostat extends OutputDevice {
|
|
|
|
public enum ThermostatState {
|
|
@SerializedName("OFF")
|
|
OFF,
|
|
@SerializedName("IDLE")
|
|
IDLE,
|
|
@SerializedName("COOLING")
|
|
COOLING,
|
|
@SerializedName("HEATING")
|
|
HEATING
|
|
}
|
|
|
|
/** Temperature to be reached */
|
|
@Column @NotNull private BigDecimal targetTemperature;
|
|
|
|
/** The temperature detected by the embedded sensor */
|
|
@Column(nullable = false, precision = 4, scale = 1)
|
|
private BigDecimal internalSensorTemperature =
|
|
Sensor.TYPICAL_VALUES.get(Sensor.SensorType.TEMPERATURE);
|
|
|
|
/** State of this thermostat */
|
|
@Column @NotNull private ThermostatState state;
|
|
|
|
@Transient private BigDecimal measuredTemperature;
|
|
|
|
@Column private boolean useExternalSensors = false;
|
|
|
|
/** Creates a thermostat with a temperature sensor and its initial OFF state */
|
|
public Thermostat() {
|
|
super("thermostat");
|
|
this.state = ThermostatState.OFF;
|
|
}
|
|
|
|
public void setState(ThermostatState state) {
|
|
this.state = state;
|
|
}
|
|
|
|
public ThermostatState getState() {
|
|
return this.state;
|
|
}
|
|
|
|
public BigDecimal getTargetTemperature() {
|
|
return this.targetTemperature;
|
|
}
|
|
|
|
public BigDecimal getInternalSensorTemperature() {
|
|
return internalSensorTemperature;
|
|
}
|
|
|
|
public boolean isUseExternalSensors() {
|
|
return useExternalSensors;
|
|
}
|
|
|
|
public BigDecimal getMeasuredTemperature() {
|
|
return measuredTemperature;
|
|
}
|
|
|
|
public void setMeasuredTemperature(BigDecimal measuredTemperature) {
|
|
this.measuredTemperature = measuredTemperature;
|
|
}
|
|
|
|
public void setTargetTemperature(BigDecimal targetTemperature) {
|
|
this.targetTemperature = targetTemperature;
|
|
}
|
|
|
|
public void setInternalSensorTemperature(BigDecimal internalSensorTemperature) {
|
|
this.internalSensorTemperature = internalSensorTemperature;
|
|
}
|
|
|
|
public void setUseExternalSensors(boolean useExternalSensors) {
|
|
this.useExternalSensors = useExternalSensors;
|
|
}
|
|
}
|