NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
sonotk
Posts: 75
0 Kudos
Accepted Solution

Terminate ALL command for CVI

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?

Trusted Enthusiast
RayFarmer
Posts: 4,648
0 Kudos

Re: Terminate ALL command for CVI

[ Edited ]

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
Active Participant
James_Grey
Posts: 687

Re: Terminate ALL command for CVI

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()

Member
sonotk
Posts: 75
0 Kudos

Re: Terminate ALL command for CVI

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()?

Member
sonotk
Posts: 75
0 Kudos

Re: Terminate ALL command for CVI

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

Active Participant
James_Grey
Posts: 687

Re: Terminate ALL command for CVI

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

Member
sonotk
Posts: 75
0 Kudos

Re: Terminate ALL command for CVI

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;
}

Active Participant
James_Grey
Posts: 687
0 Kudos

Re: Terminate ALL command for CVI

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. 

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page