gpt4 book ai didi

com.zsmartsystems.zigbee.ZigBeeGroupAddress类的使用及代码示例

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

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

ZigBeeGroupAddress介绍

[英]ZigBee group address
[中]ZigBee群地址

代码示例

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

@Override
public int compareTo(ZigBeeAddress that) {
  if (this == that) {
    return 0;
  }
  ZigBeeGroupAddress thatAddr = (ZigBeeGroupAddress) that;
  if (thatAddr.getGroupId() == getGroupId()) {
    return 0;
  }
  return (thatAddr.getGroupId() < getGroupId()) ? -1 : 1;
}

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

@Override
public void setAddress(final int address) {
  setGroupId(address);
}

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

@Test
  public void testGroupAddress() {
    ZigBeeGroupAddress group1 = new ZigBeeGroupAddress(1);
    assertTrue(group1.isGroup());

    ZigBeeGroupAddress group2 = new ZigBeeGroupAddress(1);
    assertTrue(group1.equals(group2));
    assertEquals(0, group1.compareTo(group2));
    assertEquals(1, group1.getGroupId());

    // Test that label doesn't matter
    group2 = new ZigBeeGroupAddress(1, "Test Label");
    assertTrue(group1.equals(group2));
    assertEquals("Test Label", group2.getLabel());

    group2 = new ZigBeeGroupAddress();
    group2.setGroupId(1);
    assertEquals(1, group1.getGroupId());
    group2.setLabel("Test Label");
    assertEquals("Test Label", group2.getLabel());

    group2.setGroupId(2);
    assertEquals(1, group1.compareTo(group2));

    System.out.println(group2);
  }
}

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

@Test
public void testAddRemoveGroup() {
  ZigBeeNetworkManager networkManager = mockZigBeeNetworkManager();
  networkManager.addGroup(new ZigBeeGroupAddress(1));
  assertEquals(1, networkManager.getGroups().size());
  networkManager.addGroup(new ZigBeeGroupAddress(1));
  assertEquals(1, networkManager.getGroups().size());
  networkManager.addGroup(new ZigBeeGroupAddress(2));
  assertEquals(2, networkManager.getGroups().size());
  networkManager.removeGroup(2);
  assertEquals(1, networkManager.getGroups().size());
  assertNull(networkManager.getGroup(1).getLabel());
  ZigBeeGroupAddress group = networkManager.getGroup(1);
  assertEquals(1, group.getGroupId());
  group.setLabel("Group Label");
  networkManager.updateGroup(group);
  assertEquals(1, networkManager.getGroups().size());
  assertEquals("Group Label", networkManager.getGroup(1).getLabel());
}

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

/**
   * {@inheritDoc}
   */
  @Override
  public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) {
    final List<ZigBeeGroupAddress> groups = zigbeeApi.getGroups();
    for (final ZigBeeGroupAddress group : groups) {
      print(StringUtils.leftPad(Integer.toString(group.getGroupId()), 10) + "      " + group.getLabel(), out);
    }
    return true;
  }
}

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

/**
   * {@inheritDoc}
   */
  @Override
  public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) throws Exception {
    if (args.length != 3) {
      return false;
    }
    final int groupId;
    try {
      groupId = Integer.parseInt(args[1]);
    } catch (final NumberFormatException e) {
      return false;
    }
    final String label = args[2];
    ZigBeeGroupAddress group = new ZigBeeGroupAddress();
    group.setLabel(label);
    networkManager.addGroup(group);
    return true;
  }
}

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

ConBeeQuerySendDataResponse(final int[] response) {
  super(response);
  if (deserializeUInt8() != APS_DATA_CONFIRM) {
    throw new IllegalArgumentException();
  }
  sequence = deserializeUInt8();
  deserializeUInt8();
  deserializeUInt16();
  deserializeUInt16();
  state = deserializeDeviceState();
  requestId = deserializeUInt8();
  destinationAddressMode = deserializeAddressMode();
  switch (destinationAddressMode) {
    case GROUP:
      destinationAddress = new ZigBeeGroupAddress(deserializeUInt16());
      break;
    case NWK:
      destinationAddress = new ZigBeeEndpointAddress(deserializeUInt16());
      break;
    case IEEE:
      destinationIeeeAddress = new IeeeAddress(Arrays.copyOfRange(buffer, length, length + 8));
      break;
    default:
      break;
  }
  destinationEndpoint = deserializeUInt8();
  if (destinationAddressMode == ConBeeAddressMode.NWK) {
    ((ZigBeeEndpointAddress) destinationAddress).setEndpoint(destinationEndpoint);
  }
}

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

