NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Get name of top level step

Solved!
Go to solution

When a step fails, I want to record the name of the "top level" step, not necessarily the current step.

 

For example, if I'm running a labview routine in the main sequence, I want the name of the routine. 

 

But if I'm running mainSequence->Voltage->PositiveRails->VDD-1V8. I want to record "Voltage".

 

I have found I can call runstate.caller.step.runstate.caller.name, (etc), but not sure how to follow up the chain and stop one from the top (not even sure how to stop at the top).

 

Also, it seems like TS would have an array showing the current call chain, But I can't find it. 

0 Kudos
Message 1 of 6
(915 Views)
Solution
Accepted by topic author Jed_Davidow

Hi Jed,

 

you can use the variable Runstate.CallStackDepth to figure out how far up the call chain you have to go and use the method Runstate.Thread.GetSequenceContext to get the sequence context of the top calling sequence.

 

In your example:

NameOf(RunState.Thread.GetSequenceContext(RunState.CallStackDepth-1,0).Runstate.Sequence)

will return the sequence name "Voltage" when called from inside the VDD-1V8 sequence.

 

Stefan

Message 2 of 6
(907 Views)

FANTASTIC!  I need to take a look in there.

0 Kudos
Message 3 of 6
(889 Views)

In your example:

NameOf(RunState.Thread.GetSequenceContext(RunState.CallStackDepth-1,0).Runstate.Sequence)

 

FYI, on my system this returns "Main Sequence" since the top level is "Test UUTs", but by subtracting 2 I made it work.  Thank you!

0 Kudos
Message 4 of 6
(845 Views)

Apologies, I should not have taken the call stack you described in the initial post literally, as in the Main Sequence being executed directly.

 

Of course in most applications one of the NI process models will be used, which has the executed Execution Entry Point (e.g. "Test UUTs") on top of the call stack and the "Main Sequence" of the client file at CallStackDepth 1.

 

Stefan

0 Kudos
Message 5 of 6
(837 Views)

I certainly don't blame you for overlooking the process models.  I am still getting used to thinking about them myself.

0 Kudos
Message 6 of 6
(831 Views)