NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Terminate ALL command for CVI

Solved!
Go to solution

I have three executions running. What is the command in CVI to terminate all the executions when a custom terminate button is hit.

Currently using TSUI_ExecutionViewMgrTerminateExecution(gmainWindow.executionViewMgr, &errorInfo);

Is this the correct command?

0 Kudos
Message 1 of 8
(3,680 Views)

I would think that just terminates one of your executions, you would have to call it three times using the execution handle for each of the three executions.

 

I believe you need to being doing something that is equivalent to TS_EngineTerminateAll where as you are using something that is equivalent to TS_ExecutionTerminate.

 

 You probably need to use ApplicationMgr.CloseAllExecutions which is TSUI_ApplicationMgrCloseAllExecutions

Regards
Ray Farmer
0 Kudos
Message 2 of 8
(3,676 Views)
Solution
Accepted by topic author sonotk

CloseAllExecutions tries to close all the executions, running or not. If executions are running, you might be prompted as to whether you want to terminate them.

 

If you just want to terminate all executions but not close them, you could also call applicationMgr.GetCommand(CommandKind_TerminateAll).Execute()

Message 3 of 8
(3,666 Views)

Sorry never used Execute() function in CVI. This is how I am trying to define it:

 

int CVICALLBACK StartTestAbortTest (int panel, int control, int event,void *callbackData, int eventData1, int eventData2)                                                                       
{

 TSUIObj_Command TerminateAll;

switch (event)                                                                                                            
   {                                                                                                                         
   case EVENT_COMMIT:

TSUI_ApplicationMgrGetCommand (gMainWindow.executionViewMgr, &errorInfo, TSUIConst_CommandKind_TerminateAll, 0,
                &TerminateAll);
      TerminateAll.Execute();

 

 CA_DiscardObjHandle(TerminateAll);
    break;

}

}

 

It does return me compile time error that left operand of Execute() is incompatiable type.

I suppose I am not fimiliar on how to use Execute()?

0 Kudos
Message 4 of 8
(3,663 Views)

Aha found the API call

TSUI_CommandExecute(TerminateAll,&errorInfo,VFALSE);

 

Can't understand why do I need to call

 

 TSUI_ExecutionViewMgrTerminateExecution(gMainWindow.executionViewMgr, &errorInfo);  
      

Before calling


      TSUI_ApplicationMgrGetCommand (gMainWindow.executionViewMgr, &errorInfo, TSUIConst_CommandKind_TerminateAll, 0,
                &TerminateAll);
      TSUI_CommandExecute(TerminateAll,&errorInfo,VFALSE);

 

Thanks for the help

sonotk

0 Kudos
Message 5 of 8
(3,660 Views)

You shouldn't need to. Maybe there is a problem because you are passing the ExecutionViewMgr to TSUI_ApplicationMgrGetCommand instead of the ApplicationMgr?

Message 6 of 8
(3,656 Views)

yes you are correct, when passing the ApplicationMgr I do not need the first terminate call.

Although I do get a menu ID error.

If I hit my custom TerminateAll button before a new execution is launched then the error is not there.

If I hit my custom TerminateAll button after a new execution is launched then the attached error is reported.

 

Here is the commands which I believe has TerminateAll in default Debug section.

 