/**
 * Gets destination by device identifier or group ID.
 *
 * @param zigbeeApi the ZigBee API
 * @param destinationIdentifier the device identifier or group ID
 * @return the device
 */
private ZigBeeAddress getDestination(final ZigBeeApi zigbeeApi, final String destinationIdentifier,
    final PrintStream out) {
  final ZigBeeEndpoint device = getDevice(zigbeeApi, destinationIdentifier);
  if (device != null) {
    return device.getEndpointAddress();
  }
  try {
    for (final ZigBeeGroupAddress group : zigbeeApi.getGroups()) {
      if (destinationIdentifier.equals(group.getLabel())) {
        return group;
      }
    }
    final int groupId = Integer.parseInt(destinationIdentifier);
    return zigbeeApi.getGroup(groupId);
  } catch (final NumberFormatException e) {
    return null;
  }
}

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

@Override
public void sendCommand(final ZigBeeApsFrame apsFrame) {
  ConBeeEnqueueSendDataRequest request = new ConBeeEnqueueSendDataRequest();
  request.setRequestId(apsFrame.getApsCounter());
  request.setClusterId(apsFrame.getCluster());
  switch (apsFrame.getAddressMode()) {
    case DEVICE:
      request.setDestinationAddress(
          new ZigBeeEndpointAddress(apsFrame.getDestinationAddress(), apsFrame.getDestinationEndpoint()));
      request.setDestinationAddressMode(ConBeeAddressMode.NWK);
      if (apsFrame.getDestinationAddress() > 0xfff8) {
        //
        request.setTxOptions(0);
      }
      break;
    case GROUP:
      request.setDestinationAddress(new ZigBeeGroupAddress(apsFrame.getDestinationAddress()));
      request.setDestinationAddressMode(ConBeeAddressMode.GROUP);
      break;
    default:
      break;
  }
  request.setProfileId(apsFrame.getProfile());
  request.setRadius(apsFrame.getRadius());
  request.setSourceEndpoint(apsFrame.getSourceEndpoint());
  // request.setTxOptions(txOptions);
  request.setAdsuData(apsFrame.getPayload());
  conbeeHandler.queueFrame(request);
}

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

@Override
public int getAddress() {
  return getGroupId();
}

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

public void addGroup(final ZigBeeGroupAddress group) {
  synchronized (networkGroups) {
    networkGroups.put(group.getGroupId(), group);
  }
}

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

@Override
public boolean equals(Object obj) {
  if (obj == null) {
    return false;
  }
  if (!ZigBeeGroupAddress.class.isAssignableFrom(obj.getClass())) {
    return false;
  }
  final ZigBeeGroupAddress other = (ZigBeeGroupAddress) obj;
  return other.getGroupId() == getGroupId();
}

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

public void updateGroup(ZigBeeGroupAddress group) {
  synchronized (networkGroups) {
    networkGroups.put(group.getGroupId(), group);
  }
}

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

/**
   * {@inheritDoc}
   */
  @Override
  public boolean process(final ZigBeeApi zigbeeApi, final String[] args, PrintStream out) throws Exception {
    if (args.length != 2) {
      return false;
    }
    final ZigBeeAddress destination = getDestination(zigbeeApi, args[1], out);
    if (destination == null) {
      return false;
    }
    if (!(destination instanceof ZigBeeGroupAddress)) {
      return false;
    }
    final ZigBeeGroupAddress group = (ZigBeeGroupAddress) destination;
    networkManager.removeGroup(group.getGroupId());
    return true;
  }
}

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