op_topo_connect_count()
摘要
获取指定的源对象与目的对象之间所请求类型的连接对象数量。
语法
op_topo_connect_count (src_objid, dst_objid, conn_objmtype)
| 参数 | 类型 | 说明 |
|---|---|---|
src_objid, dst_objid |
Objid |
被连接对象的对象 ID [对象 ID 可通过 Id 包中的多个内核过程获得: op_id_self()、op_id_from_userid() 和 op_id_from_name()。此外,对象 ID 也可从 Topo 包内核过程 op_topo_parent()、op_topo_child()、op_topo_assoc() 和 op_topo_connect() 的先前调用中获得。] |
conn_objmtype |
int |
连接对象的对象元类型 [该值是一个整数代码,指定所关注连接的对象类型(参见表 69“对象类型符号常量”第 19 页)。] |
返回类型
int
源对象与目的对象之间所请求类型的连接对象数量。若发生可恢复错误,将返回符号常量 OPC_INT_INVALID 所代表的特殊值。
示例
/* Loop through all of the connectors between the source and destination nodes */
/* and find the link with the lowest bit error rate. */
/* Initialize temporary variables. */
best_ber = 1.0; best_link_id = OPC_OBJID_INVALID;
/* Determine the number of connector links between source and destination. */
num_links = op_topo_connect_count (src_node_id, dest_node_id, OPC_OBJMTYPE_LINK);
/* Loop through the connector links and find the best link. */
for (i = 0; i < num_links; i++)
{
/* Obtain the link id and ber attribute value and compare with best so far. */
link_id = op_topo_connect (src_node_id, dest_node_id, OPC_OBJMTYPE_LINK, i);
op_ima_obj_attr_get (link_id, “ber”, &ber);
if (ber < best_ber)
{
best_link_id = link_id;
best_ber = ber;
}
}
详情
如果一个对象连接了另外两个对象,则该对象是连接对象。例如,数据包流可以连接两个模块,链路可以连接两个节点。有关有效的参考对象/连接对象类型组合列表,参见内核过程 op_topo_connect() 的“详情”部分中的表格。
用途
提供了一种确定源对象与目的对象之间连接对象数量的机制,这对于为对每个连接对象执行某些操作的循环设定边界非常有用。若要获得每个连接对象的对象 ID,可以使用源对象和目的对象的对象 ID、定义该对象类型的同一符号常量以及循环索引来调用内核过程 op_topo_connect()。
错误
- 可恢复错误:源对象 ID (<src_objid>) 超出范围。
- 可恢复错误:目的对象 ID (<dst_objid>) 超出范围。
- 可恢复错误:对象元类型 (<conn_objmtype>) 无法识别。
- 可恢复错误:源对象 ID (<src_objid>) 指向受限对象。
- 可恢复错误:目的对象 ID (<dst_objid>) 指向受限对象。
参考
- 使用内核过程 op_topo_connect() 获取连接对象的对象 ID
- 使用内核过程 op_ima_obj_attr_get() 获取对象属性的值
- 使用内核过程 op_ima_obj_attr_set() 为对象属性赋值
- 使用内核过程 op_topo_assoc_count() 确定输入或输出关联的数量
- 使用内核过程 op_topo_child_count() 确定对象的子对象数量
- 使用内核过程 op_topo_object_count() 确定特定类型的对象数量