NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to shutdown TestStand LabWindows/CVI operator interface programmatically?

Hi,

Like the title says, I'm trying to find a way to shutdown TestStand operator interface automatically after sequence execution is completed.

Any suggestion is appreciated, thanks in advance.
0 Kudos
Message 1 of 8
(4,707 Views)
Use the 'EndExecution' UIMessage.

The TestStand Engine posts the following UIMessage:
"UIMsg_EndExecution - (Value: 😎 TestStand sends this event after an execution completes."

I can't speak for CVI but I am doing something similar in VisualBasic.
Once that message event happens you simply close your UserInterface application - rembering to shutdown the Engine correctly too!

Hope that points you in the right direction.
Regards,
Dan
0 Kudos
Message 2 of 8
(4,707 Views)
Hello,

I just finished doing this yesterday. Essentially all that is required is to place a call to ExitApplication() within the activeX registered callback ApplicationMgr_OnEndExecution similar to this:

HRESULT CVICALLBACK ApplicationMgr_OnEndExecution (CAObjHandle caServerObjHandle, void *caCallbackData, TSUIObj_Execution exec)
{
int error = 0;
// other calls here...

//flag set somewhere else in app, or sent from teststand process model
if(gEndExecution==TRUE
{
ExitApplication();
}

Error:
DisplayError(error);
return error < 0 ? E_FAIL : S_OK;

}

ExitApplication is defined here:

static void ExitApplication(void)
{
int error = 0;
VBOOL canExitNow;

// The first call to ApplicationMgrShutDown unloads files, logs out,
runs unload callbacks, and finally triggers an OnApplicationCanExit event, which calls
// this function again. When the second call ApplicationMgrShutdown returns true for canExitNow, we call QuitUserInterface, which causes the RunUserInterface call to return.
tsErrChk( TSUI_ApplicationMgrShutdown(gMainWindow.applicationMgr, &errorInfo, &canExitNow));
if (canExitNow)
QuitUserInterface(0);

Error:
DisplayError(error);
}
These callbacks and functions should already be in your code if you are using anything close to the prepackaged interfaces that come with TestStand.

Hope this helps
Message 3 of 8
(4,707 Views)
Hello,
I'm trying to do the same thing.
But I don't know what is that TestStand prepackage.
I have a button that runs a CALLBACK on LabWindowsCVI where I call TSUI_ApplicationMgrShutdown and I check the canExitNow flag.
But since canExitNow only returns TRUE on the second TSUI_ApplicationMgrShutdown how do I close TestStand without having to click the button two times?
I apreciate your help on this.
Thanks in advance.
 
Daniel Coelho
 
Daniel Coelho
VISToolkit - http://www.vistoolkit.com - Your Real Virtual Instrument Solution
Controlar - Electronica Industrial e Sistemas, Lda
0 Kudos
Message 4 of 8
(4,274 Views)

Hi,

You dont need to modify the OI.

you should be able do the same from the command line eg

SeqEdit.exe /run MainSequence "c:\My Seqs\test\seq" /quit

This is for the SeqEditor but the same should hold true of the Operator Interface.

Regards

Ray Farmer

 

 

Regards
Ray Farmer
0 Kudos
Message 5 of 8
(4,271 Views)

Thanks for the quick reply.

I think that isn't what I have in mind.

I really want to programmatically close teststand using TSUI_AplicationMgrShutdown ().

The thing is that I need to click close twice in orden to close.

Any ideas on how to close teststand on the first click?

Thanks for you time.

 

Daniel Coelho

 

Daniel Coelho
VISToolkit - http://www.vistoolkit.com - Your Real Virtual Instrument Solution
Controlar - Electronica Industrial e Sistemas, Lda
0 Kudos
Message 6 of 8
(4,269 Views)
Hello Daniel,

If in order to shutdown TestStand you need to click your button and execute the callback code twice, you could put a for loop around the code in your callback and have it iterate twice so that you only have to click the button once.

Let me know if you run into any problems.
Manooch H.
National Instruments
0 Kudos
Message 7 of 8
(4,227 Views)

Thank you for your reply.

I did a loop but it wouldn't work :s

I managed to create an ActiveX button to exit test stand.

I found an example within the TestStand Course I and II.

...

static void ExitApplication(void)
{
 VBOOL canExitNow;

 TSUI_ApplicationMgrShutdown (AppManagerHandle, &errorInfo,&canExitNow);
 if (canExitNow)
  QuitUserInterface(0);
}

// the ApplicationMgr control sends this event when it is ok to exit the application.
HRESULT CVICALLBACK ApplicationMgr_OnExitApplication(CAObjHandle caServerObjHandle, void *caCallbackData)
{
 ExitApplication(); 
 return S_OK;
}

void CreateTSEngineHandle ()
{
 GetObjHandleFromActiveXCtrl  (panelHandle, PANEL_APPLICATIONMGR,&AppManagerHandle);
 GetObjHandleFromActiveXCtrl  (panelHandle, PANEL_EXIT,    &AppExit   );
  
 TSUI__ApplicationMgrEventsRegOnExitApplication (AppManagerHandle, ApplicationMgr_OnExitApplication, NULL, 1, NULL);
 
 TSUI_ApplicationMgrConnectCommand (AppManagerHandle, &errorInfo, AppExit, TSUIConst_CommandKind_Exit, 0,
            TSUIConst_CommandConnection_NoOptions, NULL);
 
 TSUI_ApplicationMgrGetEngine (AppManagerHandle, &errorInfo,&EngineHandle);
 
 TSUI_ApplicationMgrStart     (AppManagerHandle, &errorInfo);
 
 TS_EngineGetGlobals(EngineHandle,NULL,&Globals);
}

...

This way I click my QuitButton and it calls the the ActiveXExitButton witch calls the ExitApplication function.

The ApplicationMgr control sends ApplicationMgr_OnExitApplication event when it is ok to exit the application.

Hope this was clear enough and I hope this may be helpfull for someone else.
 

I apreaciate all the help.

Regards,

Daniel Coelho

 

Daniel Coelho
VISToolkit - http://www.vistoolkit.com - Your Real Virtual Instrument Solution
Controlar - Electronica Industrial e Sistemas, Lda
0 Kudos
Message 8 of 8
(4,220 Views)