NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you reset/close the execution using the API?

Solved!
Go to solution

I am trying to programmatically launch different sequences then look at the final results.  The results of the execution always show the results from the first call to

 

TS_ExecutionGetResultStatus.  Even if I execute a different sequence.  Is there a method to close the last execution results? 

 

Thanks,

Mike

 

Here is a code snippet of what I am doing.

 

    tsErrChk(TSUI_SequenceFileViewMgrRun (tsoHandles.sequenceFileViewMgr, &errorInfo, CA_DEFAULT_VAL, NULL));
    CA_DiscardObjHandle(tsoHandles.Executions);
    tsErrChk(TSUI_ApplicationMgrGetExecutions(tsoHandles.applicationMgr, &errorInfo, &tsoHandles.Executions));
    tsErrChk(TSUI_ExecutionsGetItem(tsoHandles.Executions, &errorInfo, 0, &tsoHandles.Execution));
    if (bWait)
    { // Wait
        while (Test_Running())
        { // Running
            ProcessSystemEvents();
            iCount++;
        } // Running
    } // Wait
    tsErrChk(TS_ExecutionGetResultStatus(tsoHandles.Execution, &errorInfo, &szResults));
    if (strcmp(szResults, "Passed") == 0)
        bRet = TRUE;
    if (strcmp(szResults, "Failed") == 0)
        bRet = FALSE;

0 Kudos
Message 1 of 5
(3,568 Views)
Solution
Accepted by topic author mjl

I think one of the following should work:

 

TSUI_ApplicationMgrCloseExecution()

TSUI_ApplicationMgrCloseAllExecutions()

 

Hope this helps,

-Doug

0 Kudos
Message 2 of 5
(3,549 Views)

Hi Doug,

     Thanks.  I found that function this morning.  It works great.

 

Mike

0 Kudos
Message 3 of 5
(3,541 Views)

Hey Mike,

It looks like you're on the right track but from the code you pasted you are always referencing the same execution.  Because the TS_ExecutionGetResultStatus function just returns the status of whichever Execution object you decide to pass it, you first should verify that you passing it the correct object. When you call the TSUI_ExecutionsGetItem function:

 

tsErrChk(TSUI_ExecutionsGetItem(tsoHandles.Executions, &errorInfo, 0, &tsoHandles.Execution));

 

you are passing a value of zero for the ItemIdx input. Try changing your value from 0 to any number between 1 and one less than the result of TSUI_ExecutionsGetCount (because of zero indexing). Give this a try and see if this helps.

 

Lars

0 Kudos
Message 4 of 5
(3,536 Views)

Hi Lars,

  You are correct.  This was just some test code I threw together.  What I am going to do is this:

 

    tsErrChk(TSUI_ExecutionsGetCount(tsoHandles.Executions, &errorInfo, &iRunning)
    tsErrChk(TSUI_ExecutionsGetItem(tsoHandles.Executions, &errorInfo, (iRunning - 1), &tsoHandles.Execution));

 

I believe this should get me the correct execution since it should be the last one.

 

Thanks,

Mike

0 Kudos
Message 5 of 5
(3,531 Views)