op_strm_connected()

摘要

判定外围处理器指定的输入或输出流是否连接到一个数据包流对象。

语法

op_strm_connected (strm_type, strm_index)
参数 类型 说明
strm_type int 目标流的类型 [该值是一个数字代码,指示目标流的类型(参见表 82“Stream Type Symbolic Constants“ 第 25 页);此参数可接受的符号常量为 OPC_STRM_IN 和 OPC_STRM_OUT。]
strm_index int 目标输入或输出流的数字索引 [流索引从 0 开始,依次递增 1。这些索引没有上限,但以连续方式使用它们可以节省内存。取负值或大于最大已分配输入/输出流索引的值将导致错误。]

返回类型

Boolean

布尔值,指示指定流索引是否被数据包流占用。若指定流已连接,返回值为 OPC_TRUE,否则为 OPC_FALSE。

示例

/** 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_intstrms; 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);
		}
	}

详情

模块的输入流与输出流可以相互连接,也可以留空不占用。此外,输入流和输出流可以是稀疏连接的。例如,一个处理器可以分配了四个输入流,但只有流 1 和流 3 处于连接状态。输入或输出流是否处于连接状态,可以使用本内核过程来判定。

超出范围或负值的流索引将被视为未占用的输入,本内核过程相应地返回常量 OPC_FALSE,但不会生成错误消息。

用途

为过程提供一种机制,用以区分外围处理器或队列所属的已连接流与未连接流。当必须对每个已连接的输入或输出流执行某一操作时,这一点尤为重要。过程可以遍历所有已分配的输入或输出流(使用内核过程 op_strm_max_index_in() 和 op_strm_max_index_out() 确定循环边界),只对那些确实已连接的流执行该操作。

错误

  • 程序中止:内核过程需要过程上下文。

参考

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · Documentation compiled and provided by Beijing ZNetLink Technology Co., Ltd.

交流群 · QQ Group:OPNET/智网妙算网络仿真交流群(群号 486383494)

原文档 © 2017 Riverbed Technology · 本站为公益翻译,由 AI 辅助完成,请仔细甄别

Original documentation © 2017 Riverbed Technology. Community translation, AI-assisted. Contact: jiazequn@znetlink.com