protected byte[] processNodeTabGetAllRequest(BidibCommand bidibMessage) { byte[] response = null; try { NodeTabCountResponse nodeTabCountResponse = new NodeTabCountResponse(bidibMessage.getAddr(), getNextSendNum(), (byte) 0x01); response = nodeTabCountResponse.getContent(); } catch (ProtocolException ex) { LOGGER.warn("Create nodeTabCount response failed.", ex); } return response; }
NodeTabCountResponse(byte[] addr, int num, int type, byte... data) throws ProtocolException { super(addr, num, type, data); if (data == null || data.length < 1) { throw new ProtocolException("No valid MSG_NODETAB_COUNT received."); } LOGGER.debug("Number of nodes in system: {}", getCount()); }
public int getCount() { return ByteUtils.getInt(getData()[0]); } }
case BidibLibrary.MSG_NODETAB_COUNT: result = new NodeTabCountResponse(result.getAddr(), result.getNum(), result.getType(), result.getData()); break; case BidibLibrary.MSG_STALL:
/** * Get the number of nodes from the system. * * @return the number of nodes * @throws ProtocolException */ public Integer getNodeCount() throws ProtocolException { LOGGER.debug("Get all registered nodes from system."); BidibMessage response = send(requestFactory.createNodeTabGetAll(), null, true, NodeTabCountResponse.TYPE); if (response instanceof NodeTabCountResponse) { int totalNodes = ((NodeTabCountResponse) response).getCount(); LOGGER.debug("Found total nodes: {}", totalNodes); return totalNodes; } if (ignoreWaitTimeout) { LOGGER.warn("No response received but ignoreWaitTimeout ist set! Current node: {}", this); return Integer.valueOf(0); } throw createNoResponseAvailable("get node count"); }