op_ima_sim_attr_exists()

摘要

判断某个仿真属性值是否在仿真环境中已定义。

语法

op_ima_sim_attr_exists (attr_name)
参数 类型 说明
attr_name const char* 目标属性的名称

返回类型

Boolean

布尔值,指示指定属性值是否在环境中已定义。

如果属性值已定义,该值等于常量 OPC_TRUE;否则返回值为 OPC_FALSE。

示例

/** This procedure loads in the .gdf file that specifies the link																	**/
/** configuration via the 'user id' attribute of duplex links.																	**/
/** If there is any error, an error message will be displayed and																	**/
/** the simulation terminated.																	**/
FIN (ams_atm_sw_link_table_setup ());
/* If the table has already been loaded in, just return the pointer. */
if (vp_lt_ptr != OPC_NIL)
	FRET (vp_lt_ptr);
/* Check if the simulation attribute exists */
if (op_ima_sim_attr_exists ("vp_config_file") == OPC_FALSE)
	FRET (OPC_NIL)
/* First, obtain name of configuration file.	*/
op_ima_sim_attr_get (OPC_IMA_STRING, "vp_config_file", vp_config_file);

详情

仿真属性的值通过环境属性机制赋值:仿真的命令行、偏好设置文件、shell 变量或环境文件。KP op_ima_sim_attr_get() 会扫描仿真的内部数据库以寻找可能的值。如果在内部数据库中找不到该值,它会通过标准输出设备向用户请求一个值。一旦从环境属性机制或用户处获得值,该值就会被加入仿真的内部数据库。

如果仿真属性在仿真的内部数据库中已有指定值,本 KP 将返回 OPC_TRUE;否则返回 OPC_FALSE。因此,如果对 op_ima_sim_attr_exists() 的调用对某属性返回 OPC_FALSE,那么对 op_ima_sim_attr_get() 的调用将会查询查询标准输出设备以获取一个值。

用途

仿真属性可以通过 KP op_ima_sim_attr_get() 动态获取。但是,如果为某个仿真属性未指定值,该 KP 会通过标准输出设备向用户请求一个值。使用 KP op_ima_sim_attr_exists(),进程或管道阶段可以避免让仿真直接向用户询问属性值。

在某些情况下,仿真属性是以条件方式定义的。而且属性名称可能依赖于动态确定的信息。在这些情况下,进程或管道阶段可能需要在获取属性值之前,通过 op_ima_sim_attr_exists() 检测该仿真属性是否存在。

错误

  • 程序中止:段违例(由于 attr_name 的地址无效)

参考

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · 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