gpt4 book ai didi

com.zsmartsystems.zigbee.ZigBeeNetworkManager.getNodes()方法的使用及代码示例

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

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

ZigBeeNetworkManager.getNodes介绍

[英]Gets a Set of ZigBeeNodes known by the network
[中]获取网络已知的一组节点

代码示例

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

/**
 * Gets the nodes in this network manager
 *
 * @return the set of {@link ZigBeeNode}s
 */
public Set<ZigBeeNode> getNodes() {
  if (networkManager == null) {
    return Collections.emptySet();
  }
  return networkManager.getNodes();
}

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

private Map<Integer, ZigBeeEndpoint> getApplications(ZigBeeNetworkManager networkManager, int clusterId) {
    Map<Integer, ZigBeeEndpoint> applications = new TreeMap<>();

    for (ZigBeeNode node : networkManager.getNodes()) {
      for (ZigBeeEndpoint endpoint : node.getEndpoints()) {
        ZigBeeApplication application = endpoint.getApplication(clusterId);
        if (application != null) {
          applications.put(endpoint.getEndpointId(), endpoint);
        }
      }
    }

    return applications;
  }
}

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

/**
 * Serializes the network state.
 *
 * @param networkState the network state
 */
@Override
public synchronized void serialize(final ZigBeeNetworkManager networkState) {
  XStream stream = openStream();
  final List<Object> objects = new ArrayList<>();
  // objects.add(networkState.getZigBeeNetworkKey());
  // objects.add(networkState.getZigBeeLinkKey());
  for (ZigBeeNode node : networkState.getNodes()) {
    ZigBeeNodeDao nodeDao = node.getDao();
    objects.add(nodeDao);
  }
  final File file = new File(networkId);
  try {
    BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
    stream.marshal(objects, new PrettyPrintWriter(writer));
    writer.flush();
    writer.close();
  } catch (IOException e) {
    logger.error("Error writing network state", e);
    return;
  }
  logger.info("ZigBee saving network state complete.");
}

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

for (ZigBeeNode node : networkManager.getNodes()) {
  ZigBeeNodeDao nodeDao = node.getDao();
  destinations.add(nodeDao);

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

/**
 * Gets {@link ZigBeeEndpoint} by device identifier.
 *
 * @param networkManager the {@link ZigBeeNetworkManager}
 * @param endpointId the device identifier
 * @return the {@link ZigBeeEndpoint}
 * @throws IllegalArgumentException
 */
protected ZigBeeEndpoint getEndpoint(final ZigBeeNetworkManager networkManager, final String endpointId)
    throws IllegalArgumentException {
  for (final ZigBeeNode node : networkManager.getNodes()) {
    for (final ZigBeeEndpoint endpoint : node.getEndpoints()) {
      if (endpointId.equals(node.getNetworkAddress() + "/" + endpoint.getEndpointId())) {
        return endpoint;
      }
    }
  }
  throw new IllegalArgumentException("Endpoint '" + endpointId + "' is not found");
}

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

/**
 * Gets device by device identifier.
 *
 * @param zigbeeApi the ZigBee API
 * @param deviceIdentifier the device identifier
 * @return the device
 */
private ZigBeeEndpoint getDevice(ZigBeeApi zigbeeApi, final String deviceIdentifier) {
  for (final ZigBeeNode node : networkManager.getNodes()) {
    for (final ZigBeeEndpoint endpoint : node.getEndpoints()) {
      if (deviceIdentifier.equals(node.getNetworkAddress() + "/" + endpoint.getEndpointId())) {
        return endpoint;
      }
    }
  }
  return null;
}

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

@Override
public void process(ZigBeeNetworkManager networkManager, String[] args, PrintStream out)
    throws IllegalArgumentException {
  final Set<ZigBeeNode> nodes = networkManager.getNodes();
  final List<Integer> nodeIds = new ArrayList<Integer>();

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

@Test
public void testAddExistingNode() {
  String address = "123456789ABCDEF0";
  ZigBeeNetworkManager networkManager = mockZigBeeNetworkManager();
  ZigBeeNode node1 = new ZigBeeNode(Mockito.mock(ZigBeeNetworkManager.class), new IeeeAddress(address));
  node1.setNetworkAddress(1234);
  ZigBeeNode node2 = new ZigBeeNode(Mockito.mock(ZigBeeNetworkManager.class), new IeeeAddress(address));
  node2.setNetworkAddress(5678);
  networkManager.addNode(node1);
  assertEquals(1, networkManager.getNodes().size());
  ZigBeeNode nodeWeGot = networkManager.getNode(new IeeeAddress(address));
  assertEquals(Integer.valueOf(1234), nodeWeGot.getNetworkAddress());
  networkManager.addNode(node2);
  assertEquals(1, networkManager.getNodes().size());
  assertEquals(Integer.valueOf(5678), nodeWeGot.getNetworkAddress());
}

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

assertEquals(1, networkManager.getNodes().size());
Mockito.verify(mockedNodeListener, Mockito.timeout(TIMEOUT)).nodeAdded(node1);
assertEquals(1, networkManager.getNodes().size());
Mockito.verify(mockedNodeListener, Mockito.timeout(TIMEOUT).times(2)).nodeAdded(node1);
Mockito.verify(mockedNodeListener, Mockito.times(0)).nodeUpdated(node1);
assertEquals(1, networkManager.getNodes().size());
Mockito.verify(mockedNodeListener, Mockito.times(2)).nodeAdded(node1);
Mockito.verify(mockedNodeListener, Mockito.timeout(TIMEOUT)).nodeUpdated(node1);
assertEquals(1, networkManager.getNodes().size());
Mockito.verify(mockedNodeListener, Mockito.times(2)).nodeAdded(node1);
assertEquals(2, networkManager.getNodes().size());
Mockito.verify(mockedNodeListener, Mockito.timeout(TIMEOUT)).nodeAdded(node2);
assertEquals(1, networkManager.getNodes().size());
Mockito.verify(mockedNodeListener, Mockito.timeout(TIMEOUT)).nodeRemoved(node1);
assertEquals(1, networkManager.getNodes().size());
Mockito.verify(mockedNodeListener, Mockito.times(1)).nodeRemoved(node1);
assertEquals(1, networkManager.getNodes().size());
Mockito.verify(mockedNodeListener, Mockito.times(1)).nodeRemoved(node1);

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