@Override public boolean evaluate(final Node node) { if (node.getUniqueId() == uuid) { LOGGER.debug("Found node: {}", node); return true; } return false; } });
@Override public int hashCode() { return (int) (NodeUtils.convertAddress(addr) + getUniqueId() + version); }
@Override public boolean equals(Object other) { if (other instanceof Node) { Node node = (Node) other; if (Arrays.equals(node.getAddr(), getAddr()) && node.getUniqueId() == uniqueId) { LOGGER.debug("Found equal node: {}", node); return true; } } return false; }
/** * Get a bidib node from the registered nodes or create a new bidib node. * * @param node * the node * @return the bidib node */ public BidibNode getNode(final Node node) { LOGGER.debug("Get the bidibNode of node: {}", node); int address = NodeUtils.convertAddress(node.getAddr()); LOGGER.info("Fetch bidibNode from nodes, address: {}", address); BidibNode bidibNode = null; synchronized (nodes) { bidibNode = nodes.get(address); LOGGER.debug("Get the bidibNode from nodesSet with address: {}, bidibNode: {}", address, bidibNode); if (bidibNode == null) { LOGGER.info("No registered node found with address: {}", address); // get the classId of the new node int classId = ByteUtils.getClassIdFromUniqueId(node.getUniqueId()); LOGGER.info("Create new bidibNode with classId: {}", classId); // create the new bidib node bidibNode = createBidibNode(node); LOGGER.info("Created new bidibNode: {}, address: {}", bidibNode, address); nodes.put(address, bidibNode); } } return bidibNode; }
/** * Prepare the node label from the stored string data of a node. * * @param node * the node * @return the node label */ public static String prepareNodeLabel(Node node) { String nodeLabel = node.getStoredString(StringData.INDEX_USERNAME); String productString = node.getStoredString(StringData.INDEX_PRODUCTNAME); if (StringUtils.isBlank(nodeLabel)) { nodeLabel = getUniqueIdAsString(node.getUniqueId()); } // try to get the product name if (StringUtils.isNotBlank(productString)) { nodeLabel += " (" + productString + ")"; } return nodeLabel; }
private Integer internalGetNumberOfPorts(String portType, final Node node, String... searchPaths) { long uniqueId = node.getUniqueId(); int relevantPidBits = node.getRelevantPidBits();
/** * Returns the provided node as CommandStationNode instance of null if the node is not an CommandStationNode. * * @param node * the node * @return the CommandStationNode instance */ public CommandStationNode getCommandStationNode(Node node) { BidibNode bidibNode = getNode(node); if (NodeUtils.hasCommandStationFunctions(node.getUniqueId())) { CommandStationNode commandStationNode = new CommandStationNode(bidibNode); LOGGER.debug("prepared command station node: {}", commandStationNode); return commandStationNode; } LOGGER.debug("The requested node is not a CommandStationNode."); throw new InvalidConfigurationException("The requested node is not a CommandStationNode."); }
/** * Returns the provided node as BoosterNode instance of null if the node is not an BoosterNode. * * @param node * the node * @return the BoosterNode instance */ public BoosterNode getBoosterNode(Node node) { BidibNode bidibNode = getNode(node); if (NodeUtils.hasBoosterFunctions(node.getUniqueId())) { BoosterNode boosterNode = new BoosterNode(bidibNode); LOGGER.debug("prepared booster node: {}", boosterNode); return boosterNode; } LOGGER.debug("The requested node is not a BoosterNode."); throw new InvalidConfigurationException("The requested node is not a BoosterNode."); }
nodesToRemove.add(address); if (NodeUtils.hasSubNodesFunctions(node.getUniqueId())) { byte[] addr = node.getAddr(); LOGGER
private VendorCvData loadCvDefintionForNode( final Node node, SoftwareVersion softwareVersion, final Context context, String... searchPaths) { long uniqueId = node.getUniqueId(); int relevantPidBits = node.getRelevantPidBits();
public static PortModelEnum getPortModel(final Node node) { // TODO add support for flat_extended // this is a hack to support wrong implementation on OneControl and OneDriveTurn if (ProductUtils.isOneControl(node.getUniqueId()) && node.getSoftwareVersion().compareTo(SoftwareVersion.build(2, 0, 6)) < 1) { return type; } // special processing for OneDriveTurn < 1.01.07 else if (ProductUtils.isOneDriveTurn(node.getUniqueId()) && node.getSoftwareVersion().compareTo(SoftwareVersion.build(1, 1, 7)) < 1) { return type; } if (node.isPortFlatModelAvailable()) { return flat; } return type; }
public ProductType loadProductForNode(final org.bidib.jbidibc.core.Node node, String... searchPaths) { long uniqueId = node.getUniqueId(); int relevantPidBits = node.getRelevantPidBits(); long pid = NodeUtils.getPid(uniqueId, relevantPidBits); long vid = NodeUtils.getVendorId(uniqueId); LOGGER.info("Load the vendor cv definition for uniqueId: {}, pid: {}, vid: {}", NodeUtils.getUniqueIdAsString(uniqueId), pid, vid); ProductType product = null; BiDiB bidib = loadBidib(vid, searchPaths); if (bidib != null) { List<ProductType> products = bidib.getProducts().getProduct(); if (products != null) { short productTypeId = (short) pid; for (ProductType current : products) { if (current.getProductTypeId() == productTypeId) { product = current; break; } } } } LOGGER.trace("Loaded product: {}", product); return product; }
String nodeId = String.format("0x%014x", node.getUniqueId() & 0xffffffffffffffL);
protected BidibNode createBidibNode(final Node node) { // create the new bidib node BidibNode bidibNode = new BidibNode(node.getAddr(), messageReceiver, ignoreWaitTimeout); // initialize the node bidibNode.setUniqueId(node.getUniqueId()); bidibNode.setBidib(bidib); bidibNode.setRequestFactory(requestFactory); bidibNode.setResponseTimeout(bidib.getResponseTimeout()); bidibNode.setFirmwarePacketTimeout(bidib.getFirmwarePacketTimeout()); LOGGER.info("Created new bidibNode, firmwarePacketTimeout: {}", bidib.getFirmwarePacketTimeout()); return bidibNode; }
BidibNode bidibNode = getBidib().getNode(node); if (bidibNode.vendorEnable(node.getUniqueId())) {
BidibNode bidibNode = getBidib().getNode(node); if (bidibNode.vendorEnable(node.getUniqueId())) { bidibNode.vendorSet(cvNumber, cvValue); bidibNode.vendorDisable();
BidibNode bidibNode = getBidib().getNode(node); if (bidibNode.vendorEnable(node.getUniqueId())) {
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; }
public NodeType toNodeType(final Node node) { VidPidKey.fromVidAndPid(NodeUtils.getVendorId(node.getUniqueId()), (int) NodeUtils.getPid(node.getUniqueId(), node.getRelevantPidBits())); masterNode .withAddress(NodeUtils.formatAddress(node.getAddr())) .withUniqueId(NodeUtils.getUniqueId(node.getUniqueId())).withClassName(className) .withProductName(node.getStoredString(StringData.INDEX_PRODUCTNAME)) .withUserName(node.getStoredString(StringData.INDEX_USERNAME)) new NodeType() .withAddress(NodeUtils.formatAddress(node.getAddr())) .withUniqueId(NodeUtils.getUniqueId(node.getUniqueId())).withClassName(className) .withProductName(node.getStoredString(StringData.INDEX_PRODUCTNAME)) .withUserName(node.getStoredString(StringData.INDEX_USERNAME))