NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Handling UIMsg_BreakOnRunTimeError from Fully Custom UI

Solved!
Go to solution

I am developing a fully custom operator UI for TestStand 2012 SP1 (without ActiveX / ApplicationMgr etc; I know, I know...).  I'm trying to handle UIMsg_BreakOnRunTimeError appropriately and need advice.

 

1) My first issue is that I'm calling DisplayRunTimeErrorDialogEx() with the appropraite SequenceContext, however the dialog disables several of the options. Under Handle Current Error, RetryIgnore and Abort Immediately (no cleanup) are grayed out (disabled) as well as the Break checkbox. With the same sequence SequenceEditor and the sample op UI display this dialog properly.  Any ideas on what's causing this?

 

TestStand Run-Time Error

 

 

2) Secondly, how best to handle the user's selections?  dontShowAgainForExecutiondontShowAgainForBatch, and suspendExecution seem straightforward enough per the documentation.  i.e.

 

if (dontShowAgainForExecution)
    execution.RTEOptionForThisExecution = RTEOptions.RTEOption_Continue;

if (dontShowAgainForBatch)
    thread.SetBatchRTEOption(RTEOptions.RTEOption_Continue);

if (suspendExecution == false)
    execution.Resume(); // Correct? The execution seems already paused. What to do if this value is true?

Now what about runTimeErrorAction?  I assume for RTEOption_Abort I call execution.Abort().  What are the proper steps for RTEOption_ContinueRTEOption_IgnoreRTEOption_Retry, & RTEOption_ShowDialog?

 

 

3) Lastly, once the dialog is closed, my execution completes with the result status Passed rather than Error.  What's going on here?

 

Your help is appreciated as always,

 

-- Terrence Jones

 

0 Kudos
Message 1 of 8
(4,635 Views)
Solution
Accepted by TerrenceJ

1) This is likely due to user privileges, you are likely either not logged in with a user at all or the user does not have debugging privileges. If you don't want to use users you can disable privilege checking in the station options.

 

2) Something like this:

 

void ApplyRTESetting(TS::SequenceContextPtr sequenceContext, TS::RTEOptions rteOption, bool breakExecution)
{
    TS::ThreadPtr thread = sequenceContext->Thread;
    TS::ExecutionPtr execution = sequenceContext->Execution;

        switch (rteOption)
        {
            case TS::RTEOption_ShowDialog:
            case TS::RTEOption_Continue:
            case TS::RTEOption_Abort:
                thread->ClearTemporaryBreakpoint();
                break;
            default:
                break;
        }
    
        // do action according to option selected
        switch (rteOption)
        {
        case TS::RTEOption_Retry:
            sequenceContext->NextStepIndex = sequenceContext->StepIndex;
            thread->ClearCurrentRTE();
            if (!breakExecution)
                execution->Resume();
            break;
        case TS::RTEOption_Continue:
            if (!breakExecution)
                execution->Resume();
            break;
        case TS::RTEOption_Ignore:
            thread->ClearCurrentRTE();
            if (!breakExecution)
                execution->Resume();        
            break;
        case TS::RTEOption_Abort:
            execution->Abort();
            break;
        }
}


Also for the other two settings we generally use the rteoption from the dialog rather than hardcoding continue, but you can make this work how you want if you prefer a different behavior:

Example:

      if (dontShowAgainForExecution)
             context->Execution->RTEOptionForThisExecution = rteOption;
        
      if (dontShowAgainForBatch)
                context->Thread->SetBatchRTEOption (rteOption);    

3) Perhaps you are calling ClearCurrentRTE() for options other than ignore.

 

Hope this helps,

-Doug

Message 2 of 8
(4,617 Views)

 

Thank You... 

 

You were right on with #1.  And #2 looks like a great implementation.

 

As for #3, my problem was that I had assumed that Execution.ResultStatus should result in Error in the case of a RTE.  I've instead begun checking Execution.ErrorObject instead as per your post here: Runtime error in process model and sequence still passes

 

Incidentally... when does Execution.ResultStatus result in ResultStatus_Error?

 

Thanks Again,

 

-- Terrence Jones

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


 

Incidentally... when does Execution.ResultStatus result in ResultStatus_Error?

 

Thanks Again,

 

-- Terrence Jones


Currently the execution status is always either Passed or Failed, Error is never set as the status for an execution.

 

-Doug

0 Kudos
Message 4 of 8
(4,596 Views)

Hi,

 

Another option is to replace the NI dialog and error handling with a fully customized error handler of your own as demonstrated in the example, <Public>\Documents\National Instruments\TestStand 2010 SP1\Examples\Callbacks\PostStepRuntimeErrorCallback

 

cc

0 Kudos
Message 5 of 8
(4,593 Views)

Hi, DowNow posted a link about replacing the error handler. I think I need to do something like that (because the 3rd party library I'm using throws exceptions that prints fine, has the embedded text, in C# but not in the TS Dialog). Where would I find the referenced document: <Public>\Documents\National Instruments\TestStand 2010 SP1\Examples\Callbacks\PostStepRuntimeErrorCallback

 

Thanks!

 

s

0 Kudos
Message 6 of 8
(4,453 Views)

Find National Instruments\TestStand in your Program Files folder and in there should be a shortcut to Examples

Humphrey H.
Applications Engineer
National Instruments
Message 7 of 8
(4,443 Views)

Thanks Humphrey, I've seen that and used it now. I guess I'll have to create my own thread as this feature doesn't help with my problem.

0 Kudos
Message 8 of 8
(4,439 Views)