NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to terminate the Sequence Test?

Hi,
 
Our production personnel complain that they can not terminate the test sequence when they spot some failures and wish to stop the test.  The only way I know how to do it is to put a stop on a step and then when TS does not run I can terminate the test.
 
What is your recommendation for implementing a better way for termination?
 
Thanks
Rafi
0 Kudos
Message 1 of 15
(6,310 Views)
Hi Rafi2003,
 
Try using the Execution.GetTerminationMonitorStatus in your code. This will sense if the user has Pressed the Terminate button from the OI and therefore you can exit out of your code module. The sequence can then terminate.
 
Regards
Ray Farmer
 
Regards
Ray Farmer
0 Kudos
Message 2 of 15
(6,309 Views)
Thanks very much Ray,
 
Could you elaborate a little as to what to do with this information? 
 
I have no idea how to use it in my code...
 
Thanks
Rafi
0 Kudos
Message 3 of 15
(6,288 Views)
Hi,
 
First thing you need to perform is Execution.InitTerminationMonitor method. This will give you a reference to a termination monitor data property object. This you use with the Execution.GetTerminationMonitorStatus method.
 
Call the Execution.GetTerminationMonitorStatus either in a parallel loop or at regular intervals in you code module.
The Execution.GetTerminationMonitorStatus method returns True if the OI is terminating/aborting the test sequences. You can then test for this to exit gracefully from your code.

Finally Release the Reference to the termination monitor data property object before returning from you code.
 
What language are you generating your code modules in, and I'll try produce an example for you/or at least some code snipets?
 
Regards
Ray Farmer
 
 
Regards
Ray Farmer
0 Kudos
Message 4 of 15
(6,281 Views)

Thanks very much Ray,

Indeed an elaborated answer... but I don't feel I know how to do it on my own.  I appreciate your suggestion for an example.

By parallel loop, did you mean as a different thread?  I'd like to see how it works as I've never tried a multithreading sequence.

I'm using CVI7.0 + TS3.0.

Thank you very much

Rafi

0 Kudos
Message 5 of 15
(6,277 Views)
Hi Rafi,
 
Here is some example code for using the execution termination monitor.  You will want to place this in your code periodically to look for possible termination requests.  This was an example written to demonstrate how you would exit out of an infinite loop with the termination monitor.
 
CAObjHandle exec = 0 ;
    int error = 0;
    int i = 0;
    VBOOL term;   
    CAObjHandle MON = 0;
    //getting the execution object from the sequence context which was passed from TestStand
 TS_SeqContextGetExecution (seqContextCVI, NULL, &exec);
 //initializing the termination monitor and setting up  MON to be the monitor data
 TS_ExecutionInitTerminationMonitor (exec, NULL, &MON);
   
    //creating an infinite loop that will end if the termination monitor status is set to TRUE
    do
    {
  
 TS_ExecutionGetTerminationMonitorStatus (exec, NULL, MON,
            CA_DEFAULT_VAL, &term);
   
    }
    while( term == VFALSE);
Error: 
    // FREE RESOURCES
    // if (lastUserName != NULL)
    //     CA_FreeMemory(lastUserName);
 CA_DiscardObjHandle(exec);
 CA_DiscardObjHandle(MON);
 
 
I hope this helps.
 
 
Thanks,
Caroline Tipton
Data Management Product Manager
National Instruments
Message 6 of 15
(6,260 Views)

Hi Caroline,

I'm almost there... 

I was able to get the termination status and determine the Termination request.  Now, what am I suppose to do with it in order to get the Termination window in TS.  ( I used a  run-time error and indeed, received a run-time error window...)

 

Thanks

Rafi

0 Kudos
Message 7 of 15
(6,244 Views)
Hi,
 
You shouldn't have to do anything other than make you test record that testing was terminated via the ReportText and probably make it fail rather than error. It's not your test that has signalled the terminate, but the user, if my assumptions are correct. Your report will show that the test has been terminated via the overall status. Its what you indicate with regards to the test in that is in progress when the termination occurs.
 
Regards
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 8 of 15
(6,237 Views)
Hello Ray and thanks,
 
I got it and it works very nice!
 
I have an implementation question regarding this issue:
 
Let's take an example of a main step module called from TS.  This module called some function which calls another function.
Is it safe to allocate and initialize the termination handles at the top module (the one called by TS) and check the status in any of the sub-functions?  It means, obviously that I will need to use some globalization in order to implement that unless I pass the variables which I don't like as they make the functions to become too long....
 
What is your suggestion for implementing it in such a case?   Can you include a demonstrative example?
 
Thank very much
Rafi
0 Kudos
Message 9 of 15
(6,231 Views)

Hi Rafi,

You can defintely check the termination status in multiple functions at the same time.  You just need to have the sequence context to check the status.  If you are not wanting to pass the status as a parameter between functions, you can create a global variable that will hold the status.

Thanks,
Caroline Tipton
Data Management Product Manager
National Instruments
0 Kudos
Message 10 of 15
(6,212 Views)