EepA50701 implements EepReceive { private boolean updatePirStatus(EspRadioTelegram telegram) { boolean isUpdate = false; Boolean oldPirStatus = pirStatus.boolValue(); this.sensorData.update(telegram.getPayload()); Boolean newPirStatus = pirStatus.boolValue(); isUpdate = ((oldPirStatus == null && newPirStatus != null) || (oldPirStatus != null && newPirStatus != null && newPirStatus != oldPirStatus)); return isUpdate; } EepA50701(DeviceID deviceID, String commandString); @Override EepType getType(); @Override boolean update(EspRadioTelegram telegram); @Override void updateSensor(Sensor sensor); static final String EEP_A50701_PIRS_DATA_FIELD_NAME; static final int EEP_A50701_PIRS_OFFSET; static final int EEP_A50701_PIRS_SIZE; static final String EEP_A50701_PIRS_OFF_DESC; static final int EEP_A50701_PIRS_OFF_DATA_RANGE_MIN; static final int EEP_A50701_PIRS_OFF_DATA_RANGE_MAX; static final String EEP_A50701_PIRS_ON_DESC; static final int EEP_A50701_PIRS_ON_DATA_RANGE_MIN; static final int EEP_A50701_PIRS_ON_DATA_RANGE_MAX; }
@Test public void testUpdatePirStatus() throws Exception { EepA50701 eep = (EepA50701)EepType.lookup("A5-07-01").createEep( deviceID, Constants.PIR_STATUS_COMMAND, null ); Assert.assertNull(eep.getPirStatus()); int rawPirStatusValue = 0; boolean isTeachIn = false; EspRadioTelegram telegram = createRadioTelegramESP3( deviceID, rawPirStatusValue, isTeachIn ); Boolean isUpdate = eep.update(telegram); Assert.assertTrue(isUpdate); Assert.assertFalse(eep.getPirStatus()); rawPirStatusValue = 127; isTeachIn = false; telegram = createRadioTelegramESP3( deviceID, rawPirStatusValue, isTeachIn ); isUpdate = eep.update(telegram); Assert.assertFalse(isUpdate); Assert.assertFalse(eep.getPirStatus()); rawPirStatusValue = 128; isTeachIn = true; telegram = createRadioTelegramESP2( deviceID, rawPirStatusValue, isTeachIn ); isUpdate = eep.update(telegram); Assert.assertFalse(isUpdate); Assert.assertFalse(eep.getPirStatus()); rawPirStatusValue = 128; isTeachIn = false; telegram = createRadioTelegramESP2( deviceID, rawPirStatusValue, isTeachIn ); isUpdate = eep.update(telegram); Assert.assertTrue(isUpdate); Assert.assertTrue(eep.getPirStatus()); rawPirStatusValue = 255; isTeachIn = false; telegram = createRadioTelegramESP2( deviceID, rawPirStatusValue, isTeachIn ); isUpdate = eep.update(telegram); Assert.assertFalse(isUpdate); Assert.assertTrue(eep.getPirStatus()); }