NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Desire for differnt subsequence calling scheme

Within my TestStand OI (LabVIEW version of full-OI) I have a sequence file I load that contains calls to a number of subsequences (all of these sequences are embedded within this sequence file).  If I want to run a particular sequence (not Test UUT as a whole), I right-click and select Run Selected Steps Using (Single Pass/Degug).That is consistent whether I'm in the sequence editor or the OI.  However, when I want to go down one level, and look at steps within a sequence, the operation differs between the OI and the sequence editor.  In the Seq editor, I right-click on a sequence and select Open Sequence...to reveal the steps within.  In the OI, this feature goes away - I have to go upto the Sequence drop down list and find the sequence in question to then reveal the tests within.  This is (1) cumbersome, and (2) it forces me to name my sequences the same as the name I use for the step.  I'm not actually 'forced' to name them the same, but if I don't, the user (since the step name is the first name he sees) looks in the drop down for the step name and may not find the desired sequence.
 
Is there a way to have the Sequence Editor (righ-click, Open Sequence) behavior when running the OI version?
0 Kudos
Message 1 of 8
(3,475 Views)
Hey Mr Bean,

This is possible to do within the Operator Interface, but it requires some additional coding. The open sequence right click option you are talking about is actually the Edit Code command for all Sequence Call step types.  It is possible to add a menu item to the right click menu that programmatically executes this command.  I have posted a tutorial below.  I would recommend going through this tutorial.  It talks about how to execute the Edit Limits substep for a Numeric Limit Step Type.  You can use almost the exact same idea, except, rather than executing the ExecuteSubStep method you will need to run the EditCode method.  

One additional thing, I would recommend moving the check for the step type into the CreateContextMenu Event Callback so the Open Sequence option is only there for SequenceCall step types.  In other words you would only insert the custom command when the selected step is a sequence call. Hope this helps!

http://zone.ni.com/devzone/cda/tut/p/id/2987

Message Edited by Patrick P. on 02-19-2007 01:20 PM

Pat P.
Software Engineer
National Instruments
0 Kudos
Message 2 of 8
(3,453 Views)
Pat,
 
I've been looking to do this for the CVI interface - is there any chance that a tutorial or example code exists that explains this for the non-LabView user?
 
Specifically, I think we'd want to add it to the "BuildSequenceViewContextMenu ()" call in the TestExec.c file, and modify the following code:
 
 // insert items for default sequence view context menu in the context menu
 tsErrChk( TSUI_CommandsInsertKind(cmds, &errorInfo, TSUIConst_CommandKind_DefaultSequenceViewContextMenu_Set, viewMgr, -1, "", "", NULL));
 /* we are using the context menu that the SequenceView control provides because it requires
    fewer lines of code. We could have built a CVI context menu instead and displayed it
    with RunPopupMenu(). If you display a CVI context menu, remember to convert the
    activeX-control-right-mouse click coordinates from control coordinates to panel
    coordinates by adding the top and left of the control to the click position. */
 tsErrChk( TSUI_CommandsInsertIntoWin32Menu(cmds, &errorInfo, menuHandle, -1, VTRUE, VTRUE));
 
The problem is, I'm not finding the EditCode method that would allow me to add it to the 'cmds' if a Sequence is selected.
I'm hoping not to have to recreate the wheel here, but find out if there's an easy way to add the ability to open the selected sequence from the Sequence Steps control.
 
Any help would be greatly appreciated.
 
Thanks,
 
-Jack
0 Kudos
Message 3 of 8
(3,440 Views)
Hey Jack,

Unfortunately there isn't a tutorial for CVI.  However, I went back through and reimplemented it in the CVI OI.  The places you have to make changes are in BuildSequenceViewContextMenu, RegisterActiveXEventCallbacks, and then create a callback for the Post Command Execute.

In BuildSequneceViewContextMenu, I'm checking to see if the step clicked on is a SequenceCall.  If it is a SequenceCall then I'm inserting a custom command.  The Post Command Execute callback happens after any Command executes including Custom Commands (which is the type of command we insert into the right click menu). Then in the post Command Execute we check to make sure it is a custom command (CommandKind = 3), and then check the userData to make sure it is the number we sent indicating an Open Sequence Command.  Then we execute an Edit Code method on the step and refresh the SequenceFileView Manager. I have listed the code for each function that needs to be changed below.  Hope this helps!

RegisterActiveXEventCallbacks:
add TSUI__ApplicationMgrEventsRegOnPostCommandExecute(gMainWindow.applicationMgr,   ApplicationMgr_OnPostCommandExecute, NULL, 1, NULL) to the section that is adding ApplicationMgr event callbacks.

