EepD50001 implements EepReceive { @Override public boolean update(EspRadioTelegram telegram) { if(!deviceID.equals(telegram.getSenderID())) { return false; } if(!eepType.isValidRadioTelegramRORG(telegram)) { log.warn( "Discarded received radio telegram from device " + "with ID {0} because of a configuration error: " + "Command for device with ID {0} has been configured " + "with an invalid EEP {1} for this device.", deviceID, getType() ); return false; } learnData.update(telegram.getPayload()); if(isLearnButtonPressed()) { return false; } Boolean oldContactState = contact.boolValue(); contactData.update(telegram.getPayload()); Boolean newContactState = contact.boolValue(); return ((oldContactState == null && newContactState != null) || (oldContactState != null && newContactState != null && oldContactState.booleanValue() != newContactState.booleanValue())); } EepD50001(DeviceID deviceID, String commandString); @Override String toString(); @Override EepType getType(); @Override boolean update(EspRadioTelegram telegram); @Override void updateSensor(Sensor sensor); static final String EEP_D50001_LRN_NAME; static final String EEP_D50001_LRN_PRESSED_DESC; static final int EEP_D50001_LRN_PRESSED_VALUE; static final String EEP_D50001_LRN_NOT_PRESSED_DESC; static final int EEP_D50001_LRN_NOT_PRESSED_VALUE; static final String EEP_D50001_CO_NAME; static final int EEP_D50001_CO_OFFSET; static final int EEP_D50001_CO_SIZE; static final String EEP_D50001_CO_OPEN_DESC; static final int EEP_D50001_CO_OPEN_VALUE; static final String EEP_D50001_CO_CLOSED_DESC; static final int EEP_D50001_CO_CLOSED_VALUE; }
@Test public void testUpdate() throws Exception { EepD50001 eep = (EepD50001)EepType.lookup("D5-00-01").createEep( deviceID, Constants.CONTACT_STATUS_COMMAND, null ); Assert.assertNull(eep.isClosed()); boolean isLearn = false; boolean isContactClosed = true; Boolean isUpdate = eep.update(createRadioTelegramESP3(deviceID, isContactClosed, isLearn)); Assert.assertTrue(isUpdate); Assert.assertTrue(eep.isClosed()); isUpdate = eep.update(createRadioTelegramESP3(deviceID, isContactClosed, isLearn)); Assert.assertFalse(isUpdate); Assert.assertTrue(eep.isClosed()); isContactClosed = false; isUpdate = eep.update(createRadioTelegramESP2(deviceID, isContactClosed, isLearn)); Assert.assertTrue(isUpdate); Assert.assertFalse(eep.isClosed()); }