User Interface Customization

OPNET Development Kit comes with a default interface that includes all of the tools and menu items supported by NetPlanner. You can, however, add elements to the interface or remove them. You can alter the functionality of a given tool or create several versions of the same tool, each with a different focus.

The configuration files summarized in the last section and explained in depth below control the availability of tools, standard action buttons, and ETS functions. By altering these files or creating alternate versions of your own, you can customize the user interface and tailor it to your specific needs.

The following sections explain the editor configuration file (OPNET Development Kit's top-level configuration file) and the process for creating variations on the existing tool set.

Creating Editor Variations

You can alter the standard NetPlanner tools by adding operations to them that use external programs (via ETS) and by removing existing operations. When you create a new entry in the editor configuration file that points to the altered definition files, an ODK application displays a menu item for the new operation. When the user chooses the new menu item, the specialized code is executed.

To create an editor variation, you need to:

  1. Alter the definition files to remove the menu operations you do not want, and add menu operations that use external programs.
  2. Create an entry in the editor configuration file for the new operation.

The ODK application will now contain the modified editor the next time it is started.

You might need to compile and link custom libraries. See "Building a Code Library" on page 13 for instructions.

The following sections present three examples of new functionality added via ETS.

Example: Controlling User Input

This project illustrates how to place algorithmic restrictions on the way links are connected. The network in question includes a router with a type attribute and a traffic-generating node with a customer attribute. The goal is to prevent the user from linking two traffic-generating nodes with the same customer attribute value to the same router.

The solution uses Ets_Nt_Object_Install_Callback_Register() to register a callback function that is called whenever an object is installed into the network. Ets_Nt_Object_Install_Callback_Register() is called from within a function called <project name>_ets_init, which is called when the application starts.

The callback function registered by Ets_Nt_Object_Install_Callback_Register() performs the algorithmic checks. The callback returns nothing but, as with all other ETS functions that need to be called from within an ODK application, it should be exported with DLLEXPORT.

The callback prototype is:

typedef void
(*EtsT_Nt_Object_Install_Callback)
   (EtsT_Obj_Handle * obj_handle_array, int array_size, void *state_ptr,
   EtsT_Nt_Object_Install_Src source)

This function:

  1. Checks to see if the installed object is a link, using Ets_Obj_Type_Get().
  2. If the object is a link and the endpoints are a traffic-generating node and a router, compares the customer attribute of the new node to the customer attributes of all other traffic-generating nodes connected to that router. The function uses Ets_Topo_Assoc_Get() to get handles to the endpoints and Ets_Obj_Attr_Get() to get their attribute values.
  3. If any existing node has the same customer attribute, destroys the link and prints an error message.

Example: Duplicating a Scenario

This project illustrates how to call a function for a specific task. In this case, the user has a custom file format but wants to use the Duplicate Scenario menu item to make a copy in both the custom format and the Riverbed format.

The developer has two options:

  • Create a custom function that does the entire duplication itself.
  • Create a custom function that performs the custom file duplication and then calls the standard scenario duplication function by using Ets_Command_Builtin_Exec (duplicate_scenario).

To implement the functionality using the second option, the developer:

  1. Creates the custom function.

  2. Modifies the std_project_scenarios_operations.ets file to call the custom function. The operation for the Duplicate scenario menu item is typically:

    operation: exec_builtin duplicate_scenario
    

    After modification, it becomes:

    operation: exec_function <library_name> <function_name>
    

    <library_name> is the name of the function without the file extensions (for example, just mylibrary instead of mylibrary.gui32.i0.ets.so) and the function cannot take any arguments.

    The function is called automatically when the menu item is clicked.

Example: Spawning an External Program

The goal is to add a button that spawns an external program with the current project-scenario name as its argument.

The tasks are to:

  1. Create a button by adding the following lines to std_project_icon_operations.ets:

    start_operation
       operation: exec_function <library_name> <function_name>
       icon:      your_icon_name
    end_operation
    

    <function_name> should be the name of the function described in step 3).

  2. Create an icon using the icon editor, as described in the Icon Database Editor chapter of the Modeler Editors Reference manual.

  3. Create a function (spawn_prog in this example) that gets the project-scenario name and spawns the external program. This function will include the following standard ETS function:

    /* Get the current model handle and name of the network. */
    Ets_Project_and_Scenario_Name_Get (model_handle_buffer);
    

The spawn_prog function then spawns the external program with the project-scenario name as its argument, by calling the standard C function system:

char arg_str[255];

sprintf (arg_str, "%s %s", external_prog, project_scenario_name);
system (arg_str);

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