op_topo_object()
Abstract
Obtains the object ID of an object specified by its type and index.
Syntax
op_topo_object (objmtype, index)
| Argument | Type | Description |
|---|---|---|
objmtype |
int |
object type [This value is an integer code that specifies the object type of the object-of-interest (see Table 69 “Object Type Symbolic Constants“ on page 19).] |
index |
int |
numeric index of the object [Object indices start at 0 and increment by one, up to the number of objects of that type less one.] |
Return Type
Objid
Object ID of the specified object. The special value represented by the symbolic constant OPC_OBJID_INVALID will be returned if a recoverable error occurs.
Example
/* Loop through the bus transmitter channels and abort all transmissions. */
/* Obtain the number of bus transmitter channels in the model. */
txch_count = op_topo_object_count (OPC_OBJTYPE_BUTXCH);
/* Loop through the channels and abort the transmission. */
for (i = 0; i < txch_count; i++)
{
ch_id = op_topo_object (OPC_OBJTYPE_BUTXCH, i);
op_ima_obj_command (ch_id, “abort”);
}
Details
None.
Purpose
Provides a mechanism to obtain the object ID of an object based on its type, regardless of its location in the object hierarchy. This is useful when a process needs to obtain or assign attributes that belong to objects of one type. For example, a process may need to set the bit error rate of all bus links to 0.0 at the beginning of the simulation. The KP op_topo_object_count() will provide the upper bound for the loop that will call op_topo_object() to obtain each bus link’s object ID followed by op_ima_obj_attr_set() to set the bit error rate attribute value.
Errors
- Recoverable Error: Object meta-type (<objmtype>) is unrecognized.
- Recoverable Error: Object index (<index>) is out-of-range.
Reference
- Use the KP op_topo_object_count() to determine the number of objects of a particular type
- Use the KP op_ima_obj_attr_get() to obtain the value of an object’s attribute
- Use the KP op_ima_obj_attr_set() to assign the value of an object’s attribute