In this example, you will use the Module Builder to create a simple module that adds a single number to each data value of a set.
Note: This function is supplied with Data Explorer as part of the Compute module and is used here only for purposes of illustration.
Name | Type in a name for the module (for this example, use "Add.") |
Category | Select a category for the new module, either by clicking on one of the entries in the Existing pull-down menu or by typing in a menu name or a name of your choosing. |
Description | Type in a short description of the module. This description will appear in the module's configuration dialog box (in the VPE window). |
Number of inputs | Use the stepper buttons to set the value to "2." The two inputs of the new module will be a data Field and the number to be added to each data value. |
Number of outputs | The module generates a single output. Use the stepper buttons to set the value to "1" if that is not already the value. The output is the new Field (i.e., the data value plus the added value). |
Outboard | Activate the outboard toggle button and type in "Add" in the Executable Name field. (Leave the other toggle buttons and fields as they are.) Note: In this example, the new ("outboard") module is an independent process. In contrast, an "inboard" module is compiled and incorporated as part of the Data Explorer executable; and a runtime-loadable module is compiled independently and loaded into Data Explorer at run time. |
Input Number < 1 > | The first input is the data field.
|
Input Number < 2 > | The second input is the value to be added to each data value.
|
Output Number < 1 > | Now describe the output of the module.
|
You can now create the necessary files:
The Module Builder creates three files for the Add module: Add.c, Add.mdf, and Add.make.
int i; float value; if (value_knt==0) value = 0; else value = value_data[0]; for (i=0; i<data_knt; i++) { result_data[i] = data_data[i]+value; }
First, variables i and value are declared. Next, the default value of 0 is enforced by checking whether a number has been passed as the value parameter. If value_knt is equal to 0, the user did not pass a number, and value is set to 0. Otherwise, the passed number is used. Finally, the data component of the output is modified by adding value to every data item in the input.
Alternatively, you could have put this information in a separate file and used the Include File Name option in the Overall Module Description section.
To create a version of Data Explorer that uses this module, type
make -f Add.makeTo run Data Explorer using this module, type
dx -edit -mdf Add.mdfIf you were creating an inboard module instead, the only difference would be in the command to run Data Explorer:
dx -edit -mdf Add.mdf -exec ./dxexec
[Data Explorer Home Page | Contact Data Explorer | Same document on Data Explorer Home Page ]