gpt4 book ai didi

com.zsmartsystems.zigbee.zcl.ZclAttribute.getLastReportTime()方法的使用及代码示例

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

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

ZclAttribute.getLastReportTime介绍

[英]Gets the last report time of this attribute
[中]获取此属性的上次报告时间

代码示例

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

/**
 * Checks if the last value received for the attribute is still current.
 * If the last update time is more recent than the allowedAge then this will return true. allowedAge is defined in
 * milliseconds.
 *
 * @param allowedAge the number of milliseconds to consider the value current
 * @return true if the last value can be considered current
 */
public boolean isLastValueCurrent(long allowedAge) {
  if (lastReportTime == null) {
    return false;
  }
  long refreshTime = Calendar.getInstance().getTimeInMillis() - allowedAge;
  if (refreshTime < 0) {
    return true;
  }
  return getLastReportTime().getTimeInMillis() > refreshTime;
}

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

private void printAttributes(final ZclCluster cluster, final PrintStream out) {
    Map<Integer, ZclAttribute> attributeTree = new TreeMap<Integer, ZclAttribute>();
    for (ZclAttribute attribute : cluster.getAttributes()) {
      attributeTree.put(attribute.getId(), attribute);
    }

    for (ZclAttribute attribute : attributeTree.values()) {
      out.println(String.format("        %s   %5d %s%s%s %s %-40s %s %s",
          (cluster.getSupportedAttributes().contains(attribute.getId()) ? "S" : "U"), attribute.getId(),
          (attribute.isReadable() ? "r" : "-"), (attribute.isWritable() ? "w" : "-"),
          (attribute.isReportable() ? "s" : "-"), printZclDataType(attribute.getDataType()),
          attribute.getName(),
          (attribute.getLastValue() == null ? "" : attribute.getLastReportTime().getTime()),
          (attribute.getLastValue() == null ? "" : attribute.getLastValue())));
    }
  }
}

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

@Test
  public void getLastReportTime() {
    ZclAttribute attribute = new ZclAttribute(ZclClusterType.ON_OFF, 0, "Test Name",
        ZclDataType.UNSIGNED_8_BIT_INTEGER, false, false, false, false);

    // No value has been set, so should always be false
    assertFalse(attribute.isLastValueCurrent(Long.MAX_VALUE));

    Calendar start = Calendar.getInstance();
    attribute.updateValue(0);
    Calendar stop = Calendar.getInstance();

    assertEquals(0, attribute.getLastValue());
    assertTrue(attribute.getLastReportTime().compareTo(start) >= 0);
    assertTrue(attribute.getLastReportTime().compareTo(stop) <= 0);

    try {
      Thread.sleep(100);
    } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    assertFalse(attribute.isLastValueCurrent(50));
    assertTrue(attribute.isLastValueCurrent(Long.MAX_VALUE));
  }
}

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