1. DescriptionIn TestStand, you can create custom step types as well as copy and edit existing step types. In this example, you edit the Numeric Limit Test step type to have the following two sets of limits:
- Warning Limits
- Pass/Fail Limits
You can create a custom step type in the type palette or in a sequence. If a custom step type is created in the type palette, it can be used in all sequences. To create a step type in the type palette, click the Type Palette button, shown in Figure 1, and select the Step Types tab. To create a step type in the sequence, select Sequence File Types in the View ring control as shown in Figure 2. Then, select the Step Types tab.
Figure 1. Type Palette Button
Figure 2. View Ring Control
To create a new Extended Numeric Limit Test step type, open the Type Palette window and go to the NITypes.ini palette. Copy the Numeric Limit Test step type. Now, open up the MyTypes.ini palette by selecting it from the Palette ring control as shown in Figure 3.
Figure 3. Palette Ring Control
Paste the Numeric Limit Test step type into this type palette. The Paste Type dialog box launches, as shown in Figure 4. This means that the Numeric Limit Test step type that you paste into the MyTypes.ini type palette is actually a reference to the Numeric Limit Test step type and not a copy of the Numeric Limit Test step type. You can determine this because the name of the step type does not change. Two different TestStand types cannot exist with the same name. You have now added the reference to the Numeric Limit Test step type to the MyTypes.ini palette.
Warning: Do not rename or in any other way modify the Numeric Limit Test step type shown in MyTypes.ini. Renaming or modifying the Numeric Limit Test step type changes all open definitions and instances of the Numeric Limit Test step type.
To create a copy of the Numeric Limit Test step type, paste the Numeric Limit Test step type into MyTypes.ini again. The second time you paste the step type it is renamed NumericLimitTest_Copy. Rename the copy to ExtendedNumericLimitTest.
Figure 4. Paste Type Dialog Box
Select the ExtendedNumericLimitTest step type in the tree view. This displays the contents of the step type in the list view. In the right pane, right-click on Limits and select View Contents from the context menu. You should now see the High and Low limit properties. Right-click in the right pane and select Insert Field>>Number from the context menu, as shown in Figure 5.
Figure 5. Inserting a Number Field
Rename the new field WarningHigh. Right-click in the right pane again and insert another number. Rename the new field WarningLow. The Limits container of ExtendedNumericLimitTest now contains four fields.
In the Result container of your step type, add a Boolean and rename it Warning. This is the flag that will show if the number is outside of the warning limits. To show the Warning flag in the report, right-click on the Warning property and select Properties from the context menu. In the Properties dialog box click Advanced. This launches the Edit Flags dialog box. Check the IncludeInReport flag. Locating the Warning property in the Result container instructs TestStand that its value should be collected, and enabling the IncludeInReport flag adds the value to the generated report.
Initialize the default values of the new fields as follows:
- Double-click on the WarningLow property and set its default value to 3.
- Double-click on the WarningHigh property and set its default value to 7.
Setting the Extended Numeric Limit Step Properties
In the left pane, right-click on ExtendedNumericLimitTest, and select Properties from the context menu. This launches the Step Type Properties dialog box, as shown in Figure 6. Use the Step Type Properties dialog box for configuring the properties, code modules, and default actions for a step type. For more information about the Step Type Properties dialog box, refer to the TestStand Help. Now, examine each tab and configure the properties for the new step type.
Figure 6. Step Type Properties Dialog Box General Tab
- General Tab-Contains the default name, description, icon, and the type of adapter associated with the step type. In the Default Step Name Expression control, replace ResStr("NI_STEPTYPES", "NUM_DEF_STEP_NAME") with “Extended Numeric Limit Test”.
- Menu Tab-Specifies the text that appears in the Insert Step submenu when an instance of this step type is inserted into a sequence. Enter “Extended Numeric Limit Test” in the Item Name Expression control as shown in Figure 7.
Figure 7. Step Type Properties Dialog Box Menu Tab
- Substeps Tab-Specifies the substeps for the step type. It is possible to call code modules as Pre-Step and Post-Step substeps for each step type. This is not the same code module as the step module that can be specified for each step instance. You cannot customize the substeps for a particular step. If a Pre-Step or Post-Step is specified, that code module is called at every execution in every instance of the step type. During execution, TestStand calls all Pre-Step substeps before calling the step module and all Post-Step substeps after calling the step module. Since you are going to execute the warning test by setting a warning flag (Results.Warning), you do not need to add a Post-Step substep. You could create a substep to run a code module if the limits were outside the warning limits, but you would have to perform the check in either another Post-Step substep that runs before this one, or within your substep. This is because all Post-Step substeps run before the Post Expression where you will put the limit check.
Using the Function Name control, select the EditExtendedNumericLimits function. When you are prompted to use parameter information from the provided function, select Yes. This function takes the sequence context as a parameter. For the Value Expression control, click the adjacent Expression Browse button. When the Expression Browser dialog box launches, select ThisContext. Click Insert and then the OK button. The Edit C/C++ DLL Call dialog box should appear as shown in Figure 8.
Figure 8. Edit C/C++ DLL Call Dialog Box
Click OK to return to the ExtendedNumericLimitTest Property dialog box.
In TestStand 2.0 or later, you now have the option to add multiple Edit substeps. Instead of changing the existing Edit substep, you can create a new edit substep just for the warning. To add a new Edit substep, select the adapter you want from the Adapter ring control. For this example, select the LabVIEW Adapter. Click Add and select the Edit Substep option as shown in Figure 9.
Figure 9. Adding a New Edit Substep
Select the new Edit substep and select Specify Module. Type in EditWarningLimits.vi in the VI Pathname field. Select Show VI Front Panel When Called and then click the Create VI button.
Figure 10. Edit LabVIEW VI Call Dialog Box
You will see a VI with three objects on the Front Panel that you will not want to see on your dialog box. Move to a section of the front panel that is blank and add the following controls to the dialog box. Your front panel should resemble Figure 11.
- Low – Numeric Control
- High – Numeric Control
- OK button
- Cancel Button
Figure 11. EditWarningLimits.vi Front panel
Select File>>VI Properties and choose Window Appearance from the Category ring control. Select the Dialog option and press the Customize button. The VI Properties dialog box should be configured as shown in Figure 12.
Figure 12. VI Properties Dialog Box
Disable the Allow User to Close Window option to ensure that the dialog box closes properly. Click OK and OK again to return to the front panel.
Figure 13. Customize Window Appearance Dialog Box
Go to the block diagram of your VI. The first step is to populate the block diagram with the two limits. The block diagram in Figure 14 shows how to do this.
Figure 14. Adding the Limits to Your Block Diagram
Next, you need to loop until the user selects the OK button or the Cancel button. If the user selects the OK button, the values need to be written to the step. The remainder of the block diagram is shown in Figure 15.
Figure 15. Loop in Block Diagram
The last step is to set the warning flag to evaluate if the value returned is outside the warning limits. Select the Default Expressions tab and type the following into the Status Expression field.
Step.Result.Warning = (CheckLimits(Step.DataSource == "Step.Result.Numeric" ? Step.Result.Numeric : (Step.Result.Numeric = Evaluate(Step.DataSource)), step.limits.Warninghigh, step.limits.Warninglow, step.Warningcomp)) == "PASSED" ? False:True,CheckLimits(Step.DataSource == "Step.Result.Numeric" ? Step.Result.Numeric : (Step.Result.Numeric = Evaluate(Step.DataSource)), step.limits.high, step.limits.low, step.comp)
This performs both limit checks. CheckLimits is a new expression function that performs the test and returns “Passed” or “Failed”.
Figure 16. Status Expression