gpt4 book ai didi

com.zsmartsystems.zigbee.zcl.protocol.ZclDataType类的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 06:27:31 27 4
gpt4 key购买 nike

本文整理了Java中com.zsmartsystems.zigbee.zcl.protocol.ZclDataType类的一些代码示例,展示了ZclDataType类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZclDataType类的具体详情如下:
包路径:com.zsmartsystems.zigbee.zcl.protocol.ZclDataType
类名称:ZclDataType

ZclDataType介绍

暂无

代码示例

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

@Override
public void deserialize(final ZigBeeDeserializer deserializer) {
  attributeIdentifier = (int) deserializer.readZigBeeType(ZclDataType.UNSIGNED_16_BIT_INTEGER);
  attributeDataType = ZclDataType.getType((int) deserializer.readZigBeeType(ZclDataType.UNSIGNED_8_BIT_INTEGER));
  attributeValue = deserializer.readZigBeeType(attributeDataType);
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

@Override
public void serialize(final ZigBeeSerializer serializer) {
  serializer.appendZigBeeType(attributeIdentifier, ZclDataType.UNSIGNED_16_BIT_INTEGER);
  serializer.appendZigBeeType(attributeDataType.getId(), ZclDataType.UNSIGNED_8_BIT_INTEGER);
  serializer.appendZigBeeType(attributeValue, attributeDataType);
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

/**
 * Deserializes a field.
 *
 * @param dataType the {@link ZclDataType} of the field.
 * @return the value
 */
public Object deserialize(final ZclDataType dataType) {
  if (ZclListItemField.class.isAssignableFrom(dataType.getDataClass())) {
    final Class<?> dataTypeClass = dataType.getDataClass();
    final List<ZclListItemField> list = new ArrayList<ZclListItemField>();
    try {
      while (deserializer.getSize() - deserializer.getPosition() > 0) {
        final ZclListItemField item;
        try {
          item = (ZclListItemField) dataTypeClass.newInstance();
        } catch (final Exception e) {
          throw new IllegalArgumentException("Error deserializing field: " + dataType.getLabel(), e);
        }
        item.deserialize(this.deserializer);
        list.add(item);
      }
    } catch (ArrayIndexOutOfBoundsException e) {
      // Eat the exception - this terminates the list!
    }
    return list;
  }
  return deserializer.readZigBeeType(dataType);
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

break;
case ZIGBEE_DATA_TYPE:
  value[0] = ZclDataType.getType(payload[index++]);
  break;
case BYTE_ARRAY:
default:
  throw new IllegalArgumentException("No reader defined in " + ZigBeeDeserializer.class.getSimpleName()
      + " for " + type.toString() + " (" + type.getId() + ")");

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

@Override
public void deserialize(final ZigBeeDeserializer deserializer) {
  direction = (int) deserializer.readZigBeeType(ZclDataType.UNSIGNED_8_BIT_INTEGER);
  attributeIdentifier = (int) deserializer.readZigBeeType(ZclDataType.UNSIGNED_16_BIT_INTEGER);
  if (direction == 1) {
    // If direction is set to 0x01, then the timeout period field is included in the payload,
    // and the attribute data type field, the minimum reporting interval field, the
    // maximum reporting interval field and the reportable change field are omitted. The
    // record is sent to a cluster client (or server) to configure how it should expect
    // reports from a server (or client) of the same cluster.
    timeoutPeriod = (int) deserializer.readZigBeeType(ZclDataType.UNSIGNED_16_BIT_INTEGER);
  } else {
    // If direction is set to 0x00, then the attribute data type field, the minimum
    // reporting interval field, the maximum reporting interval field and the reportable
    // change field are included in the payload, and the timeout period field is omitted.
    // The record is sent to a cluster server (or client) to configure how it sends reports to
    // a client (or server) of the same cluster.
    attributeDataType = ZclDataType
        .getType((int) deserializer.readZigBeeType(ZclDataType.UNSIGNED_8_BIT_INTEGER));
    minimumReportingInterval = (int) deserializer.readZigBeeType(ZclDataType.UNSIGNED_16_BIT_INTEGER);
    maximumReportingInterval = (int) deserializer.readZigBeeType(ZclDataType.UNSIGNED_16_BIT_INTEGER);
    if (attributeDataType.isAnalog()) {
      // The reportable change field shall contain the minimum change to the attribute that
      // will result in a report being issued. This field is of variable length. For attributes
      // with 'analog' data typethe field has the same data type as the attribute. The sign (if any) of the
      // reportable change field is ignored. For attributes of 'discrete' data type this field is omitted.
      reportableChange = deserializer.readZigBeeType(attributeDataType);
    }
  }
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

@Override
public void serialize(final ZigBeeSerializer serializer) {
  serializer.appendZigBeeType(direction, ZclDataType.UNSIGNED_8_BIT_INTEGER);
  serializer.appendZigBeeType(attributeIdentifier, ZclDataType.UNSIGNED_16_BIT_INTEGER);
  if (direction == 1) {
    // If direction is set to 0x01, then the timeout period field is included in the payload,
    // and the attribute data type field, the minimum reporting interval field, the
    // maximum reporting interval field and the reportable change field are omitted. The
    // record is sent to a cluster client (or server) to configure how it should expect
    // reports from a server (or client) of the same cluster.
    serializer.appendZigBeeType(timeoutPeriod, ZclDataType.UNSIGNED_16_BIT_INTEGER);
  } else {
    // If direction is set to 0x00, then the attribute data type field, the minimum
    // reporting interval field, the maximum reporting interval field and the reportable
    // change field are included in the payload, and the timeout period field is omitted.
    // The record is sent to a cluster server (or client) to configure how it sends reports to
    // a client (or server) of the same cluster.
    serializer.appendZigBeeType(attributeDataType.getId(), ZclDataType.UNSIGNED_8_BIT_INTEGER);
    serializer.appendZigBeeType(minimumReportingInterval, ZclDataType.UNSIGNED_16_BIT_INTEGER);
    serializer.appendZigBeeType(maximumReportingInterval, ZclDataType.UNSIGNED_16_BIT_INTEGER);
    // The reportable change field shall contain the minimum change to the attribute that
    // will result in a report being issued. This field is of variable length. For attributes
    // with 'analog' data typethe field has the same data type as the attribute. The sign (if any) of the
    // reportable change field is ignored. For attributes of 'discrete' data type this field is omitted.
    if (attributeDataType.isAnalog()) {
      serializer.appendZigBeeType(reportableChange, attributeDataType);
    }
  }
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

buffer[length++] = ((ZclDataType) data).getId();
  break;
default:
  throw new IllegalArgumentException("No writer defined in " + ZigBeeDeserializer.class.getSimpleName()
      + " for " + type.toString() + " (" + type.getId() + ")");

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

@Override
  public String toString() {
    StringBuilder builder = new StringBuilder(220);

    builder.append("AttributeReportingConfigurationRecord: [attributeDataType=");
    builder.append(attributeDataType);
    builder.append(", attributeIdentifier=");
    builder.append(attributeIdentifier);
    builder.append(", direction=");
    builder.append(direction);
    if (direction == 0) {
      builder.append(", minimumReportingInterval=");
      builder.append(minimumReportingInterval);
      builder.append(", maximumReportingInterval=");
      builder.append(maximumReportingInterval);
      if (attributeDataType.isAnalog()) {
        builder.append(", reportableChange=");
        builder.append(reportableChange);
      }
    } else if (direction == 1) {
      builder.append(", timeoutPeriod=");
      builder.append(timeoutPeriod);
    }
    builder.append(']');

    return builder.toString();
  }
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

@Test
public void getLabel() {
  ZclDataType type = ZclDataType.BOOLEAN;
  assertEquals("Boolean", type.getLabel());
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

/**
 * Serializes field value.
 *
 * @param value the field value
 * @param dataType the data type
 */
public void serialize(final Object value, final ZclDataType dataType) {
  if (ZclListItemField.class.isAssignableFrom(dataType.getDataClass())) {
    final List<ZclListItemField> list = (List<ZclListItemField>) value;
    for (final ZclListItemField item : list) {
      item.serialize(serializer);
    }
    return;
  }
  serializer.appendZigBeeType(value, dataType);
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

@Test
public void isAnalog() {
  ZclDataType type = ZclDataType.BOOLEAN;
  assertFalse(type.isAnalog());
  type = ZclDataType.UNSIGNED_16_BIT_INTEGER;
  assertTrue(type.isAnalog());
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

@Override
public void deserialize(final ZigBeeDeserializer deserializer) {
  attributeIdentifier = (int) deserializer.readZigBeeType(ZclDataType.UNSIGNED_16_BIT_INTEGER);
  attributeDataType = ZclDataType.getType((int) deserializer.readZigBeeType(ZclDataType.UNSIGNED_8_BIT_INTEGER));
  attributeValue = deserializer.readZigBeeType(attributeDataType);
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

@Override
public void serialize(final ZigBeeSerializer serializer) {
  serializer.appendZigBeeType(attributeIdentifier, ZclDataType.UNSIGNED_16_BIT_INTEGER);
  serializer.appendZigBeeType(attributeDataType.getId(), ZclDataType.UNSIGNED_8_BIT_INTEGER);
  serializer.appendZigBeeType(attributeValue, attributeDataType);
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

@Test
public void getType() {
  assertEquals(ZclDataType.BOOLEAN, ZclDataType.getType(0x10));
  assertEquals(ZclDataType.CHARACTER_STRING, ZclDataType.getType(0x42));
  assertEquals(ZclDataType.DATA_8_BIT, ZclDataType.getType(0x08));
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

@Test
public void getId() {
  assertEquals(0x10, ZclDataType.BOOLEAN.getId());
  assertEquals(0x42, ZclDataType.CHARACTER_STRING.getId());
  assertEquals(0x08, ZclDataType.DATA_8_BIT.getId());
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

@Override
public void deserialize(final ZigBeeDeserializer deserializer) {
  attributeIdentifier = (int) deserializer.readZigBeeType(ZclDataType.UNSIGNED_16_BIT_INTEGER);
  status = (ZclStatus) deserializer.readZigBeeType(ZclDataType.ZCL_STATUS);
  if (status.equals(ZclStatus.SUCCESS)) {
    attributeDataType = ZclDataType
        .getType((int) deserializer.readZigBeeType(ZclDataType.UNSIGNED_8_BIT_INTEGER));
    attributeValue = deserializer.readZigBeeType(attributeDataType);
  }
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

@Override
public void serialize(final ZigBeeSerializer serializer) {
  serializer.appendZigBeeType((short) attributeIdentifier, ZclDataType.UNSIGNED_16_BIT_INTEGER);
  serializer.appendZigBeeType(status, ZclDataType.ZCL_STATUS);
  serializer.appendZigBeeType((byte) attributeDataType.getId(), ZclDataType.UNSIGNED_8_BIT_INTEGER);
  serializer.appendZigBeeType(attributeValue, attributeDataType);
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

@Test
public void testDeserialize_ZIGBEE_DATA_TYPE() {
  int[] valIn = { 33 };
  ZclDataType valOut = ZclDataType.getType(valIn[0]);
  testDeserialize(valIn, valOut, ZclDataType.ZIGBEE_DATA_TYPE);
}

代码示例来源:origin: openhab/org.openhab.binding.zigbee

return;
ZclDataType dataType = ZclDataType.getType(dataTypeId);
if (dataType == null) {
  logger.debug("{}: Data type {} not found", node.getIeeeAddress(), dataType);

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com