Examples of DPT


Examples of tuwien.auto.calimero.dptxlator.DPT

  /* (non-Javadoc)
   * @see org.openhab.binding.knx.config.KNXTypeMapper#toDPTValue(org.openhab.core.types.Type, java.lang.String)
   */
  public String toDPTValue(Type type, String dptID) {

    DPT dpt;
    int mainNumber = getMainNumber(dptID);
    if (mainNumber == -1) {
      logger.error("toDPTValue couldn't identify mainnumber in dptID: {}",dptID);
      return null;
    }

    try {
      DPTXlator translator = TranslatorTypes.createTranslator(mainNumber, dptID);
      dpt=translator.getType();

    } catch (KNXException e) {
      e.printStackTrace();
      return null;
    }

    //check for HSBType first, because it extends PercentType as well
    if(type instanceof HSBType) {
      Color color = ((HSBType)type).toColor();
   
      return "r:" + Integer.toString(color.getRed()) + " g:" + Integer.toString(color.getGreen()) + " b:" + Integer.toString(color.getBlue());
    } else if(type instanceof OnOffType) {
      return type.equals(OnOffType.OFF)?dpt.getLowerValue():dpt.getUpperValue();
    } else if(type instanceof UpDownType) {
      return type.equals(UpDownType.UP)?dpt.getLowerValue():dpt.getUpperValue();
    } else if(type instanceof IncreaseDecreaseType) {
      DPT valueDPT = ((DPTXlator3BitControlled.DPT3BitControlled) dpt).getControlDPT();
      return type.equals(IncreaseDecreaseType.DECREASE)?valueDPT.getLowerValue()+" 5":valueDPT.getUpperValue()+" 5";
    } else if(type instanceof OpenClosedType) {
      return type.equals(OpenClosedType.CLOSED)?dpt.getLowerValue():dpt.getUpperValue();
    } else if(type instanceof StopMoveType) {
      return type.equals(StopMoveType.STOP)?dpt.getLowerValue():dpt.getUpperValue();
    } else if(type instanceof PercentType) {
      return type.toString();
    } else if(type instanceof DecimalType) {
      switch (mainNumber) {
      case 2:
        DPT valueDPT = ((DPTXlator1BitControlled.DPT1BitControlled) dpt).getValueDPT();
        switch (((DecimalType) type).intValue()) {
        case 0: return "0 "+valueDPT.getLowerValue();
        case 1: return "0 "+valueDPT.getUpperValue();
        case 2: return "1 "+valueDPT.getLowerValue();
        default:
          return "1 "+valueDPT.getUpperValue();
        }
      case 18:
        int intVal=((DecimalType) type).intValue();
        if (intVal > 63) {
          return "learn "+(intVal-0x80);
View Full Code Here

Examples of tuwien.auto.calimero.dptxlator.DPT

   *
   * @throws KNXFormatException
   */
  @Test
  public void testTypeMapping8BitUnsigned_5_001() throws KNXFormatException {
    DPT dpt = DPTXlator8BitUnsigned.DPT_SCALING;

    testToTypeClass(dpt, PercentType.class);

    // Use a too short byte array
    assertNull("KNXCoreTypeMapper.toType() should return null (required data length too short)",
View Full Code Here

Examples of tuwien.auto.calimero.dptxlator.DPT

   *
   * @throws KNXFormatException
   */
  @Test
  public void testTypeMapping8BitUnsigned_5_003() throws KNXFormatException {
    DPT dpt = DPTXlator8BitUnsigned.DPT_ANGLE;

    testToTypeClass(dpt, DecimalType.class);

    // Use a too short byte array
    assertNull("KNXCoreTypeMapper.toType() should return null (required data length too short)",
View Full Code Here

Examples of tuwien.auto.calimero.dptxlator.DPT

   *
   * @throws KNXFormatException
   */
  @Test
  public void testTypeMapping8BitUnsigned_5_004() throws KNXFormatException {
    DPT dpt =DPTXlator8BitUnsigned.DPT_PERCENT_U8;

    testToTypeClass(dpt, DecimalType.class);

    // Use a too short byte array
    assertNull("KNXCoreTypeMapper.toType() should return null (required data length too short)",
View Full Code Here

Examples of tuwien.auto.calimero.dptxlator.DPT

   *
   * @throws KNXFormatException
   */
  @Test
  public void testTypeMapping8BitUnsigned_5_005() throws KNXFormatException {
    DPT dpt =DPTXlator8BitUnsigned.DPT_DECIMALFACTOR;

    testToTypeClass(dpt, DecimalType.class);

    // Use a too short byte array
    assertNull("KNXCoreTypeMapper.toType() should return null (required data length too short)",
View Full Code Here

Examples of tuwien.auto.calimero.dptxlator.DPT

   *
   * @throws KNXFormatException
   */
  @Test
  public void testTypeMapping8BitUnsigned_5_006() throws KNXFormatException {
    DPT dpt =DPTXlator8BitUnsigned.DPT_TARIFF;

    testToTypeClass(dpt, DecimalType.class);

    // Use a too short byte array
    assertNull("KNXCoreTypeMapper.toType() should return null (required data length too short)",
View Full Code Here

Examples of tuwien.auto.calimero.dptxlator.DPT

   *
   * @throws KNXFormatException
   */
  @Test
  public void testTypeMapping8BitUnsigned_5_010() throws KNXFormatException {
    DPT dpt =DPTXlator8BitUnsigned.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)",
View Full Code Here

Examples of tuwien.auto.calimero.dptxlator.DPT

   *
   * @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)",
View Full Code Here

Examples of tuwien.auto.calimero.dptxlator.DPT

   *
   * @throws KNXFormatException
   */
  @Test
  public void testTypeMapping2ByteUnsigned_7_004() throws KNXFormatException {
    DPT dpt =DPTXlator2ByteUnsigned.DPT_TIMEPERIOD_100;

    testToTypeClass(dpt, DecimalType.class);

    // Use a too short byte array
    assertNull("KNXCoreTypeMapper.toType() should return null (required data length too short)",
View Full Code Here

Examples of tuwien.auto.calimero.dptxlator.DPT

   *
   * @throws KNXFormatException
   */
  @Test
  public void testTypeMappingTime_10_001() throws KNXFormatException {
    DPT dpt =DPTXlatorTime.DPT_TIMEOFDAY;

    testToTypeClass(dpt, DateTimeType.class);

    // Use a too short byte array
    assertNull("KNXCoreTypeMapper.toType() should return null (required data length too short)",
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.