BuildSequenceViewContextMenu
    int            error = 0;
    CAObjHandle    cmds = 0;
    CAObjHandle    viewMgr;
    TSUIObj_SelectedSteps SelectedSteps;
    TSUISUPPObj_Step SelectedStep;
    TSObj_StepType SelectedStepType;
    TSUIObj_Command CustomCommand = 0;
    char *StepTypeName;
    VARIANT userData;
    VARIANT userObject;
    LPUNKNOWN userObjectPtr;
   
    // determine which view manager menu commands apply to
    errChk( GetActiveViewManager(&viewMgr));
   
    tsErrChk( TSUI_ApplicationMgrNewCommands(gMainWindow.applicationMgr, &errorInfo, &cmds));
   
    //Check to see if step we are selecting is a SequenceCall
    tsErrChk( TSUI_SequenceFileViewMgrGetSelectedSteps (gMainWindow.sequenceFileViewMgr, &errorInfo, &SelectedSteps));
    tsErrChk( TSUISUPP_SelectedStepsGetItem (SelectedSteps, &errorInfo, 0,
                                             &SelectedStep));
    tsErrChk( TS_StepGetStepType (SelectedStep, &errorInfo, &SelectedStepType));
             
    tsErrChk( TS_StepTypeGetName (SelectedStepType, &errorInfo, &StepTypeName));
   
    //If it is a sequencecall, we insert Open Sequence into the menu
    if(!strcmp(StepTypeName, "SequenceCall"))
    {
       
                 
        tsErrChk( TSUI_ApplicationMgrGetCommand (gMainWindow.applicationMgr, &errorInfo,
                                                TSUIConst_CommandKind_Custom, 0,
                                                &CustomCommand));
        tsErrChk( TSUI_CommandSetEnabled (CustomCommand, &errorInfo, VTRUE));
        tsErrChk( TSUI_CommandSetVisible (CustomCommand, &errorInfo, VTRUE));
        CA_VariantSetInt (&userData, 61455);
        tsErrChk( TSUI_CommandSetUserData (CustomCommand, &errorInfo, userData));
        tsErrChk( TSUI_CommandSetDisplayName(CustomCommand, &errorInfo, "Open Sequence"));
        tsErrChk( TSUI_CommandsInsert (cmds, &errorInfo, CustomCommand, -1));
    }
       

    // insert items for default sequence view context menu in the context menu
    tsErrChk( TSUI_CommandsInsertKind(cmds, &errorInfo, TSUIConst_CommandKind_DefaultSequenceViewContextMenu_Set, viewMgr, -1, "", "", NULL));
   
    tsErrChk( TSUI_CommandsInsertIntoWin32Menu (cmds, &errorInfo, menuHandle, 0, VTRUE, VTRUE)); // we are using the context menu that the SequenceView control provides because it requires fewer lines of code. We could have built a CVI context menu instead and displayed it with RunPopupMenu(). If you display a CVI context menu, remember to convert the activeX-control-right-mouse click coordinates from control coordinates to panel coordinates by adding the top and left of the control to the click position.
   
Error:
    CA_DiscardObjHandle(cmds);
    CA_DiscardObjHandle(SelectedSteps);
    CA_DiscardObjHandle(SelectedStep); 
    CA_DiscardObjHandle(SelectedStepType);
    CA_FreeMemory(StepTypeName);
    if(CustomCommand)
        CA_DiscardObjHandle(CustomCommand);
    return error;

ApplicationMgr_OnPostCommandExecute
HRESULT CVICALLBACK ApplicationMgr_OnPostCommandExecute(CAObjHandle caServerObjHandle, void *caCallbackData, TSUIObj_Command  command)
{
    enum TSUIEnum_CommandKinds CommandKind;
    int error = 0;
    int userDataNumber;
    VARIANT userData;
    VARIANT tempUserObj;
    LPUNKNOWN tempActiveXRef;
    CAObjHandle SelectedSteps = 0;
    CAObjHandle SelectedStep = 0;
    VBOOL StepModified;
   
                                         
   
    tsErrChk( TSUI_CommandGetKind (command, &errorInfo, &CommandKind));

    if(CommandKind == 3)
    {
        tsErrChk( TSUI_CommandGetUserData(command, &errorInfo, &userData));
        CA_VariantGetInt (&userData, &userDataNumber);
       
        if(userDataNumber == 61455)
        {
            tsErrChk( TSUI_SequenceFileViewMgrGetSelectedSteps (gMainWindow.sequenceFileViewMgr, &errorInfo, &SelectedSteps));
            tsErrChk( TSUISUPP_SelectedStepsGetItem (SelectedSteps, &errorInfo, 0,
                                             &SelectedStep));   
            tsErrChk( TS_StepEditCode (SelectedStep, &errorInfo, &StepModified));
            tsErrChk( TSUI_SequenceFileViewMgrRefresh (gMainWindow.sequenceFileViewMgr, &errorInfo));
           
        }
    }
   
Error:
    if(SelectedSteps)
        CA_DiscardObjHandle(SelectedSteps);
    if(SelectedStep)
        CA_DiscardObjHandle(SelectedStep);
   
    return error;
}

Message Edited by Patrick P. on 02-21-2007 11:01 AM

Pat P.
Software Engineer
National Instruments
Message 4 of 8
(3,419 Views)

