Search in sources :

Example 26 with DPT

use of tuwien.auto.calimero.dptxlator.DPT in project openhab1-addons by openhab.

the class KNXCoreTypeMapperTest method testTypeMappingSceneNumber_17_001.

/**
     * KNXCoreTypeMapper tests method typeMapper.toType() for type “Scene Number" KNX ID: 17.001 DPT_SCENE_NUMBER
     *
     * @throws KNXFormatException
     */
@Test
public void testTypeMappingSceneNumber_17_001() throws KNXFormatException {
    DPT dpt = DPTXlatorSceneNumber.DPT_SCENE_NUMBER;
    testToTypeClass(dpt, DecimalType.class);
    // Use a too short byte array
    assertNull("KNXCoreTypeMapper.toType() should return null (required data length too short)", testToType(dpt, new byte[] {}, DecimalType.class));
    // Use a too long byte array expecting that additional bytes will be ignored
    Type type = testToType(dpt, new byte[] { (byte) 0xFF, 0 }, DecimalType.class);
    testToDPTValue(dpt, type, "63");
    type = testToType(dpt, new byte[] { 0x00 }, DecimalType.class);
    testToDPTValue(dpt, type, "0");
    type = testToType(dpt, new byte[] { 0x3F }, DecimalType.class);
    testToDPTValue(dpt, type, "63");
    // Test that the 2 msb (reserved) are ignored
    type = testToType(dpt, new byte[] { (byte) 0xC0 }, DecimalType.class);
    testToDPTValue(dpt, type, "0");
    // Test that the 2 msb (reserved) are ignored
    type = testToType(dpt, new byte[] { (byte) 0xFF }, DecimalType.class);
    testToDPTValue(dpt, type, "63");
}
Also used : OpenClosedType(org.openhab.core.library.types.OpenClosedType) IncreaseDecreaseType(org.openhab.core.library.types.IncreaseDecreaseType) StringType(org.openhab.core.library.types.StringType) OnOffType(org.openhab.core.library.types.OnOffType) DateTimeType(org.openhab.core.library.types.DateTimeType) Type(org.openhab.core.types.Type) DecimalType(org.openhab.core.library.types.DecimalType) UpDownType(org.openhab.core.library.types.UpDownType) PercentType(org.openhab.core.library.types.PercentType) HSBType(org.openhab.core.library.types.HSBType) StopMoveType(org.openhab.core.library.types.StopMoveType) DPT(tuwien.auto.calimero.dptxlator.DPT) DecimalType(org.openhab.core.library.types.DecimalType) Test(org.junit.Test)

Example 27 with DPT

use of tuwien.auto.calimero.dptxlator.DPT in project openhab1-addons by openhab.

the class KNXCoreTypeMapperTest method testTypeMappingDate_11_001__DayZero.

/**
     * KNXCoreTypeMapper tests method typeMapper.toType() for type “Time" KNX ID: 11.001 DPT_DATE
     *
     * Test illegal day (cannot be 0) This should throw an KNXIllegalArgumentException
     *
     * @throws KNXFormatException
     */
@Test
public void testTypeMappingDate_11_001__DayZero() throws KNXFormatException {
    DPT dpt = DPTXlatorDate.DPT_DATE;
    testToTypeClass(dpt, DateTimeType.class);
    assertNull("KNXCoreTypeMapper.toType() should return null", testToType(dpt, new byte[] { 0x00, 0x01, 0x00 }, DateTimeType.class));
}
Also used : DateTimeType(org.openhab.core.library.types.DateTimeType) DPT(tuwien.auto.calimero.dptxlator.DPT) Test(org.junit.Test)

Aggregations

DateTimeType (org.openhab.core.library.types.DateTimeType)27 DPT (tuwien.auto.calimero.dptxlator.DPT)27 Test (org.junit.Test)26 DecimalType (org.openhab.core.library.types.DecimalType)21 HSBType (org.openhab.core.library.types.HSBType)21 IncreaseDecreaseType (org.openhab.core.library.types.IncreaseDecreaseType)21 OnOffType (org.openhab.core.library.types.OnOffType)21 OpenClosedType (org.openhab.core.library.types.OpenClosedType)21 PercentType (org.openhab.core.library.types.PercentType)21 StopMoveType (org.openhab.core.library.types.StopMoveType)21 StringType (org.openhab.core.library.types.StringType)21 UpDownType (org.openhab.core.library.types.UpDownType)21 Type (org.openhab.core.types.Type)20 Color (java.awt.Color)1 Calendar (java.util.Calendar)1 Locale (java.util.Locale)1 Datapoint (tuwien.auto.calimero.datapoint.Datapoint)1 DPTXlator (tuwien.auto.calimero.dptxlator.DPTXlator)1 DPTXlator1BitControlled (tuwien.auto.calimero.dptxlator.DPTXlator1BitControlled)1 DPTXlator3BitControlled (tuwien.auto.calimero.dptxlator.DPTXlator3BitControlled)1