rootNode.sysDisable(); int magic = rootNode.getMagic(1500);
/** * Get the root node of the system. This is the node that represents the master. Creates a new instance of root node * if no root node is stored. * * @return the root node */ public RootNode getRootNode() { // LOGGER.debug("Get the root node."); RootNode rootNode = null; synchronized (nodes) { // get the node from the registered nodes rootNode = (RootNode) nodes.get(ROOT_ADDRESS); if (rootNode == null) { // no root node registered, create and initialize the root node. // the root node has always the local address 0 and is the interface node. LOGGER.info("The root node is not available, create new root node."); rootNode = new RootNode(messageReceiver, ignoreWaitTimeout); // initialize the root node rootNode.setBidib(bidib); rootNode.setRequestFactory(requestFactory); rootNode.setResponseTimeout(bidib.getResponseTimeout()); rootNode.setFirmwarePacketTimeout(bidib.getFirmwarePacketTimeout()); nodes.put(ROOT_ADDRESS, rootNode); } LOGGER.debug("Root node: {}", rootNode); } return rootNode; }
/** * Send the sys clock message. * * @param date * the current date * @param factor * the time factor * @throws ProtocolException */ public void clock(Calendar date, int factor) throws ProtocolException { LOGGER.info("Send the clock message."); sendNoWait(new SysClockMessage(date, factor)); }
Assert.assertEquals(netBidib.getRootNode().getNodeMagic(), Integer.valueOf(BidibLibrary.BIDIB_SYS_MAGIC)); long uniqueId = netBidib.getRootNode().getUniqueId(); uniqueId = netBidib.getRootNode().getUniqueId(true); netBidib.getRootNode().getNextFeature(); netBidib.getRootNode().getNextFeature(); netBidib.getRootNode().getNextFeature(); netBidib.getRootNode().getNextFeature();
/** * Get the magic from the node. * * @param receiveTimeout * the timeout in milliseconds used to wait for a response from the node. If null the default timeout is * used. * @return the magic * @throws ProtocolException */ @Override public int getMagic(Integer receiveTimeout) throws ProtocolException { LOGGER.trace("Get magic from root node!"); int magic = super.getMagic(receiveTimeout); LOGGER.info("Get magic from root node returns: {}", magic); if (BIDIB_MAGIC_UNKNOWN == magic) { LOGGER.warn("The interface did not respond the get magic request!"); StringBuilder sb = new StringBuilder("The interface did not respond the get magic request!"); String errorInfo = getMessageReceiver().getErrorInformation(); if (StringUtils.isNotBlank(errorInfo)) { LOGGER.warn("Found received data that was not identifed as BiDiB messages: {}", errorInfo); sb.append("\r\n"); sb.append(errorInfo); } NoAnswerException ex = new NoAnswerException("Establish communication with interface failed."); ex.setDescription(sb.toString()); LOGGER.warn("Prepared exception to throw:", ex); throw ex; } return magic; }
@Override public RootNode getRootNode() { RootNode rootNode = null; try { rootNode = delegateBidib.getRootNode(); } catch (Exception ex) { LOGGER.warn("Get the root node failed.", ex); } if (rootNode != null) { String nodeAddress = NodeUtils.formatAddress(rootNode.getAddr()); SimulatorNode simulator = SimulatorRegistry.getInstance().getSimulator(nodeAddress); if (simulator == null) { LOGGER.warn("No simulator configured for the root node."); } } else { LOGGER.error("The root node is not available."); } return rootNode; }
Assert.assertEquals(netBidib.getRootNode().getNodeMagic(), Integer.valueOf(BidibLibrary.BIDIB_SYS_MAGIC));