EepA53808 implements EepTransceive { @Override public void send(RadioInterface radioInterface) throws ConfigurationException, ConnectionException { if(parameter == null) { return; } if(command == Command.DIM) { int dimValue = parameter.getValue().intValue(); byte[] payload = new byte[4]; payload[0] = (byte)(EEP_A53808_COM_DIM_COMMAND & 0xFF); payload[1] = (byte)(dimValue & 0xFF); payload[2] = 0; if(dimValue == 0) { payload[3] = (byte)(((EEP_A53808_SW_OFF_VALUE << 0) | (EEP_A53808_EDIMR_RELATIVE_VALUE << 2) | (EEP_DATA_TELEGRAM << 3)) & 0xFF); } else { payload[3] = (byte)(((EEP_A53808_SW_ON_VALUE << 0) | (EEP_A53808_EDIMR_RELATIVE_VALUE << 2) | (EEP_DATA_TELEGRAM << 3)) & 0xFF); } radioInterface.sendRadio(eepType.getRORG(), deviceID, payload, (byte)0x00); } else if(command == Command.DIM_ELTAKO) { int dimValue = parameter.getValue().intValue(); byte[] payload = new byte[4]; payload[0] = (byte)(EEP_A53808_COM_DIM_COMMAND & 0xFF); payload[1] = (byte)(dimValue & 0xFF); payload[2] = 0; if(dimValue == 0) { payload[3] = (byte)(((EEP_A53808_SW_OFF_VALUE << 0) | (EEP_A53808_EDIMR_ABSOLUTE_VALUE << 2) | (EEP_DATA_TELEGRAM << 3)) & 0xFF); } else { payload[3] = (byte)(((EEP_A53808_SW_ON_VALUE << 0) | (EEP_A53808_EDIMR_ABSOLUTE_VALUE << 2) | (EEP_DATA_TELEGRAM << 3)) & 0xFF); } radioInterface.sendRadio(eepType.getRORG(), deviceID, payload, (byte)0x00); } } EepA53808(DeviceID deviceID, String commandString, CommandParameter parameter); @Override String toString(); @Override void send(RadioInterface radioInterface); @Override EepType getType(); @Override boolean update(EspRadioTelegram telegram); @Override void updateSensor(Sensor sensor); static final int EEP_A53808_EDIM_FRACTIONAL_DIGITS; static final String DIM_SPEED_STATUS_COMMAND; static final String DIM_RANGE_STATUS_COMMAND; static final String DIM_VALUE_STORE_STATUS_COMMAND; static final String SWITCH_STATUS_COMMAND; }
@Test public void testDimCommandWithValueParameter() throws Exception { int dimValue = 100; CommandParameter parameter = new CommandParameter(String.valueOf(dimValue)); EepA53808 eep = (EepA53808)EepType.lookup("A5-38-08").createEep( deviceID, DIM_COMMAND , parameter ); Assert.assertNotNull(eep); int commandID = 2; int dimSpeed = 0; boolean isTeachIn = false; boolean isAbsoluteRange = false; boolean isStoreDimValue = false; boolean isSwitchOn = true; EspRadioTelegram telegram = createRadioTelegramESP3( deviceID, commandID, dimValue, dimSpeed, isAbsoluteRange, isStoreDimValue, isSwitchOn, isTeachIn ); TestRadioInterface radioInterface = new TestRadioInterface(); eep.send(radioInterface); Assert.assertArrayEquals(telegram.getPayload(), radioInterface.payload); Assert.assertEquals(telegram.getRORG(), radioInterface.rorg); Assert.assertEquals(telegram.getSenderID(), radioInterface.deviceID); dimValue = 0; isSwitchOn = false; parameter = new CommandParameter(String.valueOf(dimValue)); eep = (EepA53808)EepType.lookup("A5-38-08").createEep( deviceID, DIM_COMMAND , parameter ); telegram = createRadioTelegramESP3( deviceID, commandID, dimValue, dimSpeed, isAbsoluteRange, isStoreDimValue, isSwitchOn, isTeachIn ); radioInterface = new TestRadioInterface(); eep.send(radioInterface); Assert.assertArrayEquals(telegram.getPayload(), radioInterface.payload); Assert.assertEquals(telegram.getRORG(), radioInterface.rorg); Assert.assertEquals(telegram.getSenderID(), radioInterface.deviceID); }
@Test public void testDimCommandWithStaticDimValue() throws Exception { int dimValue = 100; EepA53808 eep = (EepA53808)EepType.lookup("A5-38-08").createEep( deviceID, DIM_COMMAND + " " + String.valueOf(dimValue) , null ); Assert.assertNotNull(eep); int commandID = 2; int dimSpeed = 0; boolean isTeachIn = false; boolean isAbsoluteRange = false; boolean isStoreDimValue = false; boolean isSwitchOn = true; EspRadioTelegram telegram = createRadioTelegramESP3( deviceID, commandID, dimValue, dimSpeed, isAbsoluteRange, isStoreDimValue, isSwitchOn, isTeachIn ); TestRadioInterface radioInterface = new TestRadioInterface(); eep.send(radioInterface); Assert.assertArrayEquals(telegram.getPayload(), radioInterface.payload); Assert.assertEquals(telegram.getRORG(), radioInterface.rorg); Assert.assertEquals(telegram.getSenderID(), radioInterface.deviceID); dimValue = 0; isSwitchOn = false; eep = (EepA53808)EepType.lookup("A5-38-08").createEep( deviceID, DIM_COMMAND + " " + String.valueOf(dimValue) , null ); telegram = createRadioTelegramESP3( deviceID, commandID, dimValue, dimSpeed, isAbsoluteRange, isStoreDimValue, isSwitchOn, isTeachIn ); radioInterface = new TestRadioInterface(); eep.send(radioInterface); Assert.assertArrayEquals(telegram.getPayload(), radioInterface.payload); Assert.assertEquals(telegram.getRORG(), radioInterface.rorg); Assert.assertEquals(telegram.getSenderID(), radioInterface.deviceID); }
@Test public void testDimCommandWithValueParameterEltako() throws Exception { int dimValue = 100; CommandParameter parameter = new CommandParameter(String.valueOf(dimValue)); EepA53808 eep = (EepA53808)EepType.lookup("A5-38-08").createEep( deviceID, DIM_COMMAND_ELTAKO , parameter ); Assert.assertNotNull(eep); int commandID = 2; int dimSpeed = 0; boolean isTeachIn = false; boolean isAbsoluteRange = true; boolean isStoreDimValue = false; boolean isSwitchOn = true; EspRadioTelegram telegram = createRadioTelegramESP3( deviceID, commandID, dimValue, dimSpeed, isAbsoluteRange, isStoreDimValue, isSwitchOn, isTeachIn ); TestRadioInterface radioInterface = new TestRadioInterface(); eep.send(radioInterface); Assert.assertArrayEquals(telegram.getPayload(), radioInterface.payload); Assert.assertEquals(telegram.getRORG(), radioInterface.rorg); Assert.assertEquals(telegram.getSenderID(), radioInterface.deviceID); dimValue = 0; isSwitchOn = false; parameter = new CommandParameter(String.valueOf(dimValue)); eep = (EepA53808)EepType.lookup("A5-38-08").createEep( deviceID, DIM_COMMAND_ELTAKO , parameter ); telegram = createRadioTelegramESP3( deviceID, commandID, dimValue, dimSpeed, isAbsoluteRange, isStoreDimValue, isSwitchOn, isTeachIn ); radioInterface = new TestRadioInterface(); eep.send(radioInterface); Assert.assertArrayEquals(telegram.getPayload(), radioInterface.payload); Assert.assertEquals(telegram.getRORG(), radioInterface.rorg); Assert.assertEquals(telegram.getSenderID(), radioInterface.deviceID); }
@Test public void testDimCommandWithStaticDimValueEltako() throws Exception { int dimValue = 100; EepA53808 eep = (EepA53808)EepType.lookup("A5-38-08").createEep( deviceID, DIM_COMMAND_ELTAKO + " " + String.valueOf(dimValue) , null ); Assert.assertNotNull(eep); int commandID = 2; int dimSpeed = 0; boolean isTeachIn = false; boolean isAbsoluteRange = true; boolean isStoreDimValue = false; boolean isSwitchOn = true; EspRadioTelegram telegram = createRadioTelegramESP3( deviceID, commandID, dimValue, dimSpeed, isAbsoluteRange, isStoreDimValue, isSwitchOn, isTeachIn ); TestRadioInterface radioInterface = new TestRadioInterface(); eep.send(radioInterface); Assert.assertArrayEquals(telegram.getPayload(), radioInterface.payload); Assert.assertEquals(telegram.getRORG(), radioInterface.rorg); Assert.assertEquals(telegram.getSenderID(), radioInterface.deviceID); dimValue = 0; isSwitchOn = false; eep = (EepA53808)EepType.lookup("A5-38-08").createEep( deviceID, DIM_COMMAND_ELTAKO + " " + String.valueOf(dimValue) , null ); telegram = createRadioTelegramESP3( deviceID, commandID, dimValue, dimSpeed, isAbsoluteRange, isStoreDimValue, isSwitchOn, isTeachIn ); radioInterface = new TestRadioInterface(); eep.send(radioInterface); Assert.assertArrayEquals(telegram.getPayload(), radioInterface.payload); Assert.assertEquals(telegram.getRORG(), radioInterface.rorg); Assert.assertEquals(telegram.getSenderID(), radioInterface.deviceID); }