op_topo_object_count (objmtype)
/*Determine the number of mobile nodes*/
numnodes = op_topo_object_count(OPC_OBJTYPE_NDMOB);
可以获得指定对象类型对象的个数。
比如可以获得移动节点的个数。
配合op_topo_object (objmtype, index)
可以为同一种类型的对象进行循环操作。
/* 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");
}
lmz:
既可以获得节点层的对象也可以获得子网层的对象。
op_ima_sim_attr_get (attr_type, attr_name, value_ptr)
获取仿真属性的值
/*Read in the simulation attributes*/
op_ima_sim_attr_get(OPC_IMA_DOUBLE, "SIFS", &sifs);
op_ima_sim_attr_get(OPC_IMA_