fix
This commit is contained in:
parent
e006ff83d2
commit
7eeab40ff9
4 changed files with 9 additions and 6 deletions
|
@ -49,7 +49,7 @@ public class Sensor extends InputDevice implements RangeTriggerable {
|
|||
private BigDecimal err = new BigDecimal(1);
|
||||
|
||||
@Column(nullable = false, precision = 11, scale = 1)
|
||||
private BigDecimal typical = new BigDecimal(17);
|
||||
private BigDecimal typical = BigDecimal.valueOf(17);
|
||||
/** The type of this sensor */
|
||||
@Column(nullable = false)
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
|
|
|
@ -84,7 +84,7 @@ public class Thermostat extends Switchable implements BooleanTriggerable {
|
|||
private BigDecimal err = new BigDecimal(1);
|
||||
|
||||
@Column(nullable = false, precision = 11, scale = 1)
|
||||
private BigDecimal typical = new BigDecimal(17.0);
|
||||
private BigDecimal typical = BigDecimal.valueOf(17);
|
||||
|
||||
/** Creates a thermostat with a temperature sensor and its initial OFF state */
|
||||
public Thermostat() {
|
||||
|
|
|
@ -19,14 +19,16 @@ public class SensorService {
|
|||
|
||||
@Autowired private SensorSocketEndpoint endpoint;
|
||||
|
||||
private Random ran = new Random();
|
||||
|
||||
private void randomJitter(Sensor sensor) {
|
||||
|
||||
double x;
|
||||
Random ran = new Random();
|
||||
|
||||
x =
|
||||
(ran.nextInt(sensor.getTypical().intValue()) + sensor.getError().intValue()) * 0.975
|
||||
+ 1;
|
||||
updateValueFromSensor(sensor, new BigDecimal(x));
|
||||
updateValueFromSensor(sensor, BigDecimal.valueOf(x));
|
||||
}
|
||||
|
||||
public void sensorFakeUpdate() {
|
||||
|
|
|
@ -22,6 +22,8 @@ public class ThermostatService {
|
|||
|
||||
private final ThermostatRepository thermostatRepository;
|
||||
|
||||
private Random ran = new Random();
|
||||
|
||||
@Autowired
|
||||
public ThermostatService(
|
||||
SensorSocketEndpoint endpoint,
|
||||
|
@ -37,12 +39,11 @@ public class ThermostatService {
|
|||
private void randomJitter(Thermostat thermostat) {
|
||||
|
||||
double x;
|
||||
Random ran = new Random();
|
||||
x =
|
||||
(ran.nextInt(thermostat.getTypical().intValue()) + thermostat.getErr().intValue())
|
||||
* 0.975
|
||||
+ 1;
|
||||
updateValueForThermostat(thermostat, new BigDecimal(x));
|
||||
updateValueForThermostat(thermostat, BigDecimal.valueOf(x));
|
||||
}
|
||||
|
||||
private void updateValueForThermostat(Thermostat thermostat, BigDecimal value) {
|
||||
|
|
Loading…
Reference in a new issue