Example Code

Tile UUT Dialog Box Horizontally in TestStand for Parallel Tests

This is the standard layout of UUTs under the parallel test.

2009-06-18_142225.png

If you would like to modify the layout of the UUTs such as tiling them horizontally you need to do some serious heavy lifting. This functionality is provided to you normally via the ParallelModel.seq, so we will need to create a custom process model becaust the Run UUT Info Dialog sequence cannot be overridden by a client sequence. This is a dangerous procedure, do not write over the existing process model, make a copy, and do some research on ni.com about how to edit process models. If you know what you are doing then you can change the layout of the UUTs as seen below.

2009-06-18_141354.png

Once you have copied, and renamed your sequence file, load it into teststand and select the Run UUT Info Dialog sequence to edit. Here you will see that using the c adapter we are calling modelsupport2.dll inorder to render the UUTs. You can find this dll under C:\Program Files\National Instruments\TestStand 4.1.1\Components\Models\TestStandModels along with all the support files. Copy the support files into a new folder and rename each of the files to make sure that you never edit the system files. I appended "My_" infront of the filenames so that "paralleluutdlg.c" becomes "My_paralleluut.dlg.c", this re-naming may break the links in your project. Re-add them, you can use the below image as a guide if you forget.

2009-06-18_143434.png

Once you've changed all of the file names (note your file names should NOT match the picture above) and re-added them to the project open up the file formerly named paralleluutdlg.c and make the following modifications.

Change MakeNewTestSocket to the following that takes in an additional parameter leftPos. This parameter will specify the absolute value in the x coordinate of the test socket from the left.

static int MakeNewTestSocketCtrls(int parentPanel, int childPanel,
                                    int topPos, int leftPos, int testSocketIndex,
                                    TestSocketData *dataArray)
{
    int                    error = 0;
    int                    i, relTop, relLeft, bgCtrlTop, bgCtrlLeft;
    TestSocketData        *newTestSocket = &(dataArray[testSocketIndex]);
    char                tmpNumBuf[20];
    int                 ParallelControlwidth = 0;







    // Get the position of the bg control.
    // All other controls are relative to this one.
    errChk( GetCtrlAttribute (parentPanel, sTestSocketTemplate.ctrls[kTSCtrl_Bg],
                              ATTR_TOP, &bgCtrlTop));
   
    // bgCtrlTop absolute top value of background of control
   
   
    errChk( GetCtrlAttribute (parentPanel, sTestSocketTemplate.ctrls[kTSCtrl_Bg],
                              ATTR_LEFT, &bgCtrlLeft));
   
    //bgCtrlLeft absolute left value of background of control
   
   
     errChk( GetCtrlAttribute (parentPanel, sTestSocketTemplate.ctrls[kTSCtrl_Bg],
                              ATTR_LEFT, &bgCtrlLeft));
   


    for(i = 0; i < kTSCtrl_NumCtrls; i++)
    {
        if(i == kTSCtrl_Bg) {
            relTop = 0;
            relLeft = 0;
        } else {
            // Get the position of this control relative to the bg control.
            errChk( GetCtrlAttribute (parentPanel, sTestSocketTemplate.ctrls,
                                      ATTR_TOP, &relTop));
            errChk( GetCtrlAttribute (parentPanel, sTestSocketTemplate.ctrls,
                                      ATTR_LEFT, &relLeft));
            relTop -= bgCtrlTop;
            relLeft -= bgCtrlLeft;
        }

        errChk( newTestSocket->ctrls
                        = DuplicateCtrl (parentPanel, sTestSocketTemplate.ctrls,
                                         childPanel, 0, topPos + relTop, relLeft+ leftPos));
        errChk( SetCtrlAttribute (childPanel, newTestSocket->ctrls, ATTR_VISIBLE, 1));
        errChk( SetCtrlAttribute (childPanel, newTestSocket->ctrls, ATTR_CALLBACK_DATA,
                                  (void *)testSocketIndex));
    }


   
   
   
       
    // initialize ctrls
    sprintf(tmpNumBuf, "%d", testSocketIndex);
    errChk( SetCtrlVal (childPanel, newTestSocket->ctrls[kTSCtrl_TestSocketIndex], tmpNumBuf));
    errChk( RecessFrame(childPanel, newTestSocket->ctrls[kTSCtrl_SerialNum]));

Error:

    return error;
}



Once we have edited the above function we must edit the function that calls it. In InitializeParallelUUTDialog we must change the way the UUTs are displayed width wise versus vertically:


    //## this makes  horizontal bar, it is set for the number of test sockets, you can change this  
    SetPanelAttribute (childPanel, ATTR_WIDTH, (min(MAX_NUM_TEST_SOCKETS_VISIBLE,(int)numTestSockets)*childCtrlsWidth) + scrollBarWidth);
   
   
    //## this makes a scrollable horizontal bar, it is set for the number of test sockets, you can change this
    SetPanelAttribute (childPanel, ATTR_HEIGHT, childCtrlsHeight );

with this minor change in place we need to scroll down to the for loop inside of the InitializeParallelUUTDialog and modify the MakeNewTestSocketCtrls() to make use of our updated function:

        errChk( MakeNewTestSocketCtrls(panelId, childPanel, 0, childCtrlsWidth*i, i , panelData->testSocketDataArray));

With these changes compile your dll, and then point your process model this DLL

2009-06-18_142004.png

Save your process model and then select it by going to Configure » Station Options » Model and select your custom station model. Now when you run a sequence your UUTs will tile horizontally rather than vertically. There are many more modifications that you can make to this popup, this is only the beginning, and is meant to be more of a getting started guide rather than an authoratative manual. If you have problems with this check the example "My_paralleluutdlg.c" and you can point your process model to the dll i generated entitled HorizontalParallelModel.dll . If you run into major problems please let me know, if you have code suggestions, please submit them to the comments zipped and compiled so others may bennifit from your work. If you make a cool application make your own community example, and let others know about it below!!!.

Although this is a process model example, editing the screen for the Batch Process model is similar.

Richard S -- National Instruments -- (former) Applications Engineer -- Data Acquisition with TestStand

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors