public int execute() { int result = 20; try { openPort(getPortName(), null); BidibNode rootNode = getBidib().getRootNode(); int count = rootNode.getNodeCount(); System.out.println("Number of nodes: " + count); // NOSONAR for (int index = 1; index <= count; index++) { Node node = rootNode.getNextNode(); System.out.println("Found node: " + node); // NOSONAR } result = 0; releaseBidib(); } catch (PortNotFoundException ex) { System.err.println("The provided port was not found: " + ex.getMessage() // NOSONAR + ". Verify that the BiDiB device is connected."); } catch (Exception ex) { System.err.println("Get list of nodes failed: " + ex); // NOSONAR } return result; } }
protected Node findNode() throws ProtocolException { Node result = null; BidibNode rootNode = getBidib().getRootNode(); int count = rootNode.getNodeCount(); for (int index = 1; index <= count; index++) { Node node = rootNode.getNextNode(); if (node != null && (node.getUniqueId() & 0xffffffffffffffL) == nodeId.longValue()) { int magic = getBidib().getNode(node).getMagic(null); LOGGER.info("Node returned magic: {}", magic); // after we fetch the magic we must try to get the FEATURE_RELEVANT_PID_BITS Feature relevantPidBits = getBidib().getNode(node).getFeature(BidibLibrary.FEATURE_RELEVANT_PID_BITS); if (relevantPidBits != null) { node.setFeature(relevantPidBits); node.setRelevantPidBits(relevantPidBits.getValue()); } result = node; break; } } return result; }