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

x33g5p2x  于2022-02-05 转载在 其他  
字(3.2k)|赞(0)|评价(0)|浏览(97)

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

ZigBeeNode.setNodeState介绍

[英]Set the node ZigBeeNodeState
[中]将节点设置为ZigBeeNodeEstate

代码示例

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

} else {
  node.setNodeState(ZigBeeNodeState.OFFLINE);
  updateNode(node);

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

/**
   * Updates {@link ZigBeeNode} and adds it to the {@link ZigBeeNetworkManager}
   *
   * @param ieeeAddress the {@link IeeeAddress} of the newly announced node
   * @param networkAddress the network address of the newly announced node
   */
  private void addNode(final IeeeAddress ieeeAddress, int networkAddress) {
    logger.debug("{}: NWK Discovery add node {}", ieeeAddress, networkAddress);
    ZigBeeNode node = networkManager.getNode(ieeeAddress);
    if (node != null) {
      if (node.getNetworkAddress() != networkAddress) {
        logger.debug("{}: NWK Discovery updated network address to {}", ieeeAddress, networkAddress);
      }
      node.setNodeState(ZigBeeNodeState.ONLINE);
      node.setNetworkAddress(networkAddress);
      networkManager.updateNode(node);
      return;
    }

    node = new ZigBeeNode(networkManager, ieeeAddress);
    node.setNetworkAddress(networkAddress);

    // Add the node to the network...
    networkManager.addNode(node);
  }
}

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

@Test
  public void setNodeState() {
    ZigBeeNode node = new ZigBeeNode(Mockito.mock(ZigBeeNetworkManager.class), new IeeeAddress("1234567890"));

    assertFalse(node.setNodeState(ZigBeeNodeState.UNKNOWN));
    assertTrue(node.setNodeState(ZigBeeNodeState.ONLINE));
    assertEquals(ZigBeeNodeState.ONLINE, node.getNodeState());
    assertTrue(node.setNodeState(ZigBeeNodeState.OFFLINE));
    assertFalse(node.setNodeState(ZigBeeNodeState.OFFLINE));
    assertEquals(ZigBeeNodeState.OFFLINE, node.getNodeState());
  }
}

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

@Test
public void nodeStatusUpdate() {
  ZigBeeTransportTransmit transport = Mockito.mock(ZigBeeTransportTransmit.class);
  ZigBeeNetworkManager manager = new ZigBeeNetworkManager(transport);
  ZigBeeNode node = Mockito.mock(ZigBeeNode.class);
  Mockito.when(node.getIeeeAddress()).thenReturn(new IeeeAddress("1234567890ABCDEF"));
  manager.addNode(node);
  ZigBeeAnnounceListener announceListener = Mockito.mock(ZigBeeAnnounceListener.class);
  manager.addAnnounceListener(announceListener);
  manager.nodeStatusUpdate(ZigBeeNodeStatus.DEVICE_LEFT, 1234, new IeeeAddress("123456789ABCDEF0"));
  Mockito.verify(node, Mockito.times(0)).setNodeState(ArgumentMatchers.any(ZigBeeNodeState.class));
  Mockito.verify(announceListener, Mockito.timeout(TIMEOUT).times(1)).deviceStatusUpdate(
      ArgumentMatchers.any(ZigBeeNodeStatus.class), ArgumentMatchers.any(Integer.class),
      ArgumentMatchers.any(IeeeAddress.class));
  manager.nodeStatusUpdate(ZigBeeNodeStatus.DEVICE_LEFT, 1234, new IeeeAddress("1234567890ABCDEF"));
  Mockito.verify(node, Mockito.times(1)).setNodeState(ZigBeeNodeState.OFFLINE);
  Mockito.verify(announceListener, Mockito.timeout(TIMEOUT).times(2)).deviceStatusUpdate(
      ArgumentMatchers.any(ZigBeeNodeStatus.class), ArgumentMatchers.any(Integer.class),
      ArgumentMatchers.any(IeeeAddress.class));
  manager.removeAnnounceListener(announceListener);
}

相关文章