oms_dist_scaled_load_from_string 用法

oms_dist_scaled_load_from_string怎么用,一开始我查找帮助文档,发现没有详细的说明!于是我在 Opnet安装路径中搜索。 它是Opnet Model Support functions,使用它时必须包含以下头文件: #include 在这个头文件中,可以看到其原型为: OMSC_EXPORT OmsT_Dist_Handle oms_dist_scaled_load_from_string (const char* dist_string, double scaling_factor); 可以查看其具体实现: OMSC_EXPORT OmsT_Dist_Handle oms_dist_load_from_string (const char* dist_string) { const char* dist_name; int input_arg_count; int dist_arg_count; const char* dist_arg0_string = ""; const char* dist_arg1_string = ""; const char* file_name = ""; OmsT_Dist_Handle dist_handle; Prg_List* dist_string_lptr; char msg_string1 [128]; /** Takes a string of the form "dist_name (arg0, arg1)", **/ /** and retruns a OmsT_Dist_Handle. This handle contains **/ /** distribution-related information or a script file **/ /** information. **/ FIN (oms_dist_load_from_string (dist_string)); /* Determine the components of the supplied string. */ dist_string_lptr = prg_str_decomp (dist_string, " (,)"); /* Is the input specification a valid distribution? */ input_arg_count = prg_list_size (dist_string_lptr); if (input_arg_count == 0) { dist_handle = OPC_NIL; } else { /* Determine the number of supplied arguments. Note */ /* that the first element in the list is the name. */ dist_arg_count = input_arg_count - 1; /* The first element should be the distribution name. */ dist_name = (const char *) prg_list_access (dist_string_lptr, 0); /* Check if a proper distribution has been specified. */ if (strcmp (dist_name, "unset") == 0) { /* A proper distribution has not been specified. */ dist_handle = OPC_NIL; } else if (strcmp (dist_name, "scripted") == 0) { /* Obtain the file name from the string list */ if (dist_arg_count == 1) { /* Get the first argument (Filename). */ file_name = (const char *) prg_list_access (dist_string_lptr, 1); /* Call the procedure to create a distribution */ /* handle and load the specified file contents. */ dist_handle = oms_dist_load_from_file (dist_name, file_name); } } else { /* The next two, if applicable, are the arguments using */ /* which the distribution will be loaded. */ if (dist_arg_count >= 1) { /* Get the first argument. */ dist_arg0_string = (const char *) prg_list_access (dist_string_lptr, 1); } if (dist_arg_count >= 2) { /* Get the first argument. */ dist_arg1_string = (const char *) prg_list_access (dist_string_lptr, 2); } /* Check if proper arguments have been specified. */ if ((strcmp (dist_arg0_string, "mean") == 0) || (strcmp (dist_arg0_string, "order") == 0) || (strcmp (dist_arg0_string, "min") == 0) || (strcmp (dist_arg0_string, "location") == 0) || (strcmp (dist_arg0_string, "shape") == 0) || (strcmp (dist_arg1_string, "variance") == 0) || (strcmp (dist_arg1_string, "shape") == 0) || (strcmp (dist_arg1_string, "max") == 0) || (strcmp (dist_arg1_string, "scale") == 0)) { dist_handle = OPC_NIL; } else { /* Load the requested distribution. */ dist_handle = oms_dist_load (dist_name, (double) atof (dist_arg0_string), (double) atof (dist_arg1_string)); } } /* Deallocate any memory used by the list used to */ /* temporarily contain input arguments. */ prg_list_free (dist_string_lptr); prg_mem_free (dist_string_lptr); } /* Check if a valid distribution handle was created. */ if (dist_handle == OPC_NIL) { /* A valid distribution handle was not created. */ /* Generate an error message and terminate the */ /* simulation. */ sprintf (msg_string1, "Error loading distribution /"%s/"", dist_string); op_sim_end (msg_string1, "Please check the input string .....", OPC_NIL, OPC_NIL); } /* Return the loaded distribution. */ FRET (dist_handle); }
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值