Search in sources :

Example 16 with DPT

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

the class KNXCoreTypeMapperTest method testTypeMapping8BitSigned_6_010.

/**
     * KNXCoreTypeMapper tests method typeMapper.toType() for type “8-Bit Signed Value" KNX ID: 6.010
     * DPT_VALUE_1_UCOUNT
     *
     * @throws KNXFormatException
     */
@Test
public void testTypeMapping8BitSigned_6_010() throws KNXFormatException {
    DPT dpt = DPTXlator8BitSigned.DPT_VALUE_1_UCOUNT;
    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));
    Type type = testToType(dpt, new byte[] { 0 }, DecimalType.class);
    testToDPTValue(dpt, type, "0");
    type = testToType(dpt, new byte[] { (byte) 0x7F }, DecimalType.class);
    testToDPTValue(dpt, type, "127");
    type = testToType(dpt, new byte[] { (byte) 0x80 }, DecimalType.class);
    testToDPTValue(dpt, type, "-128");
    type = testToType(dpt, new byte[] { (byte) 0xFF }, DecimalType.class);
    testToDPTValue(dpt, type, "-1");
    // Use a too long byte array expecting that additional bytes will be ignored
    type = testToType(dpt, new byte[] { (byte) 0xFF, 0 }, DecimalType.class);
    testToDPTValue(dpt, type, "-1");
}
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 17 with DPT

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

the class KNXCoreTypeMapperTest method testTypeMappingTime_10_001_SecondsOutOfBounds.

/**
     * KNXCoreTypeMapper tests method typeMapper.toType() for type “Time" KNX ID: 10.001 DPT_TIMEOFDAY
     *
     * Set day to Monday, 23 hours, 59 minutes and 60 seconds
     *
     * @throws KNXFormatException
     */
@Test
public void testTypeMappingTime_10_001_SecondsOutOfBounds() throws KNXFormatException {
    DPT dpt = DPTXlatorTime.DPT_TIMEOFDAY;
    testToTypeClass(dpt, DateTimeType.class);
    assertNull("KNXCoreTypeMapper.toType() should return null", testToType(dpt, new byte[] { 0x37, 59, 60 }, DateTimeType.class));
}
Also used : DateTimeType(org.openhab.core.library.types.DateTimeType) DPT(tuwien.auto.calimero.dptxlator.DPT) Test(org.junit.Test)

Example 18 with DPT

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

the class KNXCoreTypeMapperTest method testTypeMappingDate_11_001_ZeroDay.

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

Example 19 with DPT

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

the class KNXCoreTypeMapperTest method testTypeMapping4ByteUnsigned_12_001.

/**
     * KNXCoreTypeMapper tests method typeMapper.toType() for type “4-Octet Unsigned Value" KNX ID: 12.001
     * DPT_VALUE_4_UCOUNT
     *
     * @throws KNXFormatException
     */
@Test
public void testTypeMapping4ByteUnsigned_12_001() throws KNXFormatException {
    DPT dpt = DPTXlator4ByteUnsigned.DPT_VALUE_4_UCOUNT;
    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, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF }, DecimalType.class);
    testToDPTValue(dpt, type, "4294967295");
    type = testToType(dpt, new byte[] { 0x00, 0x00, 0x00, 0x00 }, DecimalType.class);
    testToDPTValue(dpt, type, "0");
    type = testToType(dpt, new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF }, DecimalType.class);
    testToDPTValue(dpt, type, "4294967295");
}
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 20 with DPT

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

the class KNXCoreTypeMapperTest method testTypeMapping2ByteUnsigned_7_003.

/**
     * KNXCoreTypeMapper tests method typeMapper.toType() for type “2-Octet Unsigned Value" KNX ID: 7.003
     * DPT_TIMEPERIOD_10
     *
     * @throws KNXFormatException
     */
@Test
public void testTypeMapping2ByteUnsigned_7_003() throws KNXFormatException {
    DPT dpt = DPTXlator2ByteUnsigned.DPT_TIMEPERIOD_10;
    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));
    Type type = testToType(dpt, new byte[] { 0x00, 0x00 }, DecimalType.class);
    testToDPTValue(dpt, type, "0");
    type = testToType(dpt, new byte[] { (byte) 0xFF, 0x00 }, DecimalType.class);
    testToDPTValue(dpt, type, "652800");
    type = testToType(dpt, new byte[] { (byte) 0xFF, (byte) 0xFF }, DecimalType.class);
    testToDPTValue(dpt, type, "655350");
    // Use a too long byte array expecting that additional bytes will be ignored
    type = testToType(dpt, new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF }, DecimalType.class);
    testToDPTValue(dpt, type, "655350");
}
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)

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