This commit is contained in:
omenem 2020-05-26 12:07:36 +02:00
parent 0046143d82
commit 5f12c0c813

View file

@ -1,7 +1,5 @@
package ch.usi.inf.sa4.sanmarinoes.smarthut.service; package ch.usi.inf.sa4.sanmarinoes.smarthut.service;
import ch.usi.inf.sa4.sanmarinoes.smarthut.models.Sensor;
import ch.usi.inf.sa4.sanmarinoes.smarthut.models.Sensor.SensorType;
import ch.usi.inf.sa4.sanmarinoes.smarthut.models.Thermostat; import ch.usi.inf.sa4.sanmarinoes.smarthut.models.Thermostat;
import ch.usi.inf.sa4.sanmarinoes.smarthut.models.ThermostatRepository; import ch.usi.inf.sa4.sanmarinoes.smarthut.models.ThermostatRepository;
import ch.usi.inf.sa4.sanmarinoes.smarthut.socket.SensorSocketEndpoint; import ch.usi.inf.sa4.sanmarinoes.smarthut.socket.SensorSocketEndpoint;
@ -40,19 +38,10 @@ public class ThermostatService {
double x; double x;
Random ran = new Random(); Random ran = new Random();
; x =
if (thermostat.getTypical() == null) { (ran.nextInt(thermostat.getTypical().intValue()) + thermostat.getErr().intValue())
BigDecimal typical = Sensor.TYPICAL_VALUES.get(SensorType.TEMPERATURE); * 0.975
+ 1;
x = (ran.nextInt(typical.intValue()) + thermostat.getErr().intValue()) * 0.975 + 1;
} else {
x =
(ran.nextInt(thermostat.getTypical().intValue())
+ thermostat.getErr().intValue())
* 0.975
+ 1;
}
updateValueForThermostat(thermostat, new BigDecimal(x)); updateValueForThermostat(thermostat, new BigDecimal(x));
} }