Patrick - You the MAN! Smiley Very Happy

This worked perfectly and is exactly what we wanted! There where some small changes that I made to add a seperator and to use a different method to check for sequence files (TS_StepGetIsSequenceCall ()), but your help allowed me to get this running and understanding how it worked in about 15 minutes! I've pasted my version of the BuildSequenceViewContextMenu () call that added a seperator, removed unused variables, and added error check parameters as locals.

static int BuildSequenceViewContextMenu(int menuHandle)
{
 ERRORINFO errorInfo = {0, 0, "", "", "", 0, 0};
 ErrMsg errMsg = "";
    int            error = 0;
    CAObjHandle    cmds = 0;
    CAObjHandle    viewMgr;
    TSUIObj_SelectedSteps SelectedSteps;
    TSUISUPPObj_Step SelectedStep;
    TSUIObj_Command CustomCommand = 0;
    VARIANT userData;
 VBOOL sequenceCall = FALSE;
   
    // determine which view manager menu commands apply to
    errChk( GetActiveViewManager(&viewMgr));
   
    tsErrChk( TSUI_ApplicationMgrNewCommands(gMainWindow.applicationMgr, &errorInfo, &cmds));
   
    //Check to see if step we are selecting is a SequenceCall
    tsErrChk( TSUI_SequenceFileViewMgrGetSelectedSteps (gMainWindow.sequenceFileViewMgr,
                                                                                                  &errorInfo, &SelectedSteps));
    tsErrChk( TSUISUPP_SelectedStepsGetItem (SelectedSteps, &errorInfo, 0, &SelectedStep));
   
 tsErrChk( TS_StepGetIsSequenceCall (SelectedStep, &errorInfo, &sequenceCall));

 //If it is a sequencecall, we insert Open Sequence into the menu
    if(sequenceCall)
    {
        tsErrChk( TSUI_ApplicationMgrGetCommand (gMainWindow.applicationMgr, &errorInfo,
                                                                                   TSUIConst_CommandKind_Custom, 0,
                                                                                   &CustomCommand));
        tsErrChk( TSUI_CommandSetEnabled (CustomCommand, &errorInfo, VTRUE));
        tsErrChk( TSUI_CommandSetVisible (CustomCommand, &errorInfo, VTRUE));
        CA_VariantSetInt (&userData, 61455);
        tsErrChk( TSUI_CommandSetUserData (CustomCommand, &errorInfo, userData));
        tsErrChk( TSUI_CommandSetDisplayName(CustomCommand, &errorInfo, "Open Sequence..."));
        tsErrChk( TSUI_CommandsInsert (cmds, &errorInfo, CustomCommand, 0));
        tsErrChk( TSUI_CommandsInsertKind (cmds, &errorInfo, TSUIConst_CommandKind_Separator,
                                                                         viewMgr, -1, "", "", NULL));
    }

    // insert items for default sequence view context menu in the context menu
    tsErrChk( TSUI_CommandsInsertKind(cmds, &errorInfo, TSUIConst_CommandKind_DefaultSequenceViewContextMenu_Set,
                                                                    viewMgr, -1, "", "", NULL));
 /* we are using the context menu that the SequenceView control provides because it requires
    fewer lines of code. We could have built a CVI context menu instead and displayed it with RunPopupMenu().
    If you display a CVI context menu, remember to convert the activeX-control-right-mouse click coordinates
    from control coordinates to panel coordinates by adding the top and left of the control to the click
    position. */
    tsErrChk( TSUI_CommandsInsertIntoWin32Menu (cmds, &errorInfo, menuHandle, 0, VTRUE, VTRUE));
   
Error:
    CA_DiscardObjHandle(cmds);
    CA_DiscardObjHandle(SelectedSteps);
    CA_DiscardObjHandle(SelectedStep); 
    if(CustomCommand)
    {
        CA_DiscardObjHandle(CustomCommand);
    }
   
 return error;
} // BuildSequenceViewContextMenu

Thanks Pat!

-Jack

0 Kudos
Message 5 of 8
(3,396 Views)
I didn't even notice the TS_StepGetIsSequenceCall, nice catch!  Definitely more efficient than the way I was checking for the step type.  I am going to try and compile this into an Example program to post on our Developer's Zone so in the future people can just download the example rather than having to modify the OI themselves.  Glad I could help Jack :). 
Pat P.
Software Engineer
National Instruments
0 Kudos
Message 6 of 8
(3,371 Views)
Do Capt. Jack's findings alter the solution you suggested for LabVIEW?
0 Kudos
Message 7 of 8
(3,368 Views)
You can change it slightly.  In figure 11 of the tutorial, rather than getting the StepType and checking the name, you can use the step property IsSequenceCall.  You can use a property node on the selected step to get the property.  It isn't too big of a deal, but it will eliminate a few extra property/invoke nodes.
Pat P.
Software Engineer
National Instruments
Message 8 of 8
(3,364 Views)