Description
It is often the case that a user would like to add additional information about their Unit Under Test (UUT). This could include adding the high and low limits of a Numeric Limit Test to the step results reported in the Execution Window of the standard LabWindows/CVI Operator Interface, as demonstrated in this example. Although this may seem like a trivial task, the code of the interface can be a bit overwhelming to some. This document will explain how to achieve this with the standard LabWindows/CVI Operator Interface installed with TestStand 2.0. Although the concepts will be similar to TestStand 1.0.x, there are some differences in the methods and properties exported by the Application Programming Interface (API) between the two versions. As a result, the screen shots below may not exactly resemble those for TestStand 1.0.x. The LabWindows/CVI Operator Interface code is located in the <TestStand>\OperatorInterfaces\NI\CVI directory. When you launch the operator interface, the Sequence File Window will open. In the Sequence File Window, you can load sequences, toggle between sequences, and place breakpoints within sequences. The Sequence File Window of the Operator Interface is comparable to that of the Sequence Editor. Once you run your sequence using the Test UUTs or Single Pass execution entry points, the Execution Window will appear. By default the Execution Window provides the status of your steps as they are executed.
The status of the steps and other information pertaining to the steps are added to a string within LabWindows/CVI. You will add the high and low limits of the Numeric Limit Test to this string. Thus you will see the name of the Numeric Limit Test and the high and low limits associated with this step in both the Sequence File Window and the Execution Window.
Part A: Locating Where to Add the New Result
Before modifying the Operator Interface, copy the contents of <TestStand>\OperatorInterfaces\NI\CVI directory to the <TestStand>\OperatorInterfaces\User\CVI directory.
Note: Do not modify the contents of the <TestStand>\Components\NI directory. When you customize TestStand components, copy the components to the <TestStand>\Components\User directory. TestStand automatically searches for files found in the User directory before using those found in the NI directory. This will also prevent you from overriding the default components.
Open testexec.prj in LabWindows/CVI. This project contains all of the files used to make the LabWindows/CVI Operator Interface.
The main components of the LabWindows/CVI Operator Interface include:
· Maingui.c – Contains all the graphical user interface code that is not specific to the Execution or Sequence File window. This includes code to handle the single window (tab dialog) setting of the application as well as initialization and cleanup of the different display components such as the Tools menu. Also, this file contains all user interface components that are common to both the Sequence File and Execution windows. For example, menu item callbacks that are common to both the Sequence File and Execution windows are located in this file.
· Engine.c – Contains all of the code that accesses the TestStand ActiveX automation server. Engine.c also creates and destroys the records of data for sequence files, executions, sequences, steps, and so on.
· Data.c – The purpose of the code in this file is to provide an interface for accessing all of the global data and settings shared amongst the other source modules in the project.
Because we want to modify the graphical display of the Sequence File and Execution Windows to include additional information for Numeric Limit steps, we will modify the source code of maingui.c.
Within maingui.c, one of the functions is called AddStepToStepListControl. This function adds the data for each step to the List control that is displayed on the Sequence File and Execution windows. We only have to make modifications to this one function to add high and low limits for Numeric Limit Tests.
Part B: Adding High and Low Limits for Numeric Limit Tests
Inside of maingui.c, locate the AddStepToStepListControl function approximately 325 lines into the source file.
The first change to make is to increase the size of the string that we can print additional fields to the Operator Interface:
/* build the listbox string */
stringSizeNeeded = strlen(step->stepName) + 350;
/* Original code: stringSizeNeeded = strlen(step->stepName) + 250; */
The next step is to get a reference to the current step. We need the reference to check if the current step is a numeric limit step and if so, to get the limits. The following code will get a reference to the step and see if the step has a High Limit. If so, then we know that the current step is a Numeric Limit Step.
/* Get step as a property object. Declare myStep as: CAObjHandle myStep; */
TS_StepAsPropertyObject (step->stepH, NULL, &myStep);
/* Check for a High Limit property of the current step. Declare exists as: VBOOL exists; */
TS_PropertyExists (myStep, NULL, "Limits.High", 0, &exists);
Once we know if the current step is a Numeric Limit Step, we can format the string that contains the step name and limits by using simple conditional statements.
Inside the drawDimmed if-statement, which determines if the text line should be printed in dimmed text or regular text, we add another if-statement to see if the Limits.High property exists by checking the Boolean “exists”. If it does exist, then we can get the High and Low Limit from the current step. Then we only have to add the High and Low Limit to the string that will be printed to the Operator Interface.
We can add the same code to the else statement of if(drawDimmed) because we want the Limits to be printed in both modes of text formatting. The bold code below is added or modified code:
if(drawDimmed){
if(exists) /* If a high limit exists, the current step is a numeric limit step */
{
/* Add High and Low limits to step status. myHighLimit and myLowLimit are declared as:
double myHighLimit = 0.0; double myLowLimit = 0.0; */
TS_PropertyGetValNumber (myStep, NULL, "Limits.High", 0, &myHighLimit);
TS_PropertyGetValNumber (myStep, NULL, "Limits.Low", 0, &myLowLimit);
sprintf(tmpStr, "\033fg%x\033p%dl%s\033p%dl%s\033p%dl%s\033p%dl%s", greyTextColor, colLoc,
drawPointer?"->":"", colLoc + 25, breakAndRunModeBuf, colLoc + 50, statusBuf,
colLoc + 120, step->stepName);
/* Add the extra high and low limit strings to the formatted string that will be shown on the OI */
Fmt (tmpStr, "%s<%s %s %f %s %f", tmpStr, "Low Limit", myLowLimit, "High Limit", myHighLimit);
}
else /* Step is not a numeric limit step. Create string with no extra information */
sprintf(tmpStr, "\033fg%x\033p%dl%s\033p%dl%s\033p%dl%s\033p%dl%s", greyTextColor, colLoc,
drawPointer?"->":"", colLoc + 25, breakAndRunModeBuf, colLoc + 50, statusBuf,
colLoc + 120, step->stepName);
} /* end of if (drawDimmed) is true */
else {
if(exists) /* If a high limit exists, the current step is a numeric limit step */
{
/* Add High and Low limits to step status */
TS_PropertyGetValNumber (myStep, NULL, "Limits.High", 0, &myHighLimit);
TS_PropertyGetValNumber (myStep, NULL, "Limits.Low", 0, &myLowLimit);
sprintf(tmpStr, "\033p%dl%s\033p%dl%s\033p%dl%s\033p%dl%s", colLoc, drawPointer?"->":"",
colLoc + 25, breakAndRunModeBuf, colLoc + 50, statusBuf, colLoc + 120, step->stepName);
/* Add the extra high and low limit strings to the formatted string that will be shown on the OI */
Fmt (tmpStr, "%s<%s %s %f %s %f", tmpStr, "Low Limit", myLowLimit, "High Limit", myHighLimit);
}
else /* Step is not a numeric limit step. Create string with no extra information */
sprintf(tmpStr, "\033p%dl%s\033p%dl%s\033p%dl%s\033p%dl%s", colLoc, drawPointer?"->":"", colLoc + 25,
breakAndRunModeBuf, colLoc + 50, statusBuf, colLoc + 120, step->stepName);
} /* End of drawDimmed else statement */
After we compile and run the Operator Interface, when we run a sequence that has Numeric Limit Steps, we see the high and low limits for only the Numeric Limit Steps in both the Sequence Display and the Execution Window.

[+] Enlarge Image

[+] Enlarge Image
What To Expect
See the file in the download section.
Reader Comments | Submit a comment »
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
