op_strm_max_index_in()
Abstract
Obtains the maximum index of any input stream connected to the surrounding processor or queue.
Syntax
op_strm_max_index_in ()
| Argument | Type | Description |
|---|---|---|
| no arguments |
Return Type
int
Maximum index of any connected input stream. The value -1 will be returned if the module has no connected input streams, since input stream numbering begins at zero.
Example
/** loop through all input streams, generating an access interrupt for each **/
/* determine the number of allocated input streams */
alloc_instrms = op_strm_max_index_in ();
/* loop through each allocated stream */
for (i = 0; i <= alloc_instrms; i++)
{
/* if an input stream is connected, and... */
if (op_strm_connected (OPC_STRM_IN, i) == OPC_TRUE)
{
/* if an input stream is connected, access a packet from the source module. */
op_strm_access (i);
/* Collect and forward the packet onto the bus, if one was obtained. */
if (op_strm_empty (i) == OPC_FALSE)
op_pk_send (op_pk_get (i), OUTSTRM_BUS);
}
}
Details
The value returned by this KP is the highest physical index of all the connected input streams (i.e., the maximum value of the packet stream objects' dest stream attributes). If input streams are sparsely connected, then the returned value is not necessarily related to the number of connected input streams. If on the other hand all connected inputs are contiguous, then the returned value is one less than the number of connected streams, since numbering begins at zero. It is always the case however, that the maximum index (returned by this KP) plus one is an upper bound for the number of connected input streams.
Purpose
Provides a mechanism for upper-bounding the number of input streams that are connected to other objects. This is useful when an operation is to be performed on all connected input streams and the process has no built-in knowledge of which streams are connected. In this case, the process can test all input streams up to and including the maximum index, which is returned by this KP, and determine if they are connected by calling the KP op_strm_connected().
Errors
- Program Abort: KP requires process context.
Reference
- Use the KP op_strm_max_index_out() to determine the maximum output stream index of a module
- Use the KP op_strm_connected() to determine if a specific input or output stream is connected