07-13-2022 02:01 AM
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.
Solved! Go to Solution.
07-13-2022 03:20 AM
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
07-13-2022 08:09 PM
FANTASTIC! I need to take a look in there.
07-19-2022 12:20 PM
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!
07-21-2022 04:56 AM
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
07-21-2022 11:28 AM
I certainly don't blame you for overlooking the process models. I am still getting used to thinking about them myself.