EepA50401 implements EepReceive { private boolean updateTemperature(EspRadioTelegram telegram) { boolean isUpdate = false; Double oldTempValue = temperature.rangeValue(); if(isTemperatureAvailable()) { this.sensorData.update(telegram.getPayload()); Double newTempValue = temperature.rangeValue(); isUpdate = ((oldTempValue == null && newTempValue != null) || (oldTempValue != null && newTempValue != null && newTempValue.doubleValue() != oldTempValue.doubleValue())); } return isUpdate; } EepA50401(DeviceID deviceID, String commandString); @Override String toString(); @Override EepType getType(); @Override boolean update(EspRadioTelegram telegram); @Override void updateSensor(Sensor sensor); static final int EEP_A50401_TSN_OFFSET; static final int EEP_A50401_TSN_SIZE; static final String EEP_A50401_TSN_AVAILABLE_DESC; static final int EEP_A50401_TSN_AVAILABLE_VALUE; static final String EEP_A50401_TSN_NOT_AVAILABLE_DESC; static final int EEP_A50401_TSN_NOT_AVAILABLE_VALUE; static final int EEP_A50401_FRACTIONAL_DIGITS; }
@Test public void testUpdateTemperature() throws Exception { EepA50401 eep = (EepA50401)EepType.lookup("A5-04-01").createEep( deviceID, Constants.TEMPERATURE_STATUS_COMMAND, null ); Assert.assertNull(eep.getTemperature()); int rawTemperatureValue = 0; boolean isTemperatureAvailable = true; boolean isTeachIn = false; EspRadioTelegram telegram = createRadioTelegramESP3( deviceID, rawTemperatureValue, 0, isTemperatureAvailable, isTeachIn ); Boolean isUpdate = eep.update(telegram); Assert.assertTrue(isUpdate); Assert.assertEquals(Double.valueOf(0), eep.getTemperature()); rawTemperatureValue = 0; telegram = createRadioTelegramESP3( deviceID, rawTemperatureValue, 0, isTemperatureAvailable, isTeachIn ); isUpdate = eep.update(telegram); Assert.assertFalse(isUpdate); Assert.assertEquals(Double.valueOf(0), eep.getTemperature()); rawTemperatureValue = 250; telegram = createRadioTelegramESP3( deviceID, rawTemperatureValue, 0, isTemperatureAvailable, isTeachIn ); isUpdate = eep.update(telegram); Assert.assertTrue(isUpdate); Assert.assertEquals(Double.valueOf(40), eep.getTemperature()); isTemperatureAvailable = false; rawTemperatureValue = 100; telegram = createRadioTelegramESP2( deviceID, rawTemperatureValue, 0, isTemperatureAvailable, isTeachIn ); isUpdate = eep.update(telegram); Assert.assertFalse(isUpdate); Assert.assertEquals(Double.valueOf(40), eep.getTemperature()); isTemperatureAvailable = true; rawTemperatureValue = 0; telegram = createRadioTelegramESP2( deviceID, rawTemperatureValue, 0, isTemperatureAvailable, isTeachIn ); isUpdate = eep.update(telegram); Assert.assertTrue(isUpdate); Assert.assertEquals(Double.valueOf(0), eep.getTemperature()); rawTemperatureValue = 251; telegram = createRadioTelegramESP2( deviceID, rawTemperatureValue, 0, isTemperatureAvailable, isTeachIn ); isUpdate = eep.update(telegram); Assert.assertFalse(isUpdate); Assert.assertEquals(Double.valueOf(0), eep.getTemperature()); }