gpt4 book ai didi

com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster.onCommand()方法的使用及代码示例

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

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

ZclOnOffCluster.onCommand介绍

[英]The On Command
[中]

代码示例

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

@Override
  public void run() {
    int cnt = 0;
    while (true) {
      print("STRESSING 1 CNT: " + cnt++, out);
      ZclOnOffCluster cluster = (ZclOnOffCluster) endpoint
          .getInputCluster(ZclOnOffCluster.CLUSTER_ID);
      cluster.onCommand();
      try {
        Thread.sleep(167);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
}).start();

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

@Override
  public void run() {
    int cnt = 0;
    while (true) {
      print("STRESSING 2 CNT: " + cnt++, out);
      ZclOnOffCluster cluster = (ZclOnOffCluster) endpoint
          .getInputCluster(ZclOnOffCluster.CLUSTER_ID);
      cluster.onCommand();
      try {
        Thread.sleep(107);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
}).start();

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

@Override
  public void run() {
    int cnt = 0;
    while (true) {
      print("STRESSING 4 CNT: " + cnt++, out);
      ZclOnOffCluster cluster = (ZclOnOffCluster) endpoint
          .getInputCluster(ZclOnOffCluster.CLUSTER_ID);
      cluster.onCommand();
      try {
        Thread.sleep(187);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
}).start();

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

@Override
  public void run() {
    int cnt = 0;
    while (true) {
      print("STRESSING 3 CNT: " + cnt++, out);
      ZclOnOffCluster cluster = (ZclOnOffCluster) endpoint
          .getInputCluster(ZclOnOffCluster.CLUSTER_ID);
      cluster.onCommand();
      try {
        Thread.sleep(131);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
}).start();

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

@Override
public void handleCommand(final Command command) {
  if (clusterOnOffServer == null) {
    logger.warn("{}: OnOff converter is not linked to a server and cannot accept commands",
        endpoint.getIeeeAddress());
    return;
  }
  OnOffType cmdOnOff = null;
  if (command instanceof PercentType) {
    if (((PercentType) command).intValue() == 0) {
      cmdOnOff = OnOffType.OFF;
    } else {
      cmdOnOff = OnOffType.ON;
    }
  } else if (command instanceof OnOffType) {
    cmdOnOff = (OnOffType) command;
  } else {
    logger.warn("{}: OnOff converter only accepts PercentType and OnOffType - not {}",
        endpoint.getIeeeAddress(), command.getClass().getSimpleName());
    return;
  }
  if (cmdOnOff == OnOffType.ON) {
    clusterOnOffServer.onCommand();
  } else {
    clusterOnOffServer.offCommand();
  }
}

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

/**
 * If we support the OnOff cluster then we should perform the same function as the SwitchOnoffConverter. Otherwise,
 * interpret ON commands as moving to level 100%, and OFF commands as moving to level 0%.
 */
private void handleOnOffCommand(OnOffType cmdOnOff) {
  if (clusterOnOff != null) {
    if (cmdOnOff == OnOffType.ON) {
      clusterOnOff.onCommand();
    } else {
      clusterOnOff.offCommand();
    }
  } else {
    if (cmdOnOff == OnOffType.ON) {
      moveToLevel(PercentType.HUNDRED);
    } else {
      moveToLevel(PercentType.ZERO);
    }
  }
}

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

private void changeOnOff(OnOffType onoff) throws InterruptedException, ExecutionException {
  boolean on = onoff == OnOffType.ON;
  PercentType brightness = on ? PercentType.HUNDRED : PercentType.ZERO;
  if (clusterLevelControl != null) {
    changeBrightness(brightness);
    return;
  }
  if (clusterOnOff == null) {
    logger.warn("{}: ignoring on/off command", endpoint.getIeeeAddress());
    return;
  }
  HSBType oldHSB = currentHSB;
  currentHSB = new HSBType(oldHSB.getHue(), oldHSB.getSaturation(), brightness);
  lastBrightness = brightness;
  if (on) {
    clusterOnOff.onCommand().get();
  } else {
    clusterOnOff.offCommand().get();
  }
}

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

/**
 * Switches destination on.
 *
 * @param destination the {@link ZigBeeAddress}
 * @return the command result future.
 */
public Future<CommandResult> on(final ZigBeeAddress destination) {
  if (!(destination instanceof ZigBeeEndpointAddress)) {
    return null;
  }
  ZigBeeEndpointAddress endpointAddress = (ZigBeeEndpointAddress) destination;
  ZigBeeEndpoint endpoint = networkManager.getNode(endpointAddress.getAddress())
      .getEndpoint(endpointAddress.getEndpoint());
  if (endpoint == null) {
    return null;
  }
  ZclOnOffCluster cluster = (ZclOnOffCluster) endpoint.getInputCluster(ZclOnOffCluster.CLUSTER_ID);
  return cluster.onCommand();
}

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

@Test
public void testNodeNetworkAddressUpdate() {
  mockedTransport = Mockito.mock(ZigBeeTransportTransmit.class);
  mockedApsFrameListener = ArgumentCaptor.forClass(ZigBeeApsFrame.class);
  ZigBeeNetworkManager networkManager = new ZigBeeNetworkManager(mockedTransport);
  ZigBeeNode node = new ZigBeeNode(networkManager, new IeeeAddress("12345678990ABCDEF"));
  node.setNetworkAddress(12345);
  ZigBeeEndpoint endpoint = new ZigBeeEndpoint(node, 1);
  ZclOnOffCluster cluster = new ZclOnOffCluster(endpoint);
  networkManager.setSerializer(DefaultSerializer.class, DefaultDeserializer.class);
  Mockito.doNothing().when(mockedTransport).sendCommand(mockedApsFrameListener.capture());
  cluster.onCommand();
  assertEquals(12345, mockedApsFrameListener.getValue().getDestinationAddress());
  node.setNetworkAddress(54321);
  cluster.offCommand();
  assertEquals(54321, mockedApsFrameListener.getValue().getDestinationAddress());
}

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

@Test
public void send() {
  createEndpoint();
  ZclOnOffCluster cluster = new ZclOnOffCluster(endpoint);
  cluster.setApsSecurityRequired(true);
  cluster.onCommand();
  assertEquals(1, commandCapture.getAllValues().size());
  ZigBeeCommand command = commandCapture.getValue();
  assertNotNull(command);
  System.out.println(command);
  assertTrue(command instanceof OnCommand);
  OnCommand onCommand = (OnCommand) command;
  assertEquals(true, onCommand.getApsSecurity());
  assertEquals(ZclCommandDirection.CLIENT_TO_SERVER, onCommand.getCommandDirection());
  cluster.setApsSecurityRequired(false);
  cluster.onCommand();
  assertEquals(2, commandCapture.getAllValues().size());
  command = commandCapture.getValue();
  assertNotNull(command);
  System.out.println(command);
  assertTrue(command instanceof OnCommand);
  onCommand = (OnCommand) command;
  assertEquals(false, onCommand.getApsSecurity());
  assertEquals(ZclCommandDirection.CLIENT_TO_SERVER, onCommand.getCommandDirection());
}

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