1. Overview and Benefits of Express VIs
An Express VI is a VI that allows users to interactively configure its settings through a dialog box. This simple user interface allows users without extensive programming expertise to configure complicated operations. You can configure multiple instances of a particular Express VI on the same block diagram with different configuration settings for each instance.
An Express VI consists of two main components:
· Source VI – Contains the code for the Express VI.
The block diagram of the configuration dialog box VI contains three sections: Initialize, Main While Loop, and Reconfigure.
2. Architecture of the genHelp VI and SubVIs
The genHelp VI, shown in the following graphic, is a subVI located in the Reconfigure section of a configuration dialog box VI. The VI is named genHelpExpressVIName.vi. It updates the Context Help window with the current configuration of the Express VI.
When you create an Express VI from a standard VI or from a blank VI, the Express VI Development Toolkit automatically configures the genHelp VI. If you create an Express VI from an existing Express VI, the new Express VI includes a copy of the genHelp VI from the original Express VI.
The front panel of the genHelp VI, as shown in the following example, consists of at least two parameters: the Output Cluster and the Help Description. The Output Cluster is a type definition control that provides a reference to the source and configuration dialog box VIs and their controls. The Output Cluster is a necessary part of the genHelp VI that you should not modify. The Help Description contains a string that updates the Context Help window with the current configuration of the Express VI. The front panel also includes a comment box that describes the purpose of the genHelp VI.
The basic architecture of the genHelp VI block diagram, as shown in the following example, includes the ex_PPGetProp subVI and the Help Description string indicator. he block diagram also includes a comment box with basic instructions for building the genHelp VI, which you can remove when you no longer need help.
The ex_PPGetProp VI is the primary subVI in the genHelp VI. The VI retrieves the value of a specified control based on references to the source and configuration VIs, the Control Data array, and the name of the control you want. The VI formats the control value for the Context Help window. The following example displays the connector pane of the ex_PPGetProp VI.
The following table describes the ex_PPGetProp VI inputs and outputs.
|CR/LF||Specifies whether the VI appends a linefeed (default) or a carriage return to the control value in order to separate objects in the Context Help window.|
|Suffix||Appends information to the control value, such as units of measure.|
|Output Cluster||(Required input) Provides references to the source and configuration VIs and to the Control Data array.|
|Previous String||Contains help string output from a previous call to the ex_PPGetProp VI.|
|Enum & T/F Strings||Specifies items for controls with multiple values, such as enumerated type controls, ring controls, or array of Boolean strings.|
|Prefix||Identifies the control value when it appears in the Context Help window.|
|Control:||(Required input) Specifies a constant or control to generate help according to the object label in the source VI.|
|Enum Result||Returns the string value of an enumerated type control or ring control.|
|String||Returns the value of a string control.|
|Int32||Returns the value of a 32-bit signed integer control.|
|Dbl||Returns the value of a double-precision numeric control.|
|Bool||Returns the value of a Boolean control.|
|Dbl String||Returns the value of a double-precision numeric control formatted as a string.|
|T/F Result||Returns the value of a Boolean control formatted as a string.|
|Int32 String||Returns the value of a 32-bit signed integer formatted as a string.|
|String (Path)||Returns the value of a path control formatted as a string.|
Use a new instance of the ex_PPGetProp VI for each control that contains a value you want to display in the Context Help window. The ex_PPGetProp VI appends the control value to the help string, so you must wire the output from one copy of the VI to the input of the subsequent VI. The resulting string appears in the Help Description indicator of the genHelp VI.
3. Creating the genHelp VI for the Simulate Signal Express VI
The Simulate Signal Express VI provides a good example for creating and configuring Express VI context help. Navigate to the Configure Simulate Signal VI located in vi.lib\express\express input\SimulateSignalConfig.llb. The Configure Simulate Signal VI is the configuration dialog box VI for the Simulate Signal Express VI. The front panel should resemble the following example.
Open the block diagram and examine the Control Data array. The Control Data array, which is part of the Initialize section of the configuration dialog box VI, lists the configurable terminals for the source VI. (Configurable terminals are controls that the user can configure in the configuration dialog box, as opposed to wiring a value to the Express VI.) The array includes all controls that transfer values between the configuration dialog box and the Express VI.
Each element in the Control Data array is a cluster that contains the following objects:
· SourceVI Ctl Label – Specifies the item label as it appears on the front panel of the source VI.
· ConfigDiag Ctl Label – Specifies the item label as it appears on the front panel of the configuration dialog box VI. An empty string indicates that the label is the same as the source VI label.
The following example shows a portion of the Control Data array for the Configure Simulate Signal VI.
You can use the first element in the array to create custom titles for an Express VI. Because the Simulate Signal Express VI does not display titles, you do not need to create context help for this element.
Use the genHelpGenerator VI, which is the genHelp VI for the Simulate Signal Express VI, to create context help for the Signal type element in the Control Data array.
Complete the following steps to edit the genHelpGenerator VI so it generates context help information for Signal type.
2. Enter the text Generate in the Control Name constant and delete all other text in the constant.
Note: The text of the Control Name constant must exactly match the name of the control as it appears in the Control Data array, including the correct case, or an error occurs when you run the Express VI.
4. Expand the resulting array to display five elements.
5. Enter the ring strings into the array in the exact order they appear in the Generate control (Sine, Square, Triangle, Sawtooth, DC). The genHelpGenerator VI uses the ring values to retrieve the appropriate string, such as Sine, and displays it in the Context Help window.
The following example shows the complete genHelpGenerator VI configuration for Signal type.
You must determine which ex_PPGetProp VI outputs to use to send the Signal type control value to the next instance of the ex_PPGetProp VI. Valid output types for each ex_PPGetProp VI depend upon the data type of the parameter that Control Name specifies. In this example, Generate is a ring control, so you should use the Enum Result and int32 outputs. Enum Result returns the string label and int32 returns the numeric value associated with the string.
The next series of elements in the Control Data array include Frequency, Amplitude, Phase and Offset. Some of these elements might not be valid and might not need to appear in the Context Help window, depending on the signal type that a user selects in the configuration dialog box. For example, if a user selects Sine, Square, Triangle, or Sawtooth for Signal type, then Frequency, Amplitude, Phase, and Offset are all valid parameters. However, if a user selects DC for signal type, only Offset applies. Consider these factors when you construct the next portion of the genHelpGenerator VI.
You can use a Case structure to determine which parameters are valid based on the signal type the user selects. The int32 output determines which case executes based on the selected signal, as shown in the following block diagram.
For example, if the user selects Sine as the signal type, int32 returns a value of 0 because Sine is the first element in the ring constant. Frequency, Amplitude, and Phase all apply to the AC signal types of sine, square, triangle, and sawtooth, so you want to generate context help for these parameters if int32 returns values of 0 through 3. These parameters do not apply to a DC signal, however, so you do not need to generate help if int32 returns a value of 4. Offset applies to all signal types, so you need to generate context help for this parameter no matter which value int32 returns.
The Case structure should have two cases: one for AC signals as shown in the above example, and another for DC signals as shown in the following block diagram.
You must use a different copy of the ex_PPGetProp VI for each parameter you want to appear in the Context Help window. For this example, you need to use four subVIs in case 0..3 for Frequency, Amplitude, Phase, and Offset, and one subVI in case 4 for Offset.
The Output Cluster is a required input of the ex_PPGetProp VI, so you must wire this input in every copy of the VI. Wire the Enum Result from the first copy of the VI to the Previous String input of the VIs you use in case 0..3.
Since Amplitude, Frequency, Phase, and Offset are all double-precision numeric controls in the source VI, use the dbl String output. Do not use the dbl output because you must format all information that appears in the Context Help window as a string. If you use the dbl output, you must convert the value to a string before sending it to the final Help Description string. The dbl String output eliminates this extra step. Use the non-string outputs of the ex_PPGetProp VI - int32, dbl, and bool - for decision making, as demonstrated above with the int32 output and the Case structure.
Use the Suffix input of the ex_PPGetProp VI to add units of measurement to the context help for a parameter. For example, you can add units of Hertz (Hz) to the Frequency control.
After you add the necessary elements to the genHelp VI, save and close the VI. The configuration dialog box VIs for all instances of the Express VI update with the new data. To test the context help, place an instance of the Express VI on a block diagram and press the <Ctrl-H> keys to open the Context Help window.