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); }