static int RebuildMenuBar(int menuBar)
{
 int         error = 0;
 CAObjHandle       viewMgr = 0;

 static enum TSUIEnum_CommandKinds fileMenuCommands[] =
 {
  TSUIConst_CommandKind_DefaultFileMenu_Set,   // add all the usual commands in a File menu
  TSUIConst_CommandKind_NotACommand     // list terminator
 };
 
 // Edit menu commands defined in sEditMenuCommands, above this function
 
 //remove Run Selected Step and Loop on Selected Step commands from Execute Menu
 
 static enum TSUIEnum_CommandKinds executeMenuCommands[] =
 {
  TSUIConst_CommandKind_Restart,  // add only the command needed
  TSUIConst_CommandKind_Separator,
  TSUIConst_CommandKind_Separator,
  TSUIConst_CommandKind_ExecutionEntryPointDefaultMenuInsertionMarker,
  TSUIConst_CommandKind_ConfigurationEntryPointDefaultMenuInsertionMarker,
  TSUIConst_CommandKind_Separator,
  TSUIConst_CommandKind_RunCurrentSequence,
  TSUIConst_CommandKind_Separator,
  TSUIConst_CommandKind_RunSelectedStepsUsingEntryPointsSubmenu,
  TSUIConst_CommandKind_LoopOnSelectedStepsUsingEntryPointsSubmenu,
  TSUIConst_CommandKind_Separator,
  TSUIConst_CommandKind_BreakOnFirstStep,
  TSUIConst_CommandKind_BreakOnStepFailure,
  TSUIConst_CommandKind_BreakOnSequenceFailure,
  TSUIConst_CommandKind_TracingEnabled,
  TSUIConst_CommandKind_NotACommand     // list terminator
 };
 
 static enum TSUIEnum_CommandKinds debugMenuCommands[] =
 {
  TSUIConst_CommandKind_DefaultDebugMenu_Set,   // add all the usual commands in a Debug menu
  TSUIConst_CommandKind_NotACommand     // list terminator
 };
 static enum TSUIEnum_CommandKinds configureMenuCommands[] =
 {
  TSUIConst_CommandKind_DefaultConfigureMenu_Set,  // add all the usual commands in a Configure menu
  TSUIConst_CommandKind_NotACommand     // list terminator
 };
 static enum TSUIEnum_CommandKinds toolsMenuCommands[] =
 {
  TSUIConst_CommandKind_DefaultToolsMenu_Set,   // add all the usual commands in a Tools menu
  TSUIConst_CommandKind_NotACommand     // list terminator
 };
 static enum TSUIEnum_CommandKinds helpMenuCommands[] =
 {
  TSUIConst_CommandKind_Separator,     // separates the existing About... item
  TSUIConst_CommandKind_DefaultHelpMenu_Set,   // add all the usual commands in a Help menu. Note that most help items appear only when in Edit mode.
  TSUIConst_CommandKind_NotACommand     // list terminator
 };

 // determine which view manager the menu commands apply to
 errChk( GetActiveViewManager(&viewMgr));
 
    // discard any current menu items that were inserted by TS_InsertCommandsInMenu
 errChk( TS_RemoveMenuCommands(menuBar, 0, FALSE, FALSE));

 // rebuild File menu
 errChk( TS_InsertCommandsInMenu(fileMenuCommands, menuBar, BAR_FILE, -1, viewMgr, NULL, TRUE, errMsg));
 
 // rebuild Edit menu
 errChk( TS_InsertCommandsInMenu(sEditMenuCommands, menuBar, BAR_EDIT, -1, viewMgr, NULL, TRUE, errMsg));
 
 // rebuild Execute menu
 errChk( TS_InsertCommandsInMenu(executeMenuCommands, menuBar, BAR_EXECUTE, -1, viewMgr, NULL, TRUE, errMsg));

 // rebuild Debug menu
 errChk( TS_InsertCommandsInMenu(debugMenuCommands, menuBar, BAR_DEBUG, -1, viewMgr, NULL, TRUE, errMsg));

 // rebuild Configure menu
 errChk( TS_InsertCommandsInMenu(configureMenuCommands, menuBar, BAR_CONFIGURE, -1, viewMgr, NULL, TRUE, errMsg));

 // rebuild Tools menu
 errChk( TS_InsertCommandsInMenu(toolsMenuCommands, menuBar, BAR_TOOLS, -1, viewMgr, NULL, TRUE, errMsg));

 // rebuild the Help menu. Note that the help menu already contains an "About..." item, which is not a TestStand command item
 errChk( TS_InsertCommandsInMenu(helpMenuCommands, menuBar, BAR_HELP, -1, viewMgr, NULL, TRUE, errMsg));

 // remove duplicate separators and shortcut keys
 errChk( TS_CleanupMenu(menuBar, 0));
 
Error:
 return error;
}

0 Kudos
Message 7 of 8
(3,652 Views)

I'm not seeing a problem with your code snippet. You'll probably need to debug your project by stepping through it until you find the line that throws the error and then determining what went wrong. 

0 Kudos
Message 8 of 8
(3,647 Views)